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;
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)
457 int natts = tupdesc->
natts;
462 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
463 errmsg(
"tables can have at most %d columns",
472 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
474 for (
i = 0;
i < natts;
i++)
480 (
errcode(ERRCODE_DUPLICATE_COLUMN),
481 errmsg(
"column name \"%s\" conflicts with a system column name",
489 for (
i = 1;
i < natts;
i++)
491 for (
j = 0;
j <
i;
j++)
496 (
errcode(ERRCODE_DUPLICATE_COLUMN),
497 errmsg(
"column name \"%s\" specified more than once",
505 for (
i = 0;
i < natts;
i++)
545 Oid atttypid,
Oid attcollation,
546 List *containing_rowtypes,
552 if (att_typtype == TYPTYPE_PSEUDO)
570 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
572 errmsg(
"partition key column %s has pseudo-type %s",
576 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
577 errmsg(
"column \"%s\" has pseudo-type %s",
581 else if (att_typtype == TYPTYPE_DOMAIN)
590 else if (att_typtype == TYPTYPE_COMPOSITE)
607 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
608 errmsg(
"composite type %s cannot be made a member of itself",
611 containing_rowtypes =
lappend_oid(containing_rowtypes, atttypid);
617 for (
i = 0;
i < tupdesc->
natts;
i++)
621 if (attr->attisdropped)
624 attr->atttypid, attr->attcollation,
633 else if (att_typtype == TYPTYPE_RANGE)
661 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
663 errmsg(
"no collation was derived for partition key column %s with collatable type %s",
665 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
668 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
669 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
671 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
705 bool close_index =
false;
713 for (
int i = 0;
i < nslots;
i++)
716 while (natts < tupdesc->natts)
722 memset(slot[slotCount]->tts_isnull,
false,
723 slot[slotCount]->tts_tupleDescriptor->natts *
sizeof(
bool));
751 if (attoptions && attoptions[natts] != (
Datum) 0)
752 slot[slotCount]->
tts_values[Anum_pg_attribute_attoptions - 1] = attoptions[natts];
754 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attoptions - 1] =
true;
757 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attacl - 1] =
true;
758 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attfdwoptions - 1] =
true;
759 slot[slotCount]->
tts_isnull[Anum_pg_attribute_attmissingval - 1] =
true;
768 if (slotCount == nslots || natts == tupdesc->
natts - 1)
788 for (
int i = 0;
i < nslots;
i++)
807 int natts = tupdesc->
natts;
819 for (
int i = 0;
i < natts;
i++)
820 tupdesc->
attrs[
i].attstattarget = -1;
824 for (
int i = 0;
i < natts;
i++)
829 tupdesc->
attrs[
i].atttypid);
834 tupdesc->
attrs[
i].attcollation != DEFAULT_COLLATION_OID)
837 tupdesc->
attrs[
i].attcollation);
847 if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
887 bool nulls[Natts_pg_class];
892 memset(nulls,
false,
sizeof(nulls));
916 values[Anum_pg_class_relforcerowsecurity - 1] =
BoolGetDatum(rd_rel->relforcerowsecurity);
924 if (relacl != (
Datum) 0)
925 values[Anum_pg_class_relacl - 1] = relacl;
927 nulls[Anum_pg_class_relacl - 1] =
true;
928 if (reloptions != (
Datum) 0)
929 values[Anum_pg_class_reloptions - 1] = reloptions;
931 nulls[Anum_pg_class_reloptions - 1] =
true;
934 nulls[Anum_pg_class_relpartbound - 1] =
true;
970 new_rel_reltup = new_rel_desc->
rd_rel;
973 new_rel_reltup->relpages = 0;
974 new_rel_reltup->reltuples = -1;
975 new_rel_reltup->relallvisible = 0;
978 if (relkind == RELKIND_SEQUENCE)
980 new_rel_reltup->relpages = 1;
981 new_rel_reltup->reltuples = 1;
984 new_rel_reltup->relfrozenxid = relfrozenxid;
985 new_rel_reltup->relminmxid = relminmxid;
986 new_rel_reltup->relowner = relowner;
987 new_rel_reltup->reltype = new_type_oid;
988 new_rel_reltup->reloftype = reloftype;
991 new_rel_reltup->relispartition =
false;
994 new_rel_desc->
rd_att->
tdtypeid = new_type_oid ? new_type_oid : RECORDOID;
1027 TYPCATEGORY_COMPOSITE,
1046 TYPSTORAGE_EXTENDED,
1097 List *cooked_constraints,
1099 char relpersistence,
1100 bool shared_relation,
1101 bool mapped_relation,
1105 bool allow_system_table_mods,
1144 (
errcode(ERRCODE_DUPLICATE_TABLE),
1162 errhint(
"A relation has an associated type of the same name, "
1163 "so you must use a name that doesn't conflict "
1164 "with any existing type.")));
1170 if (shared_relation && reltablespace != GLOBALTABLESPACE_OID)
1171 elog(
ERROR,
"shared relations must be placed in pg_global tablespace");
1188 Assert(relkind != RELKIND_INDEX);
1189 Assert(relkind != RELKIND_PARTITIONED_INDEX);
1191 if (relkind == RELKIND_TOASTVALUE)
1201 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1202 errmsg(
"toast relfilenode value not set when in binary upgrade mode")));
1212 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1213 errmsg(
"pg_class heap OID value not set when in binary upgrade mode")));
1218 if (RELKIND_HAS_STORAGE(relkind))
1222 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1223 errmsg(
"relfilenode value not set when in binary upgrade mode")));
1243 case RELKIND_RELATION:
1245 case RELKIND_MATVIEW:
1246 case RELKIND_FOREIGN_TABLE:
1247 case RELKIND_PARTITIONED_TABLE:
1251 case RELKIND_SEQUENCE:
1283 allow_system_table_mods,
1290 new_rel_desc->
rd_rel->relrewrite = relrewrite;
1297 if (!(relkind == RELKIND_SEQUENCE ||
1298 relkind == RELKIND_TOASTVALUE ||
1299 relkind == RELKIND_INDEX ||
1300 relkind == RELKIND_PARTITIONED_INDEX))
1328 new_type_oid = new_type_addr.
objectId;
1330 *typaddress = new_type_addr;
1353 F_ARRAY_SUBSCRIPT_HANDLER,
1362 TYPSTORAGE_EXTENDED,
1368 pfree(relarrayname);
1374 Assert(typaddress == NULL);
1418 if (relkind != RELKIND_COMPOSITE_TYPE &&
1419 relkind != RELKIND_TOASTVALUE &&
1452 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",
1680 attStruct->attisdropped =
true;
1694 attStruct->attnotnull =
false;
1697 attStruct->attstattarget = 0;
1700 attStruct->attgenerated =
'\0';
1705 snprintf(newattname,
sizeof(newattname),
1706 "........pg.dropped.%d........",
attnum);
1707 namestrcpy(&(attStruct->attname), newattname);
1710 if (attStruct->atthasmissing)
1712 Datum valuesAtt[Natts_pg_attribute];
1713 bool nullsAtt[Natts_pg_attribute];
1714 bool replacesAtt[Natts_pg_attribute];
1717 MemSet(valuesAtt, 0,
sizeof(valuesAtt));
1718 MemSet(nullsAtt,
false,
sizeof(nullsAtt));
1719 MemSet(replacesAtt,
false,
sizeof(replacesAtt));
1721 valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
1723 replacesAtt[Anum_pg_attribute_atthasmissing - 1] =
true;
1724 valuesAtt[Anum_pg_attribute_attmissingval - 1] = (
Datum) 0;
1725 nullsAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1726 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
1729 valuesAtt, nullsAtt, replacesAtt);
1778 elog(
ERROR,
"cache lookup failed for relation %u", relid);
1794 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1823 if (rel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
1832 elog(
ERROR,
"cache lookup failed for foreign table %u", relid);
1843 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
1850 if (relid == defaultPartOid)
1856 if (RELKIND_HAS_STORAGE(rel->
rd_rel->relkind))
1915 if (
OidIsValid(defaultPartOid) && relid != defaultPartOid)
1945 Datum repl_val[Natts_pg_attribute];
1946 bool repl_null[Natts_pg_attribute];
1947 bool repl_repl[Natts_pg_attribute];
1952 memset(repl_val, 0,
sizeof(repl_val));
1953 memset(repl_null,
false,
sizeof(repl_null));
1954 memset(repl_repl,
false,
sizeof(repl_repl));
1956 repl_val[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
false);
1957 repl_null[Anum_pg_attribute_attmissingval - 1] =
true;
1959 repl_repl[Anum_pg_attribute_atthasmissing - 1] =
true;
1960 repl_repl[Anum_pg_attribute_attmissingval - 1] =
true;
1973 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1979 if (attrtuple->atthasmissing)
1982 repl_val, repl_null, repl_repl);
2009 Datum valuesAtt[Natts_pg_attribute];
2010 bool nullsAtt[Natts_pg_attribute];
2011 bool replacesAtt[Natts_pg_attribute];
2023 if (tablerel->
rd_rel->relkind != RELKIND_RELATION)
2033 elog(
ERROR,
"cache lookup failed for attribute %s of relation %u",
2044 MemSet(valuesAtt, 0,
sizeof(valuesAtt));
2045 MemSet(nullsAtt,
false,
sizeof(nullsAtt));
2046 MemSet(replacesAtt,
false,
sizeof(replacesAtt));
2048 valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
BoolGetDatum(
true);
2049 replacesAtt[Anum_pg_attribute_atthasmissing - 1] =
true;
2050 valuesAtt[Anum_pg_attribute_attmissingval - 1] = missingval;
2051 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
2054 valuesAtt, nullsAtt, replacesAtt);
2073 bool is_validated,
bool is_local,
int inhcount,
2074 bool is_no_inherit,
bool is_internal)
2103 foreach(vl, varList)
2108 for (
j = 0;
j <
i;
j++)
2123 if (is_no_inherit &&
2124 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
2126 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
2127 errmsg(
"cannot add NO INHERIT constraint to partitioned table \"%s\"",
2187 if (cooked_constraints ==
NIL)
2197 foreach(lc, cooked_constraints)
2205 is_internal,
false);
2216 elog(
ERROR,
"unrecognized constraint type: %d",
2255 List *newColDefaults,
2256 List *newConstraints,
2260 const char *queryString)
2262 List *cookedConstraints =
NIL;
2278 oldconstr = tupleDesc->
constr;
2301 foreach(cell, newColDefaults)
2308 atp->atttypid, atp->atttypmod,
2340 cooked->
name = NULL;
2342 cooked->
expr = expr;
2345 cooked->
inhcount = is_local ? 0 : 1;
2347 cookedConstraints =
lappend(cookedConstraints, cooked);
2353 numchecks = numoldchecks;
2355 foreach(cell, newConstraints)
2396 foreach(cell2, checknames)
2398 if (strcmp((
char *)
lfirst(cell2), ccname) == 0)
2401 errmsg(
"check constraint \"%s\" already exists",
2406 checknames =
lappend(checknames, ccname);
2415 allow_merge, is_local,
2456 checknames =
lappend(checknames, ccname);
2470 cooked->
conoid = constrOid;
2471 cooked->
name = ccname;
2473 cooked->
expr = expr;
2476 cooked->
inhcount = is_local ? 0 : 1;
2478 cookedConstraints =
lappend(cookedConstraints, cooked);
2490 return cookedConstraints;
2505 bool allow_merge,
bool is_local,
2506 bool is_initially_valid,
2521 Anum_pg_constraint_conrelid,
2525 Anum_pg_constraint_contypid,
2529 Anum_pg_constraint_conname,
2542 if (con->contype == CONSTRAINT_CHECK)
2548 Anum_pg_constraint_conbin,
2549 conDesc->
rd_att, &isnull);
2565 if (is_local && !con->conislocal && !rel->
rd_rel->relispartition)
2568 if (!found || !allow_merge)
2571 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
2575 if (con->connoinherit)
2577 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2578 errmsg(
"constraint \"%s\" conflicts with non-inherited constraint on relation \"%s\"",
2586 if (con->coninhcount > 0 && is_no_inherit)
2588 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2589 errmsg(
"constraint \"%s\" conflicts with inherited constraint on relation \"%s\"",
2596 if (is_initially_valid && !con->convalidated)
2598 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2599 errmsg(
"constraint \"%s\" conflicts with NOT VALID constraint on relation \"%s\"",
2604 (
errmsg(
"merging constraint \"%s\" with inherited definition",
2615 if (rel->
rd_rel->relispartition)
2617 con->coninhcount = 1;
2618 con->conislocal =
false;
2623 con->conislocal =
true;
2631 con->connoinherit =
true;
2664 elog(
ERROR,
"cache lookup failed for relation %u",
2668 if (relStruct->relchecks != numchecks)
2670 relStruct->relchecks = numchecks;
2708 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2709 errmsg(
"cannot use generated column \"%s\" in column generation expression",
2711 errdetail(
"A generated column cannot reference another generated column."),
2716 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2717 errmsg(
"cannot use whole-row variable in column generation expression"),
2718 errdetail(
"This would cause the generated column to depend on its own value."),
2757 Assert(raw_default != NULL);
2770 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2771 errmsg(
"generation expression is not immutable")));
2792 atttypid, atttypmod,
2798 (
errcode(ERRCODE_DATATYPE_MISMATCH),
2799 errmsg(
"column \"%s\" is of type %s"
2800 " but default expression is of type %s",
2804 errhint(
"You will need to rewrite or cast the expression.")));
2824 Node *raw_constraint,
2850 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2851 errmsg(
"only table \"%s\" can be referenced in check constraint",
2872 Anum_pg_statistic_starelid,
2877 true, NULL, 1,
key);
2888 statform->starelid = torelid;
2917 Anum_pg_statistic_starelid,
2926 Anum_pg_statistic_staattnum,
2984 index_build(heapRelation, currentIndex, indexInfo,
true,
false);
3007 foreach(cell, relids)
3013 relations =
lappend(relations, rel);
3020 foreach(cell, relations)
3050 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3060 toastrelid = rel->
rd_rel->reltoastrelid;
3100 foreach(cell, relations)
3104 if (rel->
rd_rel->relhastriggers ||
3105 rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
3120 if (dependents ==
NIL)
3137 foreach(cell2, dependents)
3148 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3149 errmsg(
"unsupported ON COMMIT and foreign key combination"),
3150 errdetail(
"Table \"%s\" references \"%s\", but they do not have the same ON COMMIT setting.",
3154 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3155 errmsg(
"cannot truncate a table referenced in a foreign key constraint"),
3156 errdetail(
"Table \"%s\" references \"%s\".",
3158 errhint(
"Truncate table \"%s\" at the same time, "
3159 "or use TRUNCATE ... CASCADE.",
3213 if (con->contype != CONSTRAINT_FOREIGN)
3228 parent_cons =
lappend_oid(parent_cons, con->conparentid);
3247 foreach(cell, parent_cons)
3252 Anum_pg_constraint_oid,
3257 true, NULL, 1, &
key);
3320 Datum partexprDatum;
3324 bool nulls[Natts_pg_partitioned_table];
3329 Assert(rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
3346 partexprDatum = (
Datum) 0;
3350 MemSet(nulls,
false,
sizeof(nulls));
3354 nulls[Anum_pg_partitioned_table_partexprs - 1] =
true;
3363 values[Anum_pg_partitioned_table_partexprs - 1] = partexprDatum;
3375 for (
i = 0;
i < partnatts;
i++)
3382 partcollation[
i] != DEFAULT_COLLATION_OID)
3398 for (
i = 0;
i < partnatts;
i++)
3400 if (partattrs[
i] == 0)
3444 elog(
ERROR,
"cache lookup failed for partition key of relation %u",
3471 Datum new_val[Natts_pg_class];
3472 bool new_null[Natts_pg_class],
3473 new_repl[Natts_pg_class];
3481 elog(
ERROR,
"cache lookup failed for relation %u",
3484 #ifdef USE_ASSERT_CHECKING
3490 Assert(!classForm->relispartition);
3498 memset(new_val, 0,
sizeof(new_val));
3499 memset(new_null,
false,
sizeof(new_null));
3500 memset(new_repl,
false,
sizeof(new_repl));
3502 new_null[Anum_pg_class_relpartbound - 1] =
false;
3503 new_repl[Anum_pg_class_relpartbound - 1] =
true;
3505 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)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
TransactionId MultiXactId
#define MemSet(start, val, len)
#define OidIsValid(objectId)
bool IsToastNamespace(Oid namespaceId)
Oid GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
bool IsCatalogNamespace(Oid namespaceId)
bool contain_mutable_functions(Node *clause)
bool contain_volatile_functions(Node *clause)
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 InsertPgAttributeTuples(Relation pg_attribute_rel, TupleDesc tupdesc, Oid new_rel_oid, Datum *attoptions, CatalogIndexState indstate)
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 const FormData_pg_attribute * SysAtt[]
static void RelationTruncateIndexes(Relation heapRelation)
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)
Oid binary_upgrade_next_heap_pg_class_relfilenode
void DeleteAttributeTuples(Oid relid)
void RemoveStatistics(Oid relid, AttrNumber attnum)
static const FormData_pg_attribute a4
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)
Oid binary_upgrade_next_toast_pg_class_relfilenode
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)
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
Relation heap_create(const char *relname, Oid relnamespace, Oid reltablespace, Oid relid, Oid relfilenode, 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 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)
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
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 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_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)
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)
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)
bool expression_tree_walker(Node *node, bool(*walker)(), void *context)
#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)
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)
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 list_make1_oid(x1)
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)
#define TransactionIdGetDatum(X)
static Datum Float4GetDatum(float4 X)
#define CStringGetDatum(X)
#define ObjectIdGetDatum(X)
#define MultiXactIdGetDatum(X)
#define PointerGetDatum(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)
Relation RelationBuildLocalRelation(const char *relname, Oid relnamespace, TupleDesc tupDesc, Oid relid, Oid accessmtd, Oid relfilenode, Oid reltablespace, bool shared_relation, bool mapped_relation, char relpersistence, char relkind)
void RelationForgetRelation(Oid rid)
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(RelFileNode rnode, 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
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_filenode(Relation rel, const RelFileNode *newrnode, 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)