From 12b1b5d837b5ce1c07ee3535e74e4cc3039063d6 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 11 Dec 2004 23:26:51 +0000 Subject: 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. --- src/backend/utils/adt/ruleutils.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/adt/ruleutils.c') 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; -- cgit v1.2.3