]> granicus.if.org Git - postgresql/blobdiff - src/include/nodes/primnodes.h
Support domains over composite types.
[postgresql] / src / include / nodes / primnodes.h
index 86ec82eaaae8637918b3d1a1df84ed20978b8192..c2929ac387fec7ef2a8365a6f2b9a3646543bddd 100644 (file)
@@ -150,9 +150,9 @@ typedef struct Expr
  * are very useful for debugging and interpreting completed plans, so we keep
  * them around.
  */
-#define    INNER_VAR           65000           /* reference to inner subplan */
-#define    OUTER_VAR           65001           /* reference to outer subplan */
-#define    INDEX_VAR           65002           /* reference to index column */
+#define    INNER_VAR           65000   /* reference to inner subplan */
+#define    OUTER_VAR           65001   /* reference to outer subplan */
+#define    INDEX_VAR           65002   /* reference to index column */
 
 #define IS_SPECIAL_VARNO(varno)                ((varno) >= INNER_VAR)
 
@@ -166,7 +166,7 @@ typedef struct Var
        Index           varno;                  /* index of this var's relation in the range
                                                                 * table, or INNER_VAR/OUTER_VAR/INDEX_VAR */
        AttrNumber      varattno;               /* attribute number of this var, or zero for
-                                                                * all */
+                                                                * all attrs ("whole-row Var") */
        Oid                     vartype;                /* pg_type OID for the type of this var */
        int32           vartypmod;              /* pg_attribute typmod value */
        Oid                     varcollid;              /* OID of collation, or InvalidOid if none */
@@ -400,10 +400,11 @@ typedef struct ArrayRef
        Oid                     refelemtype;    /* type of the array elements */
        int32           reftypmod;              /* typmod of the array (and elements too) */
        Oid                     refcollid;              /* OID of collation, or InvalidOid if none */
-       List       *refupperindexpr;/* expressions that evaluate to upper array
-                                                                * indexes */
-       List       *reflowerindexpr;/* expressions that evaluate to lower array
-                                                                * indexes, or NIL for single array element */
+       List       *refupperindexpr;    /* expressions that evaluate to upper
+                                                                        * array indexes */
+       List       *reflowerindexpr;    /* expressions that evaluate to lower
+                                                                        * array indexes, or NIL for single array
+                                                                        * element */
        Expr       *refexpr;            /* the expression that evaluates to an array
                                                                 * value */
        Expr       *refassgnexpr;       /* expression for the source value, or NULL if
@@ -691,8 +692,8 @@ typedef struct SubPlan
        /* Extra data useful for determining subplan's output type: */
        Oid                     firstColType;   /* Type of first column of subplan result */
        int32           firstColTypmod; /* Typmod of first column of subplan result */
-       Oid                     firstColCollation;              /* Collation of first column of
-                                                                                * subplan result */
+       Oid                     firstColCollation;      /* Collation of first column of subplan
+                                                                        * result */
        /* Information about execution strategy: */
        bool            useHashTable;   /* TRUE to store subselect output in a hash
                                                                 * table (implies we are doing "IN") */
@@ -754,6 +755,9 @@ typedef struct FieldSelect
  * the assign case of ArrayRef, this is used to implement UPDATE of a
  * portion of a column.
  *
+ * resulttype is always a named composite type (not a domain).  To update
+ * a composite domain value, apply CoerceToDomain to the FieldStore.
+ *
  * A single FieldStore can actually represent updates of several different
  * fields.  The parser only generates FieldStores with single-element lists,
  * but the planner will collapse multiple updates of the same base column
@@ -819,11 +823,12 @@ typedef struct CoerceViaIO
  * ArrayCoerceExpr
  *
  * ArrayCoerceExpr represents a type coercion from one array type to another,
- * which is implemented by applying the indicated element-type coercion
- * function to each element of the source array.  If elemfuncid is InvalidOid
- * then the element types are binary-compatible, but the coercion still
- * requires some effort (we have to fix the element type ID stored in the
- * array header).
+ * which is implemented by applying the per-element coercion expression
+ * "elemexpr" to each element of the source array.  Within elemexpr, the
+ * source element is represented by a CaseTestExpr node.  Note that even if
+ * elemexpr is a no-op (that is, just CaseTestExpr + RelabelType), the
+ * coercion still requires some effort: we have to fix the element type OID
+ * stored in the array header.
  * ----------------
  */
 
