100#include "utils/fmgroids.h"
167#define AT_NUM_PASSES (AT_PASS_MISC + 1)
266 gettext_noop(
"sequence \"%s\" does not exist, skipping"),
268 gettext_noop(
"Use DROP SEQUENCE to remove a sequence.")},
277 gettext_noop(
"materialized view \"%s\" does not exist"),
278 gettext_noop(
"materialized view \"%s\" does not exist, skipping"),
280 gettext_noop(
"Use DROP MATERIALIZED VIEW to remove a materialized view.")},
296 gettext_noop(
"foreign table \"%s\" does not exist, skipping"),
298 gettext_noop(
"Use DROP FOREIGN TABLE to remove a foreign table.")},
329#define ATT_TABLE 0x0001
330#define ATT_VIEW 0x0002
331#define ATT_MATVIEW 0x0004
332#define ATT_INDEX 0x0008
333#define ATT_COMPOSITE_TYPE 0x0010
334#define ATT_FOREIGN_TABLE 0x0020
335#define ATT_PARTITIONED_INDEX 0x0040
336#define ATT_SEQUENCE 0x0080
337#define ATT_PARTITIONED_TABLE 0x0100
366#define child_dependency_type(child_is_partition) \
367 ((child_is_partition) ? DEPENDENCY_AUTO : DEPENDENCY_NORMAL)
415 bool deferrable,
bool initdeferred,
433 bool recurse,
bool recursing,
LOCKMODE lockmode);
438 bool recurse,
bool recursing,
LOCKMODE lockmode);
463 bool recurse,
bool recursing,
LOCKMODE lockmode,
495 bool recurse,
bool recursing,
508 bool recurse,
bool recursing,
518 Node *def,
LOCKMODE lockmode,
bool recurse,
bool recursing);
520 Node *def,
LOCKMODE lockmode,
bool recurse,
bool recursing);
522 bool recurse,
bool recursing);
538 bool recurse,
bool recursing,
559 bool recurse,
bool recursing,
bool is_readd,
563 bool recurse,
bool recursing,
569 char *constraintname,
623 Oid conoid,
Oid conrelid);
625 Oid confrelid,
Oid conrelid);
636 bool missing_ok,
LOCKMODE lockmode);
639 bool recurse,
bool recursing,
640 bool missing_ok,
LOCKMODE lockmode);
643 bool recurse,
bool recursing,
661 const char *conname);
678 const char *tablespacename,
LOCKMODE lockmode);
723 bool validate_default);
807 errmsg(
"ON COMMIT can only be used on temporary tables")));
812 elog(
ERROR,
"unexpected relkind: %d", (
int) relkind);
824 errmsg(
"partitioned tables cannot be unlogged")));
844 errmsg(
"cannot create temporary table within security-restricted operation")));
880 errmsg(
"relation \"%s\" would be inherited from more than once",
890 if (
stmt->tablespacename)
897 errmsg(
"cannot specify default tablespace for partitioned relations")));
899 else if (
stmt->partbound)
928 errmsg(
"only shared relations can be placed in pg_global tablespace")));
952 if (
stmt->ofTypename)
972 stmt->relation->relpersistence,
1023 cooked->is_enforced =
true;
1024 cooked->skip_validation =
false;
1027 cooked->is_no_inherit =
false;
1044 if (
stmt->partbound)
1071 stmt->relation->relpersistence,
1110 true,
true,
false, queryString);
1118 if (
stmt->partbound)
1138 errmsg(
"\"%s\" is not partitioned",
1176 NULL,
false,
false);
1232 errmsg(
"cannot partition using more than %d columns",
1245 partcollation,
stmt->partspec->strategy);
1262 if (
stmt->partbound)
1285 if (
idxRel->rd_index->indisunique)
1288 errmsg(
"cannot create foreign partition of partitioned table \"%s\"",
1290 errdetail(
"Table \"%s\" contains indexes that are unique.",
1312 false,
false,
false,
false,
false);
1340 if (
stmt->constraints)
1342 true,
true,
false, queryString);
1421 errmsg(
"too many array dimensions"));
1426 errmsg(
"column \"%s\" cannot be declared SETOF",
1475 (
errmsg(
"schema \"%s\" does not exist, skipping",
1543 if (
drop->concurrent)
1555 errmsg(
"DROP INDEX CONCURRENTLY does not support dropping multiple objects")));
1559 errmsg(
"DROP INDEX CONCURRENTLY does not support CASCADE")));
1569 switch (
drop->removeType)
1596 elog(
ERROR,
"unrecognized drop object type: %d",
1597 (
int)
drop->removeType);
1605 foreach(cell,
drop->objects)
1625 state.expected_relkind = relkind;
1626 state.heap_lockmode =
drop->concurrent ?
1647 if (
drop->concurrent &&
1663 errmsg(
"cannot drop partitioned index \"%s\" concurrently",
1675 state.heap_lockmode,
1765 state->expected_relkind);
1806 errmsg(
"permission denied: \"%s\" is a system catalog",
1867 foreach(cell,
stmt->relations)
1871 bool recurse = rv->
inh;
1906 foreach(child, children)
1951 errmsg(
"cannot truncate only a partitioned table"),
1952 errhint(
"Do not specify the ONLY keyword, or use TRUNCATE ONLY on the partitions directly.")));
1956 stmt->behavior,
stmt->restart_seqs,
false);
2025 (
errmsg(
"truncate cascades to table \"%s\"",
2045#ifdef USE_ASSERT_CHECKING
2386 errmsg(
"cannot truncate foreign table \"%s\"",
2409 errmsg(
"permission denied: \"%s\" is a system catalog",
2446 errmsg(
"cannot truncate temporary tables of other sessions")));
2571 errmsg(
"tables can have at most %d columns",
2602 errmsg(
"column \"%s\" does not exist",
2613 if (
coldef->is_from_type)
2622 coldef->is_from_type =
false;
2628 errmsg(
"column \"%s\" specified more than once",
2684 errmsg(
"cannot inherit from partitioned table \"%s\"",
2689 errmsg(
"cannot inherit from partition \"%s\"",
2697 errmsg(
"inherited relation \"%s\" is not a table or foreign table",
2709 errmsg(
"cannot create a temporary relation as partition of permanent relation \"%s\"",
2718 ?
"cannot inherit from temporary relation \"%s\""
2719 :
"cannot create a permanent relation as partition of temporary relation \"%s\"",
2727 ?
"cannot inherit from temporary relation of another session"
2728 :
"cannot create as partition of temporary relation of another session")));
2773 if (attribute->attisdropped)
2780 attribute->atttypmod, attribute->attcollation);
2781 newdef->storage = attribute->attstorage;
2782 newdef->generated = attribute->attgenerated;
2793 newdef->identity = attribute->attidentity;
2821 newdef->is_local =
false;
2837 if (attribute->atthasdef)
2843 elog(
ERROR,
"default expression not found for attribute %d of relation \"%s\"",
2865 bool found_whole_row;
2879 if (found_whole_row)
2882 errmsg(
"cannot convert whole-row table reference"),
2883 errdetail(
"Generation expression for column \"%s\" contains a whole-row reference to table \"%s\".",
2916 bool found_whole_row;
2919 if (check[
i].ccnoinherit)
2933 if (found_whole_row)
2936 errmsg(
"cannot convert whole-row table reference"),
2937 errdetail(
"Constraint \"%s\" contains a whole-row reference to table \"%s\".",
2942 check[
i].ccenforced);
2956 nnconstraints =
lappend(nnconstraints,
nn);
2979 foreach(
lc, columns)
3022 errmsg(
"tables can have at most %d columns",
3059 errmsg(
"column \"%s\" inherits from generated column but specifies default",
3064 errmsg(
"column \"%s\" inherits from generated column but specifies identity",
3072 errmsg(
"child column \"%s\" specifies generation expression",
3074 errhint(
"A child table column cannot be generated unless its parent column is.")));
3080 errmsg(
"column \"%s\" inherits from generated column of different kind",
3082 errdetail(
"Parent column is %s, child column is %s.",
3109 errmsg(
"column \"%s\" does not exist",
3120 foreach(
lc, columns)
3129 errmsg(
"column \"%s\" inherits conflicting generation expressions",
3131 errhint(
"To resolve the conflict, specify a generation expression explicitly.")));
3135 errmsg(
"column \"%s\" inherits conflicting default values",
3137 errhint(
"To resolve the conflict, specify a default explicitly.")));
3170 foreach(
lc, constraints)
3187 errmsg(
"too many inheritance parents"));
3193 if (!
ccon->is_enforced && is_enforced)
3195 ccon->is_enforced =
true;
3196 ccon->skip_validation =
false;
3204 errmsg(
"check constraint name \"%s\" appears multiple times but with different expressions",
3217 newcon->is_enforced = is_enforced;
3218 newcon->skip_validation = !is_enforced;
3257 (
errmsg(
"merging column \"%s\" with inherited definition",
3262 errdetail(
"User-specified column moved to the position of the inherited column.")));
3274 errmsg(
"column \"%s\" has a type conflict",
3288 errmsg(
"column \"%s\" has a collation conflict",
3303 if (
inhdef->storage == 0)
3308 errmsg(
"column \"%s\" has a storage parameter conflict",
3324 errmsg(
"column \"%s\" has a compression method conflict",
3353 errmsg(
"column \"%s\" inherits from generated column but specifies default",
3358 errmsg(
"column \"%s\" inherits from generated column but specifies identity",
3366 errmsg(
"child column \"%s\" specifies generation expression",
3368 errhint(
"A child table column cannot be generated unless its parent column is.")));
3374 errmsg(
"column \"%s\" inherits from generated column of different kind",
3376 errdetail(
"Parent column is %s, child column is %s.",
3428 (
errmsg(
"merging multiple inherited definitions of column \"%s\"",
3440 errmsg(
"inherited column \"%s\" has a type conflict",
3454 errmsg(
"inherited column \"%s\" has a collation conflict",
3468 errmsg(
"inherited column \"%s\" has a storage parameter conflict",
3484 errmsg(
"column \"%s\" has a compression method conflict",
3496 errmsg(
"inherited column \"%s\" has a generation conflict",
3507 errmsg(
"too many inheritance parents"));
3613 foreach(
lc, columns)
3711 errmsg(
"cannot move system relation \"%s\"",
3718 errmsg(
"only shared relations can be placed in pg_global tablespace")));
3727 errmsg(
"cannot move temporary tables of other sessions")));
3765 elog(
ERROR,
"cache lookup failed for relation %u", reloid);
3783 rd_rel->reltablespace);
3800 errmsg(
"cannot rename column of typed table")));
3819 errmsg(
"cannot rename columns of relation \"%s\"",
3832 errmsg(
"permission denied: \"%s\" is a system catalog",
3914 errmsg(
"inherited column \"%s\" must be renamed in child tables too",
3938 errmsg(
"column \"%s\" does not exist",
3946 errmsg(
"cannot rename system column \"%s\"",
3961 errmsg(
"cannot rename inherited column \"%s\"",
4022 (
errmsg(
"relation \"%s\" does not exist, skipping",
4023 stmt->relation->relname)));
4031 stmt->relation->inh,
4080 elog(
ERROR,
"cache lookup failed for constraint %u",
4116 errmsg(
"inherited constraint \"%s\" must be renamed in child tables too",
4123 errmsg(
"cannot rename inherited constraint \"%s\"",
4168 elog(
ERROR,
"cache lookup failed for type %u", typid);
4183 (
errmsg(
"relation \"%s\" does not exist, skipping",
4184 stmt->relation->relname)));
4194 stmt->relation->inh),
4235 (
errmsg(
"relation \"%s\" does not exist, skipping",
4236 stmt->relation->relname)));
4304 errmsg(
"relation \"%s\" already exists",
4423 errmsg(
"cannot %s \"%s\" because it is being used by active queries in this session",
4432 errmsg(
"cannot %s \"%s\" because it has pending trigger events",
4458 errmsg(
"cannot alter temporary tables of other sessions")));
4851 elog(
ERROR,
"unrecognized alter table type: %d",
4909 bool recurse,
bool recursing,
LOCKMODE lockmode,
4922 if (rel->
rd_rel->relispartition &&
4927 errmsg(
"cannot alter partition \"%s\" with an incomplete detach",
4929 errhint(
"Use ALTER TABLE ... DETACH PARTITION ... FINALIZE to complete the pending detach operation."));
5156 errmsg(
"cannot change persistence setting twice")));
5173 errmsg(
"cannot have multiple SET ACCESS METHOD subcommands")));
5292 elog(
ERROR,
"unrecognized alter table type: %d",
5342 foreach(
lcmd, subcmds)
5345 lockmode,
pass, context);
5426 cmd->
recurse,
false, lockmode);
5479 cmd->
recurse,
false, lockmode);
5484 true,
true, lockmode);
5704 elog(
ERROR,
"unrecognized alter table type: %d",
5751 atstmt->relation->inh = recurse;
5754 atstmt->missing_ok =
false;
5788 switch (
cmd2->subtype)
5799 cmd2->recurse =
true;
5828 elog(
ERROR,
"ALTER TABLE scheduling failure: too late for pass %d",
5848 elog(
ERROR,
"ALTER TABLE scheduling failure: bogus item for pass %d",
5929 errmsg(
"cannot rewrite system relation \"%s\"",
5935 errmsg(
"cannot rewrite table \"%s\" used as a catalog table",
5947 errmsg(
"cannot rewrite temporary tables of other sessions")));
6008 persistence, lockmode);
6224 elog(
ERROR,
"unrecognized constraint type: %d",
6403 sizeof(
bool) *
oldslot->tts_nvalid);
6429 if (
ex->is_generated)
6451 if (!
ex->is_generated)
6483 errmsg(
"column \"%s\" of relation \"%s\" contains null values",
6503 errmsg(
"column \"%s\" of relation \"%s\" contains null values",
6520 errmsg(
"check constraint \"%s\" of relation \"%s\" is violated by some row",
6530 elog(
ERROR,
"unrecognized constraint type: %d",
6535 if (partqualstate && !
ExecCheck(partqualstate, econtext))
6540 errmsg(
"updated partition constraint for default partition \"%s\" would be violated by some row",
6546 errmsg(
"partition constraint of relation \"%s\" is violated by some row",
6554 ti_options, bistate);
6596 if (tab->
relid == relid)
6627 return "ADD COLUMN";
6630 return "ALTER COLUMN ... SET DEFAULT";
6632 return "ALTER COLUMN ... DROP NOT NULL";
6634 return "ALTER COLUMN ... SET NOT NULL";
6636 return "ALTER COLUMN ... SET EXPRESSION";
6638 return "ALTER COLUMN ... DROP EXPRESSION";
6640 return "ALTER COLUMN ... SET STATISTICS";
6642 return "ALTER COLUMN ... SET";
6644 return "ALTER COLUMN ... RESET";
6646 return "ALTER COLUMN ... SET STORAGE";
6648 return "ALTER COLUMN ... SET COMPRESSION";
6650 return "DROP COLUMN";
6658 return "ADD CONSTRAINT";
6660 return "ALTER CONSTRAINT";
6662 return "VALIDATE CONSTRAINT";
6664 return "DROP CONSTRAINT";
6668 return "ALTER COLUMN ... SET DATA TYPE";
6670 return "ALTER COLUMN ... OPTIONS";
6674 return "CLUSTER ON";
6676 return "SET WITHOUT CLUSTER";
6678 return "SET ACCESS METHOD";
6680 return "SET LOGGED";
6682 return "SET UNLOGGED";
6684 return "SET WITHOUT OIDS";
6686 return "SET TABLESPACE";
6694 return "ENABLE TRIGGER";
6696 return "ENABLE ALWAYS TRIGGER";
6698 return "ENABLE REPLICA TRIGGER";
6700 return "DISABLE TRIGGER";
6702 return "ENABLE TRIGGER ALL";
6704 return "DISABLE TRIGGER ALL";
6706 return "ENABLE TRIGGER USER";
6708 return "DISABLE TRIGGER USER";
6710 return "ENABLE RULE";
6712 return "ENABLE ALWAYS RULE";
6714 return "ENABLE REPLICA RULE";
6716 return "DISABLE RULE";
6720 return "NO INHERIT";
6726 return "REPLICA IDENTITY";
6728 return "ENABLE ROW SECURITY";
6730 return "DISABLE ROW SECURITY";
6732 return "FORCE ROW SECURITY";
6734 return "NO FORCE ROW SECURITY";
6738 return "ATTACH PARTITION";
6740 return "DETACH PARTITION";
6742 return "DETACH PARTITION ... FINALIZE";
6744 return "MERGE PARTITIONS";
6746 return "SPLIT PARTITION";
6748 return "ALTER COLUMN ... ADD IDENTITY";
6750 return "ALTER COLUMN ... SET";
6752 return "ALTER COLUMN ... DROP IDENTITY";
6772 switch (rel->
rd_rel->relkind)
6815 errmsg(
"ALTER action %s cannot be performed on relation \"%s\"",
6820 elog(
ERROR,
"invalid ALTER action attempted on relation \"%s\"",
6832 errmsg(
"permission denied: \"%s\" is a system catalog",
6853 if (recurse && rel->
rd_rel->relhassubclass)
6866 foreach(child, children)
6932 foreach(child, children)
7040 for (
int attno = 1; attno <=
tupleDesc->natts; attno++)
7043 if (
att->atttypid == typeOid && !
att->attisdropped)
7070 errmsg(
"cannot alter type \"%s\" because column \"%s.%s\" uses it",
7077 errmsg(
"cannot alter type \"%s\" because column \"%s.%s\" uses it",
7084 errmsg(
"cannot alter foreign table \"%s\" because column \"%s.%s\" uses its row type",
7091 errmsg(
"cannot alter table \"%s\" because column \"%s.%s\" uses its row type",
7147 errmsg(
"cannot alter type \"%s\" because it is the type of a typed table",
7149 errhint(
"Use ALTER ... CASCADE to alter the typed tables too.")));
7195 errmsg(
"type %s is the row type of another table",
7197 errdetail(
"A typed table must use a stand-alone composite type created with CREATE TYPE.")));
7202 errmsg(
"type %s is not a composite type",
7226 if (rel->
rd_rel->reloftype && !recursing)
7229 errmsg(
"cannot add column to typed table")));
7253 bool if_not_exists = (*cmd)->missing_ok;
7276 if (rel->
rd_rel->relispartition && !recursing)
7279 errmsg(
"cannot add column to a partition")));
7289 if (
colDef->inhcount > 0)
7308 errmsg(
"child table \"%s\" has different type for column \"%s\"",
7314 errmsg(
"child table \"%s\" has different collation for column \"%s\"",
7325 errmsg(
"too many inheritance parents"));
7332 (
errmsg(
"merging definition of column \"%s\" for child \"%s\"",
7362 if (context !=
NULL && !recursing)
7385 errmsg(
"cannot recursively add identity column to table that has child tables")));
7400 errmsg(
"tables can have at most %d columns",
7447 rawEnt->attnum = attribute->attnum;
7456 false,
true,
false,
NULL);
7508 nve->typeId = attribute->atttypid;
7530 attribute->atttypid,
7531 attribute->atttypmod,
7536 elog(
ERROR,
"failed to coerce base type to domain");
7548 newval->attnum = attribute->attnum;
7629 if (children && !recurse)
7632 errmsg(
"column must be added to child tables too")));
7640 colDef->is_local =
false;
7645 foreach(child, children)
7702 errmsg(
"column name \"%s\" conflicts with a system column name",
7710 errmsg(
"column \"%s\" of relation \"%s\" already exists, skipping",
7717 errmsg(
"column \"%s\" of relation \"%s\" already exists",
7790 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
7808 errmsg(
"cannot alter system column \"%s\"",
7814 errmsg(
"column \"%s\" of relation \"%s\" is an identity column",
7820 if (rel->
rd_rel->relispartition)
7831 errmsg(
"column \"%s\" is marked NOT NULL in parent table",
7842 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation \"%s\"",
7884 if (attr->attisdropped)
7887 if (!attr->attnotnull)
7896 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
7904 attr->attnotnull =
true;
7943 bool recurse,
bool recursing,
LOCKMODE lockmode)
7951 bool is_no_inherit =
false;
7968 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
7975 errmsg(
"cannot alter system column \"%s\"",
7988 if (
conForm->connoinherit && recurse)
7991 errmsg(
"cannot change NO INHERIT status of NOT NULL constraint \"%s\" on relation \"%s\"",
8006 errmsg(
"too many inheritance parents"));
8009 else if (!
conForm->conislocal)
8014 else if (!
conForm->convalidated)
8021 recurse, recursing, lockmode);
8053 errmsg(
"constraint must be added to child tables too"),
8054 errhint(
"Do not specify the ONLY keyword."));
8056 is_no_inherit =
true;
8078 false, !recursing,
false,
NULL);
8105 recurse,
true, lockmode);
8141 (
errmsg_internal(
"existing constraints on column \"%s.%s\" are sufficient to prove that it does not contain nulls",
8169 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8176 errmsg(
"cannot alter system column \"%s\"",
8182 errmsg(
"column \"%s\" of relation \"%s\" is an identity column",
8186 "ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY")));
8191 errmsg(
"column \"%s\" of relation \"%s\" is a generated column",
8195 errhint(
"Use %s instead.",
"ALTER TABLE ... ALTER COLUMN ... SET EXPRESSION") :
8197 errhint(
"Use %s instead.",
"ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION") : 0)));
8219 rawEnt->generated =
'\0';
8226 false,
true,
false,
NULL);
8270 Node *def,
LOCKMODE lockmode,
bool recurse,
bool recursing)
8281 if (ispartitioned && !recurse)
8284 errmsg(
"cannot add identity to a column of only the partitioned table"),
8285 errhint(
"Do not specify the ONLY keyword.")));
8287 if (rel->
rd_rel->relispartition && !recursing)
8290 errmsg(
"cannot add identity to a column of a partition"));
8298 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8307 errmsg(
"cannot alter system column \"%s\"",
8318 errmsg(
"column \"%s\" of relation \"%s\" must be declared NOT NULL before identity can be added",
8333 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation \"%s\"",
8340 errmsg(
"incompatible NOT VALID constraint \"%s\" on relation \"%s\"",
8342 errhint(
"You might need to validate it using %s.",
8343 "ALTER TABLE ... VALIDATE CONSTRAINT"));
8349 errmsg(
"column \"%s\" of relation \"%s\" is already an identity column",
8355 errmsg(
"column \"%s\" of relation \"%s\" already has a default value",
8374 if (recurse && ispartitioned)
8381 foreach(
lc, children)
8401 LOCKMODE lockmode,
bool recurse,
bool recursing)
8413 if (ispartitioned && !recurse)
8416 errmsg(
"cannot change identity column of only the partitioned table"),
8417 errhint(
"Do not specify the ONLY keyword.")));
8419 if (rel->
rd_rel->relispartition && !recursing)
8422 errmsg(
"cannot change identity column of a partition"));
8433 errmsg(
"conflicting or redundant options")));
8437 elog(
ERROR,
"option \"%s\" not recognized",
8452 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8461 errmsg(
"cannot alter system column \"%s\"",
8464 if (!
attTup->attidentity)
8467 errmsg(
"column \"%s\" of relation \"%s\" is not an identity column",
8498 foreach(
lc, children)
8518 bool recurse,
bool recursing)
8530 if (ispartitioned && !recurse)
8533 errmsg(
"cannot drop identity from a column of only the partitioned table"),
8534 errhint(
"Do not specify the ONLY keyword.")));
8536 if (rel->
rd_rel->relispartition && !recursing)
8539 errmsg(
"cannot drop identity from a column of a partition"));
8546 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8555 errmsg(
"cannot alter system column \"%s\"",
8558 if (!
attTup->attidentity)
8563 errmsg(
"column \"%s\" of relation \"%s\" is not an identity column",
8568 (
errmsg(
"column \"%s\" of relation \"%s\" is not an identity column, skipping",
8576 attTup->attidentity =
'\0';
8592 if (recurse && ispartitioned)
8599 foreach(
lc, children)
8649 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8658 errmsg(
"cannot alter system column \"%s\"",
8661 attgenerated =
attTup->attgenerated;
8665 errmsg(
"column \"%s\" of relation \"%s\" is not a generated column",
8676 errmsg(
"ALTER TABLE / SET EXPRESSION is not supported for virtual generated columns in tables with check constraints"),
8677 errdetail(
"Column \"%s\" of relation \"%s\" is a virtual generated column.",
8694 errmsg(
"ALTER TABLE / SET EXPRESSION is not supported for virtual generated columns in tables that are part of a publication"),
8695 errdetail(
"Column \"%s\" of relation \"%s\" is a virtual generated column.",
8728 elog(
ERROR,
"could not find attrdef tuple for relation %u attnum %d",
8747 rawEnt->generated = attgenerated;
8751 false,
true,
false,
NULL);
8764 newval->is_generated =
true;
8801 errmsg(
"ALTER TABLE / DROP EXPRESSION must be applied to child tables too")));
8815 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8820 if (
attTup->attinhcount > 0)
8823 errmsg(
"cannot drop generation expression from inherited column")));
8845 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8854 errmsg(
"cannot alter system column \"%s\"",
8866 errmsg(
"ALTER TABLE / DROP EXPRESSION is not supported for virtual generated columns"),
8867 errdetail(
"Column \"%s\" of relation \"%s\" is a virtual generated column.",
8870 if (!
attTup->attgenerated)
8875 errmsg(
"column \"%s\" of relation \"%s\" is not a generated column",
8880 (
errmsg(
"column \"%s\" of relation \"%s\" is not a generated column, skipping",
8892 attTup->attgenerated =
'\0';
8909 elog(
ERROR,
"could not find attrdef tuple for relation %u attnum %d",
8958 errmsg(
"cannot refer to non-index column by number")));
8978 errmsg(
"statistics target %d is too low",
8986 errmsg(
"lowering statistics target to %d",
9000 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9010 errmsg(
"column number %d of relation \"%s\" does not exist",
9020 errmsg(
"cannot alter system column \"%s\"",
9030 errmsg(
"cannot alter statistics on virtual generated column \"%s\"",
9039 errmsg(
"cannot alter statistics on included column \"%s\" of index \"%s\"",
9044 errmsg(
"cannot alter statistics on non-expression column \"%s\" of index \"%s\"",
9046 errhint(
"Alter statistics on table column instead.")));
9103 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9111 errmsg(
"cannot alter system column \"%s\"",
9176 for (
int i = 0;
i <
indrel->rd_index->indnatts;
i++)
9237 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9245 errmsg(
"cannot alter system column \"%s\"",
9289 if (rel->
rd_rel->reloftype && !recursing)
9292 errmsg(
"cannot drop column from typed table")));
9315 bool recurse,
bool recursing,
9316 bool missing_ok,
LOCKMODE lockmode,
9350 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9356 (
errmsg(
"column \"%s\" of relation \"%s\" does not exist, skipping",
9369 errmsg(
"cannot drop system column \"%s\"",
9376 if (
targetatt->attinhcount > 0 && !recursing)
9379 errmsg(
"cannot drop inherited column \"%s\"",
9392 errmsg(
"cannot drop column \"%s\" because it is part of the partition key of relation \"%s\"",
9417 errmsg(
"cannot drop column from only the partitioned table when partitions exist"),
9418 errhint(
"Do not specify the ONLY keyword.")));
9421 foreach(child, children)
9433 elog(
ERROR,
"cache lookup failed for attribute \"%s\" of relation %u",
9438 elog(
ERROR,
"relation %u has non-inherited attribute \"%s\"",
9452 behavior,
true,
true,
9453 false, lockmode, addrs);
9492 object.objectSubId =
attnum;
9582 errmsg(
"column \"%s\" of table \"%s\" is not marked NOT NULL",
9618 errmsg(
"cannot create primary key on column \"%s\"", colname),
9620 errdetail(
"The constraint \"%s\" on column \"%s\" of table \"%s\", marked %s, is incompatible with a primary key.",
9623 errhint(
"You might need to make the existing constraint inheritable using %s.",
9624 "ALTER TABLE ... ALTER CONSTRAINT ... INHERIT"));
9630 errmsg(
"cannot create primary key on column \"%s\"", colname),
9632 errdetail(
"The constraint \"%s\" on column \"%s\" of table \"%s\", marked %s, is incompatible with a primary key.",
9635 errhint(
"You might need to validate it using %s.",
9636 "ALTER TABLE ... VALIDATE CONSTRAINT"));
9757 errmsg(
"ALTER TABLE / ADD CONSTRAINT USING INDEX is not supported on partitioned tables")));
9782 (
errmsg(
"ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index \"%s\" to \"%s\"",
9861 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
9880 elog(
ERROR,
"unrecognized constraint type: %d",
9907 foreach(
lc, colnames)
9912 buf[buflen++] =
'_';
9943 Constraint *constr,
bool recurse,
bool recursing,
10050 if (!recurse && children !=
NIL)
10053 errmsg(
"constraint must be added to child tables too")));
10058 foreach(child, children)
10073 constr, recurse,
true,
is_readd, lockmode);
10099 bool recurse,
bool recursing,
LOCKMODE lockmode)
10140 errmsg(
"cannot use ONLY for foreign key on partitioned table \"%s\" referencing relation \"%s\"",
10148 errmsg(
"referenced relation \"%s\" is not a table",
10154 errmsg(
"permission denied: \"%s\" is a system catalog",
10165 switch (rel->
rd_rel->relpersistence)
10171 errmsg(
"constraints on permanent tables may reference only permanent tables")));
10178 errmsg(
"constraints on unlogged tables may reference only permanent or unlogged tables")));
10184 errmsg(
"constraints on temporary tables may reference only temporary tables")));
10188 errmsg(
"constraints on temporary tables must involve temporary tables of this session")));
10203 errmsg(
"foreign key uses PERIOD on the referenced table but not the referencing table"));
10231 errmsg(
"foreign key uses PERIOD on the referenced table but not the referencing table"));
10243 errmsg(
"foreign key uses PERIOD on the referencing table but not the referenced table"));
10257 errmsg(
"foreign key must use PERIOD when referencing a primary key using WITHOUT OVERLAPS"));
10281 errmsg(
"invalid %s action for foreign key constraint containing generated column",
10287 errmsg(
"invalid %s action for foreign key constraint containing generated column",
10302 errmsg(
"foreign key constraints on virtual generated columns are not supported")));
10316 errmsg(
"unsupported %s action for foreign key constraint using PERIOD",
10325 errmsg(
"unsupported %s action for foreign key constraint using PERIOD",
10340 errmsg(
"number of referencing and referenced columns for foreign key disagree")));
10375 opfamily =
cla_tup->opcfamily;
10376 opcintype =
cla_tup->opcintype;
10396 ?
errmsg(
"could not identify an overlaps operator for foreign key")
10397 :
errmsg(
"could not identify an equality operator for foreign key"),
10398 errdetail(
"Could not translate compare type %d for operator family \"%s\" of access method \"%s\".",
10409 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
10410 eqstrategy, opcintype, opcintype, opfamily);
10462 errmsg(
"foreign key constraint \"%s\" cannot be implemented",
10464 errdetail(
"Key columns \"%s\" of the referencing table and \"%s\" of the referenced table "
10465 "are of incompatible types: %s and %s.",
10476 elog(
ERROR,
"key columns are not both collatable");
10496 errmsg(
"foreign key constraint \"%s\" cannot be implemented",
fkconstraint->conname),
10497 errdetail(
"Key columns \"%s\" of the referencing table and \"%s\" of the referenced table "
10498 "have incompatible collations: \"%s\" and \"%s\". "
10499 "If either collation is nondeterministic, then both collations have to be the same.",
10703 errmsg(
"column \"%s\" referenced in ON DELETE SET action must be part of foreign key",
col)));
10775 errmsg(
"referenced relation \"%s\" is not a table",
10792 conname = constraintname;
10799 conislocal =
false;
10997 elog(
ERROR,
"index for %u not found in partition %s",
11087 errmsg(
"foreign key constraints are not supported on foreign tables")));
11126 newcon->refindid = indexOid;
11326 foreach(cell,
clone)
11416 elog(
ERROR,
"index for %u not found in partition %s",
11503 errmsg(
"cannot attach table \"%s\" as a partition because it is referenced by foreign key \"%s\"",
11520 errmsg(
"foreign key constraints are not supported on foreign tables")));
11540 foreach(cell,
clone)
11566 elog(
ERROR,
"cache lookup failed for constraint %u",
11770 elog(
ERROR,
"cache lookup failed for constraint %u",
fk->conoid);
11784 errmsg(
"constraint \"%s\" enforceability conflicts with constraint \"%s\" on relation \"%s\"",
11967 true,
NULL, 1, &key);
11973 if (
conform->conparentid != conoid)
12102 Oid conoid,
Oid confrelid,
Oid conrelid,
12122 if (
trgform->tgconstrrelid != conrelid)
12124 if (
trgform->tgrelid != confrelid)
12139#ifndef USE_ASSERT_CHECKING
12147 elog(
ERROR,
"could not find ON DELETE action trigger of foreign key constraint %u",
12150 elog(
ERROR,
"could not find ON UPDATE action trigger of foreign key constraint %u",
12163 Oid conoid,
Oid confrelid,
Oid conrelid,
12183 if (
trgform->tgconstrrelid != confrelid)
12185 if (
trgform->tgrelid != conrelid)
12200#ifndef USE_ASSERT_CHECKING
12208 elog(
ERROR,
"could not find ON INSERT check triggers of foreign key constraint %u",
12211 elog(
ERROR,
"could not find ON UPDATE check triggers of foreign key constraint %u",
12246 errmsg(
"constraint must be altered in child tables too"),
12247 errhint(
"Do not specify the ONLY keyword."));
12275 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
12282 errmsg(
"constraint \"%s\" of relation \"%s\" is not a foreign key constraint",
12287 errmsg(
"cannot alter enforceability of constraint \"%s\" of relation \"%s\"",
12289 if (
cmdcon->alterInheritability &&
12293 errmsg(
"constraint \"%s\" of relation \"%s\" is not a not-null constraint",
12297 if (
cmdcon->alterInheritability &&
12301 errmsg(
"cannot alter inherited constraint \"%s\" on relation \"%s\"",
12335 parent =
contup->conparentid;
12341 errmsg(
"cannot alter constraint \"%s\" on relation \"%s\"",
12344 errdetail(
"Constraint \"%s\" is derived from constraint \"%s\" of relation \"%s\".",
12346 errhint(
"You may alter the constraint it derives from instead.")));
12394 if (
cmdcon->alterEnforceability &&
12401 else if (
cmdcon->alterDeferrability &&
12421 if (
cmdcon->alterInheritability &&
12476 if (!
cmdcon->is_enforced)
12603 refrelid =
currcon->confrelid;
12692 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation %u",
12706 colName,
true,
true, lockmode);
12725 bool deferrable,
bool initdeferred,
12769 copy_tg->tgdeferrable = deferrable;
12770 copy_tg->tginitdeferred = initdeferred;
12817 true,
NULL, 1, &pkey);
12862 true,
NULL, 1, &pkey);
12891 cmdcon->alterInheritability);
12896 if (
cmdcon->alterEnforceability)
12909 if (
cmdcon->alterDeferrability)
12914 if (
cmdcon->alterInheritability)
12939 bool recurse,
bool recursing,
LOCKMODE lockmode)
12972 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
12981 errmsg(
"cannot validate constraint \"%s\" of relation \"%s\"",
12983 errdetail(
"This operation is not supported for this type of constraint."));
12985 if (!con->conenforced)
12988 errmsg(
"cannot validate NOT ENFORCED constraint")));
12990 if (!con->convalidated)
13000 tuple, recurse, recursing, lockmode);
13005 tuple, recurse, recursing, lockmode);
13038 Assert(!con->convalidated);
13063 newcon->refrelid = con->confrelid;
13064 newcon->refindid = con->conindid;
13065 newcon->conid = con->oid;
13091 true,
NULL, 1, &pkey);
13149 bool recurse,
bool recursing,
LOCKMODE lockmode)
13170 if (!recursing && !con->connoinherit)
13181 foreach(child, children)
13197 errmsg(
"constraint must be validated on child tables too")));
13213 newcon->conid = con->oid;
13275 if (!recursing && !con->connoinherit)
13297 errmsg(
"constraint must be validated on child tables too"));
13305 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation \"%s\"",
13317 false,
true, lockmode);
13374 errmsg(
"column \"%s\" referenced in foreign key constraint does not exist",
13380 errmsg(
"system columns cannot be used in foreign keys")));
13384 errmsg(
"cannot have more than %d keys in a foreign key",
13440 elog(
ERROR,
"cache lookup failed for index %u", indexoid);
13452 errmsg(
"cannot use a deferrable primary key for referenced table \"%s\"",
13455 *indexOid = indexoid;
13469 errmsg(
"there is no primary key for referenced table \"%s\"",
13521 bool found =
false;
13539 if (attnums[
i] == attnums[
j])
13542 errmsg(
"foreign key referenced-columns list must not contain duplicates")));
13561 elog(
ERROR,
"cache lookup failed for index %u", indexoid);
13645 errmsg(
"cannot use a deferrable unique constraint for referenced table \"%s\"",
13650 errmsg(
"there is no unique constraint matching given keys for referenced table \"%s\"",
13681 elog(
ERROR,
"could not find cast from %u to %u",
13707 for (
i = 0;
i < natts;
i++)
13739 (
errmsg_internal(
"validating foreign key constraint \"%s\"", conname)));
13745 trig.tgname = conname;
13747 trig.tgisinternal =
true;
13751 trig.tgdeferrable =
false;
13752 trig.tginitdeferred =
false;
13774 "validateForeignKeyConstraint",
13802 fcinfo->context = (
Node *) &trigdata;
13843 fk_trigger->trigname =
"RI_ConstraintTrigger_c";
13902 fk_trigger->trigname =
"RI_ConstraintTrigger_a";
13941 elog(
ERROR,
"unrecognized FK action type: %d",
13962 fk_trigger->trigname =
"RI_ConstraintTrigger_a";
14001 elog(
ERROR,
"unrecognized FK action type: %d",
14044 bool missing_ok,
LOCKMODE lockmode)
14050 bool found =
false;
14076 missing_ok, lockmode);
14087 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
14091 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist, skipping",
14108 bool recurse,
bool recursing,
bool missing_ok,
14117 char *colname =
NULL;
14133 if (con->coninhcount > 0 && !recursing)
14136 errmsg(
"cannot drop inherited constraint \"%s\" of relation \"%s\"",
14177 for (
int i = 0;
i <
pk->rd_index->indnkeyatts;
i++)
14188 errmsg(
"column \"%s\" is in a primary key",
14196 errmsg(
"column \"%s\" is in index used as replica identity",
14202 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
14205 if (
attForm->attidentity !=
'\0')
14208 errmsg(
"column \"%s\" of relation \"%s\" is an identity column",
14289 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation %u",
14316 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
14328 elog(
ERROR,
"inherited constraint is not a CHECK or not-null constraint");
14331 elog(
ERROR,
"relation %u has non-inherited constraint \"%s\"",
14344 recurse,
true, missing_ok,
14405 bool recurse,
bool recursing,
14417 int32 targettypmod;
14426 if (rel->
rd_rel->reloftype && !recursing)
14429 errmsg(
"cannot alter column type of typed table"),
14437 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
14457 errmsg(
"cannot specify USING when altering type of generated column"),
14466 if (
attTup->attinhcount > 0 && !recursing)
14478 errmsg(
"cannot alter column \"%s\" because it is part of the partition key of relation \"%s\"",
14523 targettype, targettypmod,
14527 if (transform ==
NULL)
14533 errmsg(
"result of USING clause for column \"%s\""
14534 " cannot be cast automatically to type %s",
14536 errhint(
"You might need to add an explicit cast.")));
14540 errmsg(
"column \"%s\" cannot be cast automatically to type %s",
14544 errhint(
"You might need to specify \"USING %s::%s\".",
14547 targettypmod)) : 0));
14566 newval->is_generated =
false;
14572 else if (transform)
14575 errmsg(
"\"%s\" is not a table",
14640 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
14647 errmsg(
"cannot alter inherited column \"%s\" of relation \"%s\"",
14659 bool found_whole_row;
14672 if (found_whole_row)
14675 errmsg(
"cannot convert whole-row table reference"),
14676 errdetail(
"USING expression contains a whole-row table reference.")));
14683 else if (!recursing &&
14687 errmsg(
"type of inherited column \"%s\" must be changed in child tables too",
14716 if (
IsA(expr,
Var) && ((
Var *) expr)->varattno == varattno)
14769 int32 targettypmod;
14801 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
14812 errmsg(
"cannot alter type of column \"%s\" twice",
14818 targettype =
tform->oid;
14841 targettype, targettypmod,
14847 if (
attTup->attgenerated)
14850 errmsg(
"generation expression for column \"%s\" cannot be cast automatically to type %s",
14855 errmsg(
"default for column \"%s\" cannot be cast automatically to type %s",
14906 elog(
ERROR,
"found unexpected dependency type '%c'",
14912 elog(
ERROR,
"found unexpected dependency for column: %s",
14927 if (
attTup->atthasmissing)
14986 attTup->atttypid = targettype;
14987 attTup->atttypmod = targettypmod;
14992 errmsg(
"too many array dimensions"));
15032 if (
attTup->attgenerated)
15037 elog(
ERROR,
"could not find attrdef tuple for relation %u attnum %d",
15133 elog(
ERROR,
"unexpected object depending on column: %s",
15159 errmsg(
"cannot alter type of a column used by a function or procedure"),
15160 errdetail(
"%s depends on column \"%s\"",
15174 errmsg(
"cannot alter type of a column used by a view or rule"),
15175 errdetail(
"%s depends on column \"%s\"",
15194 errmsg(
"cannot alter type of a column used in a trigger definition"),
15195 errdetail(
"%s depends on column \"%s\"",
15213 errmsg(
"cannot alter type of a column used in a policy definition"),
15214 errdetail(
"%s depends on column \"%s\"",
15244 errmsg(
"cannot alter type of a column used by a generated column"),
15245 errdetail(
"Column \"%s\" is used by generated column \"%s\".",
15272 errmsg(
"cannot alter type of a column used by a publication WHERE clause"),
15273 errdetail(
"%s depends on column \"%s\"",
15284 elog(
ERROR,
"unexpected object depending on column: %s",
15305 elog(
ERROR,
"relation %u has multiple indexes marked as replica identity", tab->
relid);
15320 elog(
ERROR,
"relation %u has multiple clustered indexes", tab->
relid);
15511 relid = con->conrelid;
15517 elog(
ERROR,
"could not identify relation associated with constraint %u",
oldId);
15519 confrelid = con->confrelid;
15520 conislocal = con->conislocal;
15542 if (relid != tab->
relid)
15561 if (relid != tab->
relid)
15591 if (relid != tab->
relid)
15732 stmt->reset_default_tblspc =
true;
15764 indstmt->reset_default_tblspc =
true;
15785 !rewrite && tab->
rewrite == 0)
15809 elog(
ERROR,
"unexpected statement subtype: %d",
15836 elog(
ERROR,
"unexpected statement subtype: %d",
15837 (
int)
stmt->subtype);
15854 elog(
ERROR,
"unexpected statement type: %d",
15874 const char *conname)
15919 stmt->accessMethod,
15921 stmt->excludeOpNames,
15922 stmt->iswithoutoverlaps))
15969 elog(
ERROR,
"conpfeqop is not a 1-D Oid array");
15973 for (
i = 0;
i < numkeys;
i++)
16015 errmsg(
"foreign table \"%s\" does not exist",
16029 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
16058 fdw->fdwvalidator);
16120 elog(
ERROR,
"cache lookup failed for relation %u", relationOid);
16146 errmsg(
"cannot change owner of index \"%s\"",
16148 errhint(
"Change the ownership of the index's table instead.")));
16158 errmsg(
"cannot change owner of index \"%s\"",
16160 errhint(
"Change the ownership of the index's table instead.")));
16174 errmsg(
"cannot change owner of sequence \"%s\"",
16176 errdetail(
"Sequence \"%s\" is linked to table \"%s\".",
16186 errmsg(
"\"%s\" is a composite type",
16199 errmsg(
"cannot change owner of relation \"%s\"",
16356 true,
NULL, 1, key);
16369 if (
att->attisdropped)
16440 if (
depForm->refobjsubid == 0 ||
16487 errmsg(
"index \"%s\" for table \"%s\" does not exist",
16530 if (amname !=
NULL)
16574 elog(
ERROR,
"cache lookup failed for relation %u", reloid);
16666 errmsg(
"cannot have multiple SET TABLESPACE subcommands")));
16698 elog(
ERROR,
"cache lookup failed for relation %u", relid);
16724 switch (rel->
rd_rel->relkind)
16745 errmsg(
"cannot set options for relation \"%s\"",
16757 bool check_option =
false;
16764 check_option =
true;
16779 errmsg(
"WITH CHECK OPTION is supported only on automatically updatable views"),
16921 rel->
rd_rel->relpersistence);
17032 errmsg(
"only tables, indexes, and materialized views exist in tablespaces")));
17044 errmsg(
"cannot move relations in to or out of pg_global tablespace")));
17132 if (
stmt->nowait &&
17136 errmsg(
"aborting because lock on relation \"%s.%s\" is not available",
17149 if (relations ==
NIL)
17152 errmsg(
"no matching relations in tablespace \"%s\" found",
17157 foreach(l, relations)
17163 cmd->
name =
stmt->new_tablespacename;
17200 rel->
rd_rel->relpersistence);
17219 rel->
rd_rel->relpersistence);
17274 errmsg(
"cannot change inheritance of typed table")));
17279 errmsg(
"cannot change inheritance of a partition")));
17284 errmsg(
"cannot change inheritance of partitioned table")));
17316 errmsg(
"cannot inherit from temporary relation \"%s\"",
17323 errmsg(
"cannot inherit from temporary relation of another session")));
17329 errmsg(
"cannot inherit to temporary relation of another session")));
17335 errmsg(
"cannot inherit from partitioned table \"%s\"",
17342 errmsg(
"cannot inherit from a partition")));
17364 errmsg(
"circular inheritance not allowed"),
17365 errdetail(
"\"%s\" is already a child of \"%s\".",
17378 errmsg(
"trigger \"%s\" prevents table \"%s\" from becoming an inheritance child",
17380 errdetail(
"ROW triggers with transition tables are not supported in inheritance hierarchies.")));
17427 true,
NULL, 1, &key);
17438 errmsg(
"relation \"%s\" would be inherited from more than once",
17481 elog(
ERROR,
"null conbin for constraint %u", con->oid);
17504 if (
acon->condeferrable !=
bcon->condeferrable ||
17505 acon->condeferred !=
bcon->condeferred ||
17556 errmsg(
"child table \"%s\" has different type for column \"%s\"",
17562 errmsg(
"child table \"%s\" has different collation for column \"%s\"",
17581 errmsg(
"column \"%s\" in child table \"%s\" must be marked NOT NULL",
17601 errdetail(
"Parent column is %s, child column is %s.",
17621 errmsg(
"too many inheritance parents"));
17696 bool found =
false;
17751 elog(
ERROR,
"found not-null constraint on dropped columns");
17758 errmsg(
"child table \"%s\" has different definition for check constraint \"%s\"",
17767 errmsg(
"constraint \"%s\" conflicts with non-inherited constraint on child table \"%s\"",
17778 errmsg(
"constraint \"%s\" conflicts with NOT VALID constraint on child table \"%s\"",
17789 errmsg(
"constraint \"%s\" conflicts with NOT ENFORCED constraint on child table \"%s\"",
17803 errmsg(
"too many inheritance parents"));
17830 errmsg(
"column \"%s\" in child table \"%s\" must be marked NOT NULL",
17838 errmsg(
"child table is missing constraint \"%s\"",
17858 if (rel->
rd_rel->relispartition)
17861 errmsg(
"cannot change inheritance of a partition")));
17901 bool found =
false;
17915 true,
NULL, 1, &key);
17922 if (
inhForm->inhdetachpending)
17925 errmsg(
"partition \"%s\" already pending detach in partitioned table \"%s.%s\"",
17929 errhint(
"Use ALTER TABLE ... DETACH PARTITION ... FINALIZE to complete the pending detach operation."));
17954 errmsg(
"relation \"%s\" is not a partition of relation \"%s\"",
18002 errmsg(
"relation \"%s\" is not a partition of relation \"%s\"",
18008 errmsg(
"relation \"%s\" is not a parent of relation \"%s\"",
18022 true,
NULL, 1, key);
18028 if (
att->attisdropped)
18030 if (
att->attinhcount <= 0)
18070 true,
NULL, 1, key);
18079 if (con->connoinherit)
18100 true,
NULL, 1, key);
18105 bool match =
false;
18148 elog(
ERROR,
"relation %u has non-inherited constraint \"%s\"",
18162 elog(
ERROR,
"%d unmatched constraints while removing inheritance from \"%s\" to \"%s\"",
18223 dep->refobjid == refobjid &&
18224 dep->refobjsubid == 0 &&
18225 dep->deptype == deptype)
18275 true,
NULL, 1, &key);
18279 errmsg(
"typed tables cannot inherit")));
18309 errmsg(
"table is missing column \"%s\"",
18320 errmsg(
"table has column \"%s\" where type requires \"%s\"",
18329 errmsg(
"table \"%s\" has different type for column \"%s\"",
18343 errmsg(
"table has extra column \"%s\"",
18348 if (rel->
rd_rel->reloftype)
18365 elog(
ERROR,
"cache lookup failed for relation %u", relid);
18395 errmsg(
"\"%s\" is not a typed table",
18410 elog(
ERROR,
"cache lookup failed for relation %u", relid);
18448 elog(
ERROR,
"cache lookup failed for relation \"%s\"",
18466 bool dirty =
false;
18544 elog(
ERROR,
"unexpected identity type %u",
stmt->identity_type);
18551 errmsg(
"index \"%s\" for table \"%s\" does not exist",
18561 errmsg(
"\"%s\" is not an index for table \"%s\"",
18571 !indexRel->
rd_index->indisunique) &&
18575 errmsg(
"cannot use non-unique index \"%s\" as replica identity",
18578 if (!indexRel->
rd_index->indimmediate)
18581 errmsg(
"cannot use non-immediate index \"%s\" as replica identity",
18587 errmsg(
"cannot use expression index \"%s\" as replica identity",
18593 errmsg(
"cannot use partial index \"%s\" as replica identity",
18610 errmsg(
"index \"%s\" cannot be used as replica identity because column %d is a system column",
18614 if (!attr->attnotnull)
18617 errmsg(
"index \"%s\" cannot be used as replica identity because column \"%s\" is nullable",
18646 elog(
ERROR,
"cache lookup failed for relation %u", relid);
18675 elog(
ERROR,
"cache lookup failed for relation %u", relid);
18714 errmsg(
"foreign table \"%s\" does not exist",
18736 fdw->fdwvalidator);
18794 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
18803 errmsg(
"cannot alter system column \"%s\"",
column)));
18861 switch (rel->
rd_rel->relpersistence)
18866 errmsg(
"cannot change logged status of table \"%s\" because it is temporary",
18890 errmsg(
"cannot change table \"%s\" to unlogged because it is part of a publication",
18892 errdetail(
"Unlogged relations cannot be replicated.")));
18937 errmsg(
"could not change table \"%s\" to logged because it references unlogged table \"%s\"",
18947 errmsg(
"could not change table \"%s\" to unlogged because it references logged table \"%s\"",
18992 (
errmsg(
"relation \"%s\" does not exist, skipping",
18993 stmt->relation->relname)));
19011 errmsg(
"cannot move an owned sequence into another schema"),
19012 errdetail(
"Sequence \"%s\" is linked to table \"%s\".",
19095 elog(
ERROR,
"cache lookup failed for relation %u", relOid);
19119 errmsg(
"relation \"%s\" already exists in schema \"%s\"",
19137 elog(
ERROR,
"could not change schema dependency for relation \"%s\"",
19238 if (
depForm->refobjsubid == 0 ||
19305 oc->oncommit = action;
19333 if (
oc->relid == relid)
19362 switch (
oc->oncommit)
19405 object.objectSubId = 0;
19427#ifdef USE_ASSERT_CHECKING
19544 errmsg(
"\"%s\" is not a table or materialized view", relation->
relname)));
19569 elog(
ERROR,
"cache lookup failed for relation %u", relId);
19593 elog(
ERROR,
"cache lookup failed for relation %u", relId);
19603 errmsg(
"permission denied: \"%s\" is a system catalog",
19638 errmsg(
"permission denied: \"%s\" is a system catalog",
19687 errmsg(
"\"%s\" is not a materialized view", rv->
relname)));
19727 errmsg(
"cannot change schema of index \"%s\"",
19729 errhint(
"Change the schema of the table instead.")));
19733 errmsg(
"cannot change schema of composite type \"%s\"",
19741 errmsg(
"cannot change schema of TOAST table \"%s\"",
19743 errhint(
"Change the schema of the table instead.")));
19773 errmsg(
"cannot use \"list\" partition strategy with more than one column")));
19781 NULL,
false,
true);
19822 foreach(
lc, partParams)
19839 errmsg(
"column \"%s\" named in partition key does not exist",
19847 errmsg(
"cannot use system column \"%s\" in partition key",
19861 errmsg(
"cannot use generated column in partition key"),
19862 errdetail(
"Column \"%s\" is a generated column.",
19868 attcollation =
attform->attcollation;
19891 atttype, attcollation,
19930 errmsg(
"partition key expressions cannot contain system column references")));
19943 errmsg(
"cannot use generated column in partition key"),
19944 errdetail(
"Column \"%s\" is a generated column.",
19950 ((
Var *) expr)->varattno > 0)
19957 partattrs[
attn] = ((
Var *) expr)->varattno;
19961 partattrs[
attn] = 0;
19962 *partexprs =
lappend(*partexprs, expr);
19994 errmsg(
"functions in partition key expression must be marked IMMUTABLE")));
20003 errmsg(
"cannot use constant expression as partition key")));
20010 if (
pelem->collation)
20024 errmsg(
"could not determine which collation to use for partition expression"),
20025 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
20032 errmsg(
"collations are not supported by type %s",
20036 partcollation[
attn] = attcollation;
20048 if (!
pelem->opclass)
20057 errmsg(
"data type %s has no default operator class for access method \"%s\"",
20059 errhint(
"You must specify a hash operator class or define a default hash operator class for the data type.")));
20063 errmsg(
"data type %s has no default operator class for access method \"%s\"",
20065 errhint(
"You must specify a btree operator class or define a default btree operator class for the data type.")));
20098 for (
i = 1;
i <= natts;
i++)
20121 ntest->argisrow =
false;
20150 for (
i = 0;
i < num_check;
i++)
20207 bool validate_default)
20215 if (!validate_default)
20217 (
errmsg_internal(
"partition constraint for table \"%s\" is implied by existing constraints",
20221 (
errmsg_internal(
"updated partition constraint for default partition \"%s\" is implied by existing constraints",
20359 errmsg(
"\"%s\" is already a partition",
20365 errmsg(
"cannot attach a typed table as partition")));
20381 errmsg(
"cannot attach inheritance child as partition")));
20395 errmsg(
"cannot attach inheritance parent as partition")));
20419 errmsg(
"circular inheritance not allowed"),
20420 errdetail(
"\"%s\" is already a child of \"%s\".",
20429 errmsg(
"cannot attach a temporary relation as partition of permanent relation \"%s\"",
20437 errmsg(
"cannot attach a permanent relation as partition of temporary relation \"%s\"",
20444 errmsg(
"cannot attach as partition of temporary relation of another session")));
20450 errmsg(
"cannot attach temporary relation of another session as partition")));
20458 for (attno = 1; attno <= natts; attno++)
20464 if (attribute->attisdropped)
20467 if (attribute->attidentity)
20470 errmsg(
"table \"%s\" being attached contains an identity column \"%s\"",
20472 errdetail(
"The new partition may not contain an identity column."));
20480 errmsg(
"table \"%s\" contains column \"%s\" not found in parent \"%s\"",
20483 errdetail(
"The new partition may contain only the columns present in parent.")));
20495 errmsg(
"trigger \"%s\" prevents table \"%s\" from becoming a partition",
20497 errdetail(
"ROW triggers with transition tables are not supported on partitions.")));
20505 cmd->
bound, pstate);
20628 "AttachPartitionEnsureIndexes",
20654 foreach(cell,
idxes)
20659 if (
idxRel->rd_index->indisunique ||
20660 idxRel->rd_index->indisprimary)
20663 errmsg(
"cannot attach foreign table \"%s\" as partition of partitioned table \"%s\"",
20666 errdetail(
"Partitioned table \"%s\" contains unique indexes.",
20678 foreach(cell,
idxes)
20684 bool found =
false;
20724 idxRel->rd_indcollation,
20780 true,
false,
false,
false,
false);
20812 true,
NULL, 1, &key);
20846 elog(
ERROR,
"unexpected trigger \"%s\" found",
20894 elog(
ERROR,
"tgargs is null for trigger \"%s\" in partition \"%s\"",
20926 false,
true,
trigForm->tgenabled);
20990 errmsg(
"cannot detach partitions concurrently when a default partition exists")));
21088 if (partRel !=
NULL)
21089 elog(
WARNING,
"dangling partition \"%s\" remains, can't fix",
21093 errmsg(
"partitioned table \"%s\" was removed concurrently",
21096 if (partRel ==
NULL)
21189 elog(
ERROR,
"cache lookup failed for constraint %u",
fk->conoid);
21216 if (
fk->conenforced)
21222 fk->conoid,
fk->confrelid,
fk->conrelid,
21346 foreach(cell, indexes)
21384 elog(
ERROR,
"cache lookup failed for relation %u",
21410 if (!attr->attisdropped && attr->attidentity)
21450 foreach(cell, children)
21580 if (!
state->lockedParentTbl)
21583 state->lockedParentTbl =
true;
21644 state.lockedParentTbl =
false;
21653 errmsg(
"index \"%s\" does not exist",
name->relname)));
21687 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
21690 errdetail(
"Index \"%s\" is already attached to another index.",
21707 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
21710 errdetail(
"Index \"%s\" is not an index on any partition of table \"%s\".",
21728 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
21731 errdetail(
"The index definitions do not match.")));
21747 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
21750 errdetail(
"The index \"%s\" belongs to a constraint in table \"%s\" but no constraint exists for index \"%s\".",
21760 if (parentIdx->
rd_index->indisprimary)
21796 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
21799 errdetail(
"Another index \"%s\" is already attached for partition \"%s\".",
21867 elog(
ERROR,
"cache lookup failed for index %u",
21915 for (
int i = 0;
i <
iinfo->ii_NumIndexKeyAttrs;
i++)
21918 iinfo->ii_IndexAttrNumbers[
i] - 1);
21920 if (!
att->attnotnull)
21923 errmsg(
"invalid primary key definition"),
21924 errdetail(
"Column \"%s\" of relation \"%s\" is not marked NOT NULL.",
21979 return constraints;
21995 foreach(cell, constraints)
22017 trig.tgisinternal =
true;
22021 trig.tgdeferrable =
false;
22022 trig.tginitdeferred =
false;
22041 if (compression ==
NULL ||
strcmp(compression,
"default") == 0)
22059 errmsg(
"column data type %s does not support compression",
22066 errmsg(
"invalid compression method \"%s\"", compression)));
22092 errmsg(
"invalid storage type \"%s\"",
22102 errmsg(
"column data type %s can only have storage PLAIN",
22123 switch (con->contype)
22137 elog(
ERROR,
"unrecognized constraint type: %d",
22138 (
int) con->contype);
22162 if (!
ex->is_generated)
22173 switch (con->contype)
22176 if (!
ExecCheck(con->qualstate, econtext))
22179 errmsg(
"check constraint \"%s\" of relation \"%s\" is violated by some row",
22188 elog(
ERROR,
"unrecognized constraint type: %d",
22189 (
int) con->contype);
22214 if (attribute->attisdropped)
22218 attribute->atttypmod, attribute->attcollation);
22223 def->
identity = attribute->attidentity;
22226 def->
generated = attribute->attgenerated;
22228 def->
storage = attribute->attstorage;
22284 if (attribute->attisdropped)
22288 if (attribute->atthasdef)
22291 bool found_whole_row;
22302 elog(
ERROR,
"default expression not found for attribute %d of relation \"%s\"",
22309 if (found_whole_row && attribute->attgenerated !=
'\0')
22310 elog(
ERROR,
"cannot convert whole-row table reference");
22326 newval->is_generated = (attribute->attgenerated !=
'\0');
22341 bool found_whole_row;
22359 if (found_whole_row)
22360 elog(
ERROR,
"Constraint \"%s\" contains a whole-row reference to table \"%s\".",
22376 constraints =
lappend(constraints, constr);
22381 false,
true,
true,
NULL);
22394 if (!
ccon->skip_validation)
22428 List *nnconstraints;
22475 errmsg(
"cannot create as partition of temporary relation of another session"));
22504 errmsg(
"cannot create a temporary relation as partition of permanent relation \"%s\"",
22512 errmsg(
"cannot create a permanent relation as partition of temporary relation \"%s\"",
22660 sizeof(
bool) *
srcslot->tts_nvalid);
22683 ti_options, bistate);
22755 int save_sec_context;
22756 int save_nestlevel;
22781 errmsg(
"partitions being merged have different owners"));
22868 object.objectSubId = 0;
22904 object.objectSubId = 0;
22951 pc->partRel = partRel;
23041 if (
sps->bound->is_default)
23068 pc->partqualstate =
23103 bool found =
false;
23116 if (
pc->partqualstate &&
ExecCheck(
pc->partqualstate, econtext))
23130 errmsg(
"can not find partition for split partition row"),
23152 sizeof(
bool) *
srcslot->tts_nvalid);
23175 ti_options,
pc->bistate);
23213 int save_sec_context;
23214 int save_nestlevel;
23244 errmsg(
"relation \"%s\" already exists",
sps->name->relname));
23261 object.objectSubId = 0;
23333 object.objectSubId = 0;
Datum idx(PG_FUNCTION_ARGS)
Acl * aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId)
void check_can_set_role(Oid member, Oid role)
Oid get_rolespec_oid(const RoleSpec *role, bool missing_ok)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum, Oid roleid, AclMode mode)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
void aclcheck_error_type(AclResult aclerr, Oid typeOid)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
StrategyNumber IndexAmTranslateCompareType(CompareType cmptype, Oid amoid, Oid opfamily, bool missing_ok)
Oid get_table_am_oid(const char *amname, bool missing_ok)
char * get_am_name(Oid amOid)
#define DatumGetArrayTypeP(X)
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
Datum array_get_element(Datum arraydatum, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
void free_attrmap(AttrMap *map)
AttrMap * make_attrmap(int maplen)
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
#define InvalidAttrNumber
char * get_tablespace_name(Oid spc_oid)
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)
Oid GetDefaultTablespace(char relpersistence, bool partitioned)
List * raw_parser(const char *str, RawParseMode mode)
bool TimestampTimestampTzRequiresRewrite(void)
Bitmapset * bms_make_singleton(int x)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_add_range(Bitmapset *a, int lower, int upper)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
void FlushRelationBuffers(Relation rel)
#define TextDatumGetCString(d)
#define PG_USED_FOR_ASSERTS_ONLY
#define InvalidSubTransactionId
#define Assert(condition)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
bool IsToastNamespace(Oid namespaceId)
bool IsSystemRelation(Relation relation)
RelFileNumber GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
bool IsCatalogNamespace(Oid namespaceId)
bool IsSystemClass(Oid relid, Form_pg_class reltuple)
bool contain_mutable_functions(Node *clause)
Node * eval_const_expressions(PlannerInfo *root, Node *node)
bool contain_volatile_functions(Node *clause)
void check_index_is_clusterable(Relation OldHeap, Oid indexOid, LOCKMODE lockmode)
void finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, bool is_system_catalog, bool swap_toast_by_content, bool check_constraints, bool is_internal, TransactionId frozenXid, MultiXactId cutoffMulti, char newrelpersistence)
Oid make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod, char relpersistence, LOCKMODE lockmode)
void mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
void ResetSequence(Oid seq_relid)
void SequenceChangePersistence(Oid relid, char newrelpersistence)
int32 defGetInt32(DefElem *def)
void performMultipleDeletions(const ObjectAddresses *objects, DropBehavior behavior, int flags)
void performDeletionCheck(const ObjectAddress *object, DropBehavior behavior, int flags)
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
bool object_address_present(const ObjectAddress *object, const ObjectAddresses *addrs)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
void free_object_addresses(ObjectAddresses *addrs)
#define PERFORM_DELETION_CONCURRENTLY
@ DEPENDENCY_PARTITION_PRI
@ DEPENDENCY_PARTITION_SEC
#define PERFORM_DELETION_QUIETLY
#define PERFORM_DELETION_INTERNAL
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
void hash_destroy(HTAB *hashp)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
void EventTriggerAlterTableStart(Node *parsetree)
void EventTriggerTableRewrite(Node *parsetree, Oid tableOid, int reason)
void EventTriggerAlterTableRelid(Oid objectId)
void EventTriggerAlterTableEnd(void)
void EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address)
#define AT_REWRITE_ALTER_PERSISTENCE
#define AT_REWRITE_DEFAULT_VAL
#define AT_REWRITE_ACCESS_METHOD
#define AT_REWRITE_COLUMN_REWRITE
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
bool ExecCheck(ExprState *state, ExprContext *econtext)
void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, ResultRelInfo *partition_root_rri, int instrument_options)
AttrNumber ExecRelGenVirtualNotNull(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, List *notnull_virtual_attrs)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#define GetPerTupleExprContext(estate)
#define ResetExprContext(econtext)
#define GetPerTupleMemoryContext(estate)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
#define palloc_object(type)
#define palloc_array(type, count)
#define palloc0_object(type)
#define DirectFunctionCall2(func, arg1, arg2)
#define DatumGetByteaPP(X)
#define SizeForFunctionCallInfo(nargs)
#define LOCAL_FCINFO(name, nargs)
ForeignDataWrapper * GetForeignDataWrapper(Oid fdwid)
FdwRoutine * GetFdwRoutineByServerId(Oid serverid)
ForeignServer * GetForeignServer(Oid serverid)
Oid GetForeignServerIdByRelId(Oid relid)
Datum transformGenericOptions(Oid catalogId, Datum oldOptions, List *options, Oid fdwvalidator)
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)
struct RelationData * Relation
bool allowSystemTableMods
int NewGUCNestLevel(void)
void RestrictSearchPath(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
void RelationClearMissing(Relation rel)
List * heap_truncate_find_FKs(List *relationIds)
void StorePartitionKey(Relation rel, char strategy, int16 partnatts, AttrNumber *partattrs, List *partexprs, Oid *partopclass, Oid *partcollation)
void RemoveStatistics(Oid relid, AttrNumber attnum)
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)
void heap_truncate_check_FKs(List *relations, bool tempTables)
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
List * AddRelationNotNullConstraints(Relation rel, List *constraints, List *old_notnulls)
List * AddRelationNewConstraints(Relation rel, List *newColDefaults, List *newConstraints, bool allow_merge, bool is_local, bool is_internal, const char *queryString)
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 StoreAttrMissingVal(Relation rel, AttrNumber attnum, Datum missingval)
#define CHKATYPE_IS_VIRTUAL
#define CHKATYPE_IS_PARTKEY
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
BulkInsertState GetBulkInsertState(void)
void FreeBulkInsertState(BulkInsertState bistate)
#define XLOG_HEAP_TRUNCATE
#define XLH_TRUNCATE_RESTART_SEQS
#define SizeOfHeapTruncate
#define XLH_TRUNCATE_CASCADE
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_copytuple(HeapTuple tuple)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static void * GETSTRUCT(const HeapTupleData *tuple)
#define MaxHeapAttributeNumber
Oid IndexGetRelation(Oid indexId, bool missing_ok)
bool CompareIndexInfo(const IndexInfo *info1, const IndexInfo *info2, const Oid *collations1, const Oid *collations2, const Oid *opfamilies1, const Oid *opfamilies2, const AttrMap *attmap)
bool reindex_relation(const ReindexStmt *stmt, Oid relid, int flags, const ReindexParams *params)
IndexInfo * BuildIndexInfo(Relation index)
void index_check_primary_key(Relation heapRel, const IndexInfo *indexInfo, bool is_alter_table, const IndexStmt *stmt)
ObjectAddress index_constraint_create(Relation heapRelation, Oid indexRelationId, Oid parentConstraintId, const IndexInfo *indexInfo, const char *constraintName, char constraintType, bits16 constr_flags, bool allow_system_table_mods, bool is_internal)
#define REINDEX_REL_PROCESS_TOAST
#define INDEX_CONSTR_CREATE_UPDATE_INDEX
#define INDEX_CONSTR_CREATE_REMOVE_OLD_DEPS
#define INDEX_CONSTR_CREATE_DEFERRABLE
#define INDEX_CONSTR_CREATE_MARK_AS_PRIMARY
#define INDEX_CONSTR_CREATE_INIT_DEFERRED
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
ObjectAddress DefineIndex(ParseState *pstate, Oid tableId, IndexStmt *stmt, Oid indexRelationId, Oid parentIndexId, Oid parentConstraintId, int total_parts, bool is_alter_table, bool check_rights, bool check_not_in_use, bool skip_build, bool quiet)
void IndexSetParentIndex(Relation partitionIdx, Oid parentOid)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
bool CheckIndexCompatible(Oid oldId, const char *accessMethodName, const List *attributeList, const List *exclusionOpNames, bool isWithoutOverlaps)
void WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
Oid ResolveOpClass(const List *opclass, Oid attrType, const char *accessMethodName, Oid accessMethodId)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
static bool pg_add_s16_overflow(int16 a, int16 b, int16 *result)
void AcceptInvalidationMessages(void)
void CacheInvalidateRelcache(Relation relation)
void CacheInvalidateRelcacheByRelid(Oid relid)
void CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
Datum is_valid(PG_FUNCTION_ARGS)
List * lcons_oid(Oid datum, List *list)
List * lappend(List *list, void *datum)
List * list_difference_ptr(const List *list1, const List *list2)
List * list_delete_nth_cell(List *list, int n)
List * list_concat(List *list1, const List *list2)
List * list_delete_cell(List *list, ListCell *cell)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
List * lcons(void *datum, List *list)
List * list_append_unique_oid(List *list, Oid datum)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
void list_free_deep(List *list)
bool ConditionalLockRelationOid(Oid relid, LOCKMODE lockmode)
void UnlockTuple(Relation relation, const ItemPointerData *tid, LOCKMODE lockmode)
void UnlockRelationOid(Oid relid, LOCKMODE lockmode)
void WaitForLockersMultiple(List *locktags, LOCKMODE lockmode, bool progress)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
bool CheckRelationLockedByMe(Relation relation, LOCKMODE lockmode, bool orstronger)
bool CheckRelationOidLockedByMe(Oid relid, LOCKMODE lockmode, bool orstronger)
#define SET_LOCKTAG_RELATION(locktag, dboid, reloid)
#define AccessExclusiveLock
#define ShareRowExclusiveLock
#define InplaceUpdateTupleLock
#define ShareUpdateExclusiveLock
char * get_rel_name(Oid relid)
AttrNumber get_attnum(Oid relid, const char *attname)
Oid get_constraint_index(Oid conoid)
char get_typstorage(Oid typid)
bool get_index_isreplident(Oid index_oid)
char get_rel_relkind(Oid relid)
Oid get_typcollation(Oid typid)
char * get_collation_name(Oid colloid)
bool get_index_isclustered(Oid index_oid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
char * get_constraint_name(Oid conoid)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
bool get_collation_isdeterministic(Oid colloid)
char * get_opfamily_name(Oid opfid, bool missing_ok)
Oid get_rel_relam(Oid relid)
bool type_is_collatable(Oid typid)
Oid get_rel_tablespace(Oid relid)
Oid get_typ_typrelid(Oid typid)
Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod)
Oid getBaseType(Oid typid)
char * get_namespace_name(Oid nspid)
char get_constraint_type(Oid conoid)
Oid get_relname_relid(const char *relname, Oid relnamespace)
#define TypeIsToastable(typid)
Expr * make_ands_explicit(List *andclauses)
TypeName * makeTypeNameFromNameList(List *names)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
ColumnDef * makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
Constraint * makeNotNullConstraint(String *colname)
List * make_ands_implicit(Expr *clause)
char * MemoryContextStrdup(MemoryContext context, const char *string)
void MemoryContextReset(MemoryContext context)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
MemoryContext CacheMemoryContext
void MemoryContextDelete(MemoryContext context)
MemoryContext PortalContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define ALLOCSET_SMALL_SIZES
#define SECURITY_RESTRICTED_OPERATION
#define CHECK_FOR_INTERRUPTS()
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
bool InSecurityRestrictedOperation(void)
void SetUserIdAndSecContext(Oid userid, int sec_context)
MultiXactId ReadNextMultiXactId(void)
void namestrcpy(Name name, const char *str)
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
bool isAnyTempNamespace(Oid namespaceId)
Oid get_collation_oid(List *collname, bool missing_ok)
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
RangeVar * makeRangeVarFromNameList(const List *names)
Oid LookupNamespaceNoError(const char *nspname)
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
Node * strip_implicit_coercions(Node *node)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define InvokeObjectTruncateHook(objectId)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
#define InvokeObjectPostAlterHookArg(classId, objectId, subId, auxiliaryId, is_internal)
ObjectType get_relkind_objtype(char relkind)
char * getObjectDescription(const ObjectAddress *object, bool missing_ok)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
#define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id)
char * nodeToString(const void *obj)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
@ COERCION_PATH_RELABELTYPE
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_PARTITION_EXPRESSION
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
Oid attnumCollationId(Relation rd, int attid)
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
Oid attnumTypeId(Relation rd, int attid)
const NameData * attnumAttName(Relation rd, int attid)
void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Oid *typeid_p, int32 *typmod_p)
Type typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
Oid GetColumnDefCollation(ParseState *pstate, const ColumnDef *coldef, Oid typeOid)
Oid typenameTypeId(ParseState *pstate, const TypeName *typeName)
IndexStmt * transformIndexStmt(Oid relid, IndexStmt *stmt, const char *queryString)
AlterTableStmt * transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, const char *queryString, List **beforeStmts, List **afterStmts)
CreateStatsStmt * transformStatsStmt(Oid relid, CreateStatsStmt *stmt, const char *queryString)
PartitionBoundSpec * transformPartitionBound(ParseState *pstate, Relation parent, PartitionBoundSpec *spec)
IndexStmt * generateClonedIndexStmt(RangeVar *heapRel, Relation source_idx, const AttrMap *attmap, Oid *constraintOid)
#define FKCONSTR_ACTION_RESTRICT
#define FKCONSTR_ACTION_SETDEFAULT
@ PARTITION_STRATEGY_HASH
@ PARTITION_STRATEGY_LIST
@ AT_DetachPartitionFinalize
@ AT_ReAddDomainConstraint
@ AT_AlterColumnGenericOptions
#define FKCONSTR_ACTION_CASCADE
#define FKCONSTR_ACTION_SETNULL
#define FKCONSTR_ACTION_NOACTION
List * SystemFuncName(char *name)
void check_new_partition_bound(char *relname, Relation parent, PartitionBoundSpec *spec, ParseState *pstate)
List * get_qual_from_partbound(Relation parent, PartitionBoundSpec *spec)
void check_default_partition_contents(Relation parent, Relation default_rel, PartitionBoundSpec *new_spec)
List * RelationGetPartitionQual(Relation rel)
PartitionDesc RelationGetPartitionDesc(Relation rel, bool omit_detached)
Oid get_default_oid_from_partdesc(PartitionDesc partdesc)
List * map_partition_varattnos(List *expr, int fromrel_varno, Relation to_rel, Relation from_rel)
bool has_partition_attrs(Relation rel, Bitmapset *attnums, bool *used_in_expr)
List * get_proposed_default_constraint(List *new_part_constraints)
void update_default_partition_oid(Oid parentId, Oid defaultPartId)
Oid index_get_partition(Relation partition, Oid indexId)
Oid get_partition_parent(Oid relid, bool even_if_detached)
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal)
Oid GetAttrDefaultOid(Oid relid, AttrNumber attnum)
ObjectAddress GetAttrDefaultColumnAddress(Oid attrdefoid)
void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool complain, bool internal)
FormData_pg_attribute * Form_pg_attribute
int errdetail_relkind_not_supported(char relkind)
FormData_pg_class * Form_pg_class
#define PARTITION_MAX_KEYS
Oid CreateConstraintEntry(const char *constraintName, Oid constraintNamespace, char constraintType, bool isDeferrable, bool isDeferred, bool isEnforced, bool isValidated, Oid parentConstrId, Oid relId, const int16 *constraintKey, int constraintNKeys, int constraintNTotalKeys, Oid domainId, Oid indexRelId, Oid foreignRelId, const int16 *foreignKey, const Oid *pfEqOp, const Oid *ppEqOp, const Oid *ffEqOp, int foreignNKeys, char foreignUpdateType, char foreignDeleteType, const int16 *fkDeleteSetCols, int numFkDeleteSetCols, char foreignMatchType, const Oid *exclOp, Node *conExpr, const char *conBin, bool conIsLocal, int16 conInhCount, bool conNoInherit, bool conPeriod, bool is_internal)
HeapTuple findNotNullConstraint(Oid relid, const char *colname)
bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, const char *conname)
void FindFKPeriodOpers(Oid opclass, Oid *containedbyoperoid, Oid *aggedcontainedbyoperoid, Oid *intersectoperoid)
void RenameConstraintById(Oid conId, const char *newname)
Oid get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
void ConstraintSetParentConstraint(Oid childConstrId, Oid parentConstrId, Oid childTableId)
void DeconstructFkConstraintRow(HeapTuple tuple, int *numfks, AttrNumber *conkey, AttrNumber *confkey, Oid *pf_eq_oprs, Oid *pp_eq_oprs, Oid *ff_eq_oprs, int *num_fk_del_set_cols, AttrNumber *fk_del_set_cols)
HeapTuple findNotNullConstraintAttnum(Oid relid, AttrNumber attnum)
void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, Oid newNspId, bool isType, ObjectAddresses *objsMoved)
List * RelationGetNotNullConstraints(Oid relid, bool cooked, bool include_noinh)
char * ChooseConstraintName(const char *name1, const char *name2, const char *label, Oid namespaceid, List *others)
Oid get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
AttrNumber extractNotNullColumn(HeapTuple constrTup)
Oid get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
FormData_pg_constraint * Form_pg_constraint
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
long deleteDependencyRecordsForClass(Oid classId, Oid objectId, Oid refclassId, char deptype)
List * getOwnedSequences(Oid relid)
long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDeps)
long deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype, Oid refclassId, Oid refobjectId)
Oid getIdentitySequence(Relation rel, AttrNumber attnum, bool missing_ok)
Oid get_index_constraint(Oid indexId)
bool sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
FormData_pg_depend * Form_pg_depend
FormData_pg_foreign_table * Form_pg_foreign_table
FormData_pg_index * Form_pg_index
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
bool DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending, const char *childname)
List * find_inheritance_children(Oid parentrelId, LOCKMODE lockmode)
void StoreSingleInheritance(Oid relationId, Oid parentOid, int32 seqNumber)
bool has_superclass(Oid relationId)
bool PartitionHasPendingDetach(Oid partoid)
FormData_pg_inherits * Form_pg_inherits
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_current_index(var_or_cell)
#define foreach_delete_current(lst, var_or_cell)
#define list_make1_oid(x1)
#define foreach_ptr(type, var, lst)
#define for_each_from(cell, lst, N)
static void * list_nth(const List *list, int n)
#define list_make3(x1, x2, x3)
#define foreach_node(type, var, lst)
static ListCell * list_head(const List *l)
#define foreach_oid(var, lst)
#define list_nth_node(type, list, n)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
#define foreach_int(var, lst)
FormData_pg_opclass * Form_pg_opclass
List * GetRelationPublications(Oid relid)
void changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
void changeDependencyOnTablespace(Oid classId, Oid objectId, Oid newTablespaceId)
static char buf[DEFAULT_XLOG_SEG_SIZE]
FormData_pg_trigger * Form_pg_trigger
void RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
FormData_pg_type * Form_pg_type
#define ERRCODE_UNDEFINED_TABLE
void pgstat_count_truncate(Relation rel)
Expr * expression_planner(Expr *expr)
int pg_strcasecmp(const char *s1, const char *s2)
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static Datum CharGetDatum(char X)
void CheckTableForSerializableConflictIn(Relation relation)
void TransferPredicateLocksToHeapRelation(Relation relation)
bool predicate_implied_by(List *predicate_list, List *clause_list, bool weak)
Expr * canonicalize_qual(Expr *qual, bool is_check)
void * stringToNode(const char *str)
#define RelationGetForm(relation)
#define RelationGetRelid(relation)
#define RelationIsLogicallyLogged(relation)
#define RelationIsUsedAsCatalogTable(relation)
static SMgrRelation RelationGetSmgr(Relation rel)
#define RelationGetDescr(relation)
#define RelationIsMapped(relation)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
#define RELATION_IS_OTHER_TEMP(relation)
#define RelationGetNamespace(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
#define RelationIsPermanent(relation)
List * RelationGetIndexList(Relation relation)
Oid RelationGetPrimaryKeyIndex(Relation relation, bool deferrable_ok)
int errtableconstraint(Relation rel, const char *conname)
int errtablecol(Relation rel, int attnum)
List * RelationGetIndexPredicate(Relation relation)
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
void RelationSetNewRelfilenumber(Relation relation, char persistence)
List * RelationGetFKeyList(Relation relation)
List * RelationGetIndexExpressions(Relation relation)
void RelationAssumeNewRelfilelocator(Relation relation)
int errtable(Relation rel)
@ INDEX_ATTR_BITMAP_PRIMARY_KEY
@ INDEX_ATTR_BITMAP_IDENTITY_KEY
List * untransformRelOptions(Datum options)
bytea * view_reloptions(Datum reloptions, bool validate)
bytea * index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate)
bytea * partitioned_table_reloptions(Datum reloptions, bool validate)
Datum transformRelOptions(Datum oldOptions, List *defList, const char *nameSpace, const char *const validnsps[], bool acceptOidsOff, bool isReset)
LOCKMODE AlterTableGetRelOptionsLockLevel(List *defList)
bytea * attribute_reloptions(Datum reloptions, bool validate)
bytea * heap_reloptions(char relkind, Datum reloptions, bool validate)
#define HEAP_RELOPT_NAMESPACES
#define RelFileNumberIsValid(relnumber)
void EnableDisableRule(Relation rel, const char *rulename, char fires_when)
#define RULE_FIRES_ON_ORIGIN
#define RULE_FIRES_ON_REPLICA
#define RULE_FIRES_ALWAYS
Query * get_view_query(Relation view)
const char * view_query_is_auto_updatable(Query *viewquery, bool check_cols)
Node * build_generation_expression(Relation rel, int attrno)
Node * build_column_default(Relation rel, int attrno)
Node * expand_generated_columns_in_expr(Node *node, Relation rel, int rt_index)
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
Datum RI_FKey_check_ins(PG_FUNCTION_ARGS)
bool RI_Initial_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
void RI_PartitionRemove_Check(Trigger *trigger, Relation fk_rel, Relation pk_rel)
int RI_FKey_trigger_type(Oid tgfoid)
char * pg_get_statisticsobjdef_string(Oid statextid)
char * pg_get_indexdef_string(Oid indexrelid)
const char * quote_identifier(const char *ident)
Datum pg_get_expr(PG_FUNCTION_ARGS)
char * pg_get_constraintdef_command(Oid constraintId)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
void smgrclose(SMgrRelation reln)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
Snapshot GetTransactionSnapshot(void)
Snapshot GetLatestSnapshot(void)
void UnregisterSnapshot(Snapshot snapshot)
void PushActiveSnapshot(Snapshot snapshot)
Snapshot RegisterSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
Snapshot GetActiveSnapshot(void)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation try_relation_open(Oid relationId, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
void check_stack_depth(void)
ObjectAddress CreateStatistics(CreateStatsStmt *stmt, bool check_rights)
Oid StatisticsGetRelation(Oid statId, bool missing_ok)
void RelationPreserveStorage(RelFileLocator rlocator, bool atCommit)
void RelationCopyStorage(SMgrRelation src, SMgrRelation dst, ForkNumber forkNum, char relpersistence)
SMgrRelation RelationCreateStorage(RelFileLocator rlocator, char relpersistence, bool register_delete)
void log_smgrcreate(const RelFileLocator *rlocator, ForkNumber forkNum)
void RelationDropStorage(Relation rel)
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
List * changedConstraintDefs
Expr * partition_constraint
List * changedStatisticsDefs
char * replicaIdentityIndex
List * changedStatisticsOids
List * changedConstraintOids
List * subcmds[AT_NUM_PASSES]
bool reset_default_tblspc
char actual_relpersistence
MemoryContext es_query_cxt
List * es_opened_result_relations
TupleTableSlot * ecxt_scantuple
ExecForeignTruncate_function ExecForeignTruncate
amoptions_function amoptions
SubTransactionId creating_subid
SubTransactionId deleting_subid
const char * p_sourcetext
PartitionBoundSpec * bound
PartitionStrategy strategy
const struct IndexAmRoutine * rd_indam
SubTransactionId rd_firstRelfilelocatorSubid
SubTransactionId rd_newRelfilelocatorSubid
SubTransactionId rd_createSubid
RelFileLocator rd_locator
ExprState * partqualstate
TupleTableSlot * tg_trigslot
const char * skipping_msg
const char * nonexistent_msg
const char * drophint_msg
#define FirstLowInvalidHeapAttributeNumber
#define TableOidAttributeNumber
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCacheLocked1(int cacheId, Datum key1)
HeapTuple SearchSysCacheLockedCopy1(int cacheId, Datum key1)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheExists2(cacheId, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode)
Relation table_openrv_extended(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
char * default_table_access_method
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, ScanKeyData *key)
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
static void table_endscan(TableScanDesc scan)
#define TABLE_INSERT_SKIP_FSM
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, int options, BulkInsertStateData *bistate)
static void table_finish_bulk_insert(Relation rel, int options)
static void table_relation_copy_data(Relation rel, const RelFileLocator *newrlocator)
static bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
static TableScanDesc table_beginscan(Relation rel, Snapshot snapshot, int nkeys, ScanKeyData *key)
static void QueueFKConstraintValidation(List **wqueue, Relation conrel, Relation fkrel, Oid pkrelid, HeapTuple contuple, LOCKMODE lockmode)
static AttrNumber renameatt_internal(Oid myrelid, const char *oldattname, const char *newattname, bool recurse, bool recursing, int expected_parents, DropBehavior behavior)
void ResetRelRewrite(Oid myrelid)
static int validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums, int numfksetcols, int16 *fksetcolsattnums, List *fksetcols)
static void MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel, bool ispartition)
static void MarkInheritDetached(Relation child_rel, Relation parent_rel)
static ObjectAddress ATExecAlterColumnGenericOptions(Relation rel, const char *colName, List *options, LOCKMODE lockmode)
static void ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode, AlterTableUtilityContext *context)
static void AlterConstrEnforceabilityRecurse(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Relation tgrel, Oid fkrelid, Oid pkrelid, HeapTuple contuple, LOCKMODE lockmode, Oid ReferencedParentDelTrigger, Oid ReferencedParentUpdTrigger, Oid ReferencingParentInsTrigger, Oid ReferencingParentUpdTrigger)
static ObjectAddress ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
ObjectAddress RenameRelation(RenameStmt *stmt)
static AlteredTableInfo * ATGetQueueEntry(List **wqueue, Relation rel)
static void verifyNotNullPKCompatible(HeapTuple tuple, const char *colname)
static void ATExecDropOf(Relation rel, LOCKMODE lockmode)
static ObjectAddress ATExecAlterConstraint(List **wqueue, Relation rel, ATAlterConstraint *cmdcon, bool recurse, LOCKMODE lockmode)
static ColumnDef * MergeInheritedAttribute(List *inh_columns, int exist_attno, const ColumnDef *newdef)
static void addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel, Relation pkrel, Oid indexOid, Oid parentConstr, int numfks, int16 *pkattnum, int16 *fkattnum, Oid *pfeqoperators, Oid *ppeqoperators, Oid *ffeqoperators, int numfkdelsetcols, int16 *fkdelsetcols, bool old_check_ok, LOCKMODE lockmode, Oid parentInsTrigger, Oid parentUpdTrigger, bool with_period)
static bool ConstraintImpliedByRelConstraint(Relation scanrel, List *testConstraint, List *provenConstraint)
static const char * storage_name(char c)
static ObjectAddress ATExecDropExpression(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode)
void AtEOSubXact_on_commit_actions(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
static void add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid)
static ObjectAddress ATExecColumnDefault(Relation rel, const char *colName, Node *newDefault, LOCKMODE lockmode)
static void ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd, List **wqueue, LOCKMODE lockmode, bool rewrite)
static void ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
static void MergePartitionsMoveRows(List **wqueue, List *mergingPartitions, Relation newPartRel)
static void drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid, DependencyType deptype)
static void DropForeignKeyConstraintTriggers(Relation trigrel, Oid conoid, Oid confrelid, Oid conrelid)
static void RemoveInheritance(Relation child_rel, Relation parent_rel, bool expect_detached)
void PreCommit_on_commit_actions(void)
static ObjectAddress dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior behavior, bool recurse, bool recursing, bool missing_ok, LOCKMODE lockmode)
static void RemoveInheritedConstraint(Relation conrel, Relation trigrel, Oid conoid, Oid conrelid)
static ObjectAddress ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode, bool recurse, bool recursing)
static char GetAttributeCompression(Oid atttypid, const char *compression)
static int findAttrByName(const char *attributeName, const List *columns)
static void RememberIndexForRebuilding(Oid indoid, AlteredTableInfo *tab)
static bool ATColumnChangeRequiresRewrite(Node *expr, AttrNumber varattno)
static char * ChooseForeignKeyConstraintNameAddition(List *colnames)
static ObjectAddress ATExecValidateConstraint(List **wqueue, Relation rel, char *constrName, bool recurse, bool recursing, LOCKMODE lockmode)
void AlterTable(AlterTableStmt *stmt, LOCKMODE lockmode, AlterTableUtilityContext *context)
static void RememberStatisticsForRebuilding(Oid stxoid, AlteredTableInfo *tab)
static CoercionPathType findFkeyCast(Oid targetTypeId, Oid sourceTypeId, Oid *funcid)
static void add_column_collation_dependency(Oid relid, int32 attnum, Oid collid)
static ObjectAddress ATExecDropNotNull(Relation rel, const char *colName, bool recurse, LOCKMODE lockmode)
static Oid transformFkeyCheckAttrs(Relation pkrel, int numattrs, int16 *attnums, bool with_period, Oid *opclasses, bool *pk_has_without_overlaps)
void RemoveRelations(DropStmt *drop)
static void ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel, const char *tablespacename, LOCKMODE lockmode)
static void ATTypedTableRecursion(List **wqueue, Relation rel, AlterTableCmd *cmd, LOCKMODE lockmode, AlterTableUtilityContext *context)
static void RememberReplicaIdentityForRebuilding(Oid indoid, AlteredTableInfo *tab)
static List * GetParentedForeignKeyRefs(Relation partition)
void AlterRelationNamespaceInternal(Relation classRel, Oid relOid, Oid oldNspOid, Oid newNspOid, bool hasDependEntry, ObjectAddresses *objsMoved)
static ObjectAddress ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, Constraint *newConstraint, bool recurse, bool is_readd, LOCKMODE lockmode)
ObjectAddress renameatt(RenameStmt *stmt)
void ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lockmode)
static void RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid, void *arg)
static void CheckAlterTableIsSafe(Relation rel)
static void DropErrorMsgWrongType(const char *relname, char wrongkind, char rightkind)
LOCKMODE AlterTableGetLockLevel(List *cmds)
static ObjectAddress ATExecDetachPartition(List **wqueue, AlteredTableInfo *tab, Relation rel, RangeVar *name, bool concurrent)
static void AlterSeqNamespaces(Relation classRel, Relation rel, Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved, LOCKMODE lockmode)
static void RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid, void *arg)
TupleDesc BuildDescForRelation(const List *columns)
static void attachPartitionTable(List **wqueue, Relation rel, Relation attachrel, PartitionBoundSpec *bound)
static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls)
static void createTableConstraints(List **wqueue, AlteredTableInfo *tab, Relation parent_rel, Relation newRel)
void AtEOXact_on_commit_actions(bool isCommit)
static void checkFkeyPermissions(Relation rel, int16 *attnums, int natts)
void CheckTableNotInUse(Relation rel, const char *stmt)
static Relation createPartitionTable(List **wqueue, RangeVar *newPartName, Relation parent_rel, Oid ownerId)
static void SplitPartitionMoveRows(List **wqueue, Relation rel, Relation splitRel, List *partlist, List *newPartRels)
static bool ATExecAlterConstrInheritability(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Relation rel, HeapTuple contuple, LOCKMODE lockmode)
static void createForeignKeyActionTriggers(Oid myRelOid, Oid refRelOid, Constraint *fkconstraint, Oid constraintOid, Oid indexOid, Oid parentDelTrigger, Oid parentUpdTrigger, Oid *deleteTrigOid, Oid *updateTrigOid)
static void evaluateGeneratedExpressionsAndCheckConstraints(AlteredTableInfo *tab, Relation newPartRel, TupleTableSlot *insertslot, ExprContext *econtext)
static void ATExecEnableDisableTrigger(Relation rel, const char *trigname, char fires_when, bool skip_system, bool recurse, LOCKMODE lockmode)
static void AttachPartitionForeignKey(List **wqueue, Relation partition, Oid partConstrOid, Oid parentConstrOid, Oid parentInsTrigger, Oid parentUpdTrigger, Relation trigrel)
static List * MergeCheckConstraint(List *constraints, const char *name, Node *expr, bool is_enforced)
static void renameatt_check(Oid myrelid, Form_pg_class classform, bool recursing)
static void RangeVarCallbackForAttachIndex(const RangeVar *rv, Oid relOid, Oid oldRelOid, void *arg)
static void ATCheckPartitionsNotInUse(Relation rel, LOCKMODE lockmode)
static void truncate_check_activity(Relation rel)
static void validatePartitionedIndex(Relation partedIdx, Relation partedTbl)
static void AlterConstrUpdateConstraintEntry(ATAlterConstraint *cmdcon, Relation conrel, HeapTuple contuple)
static ObjectAddress ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, Constraint *fkconstraint, bool recurse, bool recursing, LOCKMODE lockmode)
static void TryReuseIndex(Oid oldId, IndexStmt *stmt)
static void GetForeignKeyCheckTriggers(Relation trigrel, Oid conoid, Oid confrelid, Oid conrelid, Oid *insertTriggerOid, Oid *updateTriggerOid)
static ObjectAddress addFkConstraint(addFkConstraintSides fkside, char *constraintname, Constraint *fkconstraint, Relation rel, Relation pkrel, Oid indexOid, Oid parentConstr, int numfks, int16 *pkattnum, int16 *fkattnum, Oid *pfeqoperators, Oid *ppeqoperators, Oid *ffeqoperators, int numfkdelsetcols, int16 *fkdelsetcols, bool is_internal, bool with_period)
static void RememberClusterOnForRebuilding(Oid indoid, AlteredTableInfo *tab)
static ObjectAddress ATExecSetOptions(Relation rel, const char *colName, Node *options, bool isReset, LOCKMODE lockmode)
static List * getAttributesList(Relation parent_rel)
static bool ATExecAlterConstrEnforceability(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Relation tgrel, Oid fkrelid, Oid pkrelid, HeapTuple contuple, LOCKMODE lockmode, Oid ReferencedParentDelTrigger, Oid ReferencedParentUpdTrigger, Oid ReferencingParentInsTrigger, Oid ReferencingParentUpdTrigger)
static void QueueNNConstraintValidation(List **wqueue, Relation conrel, Relation rel, HeapTuple contuple, bool recurse, bool recursing, LOCKMODE lockmode)
static void detachPartitionTable(Relation parent_rel, Relation child_rel, Oid defaultPartOid)
static ObjectAddress ATExecDropColumn(List **wqueue, Relation rel, const char *colName, DropBehavior behavior, bool recurse, bool recursing, bool missing_ok, LOCKMODE lockmode, ObjectAddresses *addrs)
static void CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
static void SetIndexStorageProperties(Relation rel, Relation attrelation, AttrNumber attnum, bool setstorage, char newstorage, bool setcompression, char newcompression, LOCKMODE lockmode)
static void ATController(AlterTableStmt *parsetree, Relation rel, List *cmds, bool recurse, LOCKMODE lockmode, AlterTableUtilityContext *context)
bool CheckRelationTableSpaceMove(Relation rel, Oid newTableSpaceId)
static void ATExecSetRowSecurity(Relation rel, bool rls)
void find_composite_type_dependencies(Oid typeOid, Relation origRelation, const char *origTypeName)
static void truncate_check_perms(Oid relid, Form_pg_class reltuple)
static void truncate_check_rel(Oid relid, Form_pg_class reltuple)
static void change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, LOCKMODE lockmode)
static void StoreCatalogInheritance1(Oid relationId, Oid parentOid, int32 seqNumber, Relation inhRelation, bool child_is_partition)
static void RememberAllDependentForRebuilding(AlteredTableInfo *tab, AlterTableType subtype, Relation rel, AttrNumber attnum, const char *colName)
static void ATPrepDropExpression(Relation rel, AlterTableCmd *cmd, bool recurse, bool recursing, LOCKMODE lockmode)
static bool ATExecAlterConstraintInternal(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Relation tgrel, Relation rel, HeapTuple contuple, bool recurse, LOCKMODE lockmode)
static void verifyPartitionIndexNotNull(IndexInfo *iinfo, Relation partition)
static ObjectAddress ATExecCookedColumnDefault(Relation rel, AttrNumber attnum, Node *newDefault)
static ObjectAddress rename_constraint_internal(Oid myrelid, Oid mytypid, const char *oldconname, const char *newconname, bool recurse, bool recursing, int expected_parents)
static void DropErrorMsgNonExistent(RangeVar *rel, char rightkind, bool missing_ok)
static void ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode)
static void ATExecMergePartitions(List **wqueue, AlteredTableInfo *tab, Relation rel, PartitionCmd *cmd, AlterTableUtilityContext *context)
static AlterTableCmd * ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode, AlterTablePass cur_pass, AlterTableUtilityContext *context)
void AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid, ObjectAddresses *objsMoved)
static ObjectAddress ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, Constraint *constr, bool recurse, bool recursing, bool is_readd, LOCKMODE lockmode)
static void CloneFkReferenced(Relation parentRel, Relation partitionRel)
static void MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel)
static void ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing, AlterTableCmd *cmd, LOCKMODE lockmode, AlterTableUtilityContext *context)
void SetRelationHasSubclass(Oid relationId, bool relhassubclass)
static void MergeChildAttribute(List *inh_columns, int exist_attno, int newcol_attno, const ColumnDef *newdef)
static void ATSimplePermissions(AlterTableType cmdtype, Relation rel, int allowed_targets)
static const char * alter_table_type_to_string(AlterTableType cmdtype)
static void ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation, LOCKMODE lockmode)
static ObjectAddress ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmode, bool recurse, bool recursing)
ObjectAddress AlterTableNamespace(AlterObjectSchemaStmt *stmt, Oid *oldschema)
static void RememberConstraintForRebuilding(Oid conoid, AlteredTableInfo *tab)
void ExecuteTruncate(TruncateStmt *stmt)
static void relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid, bool is_internal)
#define ATT_FOREIGN_TABLE
static void ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing, bool is_view, AlterTableCmd *cmd, LOCKMODE lockmode, AlterTableUtilityContext *context)
static void ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNumber *partattrs, List **partexprs, Oid *partopclass, Oid *partcollation, PartitionStrategy strategy)
static void CloneRowTriggersToPartition(Relation parent, Relation partition)
static void AttachPartitionEnsureIndexes(List **wqueue, Relation rel, Relation attachrel)
static void StoreCatalogInheritance(Oid relationId, List *supers, bool child_is_partition)
static void ATExecGenericOptions(Relation rel, List *options)
static void TryReuseForeignKey(Oid oldId, Constraint *con)
Oid AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
static void AlterConstrDeferrabilityRecurse(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Relation tgrel, Relation rel, HeapTuple contuple, bool recurse, List **otherrelids, LOCKMODE lockmode)
static ObjectAddress ATExecSetStatistics(Relation rel, const char *colName, int16 colNum, Node *newValue, LOCKMODE lockmode)
static void ATSimpleRecursion(List **wqueue, Relation rel, AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode, AlterTableUtilityContext *context)
static void DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent, Oid defaultPartOid)
static void RebuildConstraintComment(AlteredTableInfo *tab, AlterTablePass pass, Oid objid, Relation rel, List *domname, const char *conname)
static void CloneForeignKeyConstraints(List **wqueue, Relation parentRel, Relation partitionRel)
static void addFkRecurseReferenced(Constraint *fkconstraint, Relation rel, Relation pkrel, Oid indexOid, Oid parentConstr, int numfks, int16 *pkattnum, int16 *fkattnum, Oid *pfeqoperators, Oid *ppeqoperators, Oid *ffeqoperators, int numfkdelsetcols, int16 *fkdelsetcols, bool old_check_ok, Oid parentDelTrigger, Oid parentUpdTrigger, bool with_period)
static bool check_for_column_name_collision(Relation rel, const char *colname, bool if_not_exists)
static ObjectAddress ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, AlterTableCmd **cmd, bool recurse, bool recursing, LOCKMODE lockmode, AlterTablePass cur_pass, AlterTableUtilityContext *context)
@ AT_PASS_ADD_OTHERCONSTR
@ AT_PASS_ADD_INDEXCONSTR
static ObjectAddress ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd, LOCKMODE lockmode)
static void validateForeignKeyConstraint(char *conname, Relation rel, Relation pkrel, Oid pkindOid, Oid constraintOid, bool hasperiod)
static char * decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
static void QueueCheckConstraintValidation(List **wqueue, Relation conrel, Relation rel, char *constrName, HeapTuple contuple, bool recurse, bool recursing, LOCKMODE lockmode)
void SetRelationTableSpace(Relation rel, Oid newTableSpaceId, RelFileNumber newRelFilenumber)
void remove_on_commit_action(Oid relid)
static void ATExecDropCluster(Relation rel, LOCKMODE lockmode)
#define ATT_PARTITIONED_INDEX
static void CreateInheritance(Relation child_rel, Relation parent_rel, bool ispartition)
static const struct dropmsgstrings dropmsgstringarray[]
static void ATPrepChangePersistence(AlteredTableInfo *tab, Relation rel, bool toLogged)
static ObjectAddress ATExecSetExpression(AlteredTableInfo *tab, Relation rel, const char *colName, Node *newExpr, LOCKMODE lockmode)
ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ObjectAddress *typaddress, const char *queryString)
static Oid CreateFKCheckTrigger(Oid myRelOid, Oid refRelOid, Constraint *fkconstraint, Oid constraintOid, Oid indexOid, Oid parentTrigOid, bool on_insert)
static void AlterConstrTriggerDeferrability(Oid conoid, Relation tgrel, Relation rel, bool deferrable, bool initdeferred, List **otherrelids)
static void ATPrepAddPrimaryKey(List **wqueue, Relation rel, AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode, AlterTableUtilityContext *context)
static void DropClonedTriggersFromPartition(Oid partitionId)
static void QueuePartitionConstraintValidation(List **wqueue, Relation scanrel, List *partConstraint, bool validate_default)
static ObjectAddress ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode)
static void RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid, void *arg)
void AlterTableInternal(Oid relid, List *cmds, bool recurse)
static void GetForeignKeyActionTriggers(Relation trigrel, Oid conoid, Oid confrelid, Oid conrelid, Oid *deleteTriggerOid, Oid *updateTriggerOid)
void check_of_type(HeapTuple typetuple)
static ObjectAddress ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
static void ATDetachCheckNoForeignKeyRefs(Relation partition)
static ObjectAddress ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel, IndexStmt *stmt, LOCKMODE lockmode)
static SplitPartitionContext * createSplitPartitionContext(Relation partRel)
static void AlterIndexNamespaces(Relation classRel, Relation rel, Oid oldNspOid, Oid newNspOid, ObjectAddresses *objsMoved)
#define ATT_PARTITIONED_TABLE
static void deleteSplitPartitionContext(SplitPartitionContext *pc, List **wqueue, int ti_options)
static void ATExecCmd(List **wqueue, AlteredTableInfo *tab, AlterTableCmd *cmd, LOCKMODE lockmode, AlterTablePass cur_pass, AlterTableUtilityContext *context)
static bool ATExecAlterConstrDeferrability(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Relation tgrel, Relation rel, HeapTuple contuple, bool recurse, List **otherrelids, LOCKMODE lockmode)
static void ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode)
static void createForeignKeyCheckTriggers(Oid myRelOid, Oid refRelOid, Constraint *fkconstraint, Oid constraintOid, Oid indexOid, Oid parentInsTrigger, Oid parentUpdTrigger, Oid *insertTrigOid, Oid *updateTrigOid)
static void ATPrepAddInherit(Relation child_rel)
static ObjectAddress ATExecDetachPartitionFinalize(Relation rel, RangeVar *name)
static ObjectAddress ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE lockmode)
static ObjectAddress ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd, AlterTableUtilityContext *context)
static List * find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior behavior)
Oid AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
static int transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, List **attnamelist, int16 *attnums, Oid *atttypids, Oid *attcollids, Oid *opclasses, bool *pk_has_without_overlaps)
static ObjectAddress ATExecAddIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmode, bool recurse, bool recursing)
static void ATExecSetAccessMethodNoStorage(Relation rel, Oid newAccessMethodId)
static void ATExecDropConstraint(Relation rel, const char *constrName, DropBehavior behavior, bool recurse, bool missing_ok, LOCKMODE lockmode)
static ObjectAddress ATExecAddIndex(AlteredTableInfo *tab, Relation rel, IndexStmt *stmt, bool is_rebuild, LOCKMODE lockmode)
static ObjectAddress ATExecSetCompression(Relation rel, const char *column, Node *newValue, LOCKMODE lockmode)
static PartitionSpec * transformPartitionSpec(Relation rel, PartitionSpec *partspec)
static void ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, bool recurse, bool recursing, LOCKMODE lockmode, AlterTableUtilityContext *context)
static void buildExpressionExecutionStates(AlteredTableInfo *tab, Relation newPartRel, EState *estate)
static void index_copy_data(Relation rel, RelFileLocator newrlocator)
static ObjectAddress ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName, bool recurse, bool recursing, LOCKMODE lockmode)
void RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bool is_index)
static void set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum, bool is_valid, bool queue_validation)
static bool tryAttachPartitionForeignKey(List **wqueue, ForeignKeyCacheInfo *fk, Relation partition, Oid parentConstrOid, int numfks, AttrNumber *mapped_conkey, AttrNumber *confkey, Oid *conpfeqop, Oid parentInsTrigger, Oid parentUpdTrigger, Relation trigrel)
static void ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
static void ATPrepAlterColumnType(List **wqueue, AlteredTableInfo *tab, Relation rel, bool recurse, bool recursing, AlterTableCmd *cmd, LOCKMODE lockmode, AlterTableUtilityContext *context)
static int transformColumnNameList(Oid relId, List *colList, int16 *attnums, Oid *atttypids, Oid *attcollids)
static void change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid newOwnerId)
#define ATT_COMPOSITE_TYPE
static ObjectAddress ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
bool PartConstraintImpliedByRelConstraint(Relation scanrel, List *partConstraint)
void RangeVarCallbackMaintainsTable(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
static void ATExecSplitPartition(List **wqueue, AlteredTableInfo *tab, Relation rel, PartitionCmd *cmd, AlterTableUtilityContext *context)
static bool constraints_equivalent(HeapTuple a, HeapTuple b, TupleDesc tupleDesc)
static ObjectAddress ATExecAddStatistics(AlteredTableInfo *tab, Relation rel, CreateStatsStmt *stmt, bool is_rebuild, LOCKMODE lockmode)
ObjectAddress RenameConstraint(RenameStmt *stmt)
static void ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode, AlterTableUtilityContext *context)
void register_on_commit_action(Oid relid, OnCommitAction action)
static void RangeVarCallbackForTruncate(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
static ObjectAddress ATExecClusterOn(Relation rel, const char *indexName, LOCKMODE lockmode)
static char GetAttributeStorage(Oid atttypid, const char *storagemode)
void RangeVarCallbackOwnsRelation(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
#define child_dependency_type(child_is_partition)
static void refuseDupeIndexAttach(Relation parentIdx, Relation partIdx, Relation partitionTbl)
void ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged, DropBehavior behavior, bool restart_seqs, bool run_as_table_owner)
static void ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
static List * MergeAttributes(List *columns, const List *supers, char relpersistence, bool is_partition, List **supconstr, List **supnotnulls)
static void ATExecEnableDisableRule(Relation rel, const char *rulename, char fires_when, LOCKMODE lockmode)
static void ATPrepSetAccessMethod(AlteredTableInfo *tab, Relation rel, const char *amname)
static bool NotNullImpliedByRelConstraints(Relation rel, Form_pg_attribute attr)
const char * GetCompressionMethodName(char method)
char CompressionNameToMethod(const char *compression)
#define CompressionMethodIsValid(cm)
#define InvalidCompressionMethod
void AlterTableCreateToastTable(Oid relOid, Datum reloptions, LOCKMODE lockmode)
void ExecBSTruncateTriggers(EState *estate, ResultRelInfo *relinfo)
void EnableDisableTrigger(Relation rel, const char *tgname, Oid tgparent, char fires_when, bool skip_system, bool recurse, LOCKMODE lockmode)
const char * FindTriggerIncompatibleWithInheritance(TriggerDesc *trigdesc)
void ExecASTruncateTriggers(EState *estate, ResultRelInfo *relinfo)
ObjectAddress CreateTrigger(CreateTrigStmt *stmt, const char *queryString, Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid, Oid funcoid, Oid parentTriggerOid, Node *whenClause, bool isInternal, bool in_partition)
void TriggerSetParentTrigger(Relation trigRel, Oid childTrigId, Oid parentTrigId, Oid childTableId)
ObjectAddress CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid, Oid funcoid, Oid parentTriggerOid, Node *whenClause, bool isInternal, bool in_partition, char trigger_fires_when)
bool AfterTriggerPendingOnRel(Oid relid)
void AfterTriggerEndQuery(EState *estate)
void AfterTriggerBeginQuery(void)
#define TRIGGER_FIRES_ON_ORIGIN
#define TRIGGER_FIRES_ON_REPLICA
#define TRIGGER_EVENT_ROW
#define TRIGGER_FIRES_ALWAYS
#define TRIGGER_EVENT_INSERT
TupleConversionMap * convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc)
void free_conversion_map(TupleConversionMap *map)
TupleTableSlot * execute_attr_map_slot(AttrMap *attrMap, TupleTableSlot *in_slot, TupleTableSlot *out_slot)
TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc)
Node * TupleDescGetDefault(TupleDesc tupdesc, AttrNumber attnum)
TupleDesc CreateTemplateTupleDesc(int natts)
void populate_compact_attribute(TupleDesc tupdesc, int attnum)
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
#define ReleaseTupleDesc(tupdesc)
#define ATTNULLABLE_VALID
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static void slot_getallattrs(TupleTableSlot *slot)
static bool slot_attisnull(TupleTableSlot *slot, int attnum)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
bool DomainHasConstraints(Oid type_id)
void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId)
ObjectAddress AlterDomainAddConstraint(List *names, Node *newConstraint, ObjectAddress *constrAddr)
void checkDomainOwner(HeapTuple tup)
Oid AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, bool isImplicitArray, bool ignoreDependent, bool errorOnTableType, ObjectAddresses *objsMoved)
List * roleSpecsToIds(List *memberNames)
void SwitchToUntrustedUser(Oid userid, UserContext *context)
void RestoreUserContext(UserContext *context)
void ProcessUtilityForAlterTable(Node *stmt, AlterTableUtilityContext *context)
#define MAX_STATISTICS_TARGET
String * makeString(char *str)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
static char * VARDATA_ANY(const void *PTR)
SubTransactionId GetCurrentSubTransactionId(void)
void CommandCounterIncrement(void)
void StartTransactionCommand(void)
void CommitTransactionCommand(void)
CommandId GetCurrentCommandId(bool used)
#define XACT_FLAGS_ACCESSEDTEMPNAMESPACE
#define XLogLogicalInfoActive()
#define XLOG_INCLUDE_ORIGIN
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterData(const void *data, uint32 len)
void XLogSetRecordFlags(uint8 flags)
void XLogBeginInsert(void)