130 bool isAddConstraint);
132 bool skipValidation);
134 List *constraintList);
136static void setSchemaName(
const char *context_schema,
char **stmt_schema_name);
142 const char *colName,
Oid colType,
int32 colTypmod,
186 stmt->relation->location);
209 (
errcode(ERRCODE_DUPLICATE_TABLE),
210 errmsg(
"relation \"%s\" already exists, skipping",
211 stmt->relation->relname)));
222 if (
stmt->relation->schemaname == NULL
223 &&
stmt->relation->relpersistence != RELPERSISTENCE_TEMP)
230 cxt.
stmtType =
"CREATE FOREIGN TABLE";
257 if (
stmt->ofTypename)
262 if (
stmt->inhRelations && !
stmt->partbound)
264 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
265 errmsg(
"cannot create partitioned table as inheritance child")));
272 foreach(elements,
stmt->tableElts)
286 case T_TableLikeClause:
291 elog(
ERROR,
"unrecognized node type: %d",
303 save_alist = cxt.
alist;
323 if (strcmp(cd->colname, colname) != 0)
329 cd->is_not_null =
true;
391 Oid seqtypid,
List *seqoptions,
392 bool for_identity,
bool col_exists,
393 char **snamespace_p,
char **sname_p)
414 foreach(
option, seqoptions)
418 if (strcmp(defel->
defname,
"sequence_name") == 0)
425 else if (strcmp(defel->
defname,
"logged") == 0 ||
426 strcmp(defel->
defname,
"unlogged") == 0)
484 (
errmsg_internal(
"%s will create implicit sequence \"%s\" for serial column \"%s.%s\"",
501 if (seqpersistence == RELPERSISTENCE_TEMP)
503 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
504 errmsg(
"cannot set logged status of a temporary sequence"),
506 else if (strcmp(loggedEl->
defname,
"logged") == 0)
507 seqpersistence = RELPERSISTENCE_PERMANENT;
509 seqpersistence = RELPERSISTENCE_UNLOGGED;
571 (
Node *) attnamelist, -1));
580 *snamespace_p = snamespace;
598 bool need_notnull =
false;
599 bool disallow_noinherit_notnull =
false;
612 if (strcmp(
typname,
"smallserial") == 0 ||
613 strcmp(
typname,
"serial2") == 0)
619 else if (strcmp(
typname,
"serial") == 0 ||
620 strcmp(
typname,
"serial4") == 0)
626 else if (strcmp(
typname,
"bigserial") == 0 ||
627 strcmp(
typname,
"serial8") == 0)
641 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
642 errmsg(
"array of serial is not implemented"),
665 &snamespace, &sname);
684 castnode->
arg = (
Node *) snamenode;
699 disallow_noinherit_notnull =
true;
717 if (!disallow_noinherit_notnull)
721 switch (constraint->contype)
725 disallow_noinherit_notnull =
true;
734 saw_nullable =
false;
736 saw_identity =
false;
737 saw_generated =
false;
741 switch (constraint->contype)
744 if ((saw_nullable && column->
is_not_null) || need_notnull)
746 (
errcode(ERRCODE_SYNTAX_ERROR),
747 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
750 constraint->location)));
758 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
759 errmsg(
"not-null constraints on partitioned tables cannot be NO INHERIT"));
764 (
errcode(ERRCODE_SYNTAX_ERROR),
765 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
768 constraint->location)));
770 if (disallow_noinherit_notnull && constraint->is_no_inherit)
773 errmsg(
"conflicting NO INHERIT declarations for not-null constraints on column \"%s\"",
791 need_notnull =
false;
794 notnull_constraint = constraint;
797 else if (notnull_constraint)
799 if (constraint->conname &&
801 strcmp(notnull_constraint->
conname, constraint->conname) != 0)
802 elog(
ERROR,
"conflicting not-null constraint names \"%s\" and \"%s\"",
803 notnull_constraint->
conname, constraint->conname);
805 if (notnull_constraint->
is_no_inherit != constraint->is_no_inherit)
808 errmsg(
"conflicting NO INHERIT declarations for not-null constraints on column \"%s\"",
811 if (!notnull_constraint->
conname && constraint->conname)
812 notnull_constraint->
conname = constraint->conname;
820 (
errcode(ERRCODE_SYNTAX_ERROR),
821 errmsg(
"multiple default values specified for column \"%s\" of table \"%s\"",
824 constraint->location)));
826 Assert(constraint->cooked_expr == NULL);
837 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
838 errmsg(
"identity columns are not supported on typed tables")));
841 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
842 errmsg(
"identity columns are not supported on partitions")));
850 (
errcode(ERRCODE_SYNTAX_ERROR),
851 errmsg(
"multiple identity specifications for column \"%s\" of table \"%s\"",
854 constraint->location)));
857 typeOid, constraint->options,
861 column->
identity = constraint->generated_when;
872 (
errcode(ERRCODE_SYNTAX_ERROR),
873 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
876 constraint->location)));
883 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
884 errmsg(
"generated columns are not supported on typed tables")));
887 (
errcode(ERRCODE_SYNTAX_ERROR),
888 errmsg(
"multiple generation clauses specified for column \"%s\" of table \"%s\"",
891 constraint->location)));
892 column->
generated = constraint->generated_kind;
894 Assert(constraint->cooked_expr == NULL);
895 saw_generated =
true;
905 (
errcode(ERRCODE_SYNTAX_ERROR),
906 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
909 constraint->location)));
914 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
915 errmsg(
"primary key constraints are not supported on foreign tables"),
917 constraint->location)));
923 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
924 errmsg(
"unique constraints are not supported on foreign tables"),
926 constraint->location)));
927 if (constraint->keys ==
NIL)
934 elog(
ERROR,
"column exclusion constraints are not supported");
940 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
941 errmsg(
"foreign key constraints are not supported on foreign tables"),
943 constraint->location)));
963 elog(
ERROR,
"unrecognized constraint type: %d",
964 constraint->contype);
968 if (saw_default && saw_identity)
970 (
errcode(ERRCODE_SYNTAX_ERROR),
971 errmsg(
"both default and identity specified for column \"%s\" of table \"%s\"",
974 constraint->location)));
976 if (saw_default && saw_generated)
978 (
errcode(ERRCODE_SYNTAX_ERROR),
979 errmsg(
"both default and generation expression specified for column \"%s\" of table \"%s\"",
982 constraint->location)));
984 if (saw_identity && saw_generated)
986 (
errcode(ERRCODE_SYNTAX_ERROR),
987 errmsg(
"both identity and generation expression specified for column \"%s\" of table \"%s\"",
990 constraint->location)));
997 if (need_notnull && !(saw_nullable && column->
is_not_null))
1042 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1043 errmsg(
"primary key constraints are not supported on foreign tables"),
1052 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1053 errmsg(
"unique constraints are not supported on foreign tables"),
1062 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1063 errmsg(
"exclusion constraints are not supported on foreign tables"),
1076 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1077 errmsg(
"not-null constraints on partitioned tables cannot be NO INHERIT"));
1085 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1086 errmsg(
"foreign key constraints are not supported on foreign tables"),
1100 elog(
ERROR,
"invalid context for constraint type %d",
1105 elog(
ERROR,
"unrecognized constraint type: %d",
1141 if (relation->
rd_rel->relkind != RELKIND_RELATION &&
1142 relation->
rd_rel->relkind != RELKIND_VIEW &&
1143 relation->
rd_rel->relkind != RELKIND_MATVIEW &&
1144 relation->
rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
1145 relation->
rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
1146 relation->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
1148 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1149 errmsg(
"relation \"%s\" is invalid in LIKE clause",
1158 if (relation->
rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
1182 for (parent_attno = 1; parent_attno <= tupleDesc->
natts;
1192 if (attribute->attisdropped)
1199 attribute->atttypmod, attribute->attcollation);
1210 if (attribute->atthasdef && attribute->attgenerated &&
1212 def->
generated = attribute->attgenerated;
1217 if (attribute->attidentity &&
1234 def->
identity = attribute->attidentity;
1240 def->
storage = attribute->attstorage;
1257 attribute->attnum)) != NULL)
1289 nnconstr->conname,
false),
1290 ConstraintRelationId,
1316 if (table_like_clause->
options &
1364 elog(
ERROR,
"expandTableLikeClause called on untransformed LIKE clause");
1369 constr = tupleDesc->
constr;
1388 if ((table_like_clause->
options &
1392 for (parent_attno = 1; parent_attno <= tupleDesc->
natts;
1401 if (attribute->attisdropped)
1409 if (attribute->atthasdef &&
1410 (attribute->attgenerated ?
1416 bool found_whole_row;
1419 if (this_default == NULL)
1420 elog(
ERROR,
"default expression not found for attribute %d of relation \"%s\"",
1425 atsubcmd->
num = attmap->
attnums[parent_attno - 1];
1437 if (found_whole_row)
1439 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1440 errmsg(
"cannot convert whole-row table reference"),
1441 errdetail(
"Generation expression for column \"%s\" contains a whole-row reference to table \"%s\".",
1445 atsubcmds =
lappend(atsubcmds, atsubcmd);
1459 for (ccnum = 0; ccnum < constr->
num_check; ccnum++)
1466 bool found_whole_row;
1481 if (found_whole_row)
1483 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1484 errmsg(
"cannot convert whole-row table reference"),
1485 errdetail(
"Constraint \"%s\" contains a whole-row reference to table \"%s\".",
1505 atsubcmds =
lappend(atsubcmds, atsubcmd);
1511 ConstraintRelationId,
1537 atcmd->
cmds = atsubcmds;
1540 result =
lcons(atcmd, result);
1547 relation->
rd_rel->relhasindex &&
1548 childrel->
rd_rel->relkind != RELKIND_FOREIGN_TABLE)
1550 List *parent_indexes;
1555 foreach(l, parent_indexes)
1581 result =
lappend(result, index_stmt);
1592 List *parent_extstats;
1597 foreach(l, parent_extstats)
1619 result =
lappend(result, stats_stmt);
1651 ofTypename->
typeOid = ofTypeId;
1654 for (
i = 0;
i < tupdesc->
natts;
i++)
1659 if (attr->attisdropped)
1663 attr->atttypmod, attr->attcollation);
1723 elog(
ERROR,
"cache lookup failed for relation %u", source_relid);
1729 indrelid = idxrec->indrelid;
1734 elog(
ERROR,
"cache lookup failed for access method %u",
1740 Anum_pg_index_indcollation);
1749 index->relation = heapRel;
1754 index->tableSpace = NULL;
1756 index->idxcomment = NULL;
1761 index->unique = idxrec->indisunique;
1762 index->nulls_not_distinct = idxrec->indnullsnotdistinct;
1763 index->primary = idxrec->indisprimary;
1764 index->iswithoutoverlaps = (idxrec->indisprimary || idxrec->indisunique) && idxrec->indisexclusion;
1765 index->transformed =
true;
1766 index->concurrent =
false;
1767 index->if_not_exists =
false;
1768 index->reset_default_tblspc =
false;
1776 index->idxname = NULL;
1784 if (
index->primary ||
index->unique || idxrec->indisexclusion)
1794 *constraintOid = constraintId;
1799 elog(
ERROR,
"cache lookup failed for constraint %u",
1803 index->isconstraint =
true;
1804 index->deferrable = conrec->condeferrable;
1805 index->initdeferred = conrec->condeferred;
1808 if (idxrec->indisexclusion)
1814 Assert(conrec->contype == CONSTRAINT_EXCLUSION ||
1815 (
index->iswithoutoverlaps &&
1816 (conrec->contype == CONSTRAINT_PRIMARY || conrec->contype == CONSTRAINT_UNIQUE)));
1819 Anum_pg_constraint_conexclop);
1822 for (
i = 0;
i < nElems;
i++)
1834 elog(
ERROR,
"cache lookup failed for operator %u",
1851 index->isconstraint =
false;
1854 index->isconstraint =
false;
1858 Anum_pg_index_indexprs, &isnull);
1874 for (keyno = 0; keyno < idxrec->indnkeyatts; keyno++)
1893 iparam->
expr = NULL;
1899 bool found_whole_row;
1901 if (indexpr_item == NULL)
1902 elog(
ERROR,
"too few entries in indexprs list");
1904 indexpr_item =
lnext(indexprs, indexpr_item);
1913 if (found_whole_row)
1915 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1916 errmsg(
"cannot convert whole-row table reference"),
1917 errdetail(
"Index \"%s\" contains a whole-row table reference.",
1920 iparam->
name = NULL;
1921 iparam->
expr = indexkey;
1949 if (opt & INDOPTION_DESC)
1952 if ((opt & INDOPTION_NULLS_FIRST) == 0)
1957 if (opt & INDOPTION_NULLS_FIRST)
1966 for (keyno = idxrec->indnkeyatts; keyno < idxrec->indnatts; keyno++)
1983 iparam->
expr = NULL;
1987 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1988 errmsg(
"expressions are not supported in included columns")));
1997 Anum_pg_class_reloptions, &isnull);
2003 Anum_pg_index_indpred, &isnull);
2008 bool found_whole_row;
2021 if (found_whole_row)
2023 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2024 errmsg(
"cannot convert whole-row table reference"),
2025 errdetail(
"Index \"%s\" contains a whole-row table reference.",
2028 index->whereClause = pred_tree;
2068 elog(
ERROR,
"cache lookup failed for statistics object %u", source_statsid);
2073 Anum_pg_statistic_ext_stxkind);
2078 elog(
ERROR,
"stxkind is not a 1-D char array");
2082 if (enabled[
i] == STATS_EXT_NDISTINCT)
2084 else if (enabled[
i] == STATS_EXT_DEPENDENCIES)
2086 else if (enabled[
i] == STATS_EXT_MCV)
2088 else if (enabled[
i] == STATS_EXT_EXPRESSIONS)
2092 elog(
ERROR,
"unrecognized statistics kind %c", enabled[
i]);
2096 for (
i = 0;
i < statsrec->stxkeys.dim1;
i++)
2104 def_names =
lappend(def_names, selem);
2117 Anum_pg_statistic_ext_stxexprs, &isnull);
2132 bool found_whole_row;
2144 def_names =
lappend(def_names, selem);
2154 stats->
exprs = def_names;
2188 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2215 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
2274 if (cxt->
pkey != NULL)
2280 foreach(lc, indexlist)
2291 foreach(k, finalindexlist)
2312 if (priorindex->
idxname == NULL)
2349 if (cxt->
pkey != NULL)
2351 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
2352 errmsg(
"multiple primary keys for table \"%s\" are not allowed",
2363 index->isconstraint =
true;
2368 if (constraint->
conname != NULL)
2371 index->idxname = NULL;
2381 index->idxcomment = NULL;
2386 index->transformed =
false;
2387 index->concurrent =
false;
2388 index->if_not_exists =
false;
2399 char *index_name = constraint->
indexname;
2405 Datum indclassDatum;
2418 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2419 errmsg(
"cannot use an existing index in CREATE TABLE"),
2427 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2428 errmsg(
"index \"%s\" does not exist", index_name),
2438 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2439 errmsg(
"index \"%s\" is already associated with a constraint",
2446 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2447 errmsg(
"index \"%s\" does not belong to table \"%s\"",
2451 if (!index_form->indisvalid)
2453 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2454 errmsg(
"index \"%s\" is not valid", index_name),
2462 if (!index_form->indisunique)
2464 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2465 errmsg(
"\"%s\" is not a unique index", index_name),
2466 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2471 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2472 errmsg(
"index \"%s\" contains expressions", index_name),
2473 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2478 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2479 errmsg(
"\"%s\" is a partial index", index_name),
2480 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2488 if (!index_form->indimmediate && !constraint->
deferrable)
2490 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2491 errmsg(
"\"%s\" is a deferrable index", index_name),
2492 errdetail(
"Cannot create a non-deferrable constraint using a deferrable index."),
2503 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2504 errmsg(
"index \"%s\" is not a btree", index_name),
2510 Anum_pg_index_indclass);
2513 for (
i = 0;
i < index_form->indnatts;
i++)
2527 Assert(attnum <= heap_rel->rd_att->natts);
2534 if (i < index_form->indnkeyatts)
2548 index_rel->
rd_rel->relam);
2549 if (indclass->
values[
i] != defopclass ||
2551 attoptions != (
Datum) 0 ||
2554 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2555 errmsg(
"index \"%s\" column number %d does not have default sorting behavior", index_name,
i + 1),
2556 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2574 index->indexOid = index_oid;
2608 foreach(lc, constraint->
keys)
2618 foreach(columns, cxt->
columns)
2652 if (nn->is_no_inherit)
2654 errcode(ERRCODE_SYNTAX_ERROR),
2655 errmsg(
"conflicting NO INHERIT declaration for not-null constraint on column \"%s\"",
2694 if (rel->
rd_rel->relkind != RELKIND_RELATION &&
2695 rel->
rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
2696 rel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
2698 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2699 errmsg(
"inherited relation \"%s\" is not a table or foreign table",
2701 for (count = 0; count < rel->
rd_att->
natts; count++)
2705 char *inhname =
NameStr(inhattr->attname);
2707 if (inhattr->attisdropped)
2709 if (strcmp(
key, inhname) == 0)
2712 typid = inhattr->atttypid;
2734 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2735 errmsg(
"column \"%s\" named in key does not exist",
key),
2739 foreach(columns,
index->indexParams)
2742 if (iparam->
name && strcmp(
key, iparam->
name) == 0)
2746 (
errcode(ERRCODE_DUPLICATE_COLUMN),
2747 errmsg(
"column \"%s\" appears twice in primary key constraint",
2752 (
errcode(ERRCODE_DUPLICATE_COLUMN),
2753 errmsg(
"column \"%s\" appears twice in unique constraint",
2778 if (attr->attisdropped)
2785 typid = attr->atttypid;
2797 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2798 errmsg(
"column \"%s\" in WITHOUT OVERLAPS is not a range or multirange type",
key),
2806 iparam->
expr = NULL;
2825 errcode(ERRCODE_SYNTAX_ERROR),
2826 errmsg(
"constraint using WITHOUT OVERLAPS needs at least two columns"));
2829 index->accessMethod =
"gist";
2849 foreach(columns, cxt->
columns)
2882 if (rel->
rd_rel->relkind != RELKIND_RELATION &&
2883 rel->
rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
2884 rel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
2886 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2887 errmsg(
"inherited relation \"%s\" is not a table or foreign table",
2889 for (count = 0; count < rel->
rd_att->
natts; count++)
2893 char *inhname =
NameStr(inhattr->attname);
2895 if (inhattr->attisdropped)
2897 if (strcmp(
key, inhname) == 0)
2917 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2918 errmsg(
"column \"%s\" named in key does not exist",
key),
2924 iparam->
expr = NULL;
2977 bool skipValidation,
bool isAddConstraint)
3013 if (!isAddConstraint)
3027 altercmd->
name = NULL;
3028 altercmd->
def = (
Node *) constraint;
3057 if (
stmt->transformed)
3078 if (
stmt->whereClause)
3089 foreach(l,
stmt->indexParams)
3122 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3123 errmsg(
"index expressions and predicates can refer only to the table being indexed")));
3131 stmt->transformed =
true;
3152 if (
stmt->transformed)
3173 foreach(l,
stmt->exprs)
3194 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3195 errmsg(
"statistics expressions can refer only to the table being referenced")));
3203 stmt->transformed =
true;
3220 List **actions,
Node **whereClause)
3235 if (rel->
rd_rel->relkind == RELKIND_MATVIEW)
3237 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3238 errmsg(
"rules on materialized views are not supported")));
3265 switch (
stmt->event)
3281 elog(
ERROR,
"unrecognized event type: %d",
3297 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3298 errmsg(
"rule WHERE condition cannot contain references to other relations")));
3325 foreach(l,
stmt->actions)
3367 *whereClause != NULL)
3369 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3370 errmsg(
"rules with WHERE conditions can only have SELECT, INSERT, UPDATE, or DELETE actions")));
3387 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3388 errmsg(
"conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
3400 switch (
stmt->event)
3405 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3406 errmsg(
"ON SELECT rule cannot use OLD")));
3409 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3410 errmsg(
"ON SELECT rule cannot use NEW")));
3418 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3419 errmsg(
"ON INSERT rule cannot use OLD")));
3424 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3425 errmsg(
"ON DELETE rule cannot use NEW")));
3428 elog(
ERROR,
"unrecognized event type: %d",
3452 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3453 errmsg(
"cannot refer to OLD within WITH query")));
3459 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3460 errmsg(
"cannot refer to NEW within WITH query")));
3488 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3489 errmsg(
"conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
3497 newactions =
lappend(newactions, top_subqry);
3502 *actions = newactions;
3526 const char *queryString,
3527 List **beforeStmts,
List **afterStmts)
3537 bool skipValidation =
true;
3558 if (rel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
3560 cxt.
stmtType =
"ALTER FOREIGN TABLE";
3589 foreach(lcmd,
stmt->cmds)
3606 skipValidation =
false;
3614 newcmds =
lappend(newcmds, cmd);
3627 skipValidation =
false;
3630 elog(
ERROR,
"unrecognized node type: %d",
3661 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3662 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
3684 newcmds =
lappend(newcmds, cmd);
3701 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3702 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
3710 newcmds =
lappend(newcmds, cmd);
3734 if (strcmp(def->
defname,
"generated") == 0)
3735 newdef =
lappend(newdef, def);
3737 newseqopts =
lappend(newseqopts, def);
3743 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3744 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
3756 seqstmt->
options = newseqopts;
3772 newcmds =
lappend(newcmds, cmd);
3786 newcmds =
lappend(newcmds, cmd);
3796 newcmds =
lappend(newcmds, cmd);
3805 save_alist = cxt.
alist;
3819 foreach(l, cxt.
alist)
3834 newcmd->
def = (
Node *) idxstmt;
3835 newcmds =
lappend(newcmds, newcmd);
3848 newcmds =
lappend(newcmds, newcmd);
3855 newcmds =
lappend(newcmds, newcmd);
3862 newcmds =
lappend(newcmds, newcmd);
3871 stmt->cmds = newcmds;
3873 *beforeStmts = cxt.
blist;
3893 bool saw_deferrability =
false;
3894 bool saw_initially =
false;
3895 bool saw_enforced =
false;
3898#define SUPPORTS_ATTRS(node) \
3899 ((node) != NULL && \
3900 ((node)->contype == CONSTR_PRIMARY || \
3901 (node)->contype == CONSTR_UNIQUE || \
3902 (node)->contype == CONSTR_EXCLUSION || \
3903 (node)->contype == CONSTR_FOREIGN))
3905 foreach(clist, constraintList)
3910 elog(
ERROR,
"unrecognized node type: %d",
3917 (
errcode(ERRCODE_SYNTAX_ERROR),
3918 errmsg(
"misplaced DEFERRABLE clause"),
3920 if (saw_deferrability)
3922 (
errcode(ERRCODE_SYNTAX_ERROR),
3923 errmsg(
"multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed"),
3925 saw_deferrability =
true;
3932 (
errcode(ERRCODE_SYNTAX_ERROR),
3933 errmsg(
"misplaced NOT DEFERRABLE clause"),
3935 if (saw_deferrability)
3937 (
errcode(ERRCODE_SYNTAX_ERROR),
3938 errmsg(
"multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed"),
3940 saw_deferrability =
true;
3942 if (saw_initially &&
3945 (
errcode(ERRCODE_SYNTAX_ERROR),
3946 errmsg(
"constraint declared INITIALLY DEFERRED must be DEFERRABLE"),
3953 (
errcode(ERRCODE_SYNTAX_ERROR),
3954 errmsg(
"misplaced INITIALLY DEFERRED clause"),
3958 (
errcode(ERRCODE_SYNTAX_ERROR),
3959 errmsg(
"multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed"),
3961 saw_initially =
true;
3967 if (!saw_deferrability)
3971 (
errcode(ERRCODE_SYNTAX_ERROR),
3972 errmsg(
"constraint declared INITIALLY DEFERRED must be DEFERRABLE"),
3979 (
errcode(ERRCODE_SYNTAX_ERROR),
3980 errmsg(
"misplaced INITIALLY IMMEDIATE clause"),
3984 (
errcode(ERRCODE_SYNTAX_ERROR),
3985 errmsg(
"multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed"),
3987 saw_initially =
true;
3992 if (lastprimarycon == NULL ||
3996 (
errcode(ERRCODE_SYNTAX_ERROR),
3997 errmsg(
"misplaced ENFORCED clause"),
4001 (
errcode(ERRCODE_SYNTAX_ERROR),
4002 errmsg(
"multiple ENFORCED/NOT ENFORCED clauses not allowed"),
4004 saw_enforced =
true;
4009 if (lastprimarycon == NULL ||
4013 (
errcode(ERRCODE_SYNTAX_ERROR),
4014 errmsg(
"misplaced NOT ENFORCED clause"),
4018 (
errcode(ERRCODE_SYNTAX_ERROR),
4019 errmsg(
"multiple ENFORCED/NOT ENFORCED clauses not allowed"),
4021 saw_enforced =
true;
4031 lastprimarycon = con;
4033 saw_deferrability =
false;
4034 saw_initially =
false;
4035 saw_enforced =
false;
4063 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4064 errmsg(
"collations are not supported by type %s",
4120 foreach(elements, schemaElts)
4126 case T_CreateSeqStmt:
4170 case T_CreateTrigStmt:
4184 elog(
ERROR,
"unrecognized node type: %d",
4207 if (*stmt_schema_name == NULL)
4208 *stmt_schema_name =
unconstify(
char *, context_schema);
4209 else if (strcmp(context_schema, *stmt_schema_name) != 0)
4211 (
errcode(ERRCODE_INVALID_SCHEMA_DEFINITION),
4212 errmsg(
"CREATE specifies a schema (%s) "
4213 "different from the one being created (%s)",
4214 *stmt_schema_name, context_schema)));
4229 switch (parentRel->
rd_rel->relkind)
4231 case RELKIND_PARTITIONED_TABLE:
4234 if (cmd->
bound != NULL)
4238 case RELKIND_PARTITIONED_INDEX:
4244 if (cmd->
bound != NULL)
4246 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4247 errmsg(
"\"%s\" is not a partitioned table",
4250 case RELKIND_RELATION:
4253 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4254 errmsg(
"table \"%s\" is not partitioned",
4260 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4261 errmsg(
"index \"%s\" is not partitioned",
4266 elog(
ERROR,
"\"%s\" is not a partitioned table or index",
4300 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4301 errmsg(
"a hash-partitioned table may not have a default partition")));
4317 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4318 errmsg(
"invalid bound specification for a hash partition"),
4321 if (spec->modulus <= 0)
4323 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4324 errmsg(
"modulus for hash partition must be an integer value greater than zero")));
4326 Assert(spec->remainder >= 0);
4328 if (spec->remainder >= spec->modulus)
4330 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4331 errmsg(
"remainder for hash partition must be less than modulus")));
4343 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4344 errmsg(
"invalid bound specification for a list partition"),
4348 if (
key->partattrs[0] != 0)
4350 key->partattrs[0],
false);
4362 foreach(cell, spec->listdatums)
4370 colname, coltype, coltypmod,
4396 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4397 errmsg(
"invalid bound specification for a range partition"),
4402 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4403 errmsg(
"FROM must specify exactly one value per partitioning column")));
4406 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4407 errmsg(
"TO must specify exactly one value per partitioning column")));
4421 elog(
ERROR,
"unexpected partition strategy: %d", (
int) strategy);
4474 else if (strcmp(
"minvalue",
cname) == 0)
4480 else if (strcmp(
"maxvalue",
cname) == 0)
4497 if (
key->partattrs[
i] != 0)
4499 key->partattrs[
i],
false);
4518 if (
value->constisnull)
4520 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4521 errmsg(
"cannot specify NULL in range bound")));
4530 result =
lappend(result, prd);
4558 if (kind == prd->
kind)
4569 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4570 errmsg(
"every bound following MAXVALUE must also be MAXVALUE"),
4576 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4577 errmsg(
"every bound following MINVALUE must also be MINVALUE"),
4589 const char *colName,
Oid colType,
int32 colTypmod,
4619 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4620 errmsg(
"specified value cannot be cast to type %s for column \"%s\"",
4635 elog(
ERROR,
"could not evaluate partition bound expression");
4645 ((
Const *)
value)->constcollid = partCollation;
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
Oid get_index_am_oid(const char *amname, bool missing_ok)
#define DatumGetArrayTypeP(X)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
#define AttributeNumberIsValid(attributeNumber)
#define InvalidAttrNumber
char * get_tablespace_name(Oid spc_oid)
#define TextDatumGetCString(d)
#define unconstify(underlying_type, expr)
#define InvalidSubTransactionId
#define OidIsValid(objectId)
Expr * evaluate_expr(Expr *expr, Oid result_type, int32 result_typmod, Oid result_collation)
List * sequence_options(Oid relid)
void errorConflictingDefElem(DefElem *defel, ParseState *pstate)
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
Assert(PointerIsAligned(start, uint64))
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
const FormData_pg_attribute * SystemAttributeDefinition(AttrNumber attno)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
#define DEFAULT_INDEX_TYPE
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
char * ChooseRelationName(const char *name1, const char *name2, const char *label, Oid namespaceid, bool isconstraint)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
if(TABLE==NULL||TABLE_index==NULL)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lcons(void *datum, List *list)
void list_free(List *list)
#define AccessExclusiveLock
char * get_rel_name(Oid relid)
AttrNumber get_attnum(Oid relid, const char *attname)
bool type_is_range(Oid typid)
Datum get_attoptions(Oid relid, int16 attnum)
Oid get_rel_namespace(Oid relid)
Oid get_typcollation(Oid typid)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
char * get_namespace_name(Oid nspid)
Oid get_atttype(Oid relid, AttrNumber attnum)
Oid get_relname_relid(const char *relname, Oid relnamespace)
bool type_is_multirange(Oid typid)
Alias * makeAlias(const char *aliasname, List *colnames)
DefElem * makeDefElem(char *name, Node *arg, int location)
FromExpr * makeFromExpr(List *fromlist, Node *quals)
ColumnDef * makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
FuncCall * makeFuncCall(List *name, List *args, CoercionForm funcformat, int location)
Constraint * makeNotNullConstraint(String *colname)
TypeName * makeTypeNameFromOid(Oid typeOid, int32 typmod)
char * pstrdup(const char *in)
void pfree(void *pointer)
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
RangeVar * makeRangeVarFromNameList(const List *names)
Oid exprType(const Node *expr)
int exprLocation(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
ObjectType get_relkind_objtype(char relkind)
#define ObjectAddressSet(addr, class_id, object_id)
char * nodeToString(const void *obj)
Node * transformWhereClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
void assign_expr_collations(ParseState *pstate, Node *expr)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
void free_parsestate(ParseState *pstate)
int parser_errposition(ParseState *pstate, int location)
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
ParseState * make_parsestate(ParseState *parentParseState)
@ EXPR_KIND_STATS_EXPRESSION
@ EXPR_KIND_INDEX_EXPRESSION
@ EXPR_KIND_PARTITION_BOUND
@ EXPR_KIND_INDEX_PREDICATE
@ EXPR_KIND_ALTER_COL_TRANSFORM
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
char * FigureIndexColname(Node *node)
Oid LookupCollation(ParseState *pstate, List *collnames, int location)
Type typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
Oid typenameTypeId(ParseState *pstate, const TypeName *typeName)
static void generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column, Oid seqtypid, List *seqoptions, bool for_identity, bool col_exists, char **snamespace_p, char **sname_p)
List * transformCreateStmt(CreateStmt *stmt, const char *queryString)
IndexStmt * transformIndexStmt(Oid relid, IndexStmt *stmt, const char *queryString)
List * transformCreateSchemaStmtElements(List *schemaElts, const char *schemaName)
static void transformColumnType(CreateStmtContext *cxt, ColumnDef *column)
static void transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
void transformRuleStmt(RuleStmt *stmt, const char *queryString, List **actions, Node **whereClause)
static void transformIndexConstraints(CreateStmtContext *cxt)
static List * get_collation(Oid collation, Oid actual_datatype)
static IndexStmt * transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
AlterTableStmt * transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, const char *queryString, List **beforeStmts, List **afterStmts)
static void transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_clause)
static void transformConstraintAttrs(CreateStmtContext *cxt, List *constraintList)
List * expandTableLikeClause(RangeVar *heapRel, TableLikeClause *table_like_clause)
static void transformTableConstraint(CreateStmtContext *cxt, Constraint *constraint)
static List * get_opclass(Oid opclass, Oid actual_datatype)
static List * transformPartitionRangeBounds(ParseState *pstate, List *blist, Relation parent)
static void transformPartitionCmd(CreateStmtContext *cxt, PartitionCmd *cmd)
static void setSchemaName(const char *context_schema, char **stmt_schema_name)
CreateStatsStmt * transformStatsStmt(Oid relid, CreateStatsStmt *stmt, const char *queryString)
static void validateInfiniteBounds(ParseState *pstate, List *blist)
static Const * transformPartitionBoundValue(ParseState *pstate, Node *val, const char *colName, Oid colType, int32 colTypmod, Oid partCollation)
static void transformCheckConstraints(CreateStmtContext *cxt, bool skipValidation)
static void transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
static CreateStatsStmt * generateClonedExtStatsStmt(RangeVar *heapRel, Oid heapRelid, Oid source_statsid, const AttrMap *attmap)
PartitionBoundSpec * transformPartitionBound(ParseState *pstate, Relation parent, PartitionBoundSpec *spec)
static void transformFKConstraints(CreateStmtContext *cxt, bool skipValidation, bool isAddConstraint)
IndexStmt * generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx, const AttrMap *attmap, Oid *constraintOid)
#define SUPPORTS_ATTRS(node)
@ PARTITION_STRATEGY_HASH
@ PARTITION_STRATEGY_LIST
@ PARTITION_STRATEGY_RANGE
@ CONSTR_ATTR_NOT_DEFERRABLE
@ CONSTR_ATTR_NOT_ENFORCED
@ PARTITION_RANGE_DATUM_MAXVALUE
@ PARTITION_RANGE_DATUM_VALUE
@ PARTITION_RANGE_DATUM_MINVALUE
@ AT_AlterColumnGenericOptions
@ CREATE_TABLE_LIKE_COMMENTS
@ CREATE_TABLE_LIKE_GENERATED
@ CREATE_TABLE_LIKE_IDENTITY
@ CREATE_TABLE_LIKE_COMPRESSION
@ CREATE_TABLE_LIKE_STORAGE
@ CREATE_TABLE_LIKE_INDEXES
@ CREATE_TABLE_LIKE_DEFAULTS
@ CREATE_TABLE_LIKE_STATISTICS
@ CREATE_TABLE_LIKE_CONSTRAINTS
Query * transformStmt(ParseState *pstate, Node *parseTree)
List * SystemFuncName(char *name)
TypeName * SystemTypeName(char *name)
PartitionKey RelationGetPartitionKey(Relation rel)
static int get_partition_strategy(PartitionKey key)
static int32 get_partition_col_typmod(PartitionKey key, int col)
static int get_partition_natts(PartitionKey key)
static Oid get_partition_col_typid(PartitionKey key, int col)
static List * get_partition_exprs(PartitionKey key)
static Oid get_partition_col_collation(PartitionKey key, int col)
FormData_pg_am * Form_pg_am
FormData_pg_attribute * Form_pg_attribute
int errdetail_relkind_not_supported(char relkind)
FormData_pg_class * Form_pg_class
FormData_pg_collation * Form_pg_collation
List * RelationGetNotNullConstraints(Oid relid, bool cooked, bool include_noinh)
Oid get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
FormData_pg_constraint * Form_pg_constraint
void checkMembershipInCurrentExtension(const ObjectAddress *object)
Oid getIdentitySequence(Relation rel, AttrNumber attnum, bool missing_ok)
Oid get_index_constraint(Oid indexId)
FormData_pg_index * Form_pg_index
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define lsecond_node(type, l)
#define foreach_delete_current(lst, var_or_cell)
static void * list_nth(const List *list, int n)
#define list_make3(x1, x2, x3)
#define foreach_node(type, var, lst)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
static ListCell * list_last_cell(const List *list)
FormData_pg_opclass * Form_pg_opclass
FormData_pg_operator * Form_pg_operator
FormData_pg_statistic_ext * Form_pg_statistic_ext
FormData_pg_type * Form_pg_type
Expr * expression_planner(Expr *expr)
static Oid DatumGetObjectId(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
void * stringToNode(const char *str)
static chr element(struct vars *v, const chr *startp, const chr *endp)
#define RelationGetForm(relation)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
List * RelationGetIndexList(Relation relation)
List * RelationGetIndexPredicate(Relation relation)
List * RelationGetStatExtList(Relation relation)
List * RelationGetIndexExpressions(Relation relation)
List * untransformRelOptions(Datum options)
#define InvalidRelFileNumber
bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
char * quote_qualified_identifier(const char *qualifier, const char *ident)
List * deparse_context_for(const char *aliasname, Oid relid)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
CollateClause * collClause
RangeVar * identitySequence
bool reset_default_tblspc
PartitionBoundSpec * partbound
SortByNulls nulls_ordering
List * indexIncludingParams
const char * p_sourcetext
PartitionBoundSpec * bound
PartitionRangeDatumKind kind
struct IndexAmRoutine * rd_indam
struct HeapTupleData * rd_indextuple
Oid values[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode)
void check_of_type(HeapTuple typetuple)
const char * GetCompressionMethodName(char method)
#define CompressionMethodIsValid(cm)
Node * TupleDescGetDefault(TupleDesc tupdesc, AttrNumber attnum)
#define ReleaseTupleDesc(tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
String * makeString(char *str)
bool contain_var_clause(Node *node)