@@ -831,11 +836,10 @@ typedef struct ArrayCoerceExpr
 {
        Expr            xpr;
        Expr       *arg;                        /* input expression (yields an array) */
-       Oid                     elemfuncid;             /* OID of element coercion function, or 0 */
+       Expr       *elemexpr;           /* expression representing per-element work */
        Oid                     resulttype;             /* output type of coercion (an array type) */
        int32           resulttypmod;   /* output typmod (also element typmod) */
        Oid                     resultcollid;   /* OID of collation, or InvalidOid if none */
-       bool            isExplicit;             /* conversion semantics flag to pass to func */
        CoercionForm coerceformat;      /* how to display this node */
        int                     location;               /* token location, or -1 if unknown */
 } ArrayCoerceExpr;
@@ -848,7 +852,8 @@ typedef struct ArrayCoerceExpr
  * 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.
+ * valid whole-row value of its parent table's rowtype.  Both resulttype
+ * and the exposed type of "arg" must be named composite types (not domains).
  * ----------------
  */
 
@@ -986,6 +991,9 @@ typedef struct RowExpr
        Oid                     row_typeid;             /* RECORDOID or a composite type's ID */
 
        /*
+        * row_typeid cannot be a domain over composite, only plain composite.  To
+        * create a composite domain value, apply CoerceToDomain to the RowExpr.
+        *
         * Note: we deliberately do NOT store a typmod.  Although a typmod will be
         * associated with specific RECORD types at runtime, it will differ for
         * different backends, and so cannot safely be stored in stored
@@ -1278,6 +1286,20 @@ typedef struct CurrentOfExpr
        int                     cursor_param;   /* refcursor parameter number, or 0 */
 } CurrentOfExpr;
 
+/*
+ * NextValueExpr - get next value from sequence
+ *
+ * This has the same effect as calling the nextval() function, but it does not
+ * check permissions on the sequence.  This is used for identity columns,
+ * where the sequence is an implicit dependency without its own permissions.
+ */
+typedef struct NextValueExpr
+{
+       Expr            xpr;
+       Oid                     seqid;
+       Oid                     typeId;
+} NextValueExpr;
+
 /*
  * InferenceElem - an element of a unique index inference specification
  *
@@ -1293,20 +1315,6 @@ typedef struct InferenceElem
        Oid                     inferopclass;   /* OID of att opclass, or InvalidOid */
 } InferenceElem;
 
-/*
- * NextValueExpr - get next value from sequence
- *
- * This has the same effect as calling the nextval() function, but it does not
- * check permissions on the sequence.  This is used for identity columns,
- * where the sequence is an implicit dependency without its own permissions.
- */
-typedef struct NextValueExpr
-{
-       Expr            xpr;
-       Oid                     seqid;
-       Oid                     typeId;
-} NextValueExpr;
-
 /*--------------------
  * TargetEntry -
  *        a target entry (used in query target lists)
@@ -1367,8 +1375,8 @@ typedef struct TargetEntry
        Expr       *expr;                       /* expression to evaluate */
        AttrNumber      resno;                  /* attribute number (see notes above) */
        char       *resname;            /* name of the column (could be NULL) */
-       Index           ressortgroupref;/* nonzero if referenced by a sort/group
-                                                                * clause */
+       Index           ressortgroupref;        /* nonzero if referenced by a sort/group
+                                                                        * clause */
        Oid                     resorigtbl;             /* OID of column's source table */
        AttrNumber      resorigcol;             /* column's number in source table */
        bool            resjunk;                /* set to true to eliminate the attribute from
@@ -1498,4 +1506,4 @@ typedef struct OnConflictExpr
        List       *exclRelTlist;       /* tlist of the EXCLUDED pseudo relation */
 } OnConflictExpr;
 
-#endif   /* PRIMNODES_H */
+#endif                                                 /* PRIMNODES_H */