133 bool isAddConstraint);
135 bool skipValidation);
137 List *constraintList);
139static void setSchemaName(
const char *context_schema,
char **stmt_schema_name);
145 const char *colName,
Oid colType,
int32 colTypmod,
189 stmt->relation->location);
212 (
errcode(ERRCODE_DUPLICATE_TABLE),
213 errmsg(
"relation \"%s\" already exists, skipping",
214 stmt->relation->relname)));
225 if (
stmt->relation->schemaname == NULL
226 &&
stmt->relation->relpersistence != RELPERSISTENCE_TEMP)
233 cxt.
stmtType =
"CREATE FOREIGN TABLE";
260 if (
stmt->ofTypename)
265 if (
stmt->inhRelations && !
stmt->partbound)
267 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
268 errmsg(
"cannot create partitioned table as inheritance child")));
275 foreach(elements,
stmt->tableElts)
289 case T_TableLikeClause:
294 elog(
ERROR,
"unrecognized node type: %d",
306 save_alist = cxt.
alist;
326 if (strcmp(cd->colname, colname) != 0)
332 cd->is_not_null =
true;
394 Oid seqtypid,
List *seqoptions,
395 bool for_identity,
bool col_exists,
396 char **snamespace_p,
char **sname_p)
417 foreach(
option, seqoptions)
421 if (strcmp(defel->
defname,
"sequence_name") == 0)
428 else if (strcmp(defel->
defname,
"logged") == 0 ||
429 strcmp(defel->
defname,
"unlogged") == 0)
487 (
errmsg_internal(
"%s will create implicit sequence \"%s\" for serial column \"%s.%s\"",
504 if (seqpersistence == RELPERSISTENCE_TEMP)
506 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
507 errmsg(
"cannot set logged status of a temporary sequence"),
509 else if (strcmp(loggedEl->
defname,
"logged") == 0)
510 seqpersistence = RELPERSISTENCE_PERMANENT;
512 seqpersistence = RELPERSISTENCE_UNLOGGED;
574 (
Node *) attnamelist, -1));
583 *snamespace_p = snamespace;
601 bool need_notnull =
false;
602 bool disallow_noinherit_notnull =
false;
615 if (strcmp(
typname,
"smallserial") == 0 ||
616 strcmp(
typname,
"serial2") == 0)
622 else if (strcmp(
typname,
"serial") == 0 ||
623 strcmp(
typname,
"serial4") == 0)
629 else if (strcmp(
typname,
"bigserial") == 0 ||
630 strcmp(
typname,
"serial8") == 0)
644 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
645 errmsg(
"array of serial is not implemented"),
668 &snamespace, &sname);
687 castnode->
arg = (
Node *) snamenode;
702 disallow_noinherit_notnull =
true;
720 if (!disallow_noinherit_notnull)
724 switch (constraint->contype)
728 disallow_noinherit_notnull =
true;
737 saw_nullable =
false;
739 saw_identity =
false;
740 saw_generated =
false;
744 switch (constraint->contype)
747 if ((saw_nullable && column->
is_not_null) || need_notnull)
749 (
errcode(ERRCODE_SYNTAX_ERROR),
750 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
753 constraint->location)));
761 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
762 errmsg(
"not-null constraints on partitioned tables cannot be NO INHERIT"));
767 (
errcode(ERRCODE_SYNTAX_ERROR),
768 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
771 constraint->location)));
773 if (disallow_noinherit_notnull && constraint->is_no_inherit)
776 errmsg(
"conflicting NO INHERIT declarations for not-null constraints on column \"%s\"",
794 need_notnull =
false;
797 notnull_constraint = constraint;
800 else if (notnull_constraint)
802 if (constraint->conname &&
804 strcmp(notnull_constraint->
conname, constraint->conname) != 0)
805 elog(
ERROR,
"conflicting not-null constraint names \"%s\" and \"%s\"",
806 notnull_constraint->
conname, constraint->conname);
808 if (notnull_constraint->
is_no_inherit != constraint->is_no_inherit)
811 errmsg(
"conflicting NO INHERIT declarations for not-null constraints on column \"%s\"",
814 if (!notnull_constraint->
conname && constraint->conname)
815 notnull_constraint->
conname = constraint->conname;
823 (
errcode(ERRCODE_SYNTAX_ERROR),
824 errmsg(
"multiple default values specified for column \"%s\" of table \"%s\"",
827 constraint->location)));
829 Assert(constraint->cooked_expr == NULL);
840 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
841 errmsg(
"identity columns are not supported on typed tables")));
844 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
845 errmsg(
"identity columns are not supported on partitions")));
853 (
errcode(ERRCODE_SYNTAX_ERROR),
854 errmsg(
"multiple identity specifications for column \"%s\" of table \"%s\"",
857 constraint->location)));
860 typeOid, constraint->options,
864 column->
identity = constraint->generated_when;
875 (
errcode(ERRCODE_SYNTAX_ERROR),
876 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
879 constraint->location)));
886 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
887 errmsg(
"generated columns are not supported on typed tables")));
890 (
errcode(ERRCODE_SYNTAX_ERROR),
891 errmsg(
"multiple generation clauses specified for column \"%s\" of table \"%s\"",
894 constraint->location)));
895 column->
generated = constraint->generated_kind;
897 Assert(constraint->cooked_expr == NULL);
898 saw_generated =
true;
908 (
errcode(ERRCODE_SYNTAX_ERROR),
909 errmsg(
"conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"",
912 constraint->location)));
917 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
918 errmsg(
"primary key constraints are not supported on foreign tables"),
920 constraint->location)));
926 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
927 errmsg(
"unique constraints are not supported on foreign tables"),
929 constraint->location)));
930 if (constraint->keys ==
NIL)
937 elog(
ERROR,
"column exclusion constraints are not supported");
943 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
944 errmsg(
"foreign key constraints are not supported on foreign tables"),
946 constraint->location)));
966 elog(
ERROR,
"unrecognized constraint type: %d",
967 constraint->contype);
971 if (saw_default && saw_identity)
973 (
errcode(ERRCODE_SYNTAX_ERROR),
974 errmsg(
"both default and identity specified for column \"%s\" of table \"%s\"",
977 constraint->location)));
979 if (saw_default && saw_generated)
981 (
errcode(ERRCODE_SYNTAX_ERROR),
982 errmsg(
"both default and generation expression specified for column \"%s\" of table \"%s\"",
985 constraint->location)));
987 if (saw_identity && saw_generated)
989 (
errcode(ERRCODE_SYNTAX_ERROR),
990 errmsg(
"both identity and generation expression specified for column \"%s\" of table \"%s\"",
993 constraint->location)));
1000 if (need_notnull && !(saw_nullable && column->
is_not_null))
1045 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1046 errmsg(
"primary key constraints are not supported on foreign tables"),
1055 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1056 errmsg(
"unique constraints are not supported on foreign tables"),
1065 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1066 errmsg(
"exclusion constraints are not supported on foreign tables"),
1079 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1080 errmsg(
"not-null constraints on partitioned tables cannot be NO INHERIT"));
1088 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1089 errmsg(
"foreign key constraints are not supported on foreign tables"),
1103 elog(
ERROR,
"invalid context for constraint type %d",
1108 elog(
ERROR,
"unrecognized constraint type: %d",
1144 if (relation->
rd_rel->relkind != RELKIND_RELATION &&
1145 relation->
rd_rel->relkind != RELKIND_VIEW &&
1146 relation->
rd_rel->relkind != RELKIND_MATVIEW &&
1147 relation->
rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
1148 relation->
rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
1149 relation->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
1151 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1152 errmsg(
"relation \"%s\" is invalid in LIKE clause",
1161 if (relation->
rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
1185 for (parent_attno = 1; parent_attno <= tupleDesc->
natts;
1195 if (attribute->attisdropped)
1202 attribute->atttypmod, attribute->attcollation);
1213 if (attribute->atthasdef && attribute->attgenerated &&
1215 def->
generated = attribute->attgenerated;
1220 if (attribute->attidentity &&
1237 def->
identity = attribute->attidentity;
1243 def->
storage = attribute->attstorage;
1260 attribute->attnum)) != NULL)
1292 nnconstr->conname,
false),
1293 ConstraintRelationId,
1319 if (table_like_clause->
options &
1367 elog(
ERROR,
"expandTableLikeClause called on untransformed LIKE clause");
1372 constr = tupleDesc->
constr;
1391 if ((table_like_clause->
options &
1395 for (parent_attno = 1; parent_attno <= tupleDesc->
natts;
1404 if (attribute->attisdropped)
1412 if (attribute->atthasdef &&
1413 (attribute->attgenerated ?
1419 bool found_whole_row;
1422 if (this_default == NULL)
1423 elog(
ERROR,
"default expression not found for attribute %d of relation \"%s\"",
1428 atsubcmd->
num = attmap->
attnums[parent_attno - 1];
1440 if (found_whole_row)
1442 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1443 errmsg(
"cannot convert whole-row table reference"),
1444 errdetail(
"Generation expression for column \"%s\" contains a whole-row reference to table \"%s\".",
1448 atsubcmds =
lappend(atsubcmds, atsubcmd);
1462 for (ccnum = 0; ccnum < constr->
num_check; ccnum++)
1469 bool found_whole_row;
1484 if (found_whole_row)
1486 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1487 errmsg(
"cannot convert whole-row table reference"),
1488 errdetail(
"Constraint \"%s\" contains a whole-row reference to table \"%s\".",
1508 atsubcmds =
lappend(atsubcmds, atsubcmd);
1514 ConstraintRelationId,
1540 atcmd->
cmds = atsubcmds;
1543 result =
lcons(atcmd, result);
1550 relation->
rd_rel->relhasindex &&
1551 childrel->
rd_rel->relkind != RELKIND_FOREIGN_TABLE)
1553 List *parent_indexes;
1558 foreach(l, parent_indexes)
1584 result =
lappend(result, index_stmt);
1595 List *parent_extstats;
1600 foreach(l, parent_extstats)
1622 result =
lappend(result, stats_stmt);
1654 ofTypename->
typeOid = ofTypeId;
1657 for (
i = 0;
i < tupdesc->
natts;
i++)
1662 if (attr->attisdropped)
1666 attr->atttypmod, attr->attcollation);
1726 elog(
ERROR,
"cache lookup failed for relation %u", source_relid);
1732 indrelid = idxrec->indrelid;
1737 elog(
ERROR,
"cache lookup failed for access method %u",
1743 Anum_pg_index_indcollation);
1752 index->relation = heapRel;
1757 index->tableSpace = NULL;
1759 index->idxcomment = NULL;
1764 index->unique = idxrec->indisunique;
1765 index->nulls_not_distinct = idxrec->indnullsnotdistinct;
1766 index->primary = idxrec->indisprimary;
1767 index->iswithoutoverlaps = (idxrec->indisprimary || idxrec->indisunique) && idxrec->indisexclusion;
1768 index->transformed =
true;
1769 index->concurrent =
false;
1770 index->if_not_exists =
false;
1771 index->reset_default_tblspc =
false;
1779 index->idxname = NULL;
1787 if (
index->primary ||
index->unique || idxrec->indisexclusion)
1797 *constraintOid = constraintId;
1802 elog(
ERROR,
"cache lookup failed for constraint %u",
1806 index->isconstraint =
true;
1807 index->deferrable = conrec->condeferrable;
1808 index->initdeferred = conrec->condeferred;
1811 if (idxrec->indisexclusion)
1817 Assert(conrec->contype == CONSTRAINT_EXCLUSION ||
1818 (
index->iswithoutoverlaps &&
1819 (conrec->contype == CONSTRAINT_PRIMARY || conrec->contype == CONSTRAINT_UNIQUE)));
1822 Anum_pg_constraint_conexclop);
1825 for (
i = 0;
i < nElems;
i++)
1837 elog(
ERROR,
"cache lookup failed for operator %u",
1854 index->isconstraint =
false;
1857 index->isconstraint =
false;
1861 Anum_pg_index_indexprs, &isnull);
1877 for (keyno = 0; keyno < idxrec->indnkeyatts; keyno++)
1896 iparam->
expr = NULL;
1902 bool found_whole_row;
1904 if (indexpr_item == NULL)
1905 elog(
ERROR,
"too few entries in indexprs list");
1907 indexpr_item =
lnext(indexprs, indexpr_item);
1916 if (found_whole_row)
1918 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1919 errmsg(
"cannot convert whole-row table reference"),
1920 errdetail(
"Index \"%s\" contains a whole-row table reference.",
1923 iparam->
name = NULL;
1924 iparam->
expr = indexkey;
1952 if (opt & INDOPTION_DESC)
1955 if ((opt & INDOPTION_NULLS_FIRST) == 0)
1960 if (opt & INDOPTION_NULLS_FIRST)
1969 for (keyno = idxrec->indnkeyatts; keyno < idxrec->indnatts; keyno++)
1986 iparam->
expr = NULL;
1990 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1991 errmsg(
"expressions are not supported in included columns")));
2000 Anum_pg_class_reloptions, &isnull);
2006 Anum_pg_index_indpred, &isnull);
2011 bool found_whole_row;
2024 if (found_whole_row)
2026 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2027 errmsg(
"cannot convert whole-row table reference"),
2028 errdetail(
"Index \"%s\" contains a whole-row table reference.",
2031 index->whereClause = pred_tree;
2071 elog(
ERROR,
"cache lookup failed for statistics object %u", source_statsid);
2076 Anum_pg_statistic_ext_stxkind);
2081 elog(
ERROR,
"stxkind is not a 1-D char array");
2085 if (enabled[
i] == STATS_EXT_NDISTINCT)
2087 else if (enabled[
i] == STATS_EXT_DEPENDENCIES)
2089 else if (enabled[
i] == STATS_EXT_MCV)
2091 else if (enabled[
i] == STATS_EXT_EXPRESSIONS)
2095 elog(
ERROR,
"unrecognized statistics kind %c", enabled[
i]);
2099 for (
i = 0;
i < statsrec->stxkeys.dim1;
i++)
2107 def_names =
lappend(def_names, selem);
2120 Anum_pg_statistic_ext_stxexprs, &isnull);
2135 bool found_whole_row;
2147 def_names =
lappend(def_names, selem);
2157 stats->
exprs = def_names;
2191 elog(
ERROR,
"cache lookup failed for collation %u", collation);
2218 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
2277 if (cxt->
pkey != NULL)
2283 foreach(lc, indexlist)
2294 foreach(k, finalindexlist)
2315 if (priorindex->
idxname == NULL)
2352 if (cxt->
pkey != NULL)
2354 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
2355 errmsg(
"multiple primary keys for table \"%s\" are not allowed",
2366 index->isconstraint =
true;
2371 if (constraint->
conname != NULL)
2374 index->idxname = NULL;
2384 index->idxcomment = NULL;
2389 index->transformed =
false;
2390 index->concurrent =
false;
2391 index->if_not_exists =
false;
2402 char *index_name = constraint->
indexname;
2408 Datum indclassDatum;
2421 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2422 errmsg(
"cannot use an existing index in CREATE TABLE"),
2430 (
errcode(ERRCODE_UNDEFINED_OBJECT),
2431 errmsg(
"index \"%s\" does not exist", index_name),
2441 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2442 errmsg(
"index \"%s\" is already associated with a constraint",
2449 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2450 errmsg(
"index \"%s\" does not belong to table \"%s\"",
2454 if (!index_form->indisvalid)
2456 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
2457 errmsg(
"index \"%s\" is not valid", index_name),
2465 if (!index_form->indisunique)
2467 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2468 errmsg(
"\"%s\" is not a unique index", index_name),
2469 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2474 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2475 errmsg(
"index \"%s\" contains expressions", index_name),
2476 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2481 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2482 errmsg(
"\"%s\" is a partial index", index_name),
2483 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2491 if (!index_form->indimmediate && !constraint->
deferrable)
2493 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2494 errmsg(
"\"%s\" is a deferrable index", index_name),
2495 errdetail(
"Cannot create a non-deferrable constraint using a deferrable index."),
2506 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2507 errmsg(
"index \"%s\" is not a btree", index_name),
2513 Anum_pg_index_indclass);
2516 for (
i = 0;
i < index_form->indnatts;
i++)
2530 Assert(attnum <= heap_rel->rd_att->natts);
2537 if (i < index_form->indnkeyatts)
2551 index_rel->
rd_rel->relam);
2552 if (indclass->
values[
i] != defopclass ||
2554 attoptions != (
Datum) 0 ||
2557 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2558 errmsg(
"index \"%s\" column number %d does not have default sorting behavior", index_name,
i + 1),
2559 errdetail(
"Cannot create a primary key or unique constraint using such an index."),
2577 index->indexOid = index_oid;
2611 foreach(lc, constraint->
keys)
2621 foreach(columns, cxt->
columns)
2655 if (nn->is_no_inherit)
2657 errcode(ERRCODE_SYNTAX_ERROR),
2658 errmsg(
"conflicting NO INHERIT declaration for not-null constraint on column \"%s\"",
2697 if (rel->
rd_rel->relkind != RELKIND_RELATION &&
2698 rel->
rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
2699 rel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
2701 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2702 errmsg(
"inherited relation \"%s\" is not a table or foreign table",
2704 for (count = 0; count < rel->
rd_att->
natts; count++)
2708 char *inhname =
NameStr(inhattr->attname);
2710 if (inhattr->attisdropped)
2712 if (strcmp(
key, inhname) == 0)
2715 typid = inhattr->atttypid;
2737 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2738 errmsg(
"column \"%s\" named in key does not exist",
key),
2742 foreach(columns,
index->indexParams)
2745 if (iparam->
name && strcmp(
key, iparam->
name) == 0)
2749 (
errcode(ERRCODE_DUPLICATE_COLUMN),
2750 errmsg(
"column \"%s\" appears twice in primary key constraint",
2755 (
errcode(ERRCODE_DUPLICATE_COLUMN),
2756 errmsg(
"column \"%s\" appears twice in unique constraint",
2781 if (attr->attisdropped)
2788 typid = attr->atttypid;
2800 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2801 errmsg(
"column \"%s\" in WITHOUT OVERLAPS is not a range or multirange type",
key),
2809 iparam->
expr = NULL;
2828 errcode(ERRCODE_SYNTAX_ERROR),
2829 errmsg(
"constraint using WITHOUT OVERLAPS needs at least two columns"));
2832 index->accessMethod =
"gist";
2852 foreach(columns, cxt->
columns)
2885 if (rel->
rd_rel->relkind != RELKIND_RELATION &&
2886 rel->
rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
2887 rel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
2889 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2890 errmsg(
"inherited relation \"%s\" is not a table or foreign table",
2892 for (count = 0; count < rel->
rd_att->
natts; count++)
2896 char *inhname =
NameStr(inhattr->attname);
2898 if (inhattr->attisdropped)
2900 if (strcmp(
key, inhname) == 0)
2920 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2921 errmsg(
"column \"%s\" named in key does not exist",
key),
2927 iparam->
expr = NULL;
2980 bool skipValidation,
bool isAddConstraint)
3016 if (!isAddConstraint)
3030 altercmd->
name = NULL;
3031 altercmd->
def = (
Node *) constraint;
3060 if (
stmt->transformed)
3081 if (
stmt->whereClause)
3092 foreach(l,
stmt->indexParams)
3125 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3126 errmsg(
"index expressions and predicates can refer only to the table being indexed")));
3134 stmt->transformed =
true;
3155 if (
stmt->transformed)
3176 foreach(l,
stmt->exprs)
3197 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3198 errmsg(
"statistics expressions can refer only to the table being referenced")));
3206 stmt->transformed =
true;
3223 List **actions,
Node **whereClause)
3238 if (rel->
rd_rel->relkind == RELKIND_MATVIEW)
3240 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3241 errmsg(
"rules on materialized views are not supported")));
3268 switch (
stmt->event)
3284 elog(
ERROR,
"unrecognized event type: %d",
3300 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3301 errmsg(
"rule WHERE condition cannot contain references to other relations")));
3328 foreach(l,
stmt->actions)
3370 *whereClause != NULL)
3372 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3373 errmsg(
"rules with WHERE conditions can only have SELECT, INSERT, UPDATE, or DELETE actions")));
3390 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3391 errmsg(
"conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
3403 switch (
stmt->event)
3408 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3409 errmsg(
"ON SELECT rule cannot use OLD")));
3412 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3413 errmsg(
"ON SELECT rule cannot use NEW")));
3421 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3422 errmsg(
"ON INSERT rule cannot use OLD")));
3427 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3428 errmsg(
"ON DELETE rule cannot use NEW")));
3431 elog(
ERROR,
"unrecognized event type: %d",
3455 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3456 errmsg(
"cannot refer to OLD within WITH query")));
3462 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3463 errmsg(
"cannot refer to NEW within WITH query")));
3491 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3492 errmsg(
"conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
3500 newactions =
lappend(newactions, top_subqry);
3505 *actions = newactions;
3528 if (partRel->
rd_rel->relkind != RELKIND_RELATION)
3530 errcode(ERRCODE_WRONG_OBJECT_TYPE),
3533 ?
errhint(
"ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions")
3534 :
errhint(
"ALTER TABLE ... SPLIT PARTITION can only split partitions don't have sub-partitions"));
3536 if (!partRel->
rd_rel->relispartition)
3538 errcode(ERRCODE_WRONG_OBJECT_TYPE),
3539 errmsg(
"\"%s\" is not a partition of partitioned table \"%s\"",
3542 ?
errhint(
"ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions")
3543 :
errhint(
"ALTER TABLE ... SPLIT PARTITION can only split partitions don't have sub-partitions"));
3548 errmsg(
"relation \"%s\" is not a partition of relation \"%s\"",
3551 ?
errhint(
"ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions")
3552 :
errhint(
"ALTER TABLE ... SPLIT PARTITION can only split partitions don't have sub-partitions"));
3572 int default_index = -1;
3573 bool isSplitPartDefault;
3610 if (sps->bound->is_default)
3612 if (default_index != -1)
3614 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3615 errmsg(
"DEFAULT partition should be one"),
3626 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3627 errmsg(
"partition of hash-partitioned table cannot be split"));
3631 elog(
ERROR,
"unexpected partition strategy: %d",
3632 (
int)
key->strategy);
3637 isSplitPartDefault = (defaultPartOid == splitPartOid);
3639 if (isSplitPartDefault && default_index == -1)
3641 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3642 errmsg(
"can not split DEFAULT partition \"%s\"",
3644 errhint(
"To split DEFAULT partition one of the new partition msut be DEFAULT"),
3652 if (!isSplitPartDefault && (default_index != -1) &&
OidIsValid(defaultPartOid))
3658 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3659 errmsg(
"can not split non-DEFAULT partition \"%s\"",
3661 errmsg(
"new partition cannot be DEFAULT because DEFAULT partition \"%s\" already exists",
3666 foreach(listptr, splitlist)
3683 errcode(ERRCODE_DUPLICATE_TABLE),
3684 errmsg(
"partition with name \"%s\" is already used",
name->relname),
3691 errcode(ERRCODE_DUPLICATE_TABLE),
3692 errmsg(
"partition with name \"%s\" is already used",
name->relname),
3719 bool isDefaultPart =
false;
3727 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3728 errmsg(
"partition of hash-partitioned table cannot be merged"));
3733 foreach(listptr, partcmd->
partlist)
3744 errcode(ERRCODE_DUPLICATE_TABLE),
3745 errmsg(
"partition with name \"%s\" is already used",
name->relname),
3760 if (partOid == defaultPartOid)
3761 isDefaultPart =
true;
3767 foreach(listptr2, partOids)
3771 if (curOid == partOid)
3773 errcode(ERRCODE_DUPLICATE_TABLE),
3774 errmsg(
"partition with name \"%s\" is already used",
name->relname),
3793 partOids, partcmd->
bound,
3811 const char *queryString,
3812 List **beforeStmts,
List **afterStmts)
3822 bool skipValidation =
true;
3843 if (rel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
3845 cxt.
stmtType =
"ALTER FOREIGN TABLE";
3874 foreach(lcmd,
stmt->cmds)
3891 skipValidation =
false;
3899 newcmds =
lappend(newcmds, cmd);
3912 skipValidation =
false;
3915 elog(
ERROR,
"unrecognized node type: %d",
3946 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3947 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
3969 newcmds =
lappend(newcmds, cmd);
3986 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3987 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
3995 newcmds =
lappend(newcmds, cmd);
4019 if (strcmp(def->
defname,
"generated") == 0)
4020 newdef =
lappend(newdef, def);
4022 newseqopts =
lappend(newseqopts, def);
4028 (
errcode(ERRCODE_UNDEFINED_COLUMN),
4029 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
4041 seqstmt->
options = newseqopts;
4057 newcmds =
lappend(newcmds, cmd);
4071 newcmds =
lappend(newcmds, cmd);
4080 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4081 errmsg(
"list of partitions to be merged should include at least two partitions"));
4084 newcmds =
lappend(newcmds, cmd);
4094 errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4095 errmsg(
"list of new partitions should contain at least two partitions"));
4098 newcmds =
lappend(newcmds, cmd);
4109 newcmds =
lappend(newcmds, cmd);
4118 save_alist = cxt.
alist;
4132 foreach(l, cxt.
alist)
4147 newcmd->
def = (
Node *) idxstmt;
4148 newcmds =
lappend(newcmds, newcmd);
4161 newcmds =
lappend(newcmds, newcmd);
4168 newcmds =
lappend(newcmds, newcmd);
4175 newcmds =
lappend(newcmds, newcmd);
4184 stmt->cmds = newcmds;
4186 *beforeStmts = cxt.
blist;
4206 bool saw_deferrability =
false;
4207 bool saw_initially =
false;
4208 bool saw_enforced =
false;
4211#define SUPPORTS_ATTRS(node) \
4212 ((node) != NULL && \
4213 ((node)->contype == CONSTR_PRIMARY || \
4214 (node)->contype == CONSTR_UNIQUE || \
4215 (node)->contype == CONSTR_EXCLUSION || \
4216 (node)->contype == CONSTR_FOREIGN))
4218 foreach(clist, constraintList)
4223 elog(
ERROR,
"unrecognized node type: %d",
4230 (
errcode(ERRCODE_SYNTAX_ERROR),
4231 errmsg(
"misplaced DEFERRABLE clause"),
4233 if (saw_deferrability)
4235 (
errcode(ERRCODE_SYNTAX_ERROR),
4236 errmsg(
"multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed"),
4238 saw_deferrability =
true;
4245 (
errcode(ERRCODE_SYNTAX_ERROR),
4246 errmsg(
"misplaced NOT DEFERRABLE clause"),
4248 if (saw_deferrability)
4250 (
errcode(ERRCODE_SYNTAX_ERROR),
4251 errmsg(
"multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed"),
4253 saw_deferrability =
true;
4255 if (saw_initially &&
4258 (
errcode(ERRCODE_SYNTAX_ERROR),
4259 errmsg(
"constraint declared INITIALLY DEFERRED must be DEFERRABLE"),
4266 (
errcode(ERRCODE_SYNTAX_ERROR),
4267 errmsg(
"misplaced INITIALLY DEFERRED clause"),
4271 (
errcode(ERRCODE_SYNTAX_ERROR),
4272 errmsg(
"multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed"),
4274 saw_initially =
true;
4280 if (!saw_deferrability)
4284 (
errcode(ERRCODE_SYNTAX_ERROR),
4285 errmsg(
"constraint declared INITIALLY DEFERRED must be DEFERRABLE"),
4292 (
errcode(ERRCODE_SYNTAX_ERROR),
4293 errmsg(
"misplaced INITIALLY IMMEDIATE clause"),
4297 (
errcode(ERRCODE_SYNTAX_ERROR),
4298 errmsg(
"multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed"),
4300 saw_initially =
true;
4305 if (lastprimarycon == NULL ||
4309 (
errcode(ERRCODE_SYNTAX_ERROR),
4310 errmsg(
"misplaced ENFORCED clause"),
4314 (
errcode(ERRCODE_SYNTAX_ERROR),
4315 errmsg(
"multiple ENFORCED/NOT ENFORCED clauses not allowed"),
4317 saw_enforced =
true;
4322 if (lastprimarycon == NULL ||
4326 (
errcode(ERRCODE_SYNTAX_ERROR),
4327 errmsg(
"misplaced NOT ENFORCED clause"),
4331 (
errcode(ERRCODE_SYNTAX_ERROR),
4332 errmsg(
"multiple ENFORCED/NOT ENFORCED clauses not allowed"),
4334 saw_enforced =
true;
4344 lastprimarycon = con;
4346 saw_deferrability =
false;
4347 saw_initially =
false;
4348 saw_enforced =
false;
4376 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4377 errmsg(
"collations are not supported by type %s",
4433 foreach(elements, schemaElts)
4439 case T_CreateSeqStmt:
4483 case T_CreateTrigStmt:
4497 elog(
ERROR,
"unrecognized node type: %d",
4520 if (*stmt_schema_name == NULL)
4521 *stmt_schema_name =
unconstify(
char *, context_schema);
4522 else if (strcmp(context_schema, *stmt_schema_name) != 0)
4524 (
errcode(ERRCODE_INVALID_SCHEMA_DEFINITION),
4525 errmsg(
"CREATE specifies a schema (%s) "
4526 "different from the one being created (%s)",
4527 *stmt_schema_name, context_schema)));
4542 switch (parentRel->
rd_rel->relkind)
4544 case RELKIND_PARTITIONED_TABLE:
4551 case RELKIND_PARTITIONED_INDEX:
4559 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4560 errmsg(
"\"%s\" is not a partitioned table",
4563 case RELKIND_RELATION:
4566 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4567 errmsg(
"table \"%s\" is not partitioned",
4573 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4574 errmsg(
"index \"%s\" is not partitioned",
4579 elog(
ERROR,
"\"%s\" is not a partitioned table or index",
4613 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4614 errmsg(
"a hash-partitioned table may not have a default partition")));
4630 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4631 errmsg(
"invalid bound specification for a hash partition"),
4634 if (spec->modulus <= 0)
4636 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4637 errmsg(
"modulus for hash partition must be an integer value greater than zero")));
4639 Assert(spec->remainder >= 0);
4641 if (spec->remainder >= spec->modulus)
4643 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4644 errmsg(
"remainder for hash partition must be less than modulus")));
4656 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4657 errmsg(
"invalid bound specification for a list partition"),
4661 if (
key->partattrs[0] != 0)
4663 key->partattrs[0],
false);
4675 foreach(cell, spec->listdatums)
4683 colname, coltype, coltypmod,
4709 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4710 errmsg(
"invalid bound specification for a range partition"),
4715 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4716 errmsg(
"FROM must specify exactly one value per partitioning column")));
4719 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
4720 errmsg(
"TO must specify exactly one value per partitioning column")));
4734 elog(
ERROR,
"unexpected partition strategy: %d", (
int) strategy);
4787 else if (strcmp(
"minvalue",
cname) == 0)
4793 else if (strcmp(
"maxvalue",
cname) == 0)
4810 if (
key->partattrs[
i] != 0)
4812 key->partattrs[
i],
false);
4831 if (
value->constisnull)
4833 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
4834 errmsg(
"cannot specify NULL in range bound")));
4843 result =
lappend(result, prd);
4871 if (kind == prd->
kind)
4882 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4883 errmsg(
"every bound following MAXVALUE must also be MAXVALUE"),
4889 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4890 errmsg(
"every bound following MINVALUE must also be MINVALUE"),
4902 const char *colName,
Oid colType,
int32 colTypmod,
4932 (
errcode(ERRCODE_DATATYPE_MISMATCH),
4933 errmsg(
"specified value cannot be cast to type %s for column \"%s\"",
4948 elog(
ERROR,
"could not evaluate partition bound expression");
4958 ((
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(const 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 errhint(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 * lappend_oid(List *list, Oid datum)
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 RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
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 transformPartitionCmdForSplit(CreateStmtContext *cxt, PartitionCmd *partcmd)
static void transformTableConstraint(CreateStmtContext *cxt, Constraint *constraint)
static List * get_opclass(Oid opclass, Oid actual_datatype)
static void transformPartitionCmdForMerge(CreateStmtContext *cxt, PartitionCmd *partcmd)
static void checkPartition(Relation rel, Oid partRelOid, bool isMerge)
static List * transformPartitionRangeBounds(ParseState *pstate, List *blist, Relation parent)
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 void transformPartitionCmd(CreateStmtContext *cxt, PartitionBoundSpec *bound)
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)
void check_partitions_for_split(Relation parent, Oid splitPartOid, List *partlist, ParseState *pstate)
void calculate_partition_bound_for_merge(Relation parent, List *partNames, List *partOids, PartitionBoundSpec *spec, ParseState *pstate)
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)
PartitionDesc RelationGetPartitionDesc(Relation rel, bool omit_detached)
Oid get_default_oid_from_partdesc(PartitionDesc partdesc)
Oid get_partition_parent(Oid relid, bool even_if_detached)
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_current_index(var_or_cell)
#define foreach_delete_current(lst, var_or_cell)
#define for_each_cell(cell, lst, initcell)
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
#define ERRCODE_UNDEFINED_TABLE
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_open(Oid relationId, LOCKMODE lockmode)
Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode)
void check_of_type(HeapTuple typetuple)
void RangeVarCallbackOwnsRelation(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
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)