72 #include "utils/fmgroids.h"
104 bool is_validated,
bool is_local,
int inhcount,
105 bool is_no_inherit,
bool is_internal);
109 bool allow_merge,
bool is_local,
110 bool is_initially_valid,
114 Node *raw_constraint,
218 .attname = {
"tableoid"},
220 .attlen =
sizeof(
Oid),
242 elog(
ERROR,
"invalid system attribute number %d", attno);
243 return SysAtt[-attno - 1];
297 bool shared_relation,
298 bool mapped_relation,
299 bool allow_system_table_mods,
318 if (!allow_system_table_mods &&
323 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
324 errmsg(
"permission denied to create \"%s.%s\"",
326 errdetail(
"System catalog modifications are currently disallowed.")));
335 if (!RELKIND_HAS_TABLESPACE(relkind))
339 if (!RELKIND_HAS_STORAGE(relkind))
340 create_storage =
false;
348 relfilenumber = relid;
387 if (RELKIND_HAS_TABLE_AM(rel->
rd_rel->relkind))
390 relfrozenxid, relminmxid);
391 else if (RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
402 if (!create_storage && reltablespace !=
InvalidOid)
460 int natts = tupdesc->
natts;
465 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
466 errmsg(
"tables can have at most %d columns",
475 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
477 for (
i = 0;
i < natts;
i++)
483 (
errcode(ERRCODE_DUPLICATE_COLUMN),
484 errmsg(
"column name \"%s\" conflicts with a system column name",
492 for (
i = 1;
i < natts;
i++)
494 for (
j = 0;
j <
i;
j++)
499 (
errcode(ERRCODE_DUPLICATE_COLUMN),
500 errmsg(
"column name \"%s\" specified more than once",
508 for (
i = 0;
i < natts;
i++)
548 Oid atttypid,
Oid attcollation,
549 List *containing_rowtypes,
555 if (att_typtype == TYPTYPE_PSEUDO)
573 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
575 errmsg(
"partition key column %s has pseudo-type %s",
579 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
580 errmsg(
"column \"%s\" has pseudo-type %s",
584 else if (att_typtype == TYPTYPE_DOMAIN)
593 else if (att_typtype == TYPTYPE_COMPOSITE)
610 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
611 errmsg(
"composite type %s cannot be made a member of itself",
614 containing_rowtypes =
lappend_oid(containing_rowtypes, atttypid);
620 for (
i = 0;
i < tupdesc->
natts;
i++)
624 if (attr->attisdropped)
627 attr->atttypid, attr->attcollation,
636 else if (att_typtype == TYPTYPE_RANGE)
664 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
666 errmsg(
"no collation was derived for partition key column %s with collatable type %s",
668 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
671 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
672 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
674 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
700 const Datum *attoptions,
708 bool close_index =
false;
716 for (
int i = 0;
i < nslots;
i++)
719 while (natts < tupdesc->natts)
725 memset(slot[slotCount]->tts_isnull,
false,
726 slot[slotCount]->tts_tupleDescriptor->natts *
sizeof(
bool));
754 if (attoptions && attoptions[natts] != (
Datum) 0)
755 slot[slotCount]->
tts_values[Anum_pg_attribute_attoptions - 1] = attoptions[natts];
757 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attoptions - 1] =
true;
760 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attacl - 1] =
true;
761 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attfdwoptions - 1] =
true;
762 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attmissingval - 1] =
true;
771 if (slotCount == nslots || natts == tupdesc->
natts - 1)
791 for (
int i = 0;
i < nslots;
i++)
810 int natts = tupdesc->
natts;
822 for (
int i = 0;
i < natts;
i++)
823 tupdesc->
attrs[
i].attstattarget = -1;
827 for (
int i = 0;
i < natts;
i++)
832 tupdesc->
attrs[
i].atttypid);
837 tupdesc->
attrs[
i].attcollation != DEFAULT_COLLATION_OID)
840 tupdesc->
attrs[
i].attcollation);
850 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
890 bool nulls[Natts_pg_class];
895 memset(nulls,
false,
sizeof(nulls));
919 values[Anum_pg_class_relforcerowsecurity - 1] =
BoolGetDatum(rd_rel->relforcerowsecurity);
927 if (relacl != (
Datum) 0)
928 values[Anum_pg_class_relacl - 1] = relacl;
930 nulls[Anum_pg_class_relacl - 1] =
true;
931 if (reloptions != (
Datum) 0)
932 values[Anum_pg_class_reloptions - 1] = reloptions;
934 nulls[Anum_pg_class_reloptions - 1] =
true;
937 nulls[Anum_pg_class_relpartbound - 1] =
true;
973 new_rel_reltup = new_rel_desc->
rd_rel;
976 new_rel_reltup->relpages = 0;
977 new_rel_reltup->reltuples = -1;
978 new_rel_reltup->relallvisible = 0;
981 if (relkind == RELKIND_SEQUENCE)
983 new_rel_reltup->relpages = 1;
984 new_rel_reltup->reltuples = 1;
987 new_rel_reltup->relfrozenxid = relfrozenxid;
988 new_rel_reltup->relminmxid = relminmxid;
989 new_rel_reltup->relowner = relowner;
990 new_rel_reltup->reltype = new_type_oid;
991 new_rel_reltup->reloftype = reloftype;
994 new_rel_reltup->relispartition =
false;
997 new_rel_desc->
rd_att->
tdtypeid = new_type_oid ? new_type_oid : RECORDOID;
1002 relacl, reloptions);
1030 TYPCATEGORY_COMPOSITE,
1049 TYPSTORAGE_EXTENDED,
1100 List *cooked_constraints,
1102 char relpersistence,
1103 bool shared_relation,
1104 bool mapped_relation,
1108 bool allow_system_table_mods,
1147 (
errcode(ERRCODE_DUPLICATE_TABLE),
1165 errhint(
"A relation has an associated type of the same name, "
1166 "so you must use a name that doesn't conflict "
1167 "with any existing type.")));
1173 if (shared_relation && reltablespace != GLOBALTABLESPACE_OID)
1174 elog(
ERROR,
"shared relations must be placed in pg_global tablespace");
1191 Assert(relkind != RELKIND_INDEX);
1192 Assert(relkind != RELKIND_PARTITIONED_INDEX);
1194 if (relkind == RELKIND_TOASTVALUE)
1204 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1205 errmsg(
"toast relfilenumber value not set when in binary upgrade mode")));
1215 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1216 errmsg(
"pg_class heap OID value not set when in binary upgrade mode")));
1221 if (RELKIND_HAS_STORAGE(relkind))
1225 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1226 errmsg(
"relfilenumber value not set when in binary upgrade mode")));
1246 case RELKIND_RELATION:
1248 case RELKIND_MATVIEW:
1249 case RELKIND_FOREIGN_TABLE:
1250 case RELKIND_PARTITIONED_TABLE:
1254 case RELKIND_SEQUENCE:
1286 allow_system_table_mods,
1293 new_rel_desc->
rd_rel->relrewrite = relrewrite;
1300 if (!(relkind == RELKIND_SEQUENCE ||
1301 relkind == RELKIND_TOASTVALUE ||
1302 relkind == RELKIND_INDEX ||
1303 relkind == RELKIND_PARTITIONED_INDEX))
1331 new_type_oid = new_type_addr.
objectId;
1333 *typaddress = new_type_addr;
1356 F_ARRAY_SUBSCRIPT_HANDLER,
1365 TYPSTORAGE_EXTENDED,
1371 pfree(relarrayname);
1377 Assert(typaddress == NULL);
1421 if (relkind != RELKIND_COMPOSITE_TYPE &&
1422 relkind != RELKIND_TOASTVALUE &&
1455 if (RELKIND_HAS_TABLE_AM(relkind) && relkind != RELKIND_TOASTVALUE)
1513 Anum_pg_inherits_inhrelid,
1546 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1577 Anum_pg_attribute_attrelid,
1614 Anum_pg_attribute_attrelid,
1618 Anum_pg_attribute_attnum,
1665 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1670 attStruct->attisdropped =
true;
1683 attStruct->attnotnull =
false;
1686 attStruct->attstattarget = 0;
1689 attStruct->attgenerated =
'\0';
1694 snprintf(newattname,
sizeof(newattname),
1695 "........pg.dropped.%d........",
attnum);
1696 namestrcpy(&(attStruct->attname), newattname);
1699 if (attStruct->atthasmissing)
1701 Datum valuesAtt[Natts_pg_attribute] = {0};
1702 bool nullsAtt[Natts_pg_attribute] = {0};
1703 bool replacesAtt[Natts_pg_attribute] = {0};
1706 valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
1708 replacesAtt[Anum_pg_attribute_atthasmissing - 1] =
true;
1709 valuesAtt[Anum_pg_attribute_attmissingval - 1] = (
Datum) 0;
1710 nullsAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1711 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1714 valuesAtt, nullsAtt, replacesAtt);
1761 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1777 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1806 if (rel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
1815 elog(
ERROR,
"cache lookup failed for foreign table %u", relid);
1826 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
1833 if (relid == defaultPartOid)
1839 if (RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
1898 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1928 Datum repl_val[Natts_pg_attribute];
1929 bool repl_null[Natts_pg_attribute];
1930 bool repl_repl[Natts_pg_attribute];
1935 memset(repl_val, 0,
sizeof(repl_val));
1936 memset(repl_null,
false,
sizeof(repl_null));
1937 memset(repl_repl,
false,
sizeof(repl_repl));
1939 repl_val[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
false);
1940 repl_null[Anum_pg_attribute_attmissingval - 1] =
true;
1942 repl_repl[Anum_pg_attribute_atthasmissing - 1] =
true;
1943 repl_repl[Anum_pg_attribute_attmissingval - 1] =
true;
1956 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1962 if (attrtuple->atthasmissing)
1965 repl_val, repl_null, repl_repl);
1992 Datum valuesAtt[Natts_pg_attribute] = {0};
1993 bool nullsAtt[Natts_pg_attribute] = {0};
1994 bool replacesAtt[Natts_pg_attribute] = {0};
2006 if (tablerel->
rd_rel->relkind != RELKIND_RELATION)
2016 elog(
ERROR,
"cache lookup failed for attribute %s of relation %u",
2027 valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
true);
2028 replacesAtt[Anum_pg_attribute_atthasmissing - 1] =
true;
2029 valuesAtt[Anum_pg_attribute_attmissingval - 1] = missingval;
2030 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
2033 valuesAtt, nullsAtt, replacesAtt);
2052 bool is_validated,
bool is_local,
int inhcount,
2053 bool is_no_inherit,
bool is_internal)
2082 foreach(vl, varList)
2087 for (
j = 0;
j <
i;
j++)
2102 if (is_no_inherit &&
2103 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
2105 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
2106 errmsg(
"cannot add NO INHERIT constraint to partitioned table \"%s\"",
2157 bool is_validated,
bool is_local,
int inhcount,
2213 if (cooked_constraints ==
NIL)
2223 foreach(lc, cooked_constraints)
2231 is_internal,
false);
2250 elog(
ERROR,
"unrecognized constraint type: %d",
2291 List *newColDefaults,
2292 List *newConstraints,
2296 const char *queryString)
2298 List *cookedConstraints =
NIL;
2315 oldconstr = tupleDesc->
constr;
2338 foreach(cell, newColDefaults)
2345 atp->atttypid, atp->atttypmod,
2377 cooked->
name = NULL;
2379 cooked->
expr = expr;
2382 cooked->
inhcount = is_local ? 0 : 1;
2384 cookedConstraints =
lappend(cookedConstraints, cooked);
2390 numchecks = numoldchecks;
2393 foreach(cell, newConstraints)
2434 foreach(cell2, checknames)
2436 if (strcmp((
char *)
lfirst(cell2), ccname) == 0)
2439 errmsg(
"check constraint \"%s\" already exists",
2444 checknames =
lappend(checknames, ccname);
2453 allow_merge, is_local,
2495 checknames =
lappend(checknames, ccname);
2509 cooked->
conoid = constrOid;
2510 cooked->
name = ccname;
2512 cooked->
expr = expr;
2515 cooked->
inhcount = is_local ? 0 : 1;
2517 cookedConstraints =
lappend(cookedConstraints, cooked);
2528 elog(
ERROR,
"cache lookup failed for attribute \"%s\" of relation %u",
2550 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2560 nnnames =
lappend(nnnames, nnname);
2571 nncooked->
conoid = constrOid;
2572 nncooked->
name = nnname;
2573 nncooked->
attnum = colnum;
2574 nncooked->
expr = NULL;
2580 cookedConstraints =
lappend(cookedConstraints, nncooked);
2593 return cookedConstraints;
2608 bool allow_merge,
bool is_local,
2609 bool is_initially_valid,
2624 Anum_pg_constraint_conrelid,
2628 Anum_pg_constraint_contypid,
2632 Anum_pg_constraint_conname,
2645 if (con->contype == CONSTRAINT_CHECK)
2651 Anum_pg_constraint_conbin,
2652 conDesc->
rd_att, &isnull);
2668 if (is_local && !con->conislocal && !rel->
rd_rel->relispartition)
2671 if (!found || !allow_merge)
2674 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2678 if (con->connoinherit)
2680 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2681 errmsg(
"constraint \"%s\" conflicts with non-inherited constraint on relation \"%s\"",
2689 if (con->coninhcount > 0 && is_no_inherit)
2691 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2692 errmsg(
"constraint \"%s\" conflicts with inherited constraint on relation \"%s\"",
2699 if (is_initially_valid && !con->convalidated)
2701 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2702 errmsg(
"constraint \"%s\" conflicts with NOT VALID constraint on relation \"%s\"",
2707 (
errmsg(
"merging constraint \"%s\" with inherited definition",
2718 if (rel->
rd_rel->relispartition)
2720 con->coninhcount = 1;
2721 con->conislocal =
false;
2726 con->conislocal =
true;
2730 if (con->coninhcount < 0)
2732 errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2733 errmsg(
"too many inheritance parents"));
2739 con->connoinherit =
true;
2809 foreach(lc, constraints)
2814 bool is_local =
true;
2827 foreach(lc2, old_notnulls)
2839 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2840 errmsg(
"cannot define not-null constraint on column \"%s\" with NO INHERIT",
2842 errdetail(
"The column has an inherited not-null constraint.")));
2856 foreach(lc2, givennames)
2861 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2867 givennames =
lappend(givennames, conname);
2876 nnnames =
lappend(nnnames, conname);
2900 for (
int outerpos = 0; outerpos <
list_length(old_notnulls); outerpos++)
2903 char *conname = NULL;
2904 int add_inhcount = 0;
2914 if (conname == NULL && cooked->
name)
2915 conname = cooked->
name;
2917 for (
int restpos = outerpos + 1; restpos <
list_length(old_notnulls);)
2924 if (conname == NULL && other->
name)
2925 conname = other->
name;
2935 if (conname != NULL)
2937 foreach(lc2, nnnames)
2939 if (strcmp(
lfirst(lc2), conname) == 0)
2948 if (conname == NULL)
2955 nnnames =
lappend(nnnames, conname);
2988 elog(
ERROR,
"cache lookup failed for relation %u",
2992 if (relStruct->relchecks != numchecks)
2994 relStruct->relchecks = numchecks;
3032 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3033 errmsg(
"cannot use generated column \"%s\" in column generation expression",
3035 errdetail(
"A generated column cannot reference another generated column."),
3040 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3041 errmsg(
"cannot use whole-row variable in column generation expression"),
3042 errdetail(
"This would cause the generated column to depend on its own value."),
3081 Assert(raw_default != NULL);
3094 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3095 errmsg(
"generation expression is not immutable")));
3116 atttypid, atttypmod,
3122 (
errcode(ERRCODE_DATATYPE_MISMATCH),
3123 errmsg(
"column \"%s\" is of type %s"
3124 " but default expression is of type %s",
3128 errhint(
"You will need to rewrite or cast the expression.")));
3148 Node *raw_constraint,
3174 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
3175 errmsg(
"only table \"%s\" can be referenced in check constraint",
3197 Anum_pg_statistic_starelid,
3202 true, NULL, 1,
key);
3213 statform->starelid = torelid;
3216 if (indstate == NULL)
3226 if (indstate != NULL)
3249 Anum_pg_statistic_starelid,
3258 Anum_pg_statistic_staattnum,
3316 index_build(heapRelation, currentIndex, indexInfo,
true,
false);
3339 foreach(cell, relids)
3345 relations =
lappend(relations, rel);
3352 foreach(cell, relations)
3382 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3392 toastrelid = rel->
rd_rel->reltoastrelid;
3432 foreach(cell, relations)
3436 if (rel->
rd_rel->relhastriggers ||
3437 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3452 if (dependents ==
NIL)
3469 foreach(cell2, dependents)
3480 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3481 errmsg(
"unsupported ON COMMIT and foreign key combination"),
3482 errdetail(
"Table \"%s\" references \"%s\", but they do not have the same ON COMMIT setting.",
3486 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3487 errmsg(
"cannot truncate a table referenced in a foreign key constraint"),
3488 errdetail(
"Table \"%s\" references \"%s\".",
3490 errhint(
"Truncate table \"%s\" at the same time, "
3491 "or use TRUNCATE ... CASCADE.",
3545 if (con->contype != CONSTRAINT_FOREIGN)
3560 parent_cons =
lappend_oid(parent_cons, con->conparentid);
3579 foreach(cell, parent_cons)
3584 Anum_pg_constraint_oid,
3589 true, NULL, 1, &
key);
3652 Datum partexprDatum;
3656 bool nulls[Natts_pg_partitioned_table] = {0};
3661 Assert(rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
3678 partexprDatum = (
Datum) 0;
3684 nulls[Anum_pg_partitioned_table_partexprs - 1] =
true;
3693 values[Anum_pg_partitioned_table_partexprs - 1] = partexprDatum;
3705 for (
i = 0;
i < partnatts;
i++)
3712 partcollation[
i] != DEFAULT_COLLATION_OID)
3728 for (
i = 0;
i < partnatts;
i++)
3730 if (partattrs[
i] == 0)
3774 elog(
ERROR,
"cache lookup failed for partition key of relation %u",
3801 Datum new_val[Natts_pg_class];
3802 bool new_null[Natts_pg_class],
3803 new_repl[Natts_pg_class];
3811 elog(
ERROR,
"cache lookup failed for relation %u",
3814 #ifdef USE_ASSERT_CHECKING
3820 Assert(!classForm->relispartition);
3828 memset(new_val, 0,
sizeof(new_val));
3829 memset(new_null,
false,
sizeof(new_null));
3830 memset(new_repl,
false,
sizeof(new_repl));
3832 new_null[Anum_pg_class_relpartbound - 1] =
false;
3833 new_repl[Anum_pg_class_relpartbound - 1] =
true;
3835 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)
TransactionId MultiXactId
#define OidIsValid(objectId)
bool IsToastNamespace(Oid namespaceId)
RelFileNumber GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
bool IsCatalogNamespace(Oid namespaceId)
bool contain_mutable_functions(Node *clause)
bool contain_volatile_functions(Node *clause)
static void PGresult const char * p2
elog(ERROR, "%s: %s", p2, msg)
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[]
void InsertPgAttributeTuples(Relation pg_attribute_rel, TupleDesc tupdesc, Oid new_rel_oid, const Datum *attoptions, CatalogIndexState indstate)
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 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_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
HeapTuple heap_copytuple(HeapTuple tuple)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
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)
void CacheInvalidateRelcache(Relation relation)
void CacheInvalidateRelcacheByRelid(Oid relid)
struct ItemPointerData ItemPointerData
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
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 is_internal)
bool AdjustNotNullInheritance1(Oid relid, AttrNumber attnum, int count, 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)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define list_make1_oid(x1)
static void * list_nth(const List *list, int n)
#define foreach_delete_current(lst, cell)
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)
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)