73 #include "utils/fmgroids.h"
105 bool is_validated,
bool is_local,
int inhcount,
106 bool is_no_inherit,
bool is_internal);
110 bool allow_merge,
bool is_local,
111 bool is_initially_valid,
115 Node *raw_constraint,
219 .attname = {
"tableoid"},
221 .attlen =
sizeof(
Oid),
243 elog(
ERROR,
"invalid system attribute number %d", attno);
244 return SysAtt[-attno - 1];
298 bool shared_relation,
299 bool mapped_relation,
300 bool allow_system_table_mods,
319 if (!allow_system_table_mods &&
324 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
325 errmsg(
"permission denied to create \"%s.%s\"",
327 errdetail(
"System catalog modifications are currently disallowed.")));
336 if (!RELKIND_HAS_TABLESPACE(relkind))
340 if (!RELKIND_HAS_STORAGE(relkind))
341 create_storage =
false;
349 relfilenumber = relid;
388 if (RELKIND_HAS_TABLE_AM(rel->
rd_rel->relkind))
391 relfrozenxid, relminmxid);
392 else if (RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
403 if (!create_storage && reltablespace !=
InvalidOid)
461 int natts = tupdesc->
natts;
466 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
467 errmsg(
"tables can have at most %d columns",
476 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
478 for (
i = 0;
i < natts;
i++)
484 (
errcode(ERRCODE_DUPLICATE_COLUMN),
485 errmsg(
"column name \"%s\" conflicts with a system column name",
493 for (
i = 1;
i < natts;
i++)
495 for (
j = 0;
j <
i;
j++)
500 (
errcode(ERRCODE_DUPLICATE_COLUMN),
501 errmsg(
"column name \"%s\" specified more than once",
509 for (
i = 0;
i < natts;
i++)
549 Oid atttypid,
Oid attcollation,
550 List *containing_rowtypes,
559 if (att_typtype == TYPTYPE_PSEUDO)
577 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
579 errmsg(
"partition key column %s has pseudo-type %s",
583 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
584 errmsg(
"column \"%s\" has pseudo-type %s",
588 else if (att_typtype == TYPTYPE_DOMAIN)
597 else if (att_typtype == TYPTYPE_COMPOSITE)
614 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
615 errmsg(
"composite type %s cannot be made a member of itself",
618 containing_rowtypes =
lappend_oid(containing_rowtypes, atttypid);
624 for (
i = 0;
i < tupdesc->
natts;
i++)
628 if (attr->attisdropped)
631 attr->atttypid, attr->attcollation,
640 else if (att_typtype == TYPTYPE_RANGE)
668 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
670 errmsg(
"no collation was derived for partition key column %s with collatable type %s",
672 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
675 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
676 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
678 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
713 bool close_index =
false;
721 for (
int i = 0;
i < nslots;
i++)
724 while (natts < tupdesc->natts)
731 memset(slot[slotCount]->tts_isnull,
false,
732 slot[slotCount]->tts_tupleDescriptor->natts *
sizeof(
bool));
769 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attstattarget - 1] =
true;
770 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attoptions - 1] =
true;
776 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attacl - 1] =
true;
777 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attfdwoptions - 1] =
true;
778 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attmissingval - 1] =
true;
787 if (slotCount == nslots || natts == tupdesc->
natts - 1)
807 for (
int i = 0;
i < nslots;
i++)
826 int natts = tupdesc->
natts;
840 for (
int i = 0;
i < natts;
i++)
845 tupdesc->
attrs[
i].atttypid);
850 tupdesc->
attrs[
i].attcollation != DEFAULT_COLLATION_OID)
853 tupdesc->
attrs[
i].attcollation);
863 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
903 bool nulls[Natts_pg_class];
908 memset(nulls,
false,
sizeof(nulls));
932 values[Anum_pg_class_relforcerowsecurity - 1] =
BoolGetDatum(rd_rel->relforcerowsecurity);
940 if (relacl != (
Datum) 0)
941 values[Anum_pg_class_relacl - 1] = relacl;
943 nulls[Anum_pg_class_relacl - 1] =
true;
944 if (reloptions != (
Datum) 0)
945 values[Anum_pg_class_reloptions - 1] = reloptions;
947 nulls[Anum_pg_class_reloptions - 1] =
true;
950 nulls[Anum_pg_class_relpartbound - 1] =
true;
986 new_rel_reltup = new_rel_desc->
rd_rel;
989 new_rel_reltup->relpages = 0;
990 new_rel_reltup->reltuples = -1;
991 new_rel_reltup->relallvisible = 0;
994 if (relkind == RELKIND_SEQUENCE)
996 new_rel_reltup->relpages = 1;
997 new_rel_reltup->reltuples = 1;
1000 new_rel_reltup->relfrozenxid = relfrozenxid;
1001 new_rel_reltup->relminmxid = relminmxid;
1002 new_rel_reltup->relowner = relowner;
1003 new_rel_reltup->reltype = new_type_oid;
1004 new_rel_reltup->reloftype = reloftype;
1007 new_rel_reltup->relispartition =
false;
1010 new_rel_desc->
rd_att->
tdtypeid = new_type_oid ? new_type_oid : RECORDOID;
1015 relacl, reloptions);
1043 TYPCATEGORY_COMPOSITE,
1062 TYPSTORAGE_EXTENDED,
1113 List *cooked_constraints,
1115 char relpersistence,
1116 bool shared_relation,
1117 bool mapped_relation,
1121 bool allow_system_table_mods,
1160 (
errcode(ERRCODE_DUPLICATE_TABLE),
1178 errhint(
"A relation has an associated type of the same name, "
1179 "so you must use a name that doesn't conflict "
1180 "with any existing type.")));
1186 if (shared_relation && reltablespace != GLOBALTABLESPACE_OID)
1187 elog(
ERROR,
"shared relations must be placed in pg_global tablespace");
1204 Assert(relkind != RELKIND_INDEX);
1205 Assert(relkind != RELKIND_PARTITIONED_INDEX);
1207 if (relkind == RELKIND_TOASTVALUE)
1217 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1218 errmsg(
"toast relfilenumber value not set when in binary upgrade mode")));
1228 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1229 errmsg(
"pg_class heap OID value not set when in binary upgrade mode")));
1234 if (RELKIND_HAS_STORAGE(relkind))
1238 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1239 errmsg(
"relfilenumber value not set when in binary upgrade mode")));
1259 case RELKIND_RELATION:
1261 case RELKIND_MATVIEW:
1262 case RELKIND_FOREIGN_TABLE:
1263 case RELKIND_PARTITIONED_TABLE:
1267 case RELKIND_SEQUENCE:
1299 allow_system_table_mods,
1306 new_rel_desc->
rd_rel->relrewrite = relrewrite;
1313 if (!(relkind == RELKIND_SEQUENCE ||
1314 relkind == RELKIND_TOASTVALUE ||
1315 relkind == RELKIND_INDEX ||
1316 relkind == RELKIND_PARTITIONED_INDEX))
1344 new_type_oid = new_type_addr.
objectId;
1346 *typaddress = new_type_addr;
1369 F_ARRAY_SUBSCRIPT_HANDLER,
1378 TYPSTORAGE_EXTENDED,
1384 pfree(relarrayname);
1390 Assert(typaddress == NULL);
1434 if (relkind != RELKIND_COMPOSITE_TYPE &&
1435 relkind != RELKIND_TOASTVALUE &&
1468 if (RELKIND_HAS_TABLE_AM(relkind) && relkind != RELKIND_TOASTVALUE)
1526 Anum_pg_inherits_inhrelid,
1559 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1590 Anum_pg_attribute_attrelid,
1627 Anum_pg_attribute_attrelid,
1631 Anum_pg_attribute_attnum,
1663 Datum valuesAtt[Natts_pg_attribute] = {0};
1664 bool nullsAtt[Natts_pg_attribute] = {0};
1665 bool replacesAtt[Natts_pg_attribute] = {0};
1681 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1686 attStruct->attisdropped =
true;
1699 attStruct->attnotnull =
false;
1702 attStruct->attgenerated =
'\0';
1707 snprintf(newattname,
sizeof(newattname),
1708 "........pg.dropped.%d........",
attnum);
1709 namestrcpy(&(attStruct->attname), newattname);
1712 attStruct->atthasmissing =
false;
1713 nullsAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1714 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1720 nullsAtt[Anum_pg_attribute_attstattarget - 1] =
true;
1721 replacesAtt[Anum_pg_attribute_attstattarget - 1] =
true;
1722 nullsAtt[Anum_pg_attribute_attacl - 1] =
true;
1723 replacesAtt[Anum_pg_attribute_attacl - 1] =
true;
1724 nullsAtt[Anum_pg_attribute_attoptions - 1] =
true;
1725 replacesAtt[Anum_pg_attribute_attoptions - 1] =
true;
1726 nullsAtt[Anum_pg_attribute_attfdwoptions - 1] =
true;
1727 replacesAtt[Anum_pg_attribute_attfdwoptions - 1] =
true;
1730 valuesAtt, nullsAtt, replacesAtt);
1776 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1792 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1821 if (rel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
1830 elog(
ERROR,
"cache lookup failed for foreign table %u", relid);
1841 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
1848 if (relid == defaultPartOid)
1854 if (RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
1913 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1943 Datum repl_val[Natts_pg_attribute];
1944 bool repl_null[Natts_pg_attribute];
1945 bool repl_repl[Natts_pg_attribute];
1950 memset(repl_val, 0,
sizeof(repl_val));
1951 memset(repl_null,
false,
sizeof(repl_null));
1952 memset(repl_repl,
false,
sizeof(repl_repl));
1954 repl_val[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
false);
1955 repl_null[Anum_pg_attribute_attmissingval - 1] =
true;
1957 repl_repl[Anum_pg_attribute_atthasmissing - 1] =
true;
1958 repl_repl[Anum_pg_attribute_attmissingval - 1] =
true;
1971 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1977 if (attrtuple->atthasmissing)
1980 repl_val, repl_null, repl_repl);
2007 Datum valuesAtt[Natts_pg_attribute] = {0};
2008 bool nullsAtt[Natts_pg_attribute] = {0};
2009 bool replacesAtt[Natts_pg_attribute] = {0};
2021 if (tablerel->
rd_rel->relkind != RELKIND_RELATION)
2031 elog(
ERROR,
"cache lookup failed for attribute %s of relation %u",
2042 valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
true);
2043 replacesAtt[Anum_pg_attribute_atthasmissing - 1] =
true;
2044 valuesAtt[Anum_pg_attribute_attmissingval - 1] = missingval;
2045 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
2048 valuesAtt, nullsAtt, replacesAtt);
2067 bool is_validated,
bool is_local,
int inhcount,
2068 bool is_no_inherit,
bool is_internal)
2097 foreach(vl, varList)
2102 for (
j = 0;
j <
i;
j++)
2117 if (is_no_inherit &&
2118 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
2120 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
2121 errmsg(
"cannot add NO INHERIT constraint to partitioned table \"%s\"",
2173 bool is_validated,
bool is_local,
int inhcount,
2230 if (cooked_constraints ==
NIL)
2240 foreach(lc, cooked_constraints)
2248 is_internal,
false);
2267 elog(
ERROR,
"unrecognized constraint type: %d",
2308 List *newColDefaults,
2309 List *newConstraints,
2313 const char *queryString)
2315 List *cookedConstraints =
NIL;
2332 oldconstr = tupleDesc->
constr;
2355 foreach(cell, newColDefaults)
2362 atp->atttypid, atp->atttypmod,
2395 cooked->
name = NULL;
2397 cooked->
expr = expr;
2400 cooked->
inhcount = is_local ? 0 : 1;
2402 cookedConstraints =
lappend(cookedConstraints, cooked);
2408 numchecks = numoldchecks;
2411 foreach(cell, newConstraints)
2452 foreach(cell2, checknames)
2454 if (strcmp((
char *)
lfirst(cell2), ccname) == 0)
2457 errmsg(
"check constraint \"%s\" already exists",
2462 checknames =
lappend(checknames, ccname);
2471 allow_merge, is_local,
2513 checknames =
lappend(checknames, ccname);
2527 cooked->
conoid = constrOid;
2528 cooked->
name = ccname;
2530 cooked->
expr = expr;
2533 cooked->
inhcount = is_local ? 0 : 1;
2535 cookedConstraints =
lappend(cookedConstraints, cooked);
2547 elog(
ERROR,
"cache lookup failed for attribute \"%s\" of relation %u",
2561 else if (existing == -1)
2596 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2606 nnnames =
lappend(nnnames, nnname);
2617 nncooked->
conoid = constrOid;
2618 nncooked->
name = nnname;
2619 nncooked->
attnum = colnum;
2620 nncooked->
expr = NULL;
2626 cookedConstraints =
lappend(cookedConstraints, nncooked);
2639 return cookedConstraints;
2654 bool allow_merge,
bool is_local,
2655 bool is_initially_valid,
2670 Anum_pg_constraint_conrelid,
2674 Anum_pg_constraint_contypid,
2678 Anum_pg_constraint_conname,
2691 if (con->contype == CONSTRAINT_CHECK)
2697 Anum_pg_constraint_conbin,
2698 conDesc->
rd_att, &isnull);
2714 if (is_local && !con->conislocal && !rel->
rd_rel->relispartition)
2717 if (!found || !allow_merge)
2720 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2724 if (con->connoinherit)
2726 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2727 errmsg(
"constraint \"%s\" conflicts with non-inherited constraint on relation \"%s\"",
2735 if (con->coninhcount > 0 && is_no_inherit)
2737 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2738 errmsg(
"constraint \"%s\" conflicts with inherited constraint on relation \"%s\"",
2745 if (is_initially_valid && !con->convalidated)
2747 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2748 errmsg(
"constraint \"%s\" conflicts with NOT VALID constraint on relation \"%s\"",
2753 (
errmsg(
"merging constraint \"%s\" with inherited definition",
2764 if (rel->
rd_rel->relispartition)
2766 con->coninhcount = 1;
2767 con->conislocal =
false;
2772 con->conislocal =
true;
2776 if (con->coninhcount < 0)
2778 errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2779 errmsg(
"too many inheritance parents"));
2785 con->connoinherit =
true;
2851 foreach(lc, constraints)
2856 bool is_local =
true;
2869 foreach(lc2, old_notnulls)
2881 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2882 errmsg(
"cannot define not-null constraint on column \"%s\" with NO INHERIT",
2884 errdetail(
"The column has an inherited not-null constraint.")));
2898 foreach(lc2, givennames)
2903 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2909 givennames =
lappend(givennames, conname);
2918 nnnames =
lappend(nnnames, conname);
2942 for (
int outerpos = 0; outerpos <
list_length(old_notnulls); outerpos++)
2945 char *conname = NULL;
2946 int add_inhcount = 0;
2956 if (conname == NULL && cooked->
name)
2957 conname = cooked->
name;
2959 for (
int restpos = outerpos + 1; restpos <
list_length(old_notnulls);)
2966 if (conname == NULL && other->
name)
2967 conname = other->
name;
2977 if (conname != NULL)
2979 foreach(lc2, nnnames)
2981 if (strcmp(
lfirst(lc2), conname) == 0)
2990 if (conname == NULL)
2997 nnnames =
lappend(nnnames, conname);
3030 elog(
ERROR,
"cache lookup failed for relation %u",
3034 if (relStruct->relchecks != numchecks)
3036 relStruct->relchecks = numchecks;
3074 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3075 errmsg(
"cannot use generated column \"%s\" in column generation expression",
3077 errdetail(
"A generated column cannot reference another generated column."),
3082 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3083 errmsg(
"cannot use whole-row variable in column generation expression"),
3084 errdetail(
"This would cause the generated column to depend on its own value."),
3123 Assert(raw_default != NULL);
3138 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3139 errmsg(
"generation expression is not immutable")));
3160 atttypid, atttypmod,
3166 (
errcode(ERRCODE_DATATYPE_MISMATCH),
3167 errmsg(
"column \"%s\" is of type %s"
3168 " but default expression is of type %s",
3172 errhint(
"You will need to rewrite or cast the expression.")));
3192 Node *raw_constraint,
3218 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3219 errmsg(
"only table \"%s\" can be referenced in check constraint",
3241 Anum_pg_statistic_starelid,
3246 true, NULL, 1,
key);
3257 statform->starelid = torelid;
3260 if (indstate == NULL)
3270 if (indstate != NULL)
3293 Anum_pg_statistic_starelid,
3302 Anum_pg_statistic_staattnum,
3360 index_build(heapRelation, currentIndex, indexInfo,
true,
false);
3383 foreach(cell, relids)
3389 relations =
lappend(relations, rel);
3396 foreach(cell, relations)
3426 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3436 toastrelid = rel->
rd_rel->reltoastrelid;
3476 foreach(cell, relations)
3480 if (rel->
rd_rel->relhastriggers ||
3481 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3496 if (dependents ==
NIL)
3513 foreach(cell2, dependents)
3524 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3525 errmsg(
"unsupported ON COMMIT and foreign key combination"),
3526 errdetail(
"Table \"%s\" references \"%s\", but they do not have the same ON COMMIT setting.",
3530 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3531 errmsg(
"cannot truncate a table referenced in a foreign key constraint"),
3532 errdetail(
"Table \"%s\" references \"%s\".",
3534 errhint(
"Truncate table \"%s\" at the same time, "
3535 "or use TRUNCATE ... CASCADE.",
3589 if (con->contype != CONSTRAINT_FOREIGN)
3604 parent_cons =
lappend_oid(parent_cons, con->conparentid);
3623 foreach(cell, parent_cons)
3628 Anum_pg_constraint_oid,
3633 true, NULL, 1, &
key);
3696 Datum partexprDatum;
3700 bool nulls[Natts_pg_partitioned_table] = {0};
3705 Assert(rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
3722 partexprDatum = (
Datum) 0;
3728 nulls[Anum_pg_partitioned_table_partexprs - 1] =
true;
3737 values[Anum_pg_partitioned_table_partexprs - 1] = partexprDatum;
3749 for (
i = 0;
i < partnatts;
i++)
3756 partcollation[
i] != DEFAULT_COLLATION_OID)
3772 for (
i = 0;
i < partnatts;
i++)
3774 if (partattrs[
i] == 0)
3818 elog(
ERROR,
"cache lookup failed for partition key of relation %u",
3845 Datum new_val[Natts_pg_class];
3846 bool new_null[Natts_pg_class],
3847 new_repl[Natts_pg_class];
3855 elog(
ERROR,
"cache lookup failed for relation %u",
3858 #ifdef USE_ASSERT_CHECKING
3864 Assert(!classForm->relispartition);
3872 memset(new_val, 0,
sizeof(new_val));
3873 memset(new_null,
false,
sizeof(new_null));
3874 memset(new_repl,
false,
sizeof(new_repl));
3876 new_null[Anum_pg_class_relpartbound - 1] =
false;
3877 new_repl[Anum_pg_class_relpartbound - 1] =
true;
3879 new_val, new_null, new_repl);
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)
static void PGresult const char * p2
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)
ObjectAddresses * new_object_addresses(void)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
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 * ExecStoreVirtualTuple(TupleTableSlot *slot)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
const TupleTableSlotOps TTSOpsHeapTuple
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
#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)
static Oid StoreRelCheck(Relation rel, const char *ccname, Node *expr, bool is_validated, bool is_local, int inhcount, bool is_no_inherit, bool is_internal)
void RelationClearMissing(Relation rel)
static bool MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr, bool allow_merge, bool is_local, bool is_initially_valid, bool is_no_inherit)
void SetAttrMissing(Oid relid, char *attname, char *value)
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)
List * heap_truncate_find_FKs(List *relationIds)
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)
List * AddRelationNotNullConstraints(Relation rel, List *constraints, List *old_notnulls)
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 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 * SystemAttributeDefinition(AttrNumber attno)
void CopyStatistics(Oid fromrelid, Oid torelid)
Node * cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, int32 atttypmod, const char *attname, char attgenerated)
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
static int list_cookedconstr_attnum_cmp(const ListCell *p1, const ListCell *p2)
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
void heap_drop_with_catalog(Oid relid)
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)
void heap_truncate_one_rel(Relation rel)
void RemovePartitionKeyByRelId(Oid relid)
Oid binary_upgrade_next_heap_pg_class_oid
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
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)
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal, const char *queryString)
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)
#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 int pg_cmp_s16(int16 a, int16 b)
void CacheInvalidateRelcache(Relation relation)
void CacheInvalidateRelcacheByRelid(Oid relid)
struct ItemPointerData ItemPointerData
void list_sort(List *list, list_sort_comparator cmp)
List * list_union(const List *list1, const List *list2)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
List * list_copy(const List *oldlist)
void list_deduplicate_oid(List *list)
int list_oid_cmp(const ListCell *p1, const ListCell *p2)
List * list_delete_nth_cell(List *list, int n)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
List * list_append_unique_oid(List *list, Oid datum)
List * list_delete_last(List *list)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
#define AccessExclusiveLock
Oid get_range_subtype(Oid rangeOid)
AttrNumber get_attnum(Oid relid, const char *attname)
Oid get_element_type(Oid typid)
char get_attgenerated(Oid relid, AttrNumber attnum)
char * get_namespace_name(Oid nspid)
char * get_rel_name(Oid relid)
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)
Oid get_relname_relid(const char *relname, Oid relnamespace)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
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_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)
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
char * ChooseConstraintName(const char *name1, const char *name2, const char *label, Oid namespaceid, List *others)
bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, const char *conname)
int AdjustNotNullInheritance1(Oid relid, AttrNumber attnum, int count, bool is_no_inherit)
Oid CreateConstraintEntry(const char *constraintName, Oid constraintNamespace, char constraintType, bool isDeferrable, bool isDeferred, 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, int conInhCount, bool conNoInherit, bool conPeriod, bool is_internal)
FormData_pg_constraint * Form_pg_constraint
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
List * find_inheritance_children(Oid parentrelId, LOCKMODE lockmode)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define foreach_delete_current(lst, var_or_cell)
#define list_make1_oid(x1)
static void * list_nth(const List *list, int n)
#define foreach_oid(var, lst)
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)
char * makeArrayTypeName(const char *typeName, Oid typeNamespace)
bool moveArrayTypeName(Oid typeOid, const char *typeName, Oid typeNamespace)
void pgstat_create_relation(Relation rel)
void pgstat_drop_relation(Relation rel)
void check_stack_depth(void)
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)
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
FormData_pg_attribute attrs[FLEXIBLE_ARRAY_MEMBER]
#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)
#define TupleDescAttr(tupdesc, i)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Oid AssignTypeArrayOid(void)
List * pull_var_clause(Node *node, int flags)
bool contain_var_clause(Node *node)
void CommandCounterIncrement(void)