73#include "utils/fmgroids.h"
105 bool is_enforced,
bool is_validated,
bool is_local,
106 int16 inhcount,
bool is_no_inherit,
bool is_internal);
110 bool allow_merge,
bool is_local,
112 bool is_initially_valid,
116 Node *raw_constraint,
215 .attname = {
"tableoid"},
217 .attlen =
sizeof(
Oid),
238 elog(
ERROR,
"invalid system attribute number %d", attno);
239 return SysAtt[-attno - 1];
293 bool shared_relation,
294 bool mapped_relation,
295 bool allow_system_table_mods,
314 if (!allow_system_table_mods &&
319 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
320 errmsg(
"permission denied to create \"%s.%s\"",
322 errdetail(
"System catalog modifications are currently disallowed.")));
331 if (!RELKIND_HAS_TABLESPACE(relkind))
335 if (!RELKIND_HAS_STORAGE(relkind))
336 create_storage =
false;
344 relfilenumber = relid;
383 if (RELKIND_HAS_TABLE_AM(rel->
rd_rel->relkind))
386 relfrozenxid, relminmxid);
387 else if (RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
398 if (!create_storage && reltablespace !=
InvalidOid)
456 int natts = tupdesc->
natts;
461 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
462 errmsg(
"tables can have at most %d columns",
471 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
473 for (
i = 0;
i < natts;
i++)
479 (
errcode(ERRCODE_DUPLICATE_COLUMN),
480 errmsg(
"column name \"%s\" conflicts with a system column name",
488 for (
i = 1;
i < natts;
i++)
490 for (
j = 0;
j <
i;
j++)
495 (
errcode(ERRCODE_DUPLICATE_COLUMN),
496 errmsg(
"column name \"%s\" specified more than once",
504 for (
i = 0;
i < natts;
i++)
544 Oid atttypid,
Oid attcollation,
545 List *containing_rowtypes,
554 if (att_typtype == TYPTYPE_PSEUDO)
572 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
574 errmsg(
"partition key column %s has pseudo-type %s",
578 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
579 errmsg(
"column \"%s\" has pseudo-type %s",
583 else if (att_typtype == TYPTYPE_DOMAIN)
592 else if (att_typtype == TYPTYPE_COMPOSITE)
609 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
610 errmsg(
"composite type %s cannot be made a member of itself",
613 containing_rowtypes =
lappend_oid(containing_rowtypes, atttypid);
619 for (
i = 0;
i < tupdesc->
natts;
i++)
623 if (attr->attisdropped)
626 attr->atttypid, attr->attcollation,
635 else if (att_typtype == TYPTYPE_RANGE)
663 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
665 errmsg(
"no collation was derived for partition key column %s with collatable type %s",
667 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
670 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
671 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
673 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
707 bool close_index =
false;
715 for (
int i = 0;
i < nslots;
i++)
718 while (natts < tupdesc->natts)
725 memset(slot[slotCount]->tts_isnull,
false,
726 slot[slotCount]->tts_tupleDescriptor->natts *
sizeof(
bool));
762 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attstattarget - 1] =
true;
763 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attoptions - 1] =
true;
769 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attacl - 1] =
true;
770 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attfdwoptions - 1] =
true;
771 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attmissingval - 1] =
true;
780 if (slotCount == nslots || natts == tupdesc->
natts - 1)
800 for (
int i = 0;
i < nslots;
i++)
819 int natts = tupdesc->
natts;
833 for (
int i = 0;
i < natts;
i++)
844 attr->attcollation != DEFAULT_COLLATION_OID)
857 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
897 bool nulls[Natts_pg_class];
902 memset(nulls,
false,
sizeof(nulls));
926 values[Anum_pg_class_relforcerowsecurity - 1] =
BoolGetDatum(rd_rel->relforcerowsecurity);
934 if (relacl != (
Datum) 0)
935 values[Anum_pg_class_relacl - 1] = relacl;
937 nulls[Anum_pg_class_relacl - 1] =
true;
938 if (reloptions != (
Datum) 0)
939 values[Anum_pg_class_reloptions - 1] = reloptions;
941 nulls[Anum_pg_class_reloptions - 1] =
true;
944 nulls[Anum_pg_class_relpartbound - 1] =
true;
980 new_rel_reltup = new_rel_desc->
rd_rel;
983 new_rel_reltup->relpages = 0;
984 new_rel_reltup->reltuples = -1;
985 new_rel_reltup->relallvisible = 0;
988 if (relkind == RELKIND_SEQUENCE)
990 new_rel_reltup->relpages = 1;
991 new_rel_reltup->reltuples = 1;
994 new_rel_reltup->relfrozenxid = relfrozenxid;
995 new_rel_reltup->relminmxid = relminmxid;
996 new_rel_reltup->relowner = relowner;
997 new_rel_reltup->reltype = new_type_oid;
998 new_rel_reltup->reloftype = reloftype;
1001 new_rel_reltup->relispartition =
false;
1004 new_rel_desc->
rd_att->
tdtypeid = new_type_oid ? new_type_oid : RECORDOID;
1009 relacl, reloptions);
1037 TYPCATEGORY_COMPOSITE,
1056 TYPSTORAGE_EXTENDED,
1107 List *cooked_constraints,
1109 char relpersistence,
1110 bool shared_relation,
1111 bool mapped_relation,
1115 bool allow_system_table_mods,
1154 (
errcode(ERRCODE_DUPLICATE_TABLE),
1172 errhint(
"A relation has an associated type of the same name, "
1173 "so you must use a name that doesn't conflict "
1174 "with any existing type.")));
1180 if (shared_relation && reltablespace != GLOBALTABLESPACE_OID)
1181 elog(
ERROR,
"shared relations must be placed in pg_global tablespace");
1198 Assert(relkind != RELKIND_INDEX);
1199 Assert(relkind != RELKIND_PARTITIONED_INDEX);
1201 if (relkind == RELKIND_TOASTVALUE)
1211 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1212 errmsg(
"toast relfilenumber value not set when in binary upgrade mode")));
1222 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1223 errmsg(
"pg_class heap OID value not set when in binary upgrade mode")));
1228 if (RELKIND_HAS_STORAGE(relkind))
1232 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1233 errmsg(
"relfilenumber value not set when in binary upgrade mode")));
1260 case RELKIND_RELATION:
1262 case RELKIND_MATVIEW:
1263 case RELKIND_FOREIGN_TABLE:
1264 case RELKIND_PARTITIONED_TABLE:
1268 case RELKIND_SEQUENCE:
1300 allow_system_table_mods,
1307 new_rel_desc->
rd_rel->relrewrite = relrewrite;
1314 if (!(relkind == RELKIND_SEQUENCE ||
1315 relkind == RELKIND_TOASTVALUE ||
1316 relkind == RELKIND_INDEX ||
1317 relkind == RELKIND_PARTITIONED_INDEX))
1345 new_type_oid = new_type_addr.
objectId;
1347 *typaddress = new_type_addr;
1370 F_ARRAY_SUBSCRIPT_HANDLER,
1379 TYPSTORAGE_EXTENDED,
1385 pfree(relarrayname);
1391 Assert(typaddress == NULL);
1435 if (relkind != RELKIND_COMPOSITE_TYPE &&
1436 relkind != RELKIND_TOASTVALUE &&
1470 if ((RELKIND_HAS_TABLE_AM(relkind) && relkind != RELKIND_TOASTVALUE) ||
1471 (relkind == RELKIND_PARTITIONED_TABLE &&
OidIsValid(accessmtd)))
1529 Anum_pg_inherits_inhrelid,
1562 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1593 Anum_pg_attribute_attrelid,
1630 Anum_pg_attribute_attrelid,
1634 Anum_pg_attribute_attnum,
1666 Datum valuesAtt[Natts_pg_attribute] = {0};
1667 bool nullsAtt[Natts_pg_attribute] = {0};
1668 bool replacesAtt[Natts_pg_attribute] = {0};
1684 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1689 attStruct->attisdropped =
true;
1702 attStruct->attnotnull =
false;
1705 attStruct->attgenerated =
'\0';
1710 snprintf(newattname,
sizeof(newattname),
1711 "........pg.dropped.%d........",
attnum);
1712 namestrcpy(&(attStruct->attname), newattname);
1715 attStruct->atthasmissing =
false;
1716 nullsAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1717 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1723 nullsAtt[Anum_pg_attribute_attstattarget - 1] =
true;
1724 replacesAtt[Anum_pg_attribute_attstattarget - 1] =
true;
1725 nullsAtt[Anum_pg_attribute_attacl - 1] =
true;
1726 replacesAtt[Anum_pg_attribute_attacl - 1] =
true;
1727 nullsAtt[Anum_pg_attribute_attoptions - 1] =
true;
1728 replacesAtt[Anum_pg_attribute_attoptions - 1] =
true;
1729 nullsAtt[Anum_pg_attribute_attfdwoptions - 1] =
true;
1730 replacesAtt[Anum_pg_attribute_attfdwoptions - 1] =
true;
1733 valuesAtt, nullsAtt, replacesAtt);
1779 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1795 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1824 if (rel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
1833 elog(
ERROR,
"cache lookup failed for foreign table %u", relid);
1844 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
1851 if (relid == defaultPartOid)
1857 if (RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
1916 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1946 Datum repl_val[Natts_pg_attribute];
1947 bool repl_null[Natts_pg_attribute];
1948 bool repl_repl[Natts_pg_attribute];
1953 memset(repl_val, 0,
sizeof(repl_val));
1954 memset(repl_null,
false,
sizeof(repl_null));
1955 memset(repl_repl,
false,
sizeof(repl_repl));
1957 repl_val[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
false);
1958 repl_null[Anum_pg_attribute_attmissingval - 1] =
true;
1960 repl_repl[Anum_pg_attribute_atthasmissing - 1] =
true;
1961 repl_repl[Anum_pg_attribute_attmissingval - 1] =
true;
1974 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1980 if (attrtuple->atthasmissing)
1983 repl_val, repl_null, repl_repl);
2010 Datum valuesAtt[Natts_pg_attribute] = {0};
2011 bool nullsAtt[Natts_pg_attribute] = {0};
2012 bool replacesAtt[Natts_pg_attribute] = {0};
2024 if (tablerel->
rd_rel->relkind != RELKIND_RELATION)
2034 elog(
ERROR,
"cache lookup failed for attribute %s of relation %u",
2045 valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
true);
2046 replacesAtt[Anum_pg_attribute_atthasmissing - 1] =
true;
2047 valuesAtt[Anum_pg_attribute_attmissingval - 1] = missingval;
2048 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
2051 valuesAtt, nullsAtt, replacesAtt);
2070 bool is_enforced,
bool is_validated,
bool is_local,
2071 int16 inhcount,
bool is_no_inherit,
bool is_internal)
2100 foreach(vl, varList)
2105 for (
j = 0;
j <
i;
j++)
2120 if (is_no_inherit &&
2121 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
2123 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
2124 errmsg(
"cannot add NO INHERIT constraint to partitioned table \"%s\"",
2177 bool is_validated,
bool is_local,
int inhcount,
2237 if (cooked_constraints ==
NIL)
2247 foreach(lc, cooked_constraints)
2255 is_internal,
false);
2267 elog(
ERROR,
"unrecognized constraint type: %d",
2308 List *newColDefaults,
2309 List *newConstraints,
2313 const char *queryString)
2315 List *cookedConstraints =
NIL;
2331 oldconstr = tupleDesc->
constr;
2360 atp->atttypid, atp->atttypmod,
2377 (!colDef->generated &&
2383 if (colDef->missingMode &&
2385 colDef->missingMode =
false;
2388 colDef->missingMode);
2393 cooked->
name = NULL;
2394 cooked->
attnum = colDef->attnum;
2395 cooked->
expr = expr;
2399 cooked->
inhcount = is_local ? 0 : 1;
2401 cookedConstraints =
lappend(cookedConstraints, cooked);
2407 numchecks = numoldchecks;
2418 if (cdef->raw_expr != NULL)
2420 Assert(cdef->cooked_expr == NULL);
2431 Assert(cdef->cooked_expr != NULL);
2443 if (cdef->conname != NULL)
2445 ccname = cdef->conname;
2450 if (strcmp(chkname, ccname) == 0)
2453 errmsg(
"check constraint \"%s\" already exists",
2458 checknames =
lappend(checknames, ccname);
2467 allow_merge, is_local,
2469 cdef->initially_valid,
2470 cdef->is_no_inherit))
2510 checknames =
lappend(checknames, ccname);
2518 cdef->initially_valid, is_local,
2519 is_local ? 0 : 1, cdef->is_no_inherit,
2526 cooked->
conoid = constrOid;
2527 cooked->
name = ccname;
2529 cooked->
expr = expr;
2533 cooked->
inhcount = is_local ? 0 : 1;
2535 cookedConstraints =
lappend(cookedConstraints, cooked);
2541 int16 inhcount = is_local ? 0 : 1;
2548 errcode(ERRCODE_UNDEFINED_COLUMN),
2549 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2553 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2554 errmsg(
"cannot add not-null constraint on system column \"%s\"",
2562 is_local, cdef->is_no_inherit))
2576 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2578 nnname = cdef->conname;
2586 nnnames =
lappend(nnnames, nnname);
2590 cdef->initially_valid,
2593 cdef->is_no_inherit);
2597 nncooked->
conoid = constrOid;
2598 nncooked->
name = nnname;
2599 nncooked->
attnum = colnum;
2600 nncooked->
expr = NULL;
2607 cookedConstraints =
lappend(cookedConstraints, nncooked);
2620 return cookedConstraints;
2635 bool allow_merge,
bool is_local,
2637 bool is_initially_valid,
2652 Anum_pg_constraint_conrelid,
2656 Anum_pg_constraint_contypid,
2660 Anum_pg_constraint_conname,
2673 if (con->contype == CONSTRAINT_CHECK)
2679 Anum_pg_constraint_conbin,
2680 conDesc->
rd_att, &isnull);
2696 if (is_local && !con->conislocal && !rel->
rd_rel->relispartition)
2699 if (!found || !allow_merge)
2702 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2706 if (con->connoinherit)
2708 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2709 errmsg(
"constraint \"%s\" conflicts with non-inherited constraint on relation \"%s\"",
2717 if (con->coninhcount > 0 && is_no_inherit)
2719 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2720 errmsg(
"constraint \"%s\" conflicts with inherited constraint on relation \"%s\"",
2727 if (is_initially_valid && con->conenforced && !con->convalidated)
2729 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2730 errmsg(
"constraint \"%s\" conflicts with NOT VALID constraint on relation \"%s\"",
2738 if ((!is_local && is_enforced && !con->conenforced) ||
2739 (is_local && !is_enforced && con->conenforced))
2741 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2742 errmsg(
"constraint \"%s\" conflicts with NOT ENFORCED constraint on relation \"%s\"",
2747 (
errmsg(
"merging constraint \"%s\" with inherited definition",
2758 if (rel->
rd_rel->relispartition)
2760 con->coninhcount = 1;
2761 con->conislocal =
false;
2766 con->conislocal =
true;
2770 errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2771 errmsg(
"too many inheritance parents"));
2777 con->connoinherit =
true;
2786 if (is_enforced && !con->conenforced)
2789 con->conenforced =
true;
2790 con->convalidated =
true;
2847 for (
int outerpos = 0; outerpos <
list_length(constraints); outerpos++)
2862 errcode(ERRCODE_UNDEFINED_COLUMN),
2863 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2868 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2869 errmsg(
"cannot add not-null constraint on system column \"%s\"",
2877 for (
int restpos = outerpos + 1; restpos <
list_length(constraints);)
2887 errcode(ERRCODE_SYNTAX_ERROR),
2888 errmsg(
"conflicting NO INHERIT declaration for not-null constraint on column \"%s\"",
2901 errcode(ERRCODE_SYNTAX_ERROR),
2902 errmsg(
"conflicting not-null constraint names \"%s\" and \"%s\"",
2923 if (old->attnum ==
attnum)
2931 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2932 errmsg(
"cannot define not-null constraint on column \"%s\" with NO INHERIT",
2934 errdetail(
"The column has an inherited not-null constraint.")));
2950 if (strcmp(thisname, constr->
conname) == 0)
2953 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2959 givennames =
lappend(givennames, conname);
2968 nnnames =
lappend(nnnames, conname);
2991 for (
int outerpos = 0; outerpos <
list_length(old_notnulls); outerpos++)
2994 char *conname = NULL;
3004 if (conname == NULL)
3005 conname = cooked->
name;
3007 for (
int restpos = outerpos + 1; restpos <
list_length(old_notnulls);)
3015 if (conname == NULL)
3016 conname = other->
name;
3026 if (conname != NULL)
3030 if (strcmp(thisname, conname) == 0)
3039 if (conname == NULL)
3046 nnnames =
lappend(nnnames, conname);
3050 false, inhcount,
false);
3079 elog(
ERROR,
"cache lookup failed for relation %u",
3083 if (relStruct->relchecks != numchecks)
3085 relStruct->relchecks = numchecks;
3123 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3124 errmsg(
"cannot use generated column \"%s\" in column generation expression",
3126 errdetail(
"A generated column cannot reference another generated column."),
3131 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3132 errmsg(
"cannot use whole-row variable in column generation expression"),
3133 errdetail(
"This would cause the generated column to depend on its own value."),
3172 Assert(raw_default != NULL);
3187 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3188 errmsg(
"generation expression is not immutable")));
3209 atttypid, atttypmod,
3215 (
errcode(ERRCODE_DATATYPE_MISMATCH),
3216 errmsg(
"column \"%s\" is of type %s"
3217 " but default expression is of type %s",
3221 errhint(
"You will need to rewrite or cast the expression.")));
3241 Node *raw_constraint,
3267 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3268 errmsg(
"only table \"%s\" can be referenced in check constraint",
3290 Anum_pg_statistic_starelid,
3295 true, NULL, 1,
key);
3306 statform->starelid = torelid;
3309 if (indstate == NULL)
3319 if (indstate != NULL)
3342 Anum_pg_statistic_starelid,
3351 Anum_pg_statistic_staattnum,
3409 index_build(heapRelation, currentIndex, indexInfo,
true,
false);
3432 foreach(cell, relids)
3438 relations =
lappend(relations, rel);
3445 foreach(cell, relations)
3475 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3485 toastrelid = rel->
rd_rel->reltoastrelid;
3525 foreach(cell, relations)
3529 if (rel->
rd_rel->relhastriggers ||
3530 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3545 if (dependents ==
NIL)
3562 foreach(cell2, dependents)
3573 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3574 errmsg(
"unsupported ON COMMIT and foreign key combination"),
3575 errdetail(
"Table \"%s\" references \"%s\", but they do not have the same ON COMMIT setting.",
3579 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3580 errmsg(
"cannot truncate a table referenced in a foreign key constraint"),
3581 errdetail(
"Table \"%s\" references \"%s\".",
3583 errhint(
"Truncate table \"%s\" at the same time, "
3584 "or use TRUNCATE ... CASCADE.",
3638 if (con->contype != CONSTRAINT_FOREIGN)
3653 parent_cons =
lappend_oid(parent_cons, con->conparentid);
3672 foreach(cell, parent_cons)
3677 Anum_pg_constraint_oid,
3682 true, NULL, 1, &
key);
3745 Datum partexprDatum;
3749 bool nulls[Natts_pg_partitioned_table] = {0};
3754 Assert(rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
3771 partexprDatum = (
Datum) 0;
3777 nulls[Anum_pg_partitioned_table_partexprs - 1] =
true;
3786 values[Anum_pg_partitioned_table_partexprs - 1] = partexprDatum;
3798 for (
i = 0;
i < partnatts;
i++)
3805 partcollation[
i] != DEFAULT_COLLATION_OID)
3821 for (
i = 0;
i < partnatts;
i++)
3823 if (partattrs[
i] == 0)
3867 elog(
ERROR,
"cache lookup failed for partition key of relation %u",
3894 Datum new_val[Natts_pg_class];
3895 bool new_null[Natts_pg_class],
3896 new_repl[Natts_pg_class];
3904 elog(
ERROR,
"cache lookup failed for relation %u",
3907#ifdef USE_ASSERT_CHECKING
3913 Assert(!classForm->relispartition);
3921 memset(new_val, 0,
sizeof(new_val));
3922 memset(new_null,
false,
sizeof(new_null));
3923 memset(new_repl,
false,
sizeof(new_repl));
3925 new_null[Anum_pg_class_relpartbound - 1] =
false;
3926 new_repl[Anum_pg_class_relpartbound - 1] =
true;
3928 new_val, new_null, new_repl);
3936 if (rel->
rd_rel->relkind == RELKIND_RELATION && rel->
rd_rel->relhassubclass)
void recordDependencyOnNewAcl(Oid classId, Oid objectId, int32 objsubId, Oid ownerId, Acl *acl)
Acl * get_user_default_acl(ObjectType objtype, Oid ownerId, Oid nsp_oid)
#define InvalidAttrNumber
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define Assert(condition)
TransactionId MultiXactId
#define OidIsValid(objectId)
bool IsToastNamespace(Oid namespaceId)
RelFileNumber GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
bool IsCatalogNamespace(Oid namespaceId)
bool contain_volatile_functions_after_planning(Expr *expr)
bool contain_mutable_functions_after_planning(Expr *expr)
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
void recordDependencyOnSingleRelExpr(const ObjectAddress *depender, Node *expr, Oid relId, DependencyType behavior, DependencyType self_behavior, bool reverse_self)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
void free_object_addresses(ObjectAddresses *addrs)
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)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
const TupleTableSlotOps TTSOpsHeapTuple
#define OidFunctionCall3(functionId, arg1, arg2, arg3)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
void RemoveAttributeById(Oid relid, AttrNumber attnum)
void RelationClearMissing(Relation rel)
void SetAttrMissing(Oid relid, char *attname, char *value)
static Oid StoreRelCheck(Relation rel, const char *ccname, Node *expr, bool is_enforced, bool is_validated, bool is_local, int16 inhcount, bool is_no_inherit, bool is_internal)
List * heap_truncate_find_FKs(List *relationIds)
void DeleteSystemAttributeTuples(Oid relid)
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
static void StoreConstraints(Relation rel, List *cooked_constraints, bool is_internal)
static void AddNewAttributeTuples(Oid new_rel_oid, TupleDesc tupdesc, char relkind)
void DeleteRelationTuple(Oid relid)
static void RelationTruncateIndexes(Relation heapRelation)
RelFileNumber binary_upgrade_next_heap_pg_class_relfilenumber
static void AddNewRelationTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, Oid new_type_oid, Oid reloftype, Oid relowner, char relkind, TransactionId relfrozenxid, TransactionId relminmxid, Datum relacl, Datum reloptions)
void DeleteAttributeTuples(Oid relid)
void RemoveStatistics(Oid relid, AttrNumber attnum)
static const FormData_pg_attribute a4
RelFileNumber binary_upgrade_next_toast_pg_class_relfilenumber
static ObjectAddress AddNewRelationType(const char *typeName, Oid typeNamespace, Oid new_rel_oid, char new_rel_kind, Oid ownerid, Oid new_row_type, Oid new_array_type)
static const FormData_pg_attribute a1
Oid heap_create_with_catalog(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, Oid reltypeid, Oid reloftypeid, Oid ownerid, Oid accessmtd, TupleDesc tupdesc, List *cooked_constraints, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, OnCommitAction oncommit, Datum reloptions, bool use_user_acl, bool allow_system_table_mods, bool is_internal, Oid relrewrite, ObjectAddress *typaddress)
void heap_truncate(List *relids)
static bool MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr, bool allow_merge, bool is_local, bool is_enforced, bool is_initially_valid, bool is_no_inherit)
static const FormData_pg_attribute *const SysAtt[]
static Oid StoreRelNotNull(Relation rel, const char *nnname, AttrNumber attnum, bool is_validated, bool is_local, int inhcount, bool is_no_inherit)
void CheckAttributeType(const char *attname, Oid atttypid, Oid attcollation, List *containing_rowtypes, int flags)
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
void CopyStatistics(Oid fromrelid, Oid torelid)
void heap_truncate_check_FKs(List *relations, bool tempTables)
static const FormData_pg_attribute a6
static bool check_nested_generated_walker(Node *node, void *context)
static void SetRelationNumChecks(Relation rel, int numchecks)
static const FormData_pg_attribute a3
static void RelationRemoveInheritance(Oid relid)
static const FormData_pg_attribute a2
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
List * AddRelationNotNullConstraints(Relation rel, List *constraints, List *old_notnulls)
void heap_drop_with_catalog(Oid relid)
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal, const char *queryString)
void InsertPgClassTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, Datum relacl, Datum reloptions)
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, int flags)
static void check_nested_generated(ParseState *pstate, Node *node)
Oid binary_upgrade_next_toast_pg_class_oid
void InsertPgAttributeTuples(Relation pg_attribute_rel, TupleDesc tupdesc, Oid new_rel_oid, const FormExtraData_pg_attribute tupdesc_extra[], CatalogIndexState indstate)
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname, char attgenerated)
void heap_truncate_one_rel(Relation rel)
void RemovePartitionKeyByRelId(Oid relid)
Oid binary_upgrade_next_heap_pg_class_oid
const FormData_pg_attribute * SystemAttributeDefinition(AttrNumber attno)
static const FormData_pg_attribute a5
Relation heap_create(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, RelFileNumber relfilenumber, Oid accessmtd, TupleDesc tupDesc, char relkind, char relpersistence, bool shared_relation, bool mapped_relation, bool allow_system_table_mods, TransactionId *relfrozenxid, MultiXactId *relminmxid, bool create_storage)
static Node * cookConstraint(ParseState *pstate, Node *raw_constraint, char *relname)
#define CHKATYPE_ANYRECORD
#define CHKATYPE_ANYARRAY
#define CHKATYPE_IS_PARTKEY
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_copytuple(HeapTuple tuple)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
#define MaxHeapAttributeNumber
static Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
IndexInfo * BuildDummyIndexInfo(Relation index)
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isreindex, bool parallel)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTuplesMultiInsertWithInfo(Relation heapRel, TupleTableSlot **slot, int ntuples, CatalogIndexState indstate)
void CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup, CatalogIndexState indstate)
void CatalogCloseIndexes(CatalogIndexState indstate)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
#define MAX_CATALOG_MULTI_INSERT_BYTES
int2vector * buildint2vector(const int16 *int2s, int n)
static bool pg_add_s16_overflow(int16 a, int16 b, int16 *result)
void CacheInvalidateRelcache(Relation relation)
void CacheInvalidateRelcacheByRelid(Oid relid)
struct ItemPointerData ItemPointerData
List * lappend(List *list, void *datum)
void list_sort(List *list, list_sort_comparator cmp)
List * list_delete_nth_cell(List *list, int n)
List * list_copy(const List *oldlist)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
List * list_append_unique_oid(List *list, Oid datum)
void list_deduplicate_oid(List *list)
int list_oid_cmp(const ListCell *p1, const ListCell *p2)
List * list_delete_last(List *list)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
List * list_union(const List *list1, const List *list2)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
#define AccessExclusiveLock
Oid get_range_subtype(Oid rangeOid)
char * get_rel_name(Oid relid)
AttrNumber get_attnum(Oid relid, const char *attname)
Oid get_element_type(Oid typid)
char get_attgenerated(Oid relid, AttrNumber attnum)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Oid get_range_collation(Oid rangeOid)
bool type_is_collatable(Oid typid)
Oid get_typ_typrelid(Oid typid)
char get_typtype(Oid typid)
Oid getBaseType(Oid typid)
char * get_namespace_name(Oid nspid)
Oid get_relname_relid(const char *relname, Oid relnamespace)
char * pstrdup(const char *in)
void pfree(void *pointer)
#define IsBootstrapProcessingMode()
#define IsNormalProcessingMode()
#define InvalidMultiXactId
void namestrcpy(Name name, const char *str)
Oid exprType(const Node *expr)
#define expression_tree_walker(n, w, c)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
#define InvokeObjectPostCreateHookArg(classId, objectId, subId, is_internal)
#define ObjectAddressSet(addr, class_id, object_id)
#define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id)
oidvector * buildoidvector(const Oid *oids, int n)
char * nodeToString(const void *obj)
Node * coerce_to_boolean(ParseState *pstate, Node *node, 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)
int parser_errposition(ParseState *pstate, int location)
ParseState * make_parsestate(ParseState *parentParseState)
@ EXPR_KIND_COLUMN_DEFAULT
@ EXPR_KIND_GENERATED_COLUMN
@ EXPR_KIND_CHECK_CONSTRAINT
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)
#define rt_fetch(rangetable_index, rangetable)
PartitionDesc RelationGetPartitionDesc(Relation rel, bool omit_detached)
Oid get_default_oid_from_partdesc(PartitionDesc partdesc)
void update_default_partition_oid(Oid parentId, Oid defaultPartId)
Oid get_default_partition_oid(Oid parentId)
Oid get_partition_parent(Oid relid, bool even_if_detached)
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal, bool add_column_mode)
FormData_pg_attribute * Form_pg_attribute
FormData_pg_class * Form_pg_class
Oid CreateConstraintEntry(const char *constraintName, Oid constraintNamespace, char constraintType, bool isDeferrable, bool isDeferred, bool isEnforced, bool isValidated, Oid parentConstrId, Oid relId, const int16 *constraintKey, int constraintNKeys, int constraintNTotalKeys, Oid domainId, Oid indexRelId, Oid foreignRelId, const int16 *foreignKey, const Oid *pfEqOp, const Oid *ppEqOp, const Oid *ffEqOp, int foreignNKeys, char foreignUpdateType, char foreignDeleteType, const int16 *fkDeleteSetCols, int numFkDeleteSetCols, char foreignMatchType, const Oid *exclOp, Node *conExpr, const char *conBin, bool conIsLocal, int16 conInhCount, bool conNoInherit, bool conPeriod, bool is_internal)
bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, const char *conname)
char * ChooseConstraintName(const char *name1, const char *name2, const char *label, Oid namespaceid, List *others)
bool AdjustNotNullInheritance(Oid relid, AttrNumber attnum, bool is_local, bool is_no_inherit)
FormData_pg_constraint * Form_pg_constraint
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
static int list_length(const List *l)
#define foreach_delete_current(lst, var_or_cell)
#define list_make1_oid(x1)
#define foreach_ptr(type, var, lst)
static void * list_nth(const List *list, int n)
#define foreach_node(type, var, lst)
#define list_nth_node(type, list, n)
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
void recordDependencyOnTablespace(Oid classId, Oid objectId, Oid tablespace)
FormData_pg_statistic * Form_pg_statistic
void RemoveSubscriptionRel(Oid subid, Oid relid)
ObjectAddress TypeCreate(Oid newTypeOid, const char *typeName, Oid typeNamespace, Oid relationOid, char relationKind, Oid ownerId, int16 internalSize, char typeType, char typeCategory, bool typePreferred, char typDelim, Oid inputProcedure, Oid outputProcedure, Oid receiveProcedure, Oid sendProcedure, Oid typmodinProcedure, Oid typmodoutProcedure, Oid analyzeProcedure, Oid subscriptProcedure, Oid elementType, bool isImplicitArray, Oid arrayType, Oid baseType, const char *defaultTypeValue, char *defaultTypeBin, bool passedByValue, char alignment, char storage, int32 typeMod, int32 typNDims, bool typeNotNull, Oid typeCollation)
bool moveArrayTypeName(Oid typeOid, const char *typeName, Oid typeNamespace)
char * makeArrayTypeName(const char *typeName, Oid typeNamespace)
void pgstat_create_relation(Relation rel)
void pgstat_drop_relation(Relation rel)
static Datum PointerGetDatum(const void *X)
static Datum Float4GetDatum(float4 X)
static Datum TransactionIdGetDatum(TransactionId X)
static Datum Int16GetDatum(int16 X)
static Datum MultiXactIdGetDatum(MultiXactId X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static Datum CharGetDatum(char X)
void CheckTableForSerializableConflictIn(Relation relation)
void * stringToNode(const char *str)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
List * RelationGetIndexList(Relation relation)
void RelationForgetRelation(Oid rid)
Relation RelationBuildLocalRelation(const char *relname, Oid relnamespace, TupleDesc tupDesc, Oid relid, Oid accessmtd, RelFileNumber relfilenumber, Oid reltablespace, bool shared_relation, bool mapped_relation, char relpersistence, char relkind)
#define InvalidRelFileNumber
#define RelFileNumberIsValid(relnumber)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
void check_stack_depth(void)
SMgrRelation RelationCreateStorage(RelFileLocator rlocator, char relpersistence, bool register_delete)
void RelationDropStorage(Relation rel)
void RelationTruncate(Relation rel, BlockNumber nblocks)
#define BTEqualStrategyNumber
#define BTLessEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
const char * p_sourcetext
RelFileLocator rd_locator
#define MinTransactionIdAttributeNumber
#define MaxCommandIdAttributeNumber
#define MaxTransactionIdAttributeNumber
#define TableOidAttributeNumber
#define SelfItemPointerAttributeNumber
#define MinCommandIdAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheCopy2(cacheId, key1, key2)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static void table_relation_set_new_filelocator(Relation rel, const RelFileLocator *newrlocator, char persistence, TransactionId *freezeXid, MultiXactId *minmulti)
static void table_relation_nontransactional_truncate(Relation rel)
void CheckTableNotInUse(Relation rel, const char *stmt)
void remove_on_commit_action(Oid relid)
void register_on_commit_action(Oid relid, OnCommitAction action)
#define InvalidTransactionId
void FreeTupleDesc(TupleDesc tupdesc)
TupleDesc CreateTupleDesc(int natts, Form_pg_attribute *attrs)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Oid AssignTypeArrayOid(void)
bool contain_var_clause(Node *node)
List * pull_var_clause(Node *node, int flags)
void CommandCounterIncrement(void)