*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.169 2004/09/22 17:41:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.170 2004/12/11 23:26:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
+static Datum ExecEvalConvertRowtype(ConvertRowtypeExprState *cstate,
+ ExprContext *econtext,
+ bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalCaseTestExpr(ExprState *exprstate,
*
* Returns a Datum whose value is the value of a range
* variable with respect to given expression context.
- * ---------------------------------------------------------------- */
+ * ----------------------------------------------------------------
+ */
static Datum
ExecEvalVar(ExprState *exprstate, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
return BoolGetDatum(!AnyNull);
}
+/* ----------------------------------------------------------------
+ * ExecEvalConvertRowtype
+ *
+ * Evaluate a rowtype coercion operation. This may require
+ * rearranging field positions.
+ * ----------------------------------------------------------------
+ */
+static Datum
+ExecEvalConvertRowtype(ConvertRowtypeExprState *cstate,
+ ExprContext *econtext,
+ bool *isNull, ExprDoneCond *isDone)
+{
+ HeapTuple result;
+ Datum tupDatum;
+ HeapTupleHeader tuple;
+ HeapTupleData tmptup;
+ AttrNumber *attrMap = cstate->attrMap;
+ Datum *invalues = cstate->invalues;
+ char *innulls = cstate->innulls;
+ Datum *outvalues = cstate->outvalues;
+ char *outnulls = cstate->outnulls;
+ int i;
+ int outnatts = cstate->outdesc->natts;
+
+ tupDatum = ExecEvalExpr(cstate->arg, econtext, isNull, isDone);
+
+ /* this test covers the isDone exception too: */
+ if (*isNull)
+ return tupDatum;
+
+ tuple = DatumGetHeapTupleHeader(tupDatum);
+
+ Assert(HeapTupleHeaderGetTypeId(tuple) == cstate->indesc->tdtypeid);
+ Assert(HeapTupleHeaderGetTypMod(tuple) == cstate->indesc->tdtypmod);
+
+ /*
+ * heap_deformtuple needs a HeapTuple not a bare HeapTupleHeader.
+ */
+ tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
+ tmptup.t_data = tuple;
+
+ /*
+ * Extract all the values of the old tuple, offsetting the arrays
+ * so that invalues[0] is NULL and invalues[1] is the first
+ * source attribute; this exactly matches the numbering convention
+ * in attrMap.
+ */
+ heap_deformtuple(&tmptup, cstate->indesc, invalues + 1, innulls + 1);
+ invalues[0] = (Datum) 0;
+ innulls[0] = 'n';
+
+ /*
+ * Transpose into proper fields of the new tuple.
+ */
+ for (i = 0; i < outnatts; i++)
+ {
+ int j = attrMap[i];
+
+ outvalues[i] = invalues[j];
+ outnulls[i] = innulls[j];
+ }
+
+ /*
+ * Now form the new tuple.
+ */
+ result = heap_formtuple(cstate->outdesc, outvalues, outnulls);
+
+ return HeapTupleGetDatum(result);
+}
/* ----------------------------------------------------------------
* ExecEvalCase
state = (ExprState *) gstate;
}
break;
+ case T_ConvertRowtypeExpr:
+ {
+ ConvertRowtypeExpr *convert = (ConvertRowtypeExpr *) node;
+ ConvertRowtypeExprState *cstate = makeNode(ConvertRowtypeExprState);
+ int i;
+ int n;
+
+ cstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalConvertRowtype;
+ cstate->arg = ExecInitExpr(convert->arg, parent);
+ /* save copies of needed tuple descriptors */
+ cstate->indesc = lookup_rowtype_tupdesc(exprType((Node *) convert->arg), -1);
+ cstate->indesc = CreateTupleDescCopy(cstate->indesc);
+ cstate->outdesc = lookup_rowtype_tupdesc(convert->resulttype, -1);
+ cstate->outdesc = CreateTupleDescCopy(cstate->outdesc);
+ /* prepare map from old to new attribute numbers */
+ n = cstate->outdesc->natts;
+ cstate->attrMap = (AttrNumber *) palloc0(n * sizeof(AttrNumber));
+ for (i = 0; i < n; i++)
+ {
+ Form_pg_attribute att = cstate->outdesc->attrs[i];
+ char *attname;
+ Oid atttypid;
+ int32 atttypmod;
+ int j;
+
+ if (att->attisdropped)
+ continue; /* attrMap[i] is already 0 */
+ attname = NameStr(att->attname);
+ atttypid = att->atttypid;
+ atttypmod = att->atttypmod;
+ for (j = 0; j < cstate->indesc->natts; j++)
+ {
+ att = cstate->indesc->attrs[j];
+ if (att->attisdropped)
+ continue;
+ if (strcmp(attname, NameStr(att->attname)) == 0)
+ {
+ /* Found it, check type */
+ if (atttypid != att->atttypid || atttypmod != att->atttypmod)
+ elog(ERROR, "attribute \"%s\" of type %s does not match corresponding attribute of type %s",
+ attname,
+ format_type_be(cstate->indesc->tdtypeid),
+ format_type_be(cstate->outdesc->tdtypeid));
+ cstate->attrMap[i] = (AttrNumber) (j + 1);
+ break;
+ }
+ }
+ if (cstate->attrMap[i] == 0)
+ elog(ERROR, "attribute \"%s\" of type %s does not exist",
+ attname,
+ format_type_be(cstate->indesc->tdtypeid));
+ }
+ /* preallocate workspace for Datum arrays */
+ n = cstate->indesc->natts + 1; /* +1 for NULL */
+ cstate->invalues = (Datum *) palloc(n * sizeof(Datum));
+ cstate->innulls = (char *) palloc(n * sizeof(char));
+ n = cstate->outdesc->natts;
+ cstate->outvalues = (Datum *) palloc(n * sizeof(Datum));
+ cstate->outnulls = (char *) palloc(n * sizeof(char));
+ state = (ExprState *) cstate;
+ }
+ break;
case T_CaseExpr:
{
CaseExpr *caseexpr = (CaseExpr *) node;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.293 2004/11/05 19:15:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.294 2004/12/11 23:26:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
return newnode;
}
+/*
+ * _copyConvertRowtypeExpr
+ */
+static ConvertRowtypeExpr *
+_copyConvertRowtypeExpr(ConvertRowtypeExpr *from)
+{
+ ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
+
+ COPY_NODE_FIELD(arg);
+ COPY_SCALAR_FIELD(resulttype);
+ COPY_SCALAR_FIELD(convertformat);
+
+ return newnode;
+}
+
/*
* _copyCaseExpr
*/
case T_RelabelType:
retval = _copyRelabelType(from);
break;
+ case T_ConvertRowtypeExpr:
+ retval = _copyConvertRowtypeExpr(from);
+ break;
case T_CaseExpr:
retval = _copyCaseExpr(from);
break;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.232 2004/11/05 19:15:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.233 2004/12/11 23:26:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
return true;
}
+static bool
+_equalConvertRowtypeExpr(ConvertRowtypeExpr *a, ConvertRowtypeExpr *b)
+{
+ COMPARE_NODE_FIELD(arg);
+ COMPARE_SCALAR_FIELD(resulttype);
+
+ /*
+ * Special-case COERCE_DONTCARE, so that planner can build coercion
+ * nodes that are equal() to both explicit and implicit coercions.
+ */
+ if (a->convertformat != b->convertformat &&
+ a->convertformat != COERCE_DONTCARE &&
+ b->convertformat != COERCE_DONTCARE)
+ return false;
+
+ return true;
+}
+
static bool
_equalCaseExpr(CaseExpr *a, CaseExpr *b)
{
case T_RelabelType:
retval = _equalRelabelType(a, b);
break;
+ case T_ConvertRowtypeExpr:
+ retval = _equalConvertRowtypeExpr(a, b);
+ break;
case T_CaseExpr:
retval = _equalCaseExpr(a, b);
break;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.243 2004/08/29 05:06:43 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.244 2004/12/11 23:26:33 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
WRITE_ENUM_FIELD(relabelformat, CoercionForm);
}
+static void
+_outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
+{
+ WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
+
+ WRITE_NODE_FIELD(arg);
+ WRITE_OID_FIELD(resulttype);
+ WRITE_ENUM_FIELD(convertformat, CoercionForm);
+}
+
static void
_outCaseExpr(StringInfo str, CaseExpr *node)
{
case T_RelabelType:
_outRelabelType(str, obj);
break;
+ case T_ConvertRowtypeExpr:
+ _outConvertRowtypeExpr(str, obj);
+ break;
case T_CaseExpr:
_outCaseExpr(str, obj);
break;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.173 2004/08/29 04:12:33 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.174 2004/12/11 23:26:34 tgl Exp $
*
* NOTES
* Path and Plan nodes do not have any readfuncs support, because we
READ_DONE();
}
+/*
+ * _readConvertRowtypeExpr
+ */
+static ConvertRowtypeExpr *
+_readConvertRowtypeExpr(void)
+{
+ READ_LOCALS(ConvertRowtypeExpr);
+
+ READ_NODE_FIELD(arg);
+ READ_OID_FIELD(resulttype);
+ READ_ENUM_FIELD(convertformat, CoercionForm);
+
+ READ_DONE();
+}
+
/*
* _readCaseExpr
*/
return_value = _readFieldStore();
else if (MATCH("RELABELTYPE", 11))
return_value = _readRelabelType();
+ else if (MATCH("CONVERTROWTYPEEXPR", 18))
+ return_value = _readConvertRowtypeExpr();
else if (MATCH("CASE", 4))
return_value = _readCaseExpr();
else if (MATCH("WHEN", 4))
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.23 2004/08/29 05:06:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.24 2004/12/11 23:26:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
result = find_nonnullable_rels((Node *) expr->arg, top_level);
}
+ else if (IsA(node, ConvertRowtypeExpr))
+ {
+ /* not clear this is useful, but it can't hurt */
+ ConvertRowtypeExpr *expr = (ConvertRowtypeExpr *) node;
+
+ result = find_nonnullable_rels((Node *) expr->arg, top_level);
+ }
else if (IsA(node, NullTest))
{
NullTest *expr = (NullTest *) node;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.117 2004/10/02 22:39:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.118 2004/12/11 23:26:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
Index old_rt_index;
Index new_rt_index;
+ Oid old_rel_type;
+ Oid new_rel_type;
TupleDesc old_tupdesc;
TupleDesc new_tupdesc;
char *old_rel_name;
context.old_rt_index = old_rt_index;
context.new_rt_index = new_rt_index;
+ context.old_rel_type = oldrelation->rd_rel->reltype;
+ context.new_rel_type = newrelation->rd_rel->reltype;
context.old_tupdesc = RelationGetDescr(oldrelation);
context.new_tupdesc = RelationGetDescr(newrelation);
context.old_rel_name = RelationGetRelationName(oldrelation);
return 0; /* keep compiler quiet */
}
-/*
- * Translate a whole-row Var to be correct for a child table.
- *
- * In general the child will not have a suitable field layout to be used
- * directly, so we translate the simple whole-row Var into a ROW() construct.
- */
-static Node *
-generate_whole_row(Var *var,
- adjust_inherited_attrs_context *context)
-{
- RowExpr *rowexpr;
- List *fields = NIL;
- int oldnatts = context->old_tupdesc->natts;
- int i;
-
- for (i = 0; i < oldnatts; i++)
- {
- Form_pg_attribute att = context->old_tupdesc->attrs[i];
- Var *newvar;
-
- if (att->attisdropped)
- {
- /*
- * can't use atttypid here, but it doesn't really matter what
- * type the Const claims to be.
- */
- newvar = (Var *) makeNullConst(INT4OID);
- }
- else
- newvar = makeVar(context->new_rt_index,
- translate_inherited_attnum(i + 1, context),
- att->atttypid,
- att->atttypmod,
- 0);
- fields = lappend(fields, newvar);
- }
- rowexpr = makeNode(RowExpr);
- rowexpr->args = fields;
- rowexpr->row_typeid = var->vartype; /* report parent's rowtype */
- rowexpr->row_format = COERCE_IMPLICIT_CAST;
-
- return (Node *) rowexpr;
-}
-
static Node *
adjust_inherited_attrs_mutator(Node *node,
adjust_inherited_attrs_context *context)
}
else if (var->varattno == 0)
{
- /* expand whole-row reference into a ROW() construct */
- return generate_whole_row(var, context);
+ /*
+ * Whole-row Var: we need to insert a coercion step to convert
+ * the tuple layout to the parent's rowtype.
+ */
+ if (context->old_rel_type != context->new_rel_type)
+ {
+ ConvertRowtypeExpr *r = makeNode(ConvertRowtypeExpr);
+
+ r->arg = (Expr *) var;
+ r->resulttype = context->old_rel_type;
+ r->convertformat = COERCE_IMPLICIT_CAST;
+ /* Make sure the Var node has the right type ID, too */
+ Assert(var->vartype == context->old_rel_type);
+ var->vartype = context->new_rel_type;
+ return (Node *) r;
+ }
}
/* system attributes don't need any translation */
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.184 2004/11/09 21:42:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.185 2004/12/11 23:26:39 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
if (r->relabelformat == COERCE_IMPLICIT_CAST)
return strip_implicit_coercions((Node *) r->arg);
}
+ else if (IsA(node, ConvertRowtypeExpr))
+ {
+ ConvertRowtypeExpr *c = (ConvertRowtypeExpr *) node;
+
+ if (c->convertformat == COERCE_IMPLICIT_CAST)
+ return strip_implicit_coercions((Node *) c->arg);
+ }
else if (IsA(node, CoerceToDomain))
{
CoerceToDomain *c = (CoerceToDomain *) node;
return false;
if (IsA(node, FuncExpr))
((FuncExpr *) node)->funcformat = COERCE_DONTCARE;
- if (IsA(node, RelabelType))
+ else if (IsA(node, RelabelType))
((RelabelType *) node)->relabelformat = COERCE_DONTCARE;
- if (IsA(node, RowExpr))
+ else if (IsA(node, ConvertRowtypeExpr))
+ ((ConvertRowtypeExpr *) node)->convertformat = COERCE_DONTCARE;
+ else if (IsA(node, RowExpr))
((RowExpr *) node)->row_format = COERCE_DONTCARE;
- if (IsA(node, CoerceToDomain))
+ else if (IsA(node, CoerceToDomain))
((CoerceToDomain *) node)->coercionformat = COERCE_DONTCARE;
return expression_tree_walker(node, set_coercionform_dontcare_walker,
context);
break;
case T_RelabelType:
return walker(((RelabelType *) node)->arg, context);
+ case T_ConvertRowtypeExpr:
+ return walker(((ConvertRowtypeExpr *) node)->arg, context);
case T_CaseExpr:
{
CaseExpr *caseexpr = (CaseExpr *) node;
return (Node *) newnode;
}
break;
+ case T_ConvertRowtypeExpr:
+ {
+ ConvertRowtypeExpr *convexpr = (ConvertRowtypeExpr *) node;
+ ConvertRowtypeExpr *newnode;
+
+ FLATCOPY(newnode, convexpr, ConvertRowtypeExpr);
+ MUTATE(newnode->arg, convexpr->arg, Expr *);
+ return (Node *) newnode;
+ }
+ break;
case T_CaseExpr:
{
CaseExpr *caseexpr = (CaseExpr *) node;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.124 2004/11/06 17:46:33 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.125 2004/12/11 23:26:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (typeInheritsFrom(inputTypeId, targetTypeId))
{
/*
- * Input class type is a subclass of target, so nothing to do ---
- * except relabel the type. This is binary compatibility for
- * complex types.
+ * Input class type is a subclass of target, so generate an
+ * appropriate runtime conversion (removing unneeded columns
+ * and possibly rearranging the ones that are wanted).
*/
- return (Node *) makeRelabelType((Expr *) node,
- targetTypeId, -1,
- cformat);
+ ConvertRowtypeExpr *r = makeNode(ConvertRowtypeExpr);
+
+ r->arg = (Expr *) node;
+ r->resulttype = targetTypeId;
+ r->convertformat = cformat;
+ return (Node *) r;
}
/* If we get here, caller blew it */
elog(ERROR, "failed to find conversion function from %s to %s",
((FuncExpr *) node)->funcformat = COERCE_IMPLICIT_CAST;
else if (IsA(node, RelabelType))
((RelabelType *) node)->relabelformat = COERCE_IMPLICIT_CAST;
+ else if (IsA(node, ConvertRowtypeExpr))
+ ((ConvertRowtypeExpr *) node)->convertformat = COERCE_IMPLICIT_CAST;
else if (IsA(node, RowExpr))
((RowExpr *) node)->row_format = COERCE_IMPLICIT_CAST;
else if (IsA(node, CoerceToDomain))
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.176 2004/08/29 05:06:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.177 2004/12/11 23:26:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
case T_FieldSelect:
case T_FieldStore:
case T_RelabelType:
+ case T_ConvertRowtypeExpr:
case T_CaseTestExpr:
case T_CoerceToDomain:
case T_CoerceToDomainValue:
case T_RelabelType:
type = ((RelabelType *) expr)->resulttype;
break;
+ case T_ConvertRowtypeExpr:
+ type = ((ConvertRowtypeExpr *) expr)->resulttype;
+ break;
case T_CaseExpr:
type = ((CaseExpr *) expr)->casetype;
break;
* 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.
*
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:
{
}
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;
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.120 2004/10/07 18:38:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.121 2004/12/11 23:26:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
TupleDesc argdesc; /* tupdesc for most recent input */
} FieldStoreState;
+/* ----------------
+ * ConvertRowtypeExprState node
+ * ----------------
+ */
+typedef struct ConvertRowtypeExprState
+{
+ ExprState xprstate;
+ ExprState *arg; /* input tuple value */
+ TupleDesc indesc; /* tupdesc for source rowtype */
+ TupleDesc outdesc; /* tupdesc for result rowtype */
+ AttrNumber *attrMap; /* indexes of input fields, or 0 for null */
+ Datum *invalues; /* workspace for deconstructing source */
+ char *innulls;
+ Datum *outvalues; /* workspace for constructing result */
+ char *outnulls;
+} ConvertRowtypeExprState;
+
/* ----------------
* CaseExprState node
* ----------------
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.161 2004/09/14 03:21:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.162 2004/12/11 23:26:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
T_FieldSelect,
T_FieldStore,
T_RelabelType,
+ T_ConvertRowtypeExpr,
T_CaseExpr,
T_CaseWhen,
T_CaseTestExpr,
T_SubPlanState,
T_FieldSelectState,
T_FieldStoreState,
+ T_ConvertRowtypeExprState,
T_CaseExprState,
T_CaseWhenState,
T_ArrayExprState,
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.104 2004/08/29 05:06:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.105 2004/12/11 23:26:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
CoercionForm relabelformat; /* how to display this node */
} RelabelType;
+/* ----------------
+ * ConvertRowtypeExpr
+ *
+ * ConvertRowtypeExpr represents a type coercion from one composite type
+ * to another, where the source type is guaranteed to contain all the columns
+ * needed for the destination type plus possibly others; the columns need not
+ * be in the same positions, but are matched up by name. This is primarily
+ * used to convert a whole-row value of an inheritance child table into a
+ * valid whole-row value of its parent table's rowtype.
+ * ----------------
+ */
+
+typedef struct ConvertRowtypeExpr
+{
+ Expr xpr;
+ Expr *arg; /* input expression */
+ Oid resulttype; /* output type (always a composite type) */
+ /* result typmod is not stored, but must be -1; see RowExpr comments */
+ CoercionForm convertformat; /* how to display this node */
+} ConvertRowtypeExpr;
+
/*----------
* CaseExpr - a CASE expression
*
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.123 2004/11/30 03:50:29 neilc Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.124 2004/12/11 23:26:51 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
case T_RelabelType:
return exec_simple_check_node((Node *) ((RelabelType *) node)->arg);
+ case T_ConvertRowtypeExpr:
+ return exec_simple_check_node((Node *) ((ConvertRowtypeExpr *) node)->arg);
+
case T_CaseExpr:
{
CaseExpr *expr = (CaseExpr *) node;