diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-12-11 23:26:51 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-12-11 23:26:51 +0000 |
commit | 12b1b5d837b5ce1c07ee3535e74e4cc3039063d6 (patch) | |
tree | 1ef0ecc2ccfba9a8a33f0b20ef31533b499cbdba /src/backend/utils/adt/ruleutils.c | |
parent | fd536dd257b12a8b1abf8d744d8a3688e1db126b (diff) | |
download | postgresql-12b1b5d837b5ce1c07ee3535e74e4cc3039063d6.tar.gz postgresql-12b1b5d837b5ce1c07ee3535e74e4cc3039063d6.zip |
Instead of supposing (wrongly, in the general case) that the rowtype
of an inheritance child table is binary-compatible with the rowtype of
its parent, invent an expression node type that does the conversion
correctly. Fixes the new bug exhibited by Kris Shannon as well as a
lot of old bugs that would only show up when using multiple inheritance
or after altering the parent table.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 36e7208dc1b..44fdafcded8 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.185 2004/11/05 19:16:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.186 2004/12/11 23:26:45 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -2622,6 +2622,9 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) case T_RelabelType: return isSimpleNode((Node *) ((RelabelType *) node)->arg, node, prettyFlags); + case T_ConvertRowtypeExpr: + return isSimpleNode((Node *) ((ConvertRowtypeExpr *) node)->arg, + node, prettyFlags); case T_OpExpr: { @@ -3133,6 +3136,30 @@ get_rule_expr(Node *node, deparse_context *context, } break; + case T_ConvertRowtypeExpr: + { + ConvertRowtypeExpr *convert = (ConvertRowtypeExpr *) node; + Node *arg = (Node *) convert->arg; + + if (convert->convertformat == COERCE_IMPLICIT_CAST && + !showimplicit) + { + /* don't show the implicit cast */ + get_rule_expr_paren(arg, context, false, node); + } + else + { + if (!PRETTY_PAREN(context)) + appendStringInfoChar(buf, '('); + get_rule_expr_paren(arg, context, false, node); + if (!PRETTY_PAREN(context)) + appendStringInfoChar(buf, ')'); + appendStringInfo(buf, "::%s", + format_type_with_typemod(convert->resulttype, -1)); + } + } + break; + case T_CaseExpr: { CaseExpr *caseexpr = (CaseExpr *) node; |