43#include "catalog/pg_extension_d.h"
103#include "utils/fmgroids.h"
170#define AT_NUM_PASSES (AT_PASS_MISC + 1)
269 gettext_noop(
"sequence \"%s\" does not exist, skipping"),
271 gettext_noop(
"Use DROP SEQUENCE to remove a sequence.")},
280 gettext_noop(
"materialized view \"%s\" does not exist"),
281 gettext_noop(
"materialized view \"%s\" does not exist, skipping"),
283 gettext_noop(
"Use DROP MATERIALIZED VIEW to remove a materialized view.")},
299 gettext_noop(
"foreign table \"%s\" does not exist, skipping"),
301 gettext_noop(
"Use DROP FOREIGN TABLE to remove a foreign table.")},
317 gettext_noop(
"property graph \"%s\" does not exist, skipping"),
319 gettext_noop(
"Use DROP PROPERTY GRAPH to remove a property graph.")},
338#define ATT_TABLE 0x0001
339#define ATT_VIEW 0x0002
340#define ATT_MATVIEW 0x0004
341#define ATT_INDEX 0x0008
342#define ATT_COMPOSITE_TYPE 0x0010
343#define ATT_FOREIGN_TABLE 0x0020
344#define ATT_PARTITIONED_INDEX 0x0040
345#define ATT_SEQUENCE 0x0080
346#define ATT_PARTITIONED_TABLE 0x0100
396#define child_dependency_type(child_is_partition) \
397 ((child_is_partition) ? DEPENDENCY_AUTO : DEPENDENCY_NORMAL)
439 bool recurse,
bool recursing,
450 bool deferrable,
bool initdeferred,
462 bool recurse,
bool recursing,
477 bool recurse,
bool recursing,
LOCKMODE lockmode);
482 bool recurse,
bool recursing,
LOCKMODE lockmode);
508 bool recurse,
bool recursing,
LOCKMODE lockmode,
540 bool recurse,
bool recursing,
553 bool recurse,
bool recursing,
563 Node *def,
LOCKMODE lockmode,
bool recurse,
bool recursing);
565 Node *def,
LOCKMODE lockmode,
bool recurse,
bool recursing);
567 bool recurse,
bool recursing);
583 bool recurse,
bool recursing,
604 bool recurse,
bool recursing,
bool is_readd,
608 bool recurse,
bool recursing,
614 char *constraintname,
668 Oid conoid,
Oid conrelid);
670 Oid confrelid,
Oid conrelid);
681 bool missing_ok,
LOCKMODE lockmode);
684 bool recurse,
bool recursing,
685 bool missing_ok,
LOCKMODE lockmode);
688 bool recurse,
bool recursing,
707 const char *conname);
724 const char *tablespacename,
LOCKMODE lockmode);
769 bool validate_default);
857 errmsg(
"ON COMMIT can only be used on temporary tables")));
862 elog(
ERROR,
"unexpected relkind: %d", (
int) relkind);
874 errmsg(
"partitioned tables cannot be unlogged")));
894 errmsg(
"cannot create temporary table within security-restricted operation")));
930 errmsg(
"relation \"%s\" would be inherited from more than once",
940 if (
stmt->tablespacename)
947 errmsg(
"cannot specify default tablespace for partitioned relations")));
949 else if (
stmt->partbound)
978 errmsg(
"only shared relations can be placed in pg_global tablespace")));
1002 if (
stmt->ofTypename)
1022 stmt->relation->relpersistence,
1073 cooked->is_enforced =
true;
1074 cooked->skip_validation =
false;
1077 cooked->is_no_inherit =
false;
1096 if (
stmt->partbound)
1123 stmt->relation->relpersistence,
1162 true,
true,
false, queryString);
1170 if (
stmt->partbound)
1190 errmsg(
"\"%s\" is not partitioned",
1228 NULL,
false,
false);
1284 errmsg(
"cannot partition using more than %d columns",
1297 partcollation,
stmt->partspec->strategy);
1314 if (
stmt->partbound)
1337 if (
idxRel->rd_index->indisunique)
1340 errmsg(
"cannot create foreign partition of partitioned table \"%s\"",
1342 errdetail(
"Table \"%s\" contains indexes that are unique.",
1364 false,
false,
false,
false,
false);
1392 if (
stmt->constraints)
1397 true,
true,
false, queryString);
1482 errmsg(
"too many array dimensions"));
1487 errmsg(
"column \"%s\" cannot be declared SETOF",
1491 atttypid, atttypmod,
attdim);
1500 att->attinhcount = entry->
inhcount;
1501 att->attidentity = entry->
identity;
1505 att->attstorage = entry->
storage;
1538 (
errmsg(
"schema \"%s\" does not exist, skipping",
1606 if (
drop->concurrent)
1618 errmsg(
"DROP INDEX CONCURRENTLY does not support dropping multiple objects")));
1622 errmsg(
"DROP INDEX CONCURRENTLY does not support CASCADE")));
1632 switch (
drop->removeType)
1663 elog(
ERROR,
"unrecognized drop object type: %d",
1664 (
int)
drop->removeType);
1672 foreach(cell,
drop->objects)
1692 state.expected_relkind = relkind;
1693 state.heap_lockmode =
drop->concurrent ?
1714 if (
drop->concurrent &&
1730 errmsg(
"cannot drop partitioned index \"%s\" concurrently",
1742 state.heap_lockmode,
1832 state->expected_relkind);
1873 errmsg(
"permission denied: \"%s\" is a system catalog",
1934 foreach(cell,
stmt->relations)
1938 bool recurse = rv->
inh;
1973 foreach(child, children)
2018 errmsg(
"cannot truncate only a partitioned table"),
2019 errhint(
"Do not specify the ONLY keyword, or use TRUNCATE ONLY on the partitions directly.")));
2023 stmt->behavior,
stmt->restart_seqs,
false);
2092 (
errmsg(
"truncate cascades to table \"%s\"",
2112#ifdef USE_ASSERT_CHECKING
2453 errmsg(
"cannot truncate foreign table \"%s\"",
2478 errmsg(
"permission denied: \"%s\" is a system catalog",
2515 errmsg(
"cannot truncate temporary tables of other sessions")));
2640 errmsg(
"tables can have at most %d columns",
2671 errmsg(
"column \"%s\" does not exist",
2682 if (
coldef->is_from_type)
2691 coldef->is_from_type =
false;
2697 errmsg(
"column \"%s\" specified more than once",
2753 errmsg(
"cannot inherit from partitioned table \"%s\"",
2758 errmsg(
"cannot inherit from partition \"%s\"",
2769 errmsg(
"cannot inherit from conflict log table \"%s\"",
2771 errdetail(
"Conflict log tables are system-managed tables for logical replication conflicts.")));
2778 errmsg(
"inherited relation \"%s\" is not a table or foreign table",
2790 errmsg(
"cannot create a temporary relation as partition of permanent relation \"%s\"",
2799 ?
"cannot inherit from temporary relation \"%s\""
2800 :
"cannot create a permanent relation as partition of temporary relation \"%s\"",
2808 ?
"cannot inherit from temporary relation of another session"
2809 :
"cannot create as partition of temporary relation of another session")));
2902 newdef->is_local =
false;
2924 elog(
ERROR,
"default expression not found for attribute %d of relation \"%s\"",
2946 bool found_whole_row;
2960 if (found_whole_row)
2963 errmsg(
"cannot convert whole-row table reference"),
2964 errdetail(
"Generation expression for column \"%s\" contains a whole-row reference to table \"%s\".",
2997 bool found_whole_row;
3000 if (check[
i].ccnoinherit)
3014 if (found_whole_row)
3017 errmsg(
"cannot convert whole-row table reference"),
3018 errdetail(
"Constraint \"%s\" contains a whole-row reference to table \"%s\".",
3023 check[
i].ccenforced);
3037 nnconstraints =
lappend(nnconstraints,
nn);
3060 foreach(
lc, columns)
3103 errmsg(
"tables can have at most %d columns",
3140 errmsg(
"column \"%s\" inherits from generated column but specifies default",
3145 errmsg(
"column \"%s\" inherits from generated column but specifies identity",
3153 errmsg(
"child column \"%s\" specifies generation expression",
3155 errhint(
"A child table column cannot be generated unless its parent column is.")));
3161 errmsg(
"column \"%s\" inherits from generated column of different kind",
3163 errdetail(
"Parent column is %s, child column is %s.",
3190 errmsg(
"column \"%s\" does not exist",
3201 foreach(
lc, columns)
3210 errmsg(
"column \"%s\" inherits conflicting generation expressions",
3212 errhint(
"To resolve the conflict, specify a generation expression explicitly.")));
3216 errmsg(
"column \"%s\" inherits conflicting default values",
3218 errhint(
"To resolve the conflict, specify a default explicitly.")));
3251 foreach(
lc, constraints)
3268 errmsg(
"too many inheritance parents"));
3274 if (!
ccon->is_enforced && is_enforced)
3276 ccon->is_enforced =
true;
3277 ccon->skip_validation =
false;
3285 errmsg(
"check constraint name \"%s\" appears multiple times but with different expressions",
3298 newcon->is_enforced = is_enforced;
3299 newcon->skip_validation = !is_enforced;
3338 (
errmsg(
"merging column \"%s\" with inherited definition",
3343 errdetail(
"User-specified column moved to the position of the inherited column.")));
3355 errmsg(
"column \"%s\" has a type conflict",
3369 errmsg(
"column \"%s\" has a collation conflict",
3384 if (
inhdef->storage == 0)
3389 errmsg(
"column \"%s\" has a storage parameter conflict",
3405 errmsg(
"column \"%s\" has a compression method conflict",
3434 errmsg(
"column \"%s\" inherits from generated column but specifies default",
3439 errmsg(
"column \"%s\" inherits from generated column but specifies identity",
3447 errmsg(
"child column \"%s\" specifies generation expression",
3449 errhint(
"A child table column cannot be generated unless its parent column is.")));
3455 errmsg(
"column \"%s\" inherits from generated column of different kind",
3457 errdetail(
"Parent column is %s, child column is %s.",
3509 (
errmsg(
"merging multiple inherited definitions of column \"%s\"",
3521 errmsg(
"inherited column \"%s\" has a type conflict",
3535 errmsg(
"inherited column \"%s\" has a collation conflict",
3549 errmsg(
"inherited column \"%s\" has a storage parameter conflict",
3565 errmsg(
"column \"%s\" has a compression method conflict",
3577 errmsg(
"inherited column \"%s\" has a generation conflict",
3588 errmsg(
"too many inheritance parents"));
3694 foreach(
lc, columns)
3792 errmsg(
"cannot move system relation \"%s\"",
3799 errmsg(
"only shared relations can be placed in pg_global tablespace")));
3808 errmsg(
"cannot move temporary tables of other sessions")));
3846 elog(
ERROR,
"cache lookup failed for relation %u", reloid);
3864 rd_rel->reltablespace);
3881 errmsg(
"cannot rename column of typed table")));
3900 errmsg(
"cannot rename columns of relation \"%s\"",
3919 errmsg(
"cannot rename columns of conflict log table \"%s\"",
3921 errdetail(
"Conflict log tables are system-managed tables for logical replication conflicts.")));
3926 errmsg(
"permission denied: \"%s\" is a system catalog",
4008 errmsg(
"inherited column \"%s\" must be renamed in child tables too",
4032 errmsg(
"column \"%s\" does not exist",
4040 errmsg(
"cannot rename system column \"%s\"",
4055 errmsg(
"cannot rename inherited column \"%s\"",
4116 (
errmsg(
"relation \"%s\" does not exist, skipping",
4117 stmt->relation->relname)));
4125 stmt->relation->inh,
4174 elog(
ERROR,
"cache lookup failed for constraint %u",
4210 errmsg(
"inherited constraint \"%s\" must be renamed in child tables too",
4217 errmsg(
"cannot rename inherited constraint \"%s\"",
4262 elog(
ERROR,
"cache lookup failed for type %u", typid);
4277 (
errmsg(
"relation \"%s\" does not exist, skipping",
4278 stmt->relation->relname)));
4288 stmt->relation->inh),
4329 (
errmsg(
"relation \"%s\" does not exist, skipping",
4330 stmt->relation->relname)));
4398 errmsg(
"relation \"%s\" already exists",
4517 errmsg(
"cannot %s \"%s\" because it is being used by active queries in this session",
4526 errmsg(
"cannot %s \"%s\" because it has pending trigger events",
4552 errmsg(
"cannot alter temporary tables of other sessions")));
4945 elog(
ERROR,
"unrecognized alter table type: %d",
5003 bool recurse,
bool recursing,
LOCKMODE lockmode,
5016 if (rel->
rd_rel->relispartition &&
5021 errmsg(
"cannot alter partition \"%s\" with an incomplete detach",
5023 errhint(
"Use ALTER TABLE ... DETACH PARTITION ... FINALIZE to complete the pending detach operation."));
5250 errmsg(
"cannot change persistence setting twice")));
5267 errmsg(
"cannot have multiple SET ACCESS METHOD subcommands")));
5386 elog(
ERROR,
"unrecognized alter table type: %d",
5436 foreach(
lcmd, subcmds)
5439 lockmode,
pass, context);
5520 cmd->
recurse,
false, lockmode);
5573 cmd->
recurse,
false, lockmode);
5578 true,
true, lockmode);
5798 elog(
ERROR,
"unrecognized alter table type: %d",
5845 atstmt->relation->inh = recurse;
5848 atstmt->missing_ok =
false;
5882 switch (
cmd2->subtype)
5893 cmd2->recurse =
true;
5922 elog(
ERROR,
"ALTER TABLE scheduling failure: too late for pass %d",
5942 elog(
ERROR,
"ALTER TABLE scheduling failure: bogus item for pass %d",
6023 errmsg(
"cannot rewrite system relation \"%s\"",
6029 errmsg(
"cannot rewrite table \"%s\" used as a catalog table",
6041 errmsg(
"cannot rewrite temporary tables of other sessions")));
6102 persistence, lockmode);
6319 elog(
ERROR,
"unrecognized constraint type: %d",
6499 sizeof(
bool) *
oldslot->tts_nvalid);
6525 if (
ex->is_generated)
6547 if (!
ex->is_generated)
6579 errmsg(
"column \"%s\" of relation \"%s\" contains null values",
6599 errmsg(
"column \"%s\" of relation \"%s\" contains null values",
6616 errmsg(
"check constraint \"%s\" of relation \"%s\" is violated by some row",
6626 elog(
ERROR,
"unrecognized constraint type: %d",
6631 if (partqualstate && !
ExecCheck(partqualstate, econtext))
6636 errmsg(
"updated partition constraint for default partition \"%s\" would be violated by some row",
6642 errmsg(
"partition constraint of relation \"%s\" is violated by some row",
6650 ti_options, bistate);
6692 if (tab->
relid == relid)
6723 return "ADD COLUMN";
6726 return "ALTER COLUMN ... SET DEFAULT";
6728 return "ALTER COLUMN ... DROP NOT NULL";
6730 return "ALTER COLUMN ... SET NOT NULL";
6732 return "ALTER COLUMN ... SET EXPRESSION";
6734 return "ALTER COLUMN ... DROP EXPRESSION";
6736 return "ALTER COLUMN ... SET STATISTICS";
6738 return "ALTER COLUMN ... SET";
6740 return "ALTER COLUMN ... RESET";
6742 return "ALTER COLUMN ... SET STORAGE";
6744 return "ALTER COLUMN ... SET COMPRESSION";
6746 return "DROP COLUMN";
6754 return "ADD CONSTRAINT";
6756 return "ALTER CONSTRAINT";
6758 return "VALIDATE CONSTRAINT";
6760 return "DROP CONSTRAINT";
6764 return "ALTER COLUMN ... SET DATA TYPE";
6766 return "ALTER COLUMN ... OPTIONS";
6770 return "CLUSTER ON";
6772 return "SET WITHOUT CLUSTER";
6774 return "SET ACCESS METHOD";
6776 return "SET LOGGED";
6778 return "SET UNLOGGED";
6780 return "SET WITHOUT OIDS";
6782 return "SET TABLESPACE";
6790 return "ENABLE TRIGGER";
6792 return "ENABLE ALWAYS TRIGGER";
6794 return "ENABLE REPLICA TRIGGER";
6796 return "DISABLE TRIGGER";
6798 return "ENABLE TRIGGER ALL";
6800 return "DISABLE TRIGGER ALL";
6802 return "ENABLE TRIGGER USER";
6804 return "DISABLE TRIGGER USER";
6806 return "ENABLE RULE";
6808 return "ENABLE ALWAYS RULE";
6810 return "ENABLE REPLICA RULE";
6812 return "DISABLE RULE";
6816 return "NO INHERIT";
6822 return "REPLICA IDENTITY";
6824 return "ENABLE ROW SECURITY";
6826 return "DISABLE ROW SECURITY";
6828 return "FORCE ROW SECURITY";
6830 return "NO FORCE ROW SECURITY";
6834 return "ATTACH PARTITION";
6836 return "DETACH PARTITION";
6838 return "DETACH PARTITION ... FINALIZE";
6840 return "MERGE PARTITIONS";
6842 return "SPLIT PARTITION";
6844 return "ALTER COLUMN ... ADD IDENTITY";
6846 return "ALTER COLUMN ... SET";
6848 return "ALTER COLUMN ... DROP IDENTITY";
6868 switch (rel->
rd_rel->relkind)
6911 errmsg(
"ALTER action %s cannot be performed on relation \"%s\"",
6916 elog(
ERROR,
"invalid ALTER action attempted on relation \"%s\"",
6937 errmsg(
"cannot alter conflict log table \"%s\"",
6939 errdetail(
"Conflict log tables are system-managed tables for logical replication conflicts.")));
6944 errmsg(
"permission denied: \"%s\" is a system catalog",
6965 if (recurse && rel->
rd_rel->relhassubclass)
6978 foreach(child, children)
7044 foreach(child, children)
7152 for (
int attno = 1; attno <=
tupleDesc->natts; attno++)
7155 if (att->atttypid == typeOid && !att->attisdropped)
7182 errmsg(
"cannot alter type \"%s\" because column \"%s.%s\" uses it",
7189 errmsg(
"cannot alter type \"%s\" because column \"%s.%s\" uses it",
7196 errmsg(
"cannot alter foreign table \"%s\" because column \"%s.%s\" uses its row type",
7203 errmsg(
"cannot alter table \"%s\" because column \"%s.%s\" uses its row type",
7259 errmsg(
"cannot alter type \"%s\" because it is the type of a typed table",
7261 errhint(
"Use ALTER ... CASCADE to alter the typed tables too.")));
7307 errmsg(
"type %s is the row type of another table",
7309 errdetail(
"A typed table must use a stand-alone composite type created with CREATE TYPE.")));
7314 errmsg(
"type %s is not a composite type",
7338 if (rel->
rd_rel->reloftype && !recursing)
7341 errmsg(
"cannot add column to typed table")));
7365 bool if_not_exists = (*cmd)->missing_ok;
7388 if (rel->
rd_rel->relispartition && !recursing)
7391 errmsg(
"cannot add column to a partition")));
7401 if (
colDef->inhcount > 0)
7420 errmsg(
"child table \"%s\" has different type for column \"%s\"",
7426 errmsg(
"child table \"%s\" has different collation for column \"%s\"",
7437 errmsg(
"too many inheritance parents"));
7444 (
errmsg(
"merging definition of column \"%s\" for child \"%s\"",
7474 if (context !=
NULL && !recursing)
7497 errmsg(
"cannot recursively add identity column to table that has child tables")));
7512 errmsg(
"tables can have at most %d columns",
7568 false,
true,
false,
NULL);
7648 elog(
ERROR,
"failed to coerce base type to domain");
7741 if (children && !recurse)
7744 errmsg(
"column must be added to child tables too")));
7752 colDef->is_local =
false;
7757 foreach(child, children)
7814 errmsg(
"column name \"%s\" conflicts with a system column name",
7822 errmsg(
"column \"%s\" of relation \"%s\" already exists, skipping",
7829 errmsg(
"column \"%s\" of relation \"%s\" already exists",
7902 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
7920 errmsg(
"cannot alter system column \"%s\"",
7926 errmsg(
"column \"%s\" of relation \"%s\" is an identity column",
7932 if (rel->
rd_rel->relispartition)
7943 errmsg(
"column \"%s\" is marked NOT NULL in parent table",
7954 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation \"%s\"",
7996 if (attr->attisdropped)
7999 if (!attr->attnotnull)
8008 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
8016 attr->attnotnull =
true;
8055 bool recurse,
bool recursing,
LOCKMODE lockmode)
8063 bool is_no_inherit =
false;
8080 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8087 errmsg(
"cannot alter system column \"%s\"",
8100 if (
conForm->connoinherit && recurse)
8103 errmsg(
"cannot change NO INHERIT status of NOT NULL constraint \"%s\" on relation \"%s\"",
8118 errmsg(
"too many inheritance parents"));
8121 else if (!
conForm->conislocal)
8126 else if (!
conForm->convalidated)
8133 recurse, recursing, lockmode);
8165 errmsg(
"constraint must be added to child tables too"),
8166 errhint(
"Do not specify the ONLY keyword."));
8168 is_no_inherit =
true;
8190 false, !recursing,
false,
NULL);
8217 recurse,
true, lockmode);
8253 (
errmsg_internal(
"existing constraints on column \"%s.%s\" are sufficient to prove that it does not contain nulls",
8281 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8288 errmsg(
"cannot alter system column \"%s\"",
8294 errmsg(
"column \"%s\" of relation \"%s\" is an identity column",
8298 "ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY")));
8303 errmsg(
"column \"%s\" of relation \"%s\" is a generated column",
8307 errhint(
"Use %s instead.",
"ALTER TABLE ... ALTER COLUMN ... SET EXPRESSION") :
8309 errhint(
"Use %s instead.",
"ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION") : 0)));
8331 rawEnt->generated =
'\0';
8338 false,
true,
false,
NULL);
8382 Node *def,
LOCKMODE lockmode,
bool recurse,
bool recursing)
8393 if (ispartitioned && !recurse)
8396 errmsg(
"cannot add identity to a column of only the partitioned table"),
8397 errhint(
"Do not specify the ONLY keyword.")));
8399 if (rel->
rd_rel->relispartition && !recursing)
8402 errmsg(
"cannot add identity to a column of a partition"));
8410 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8419 errmsg(
"cannot alter system column \"%s\"",
8430 errmsg(
"column \"%s\" of relation \"%s\" must be declared NOT NULL before identity can be added",
8445 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation \"%s\"",
8452 errmsg(
"incompatible NOT VALID constraint \"%s\" on relation \"%s\"",
8454 errhint(
"You might need to validate it using %s.",
8455 "ALTER TABLE ... VALIDATE CONSTRAINT"));
8461 errmsg(
"column \"%s\" of relation \"%s\" is already an identity column",
8467 errmsg(
"column \"%s\" of relation \"%s\" already has a default value",
8486 if (recurse && ispartitioned)
8493 foreach(
lc, children)
8513 LOCKMODE lockmode,
bool recurse,
bool recursing)
8525 if (ispartitioned && !recurse)
8528 errmsg(
"cannot change identity column of only the partitioned table"),
8529 errhint(
"Do not specify the ONLY keyword.")));
8531 if (rel->
rd_rel->relispartition && !recursing)
8534 errmsg(
"cannot change identity column of a partition"));
8545 errmsg(
"conflicting or redundant options")));
8549 elog(
ERROR,
"option \"%s\" not recognized",
8564 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8573 errmsg(
"cannot alter system column \"%s\"",
8576 if (!
attTup->attidentity)
8579 errmsg(
"column \"%s\" of relation \"%s\" is not an identity column",
8610 foreach(
lc, children)
8630 bool recurse,
bool recursing)
8642 if (ispartitioned && !recurse)
8645 errmsg(
"cannot drop identity from a column of only the partitioned table"),
8646 errhint(
"Do not specify the ONLY keyword.")));
8648 if (rel->
rd_rel->relispartition && !recursing)
8651 errmsg(
"cannot drop identity from a column of a partition"));
8658 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8667 errmsg(
"cannot alter system column \"%s\"",
8670 if (!
attTup->attidentity)
8675 errmsg(
"column \"%s\" of relation \"%s\" is not an identity column",
8680 (
errmsg(
"column \"%s\" of relation \"%s\" is not an identity column, skipping",
8688 attTup->attidentity =
'\0';
8704 if (recurse && ispartitioned)
8711 foreach(
lc, children)
8761 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8770 errmsg(
"cannot alter system column \"%s\"",
8773 attgenerated =
attTup->attgenerated;
8777 errmsg(
"column \"%s\" of relation \"%s\" is not a generated column",
8794 errmsg(
"ALTER TABLE / SET EXPRESSION is not supported for virtual generated columns in tables that are part of a publication"),
8795 errdetail(
"Column \"%s\" of relation \"%s\" is a virtual generated column.",
8834 elog(
ERROR,
"could not find attrdef tuple for relation %u attnum %d",
8853 rawEnt->generated = attgenerated;
8857 false,
true,
false,
NULL);
8870 newval->is_generated =
true;
8907 errmsg(
"ALTER TABLE / DROP EXPRESSION must be applied to child tables too")));
8921 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8926 if (
attTup->attinhcount > 0)
8929 errmsg(
"cannot drop generation expression from inherited column")));
8951 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
8960 errmsg(
"cannot alter system column \"%s\"",
8972 errmsg(
"ALTER TABLE / DROP EXPRESSION is not supported for virtual generated columns"),
8973 errdetail(
"Column \"%s\" of relation \"%s\" is a virtual generated column.",
8976 if (!
attTup->attgenerated)
8981 errmsg(
"column \"%s\" of relation \"%s\" is not a generated column",
8986 (
errmsg(
"column \"%s\" of relation \"%s\" is not a generated column, skipping",
8998 attTup->attgenerated =
'\0';
9015 elog(
ERROR,
"could not find attrdef tuple for relation %u attnum %d",
9064 errmsg(
"cannot refer to non-index column by number")));
9084 errmsg(
"statistics target %d is too low",
9092 errmsg(
"lowering statistics target to %d",
9106 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9116 errmsg(
"column number %d of relation \"%s\" does not exist",
9126 errmsg(
"cannot alter system column \"%s\"",
9136 errmsg(
"cannot alter statistics on virtual generated column \"%s\"",
9145 errmsg(
"cannot alter statistics on included column \"%s\" of index \"%s\"",
9150 errmsg(
"cannot alter statistics on non-expression column \"%s\" of index \"%s\"",
9152 errhint(
"Alter statistics on table column instead.")));
9209 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9217 errmsg(
"cannot alter system column \"%s\"",
9282 for (
int i = 0;
i <
indrel->rd_index->indnatts;
i++)
9343 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9351 errmsg(
"cannot alter system column \"%s\"",
9395 if (rel->
rd_rel->reloftype && !recursing)
9398 errmsg(
"cannot drop column from typed table")));
9421 bool recurse,
bool recursing,
9422 bool missing_ok,
LOCKMODE lockmode,
9456 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
9462 (
errmsg(
"column \"%s\" of relation \"%s\" does not exist, skipping",
9475 errmsg(
"cannot drop system column \"%s\"",
9482 if (
targetatt->attinhcount > 0 && !recursing)
9485 errmsg(
"cannot drop inherited column \"%s\"",
9498 errmsg(
"cannot drop column \"%s\" because it is part of the partition key of relation \"%s\"",
9523 errmsg(
"cannot drop column from only the partitioned table when partitions exist"),
9524 errhint(
"Do not specify the ONLY keyword.")));
9527 foreach(child, children)
9539 elog(
ERROR,
"cache lookup failed for attribute \"%s\" of relation %u",
9544 elog(
ERROR,
"relation %u has non-inherited attribute \"%s\"",
9558 behavior,
true,
true,
9559 false, lockmode, addrs);
9598 object.objectSubId =
attnum;
9688 errmsg(
"column \"%s\" of table \"%s\" is not marked NOT NULL",
9724 errmsg(
"cannot create primary key on column \"%s\"", colname),
9726 errdetail(
"The constraint \"%s\" on column \"%s\" of table \"%s\", marked %s, is incompatible with a primary key.",
9729 errhint(
"You might need to make the existing constraint inheritable using %s.",
9730 "ALTER TABLE ... ALTER CONSTRAINT ... INHERIT"));
9736 errmsg(
"cannot create primary key on column \"%s\"", colname),
9738 errdetail(
"The constraint \"%s\" on column \"%s\" of table \"%s\", marked %s, is incompatible with a primary key.",
9741 errhint(
"You might need to validate it using %s.",
9742 "ALTER TABLE ... VALIDATE CONSTRAINT"));
9863 errmsg(
"ALTER TABLE / ADD CONSTRAINT USING INDEX is not supported on partitioned tables")));
9888 (
errmsg(
"ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index \"%s\" to \"%s\"",
9967 errmsg(
"constraint \"%s\" for relation \"%s\" already exists",
9986 elog(
ERROR,
"unrecognized constraint type: %d",
10013 foreach(
lc, colnames)
10018 buf[buflen++] =
'_';
10049 Constraint *constr,
bool recurse,
bool recursing,
10156 if (!recurse && children !=
NIL)
10159 errmsg(
"constraint must be added to child tables too")));
10164 foreach(child, children)
10179 constr, recurse,
true,
is_readd, lockmode);
10205 bool recurse,
bool recursing,
LOCKMODE lockmode)
10246 errmsg(
"cannot use ONLY for foreign key on partitioned table \"%s\" referencing relation \"%s\"",
10254 errmsg(
"referenced relation \"%s\" is not a table",
10265 errmsg(
"cannot reference conflict log table \"%s\"",
10267 errdetail(
"Conflict log tables are system-managed tables for logical replication conflicts.")));
10272 errmsg(
"permission denied: \"%s\" is a system catalog",
10283 switch (rel->
rd_rel->relpersistence)
10289 errmsg(
"constraints on permanent tables may reference only permanent tables")));
10296 errmsg(
"constraints on unlogged tables may reference only permanent or unlogged tables")));
10302 errmsg(
"constraints on temporary tables may reference only temporary tables")));
10306 errmsg(
"constraints on temporary tables must involve temporary tables of this session")));
10321 errmsg(
"foreign key uses PERIOD on the referenced table but not the referencing table"));
10349 errmsg(
"foreign key uses PERIOD on the referenced table but not the referencing table"));
10361 errmsg(
"foreign key uses PERIOD on the referencing table but not the referenced table"));
10375 errmsg(
"foreign key must use PERIOD when referencing a primary key using WITHOUT OVERLAPS"));
10399 errmsg(
"invalid %s action for foreign key constraint containing generated column",
10405 errmsg(
"invalid %s action for foreign key constraint containing generated column",
10420 errmsg(
"foreign key constraints on virtual generated columns are not supported")));
10434 errmsg(
"unsupported %s action for foreign key constraint using PERIOD",
10443 errmsg(
"unsupported %s action for foreign key constraint using PERIOD",
10458 errmsg(
"number of referencing and referenced columns for foreign key disagree")));
10493 opfamily =
cla_tup->opcfamily;
10494 opcintype =
cla_tup->opcintype;
10514 ?
errmsg(
"could not identify an overlaps operator for foreign key")
10515 :
errmsg(
"could not identify an equality operator for foreign key"),
10516 errdetail(
"Could not translate compare type %d for operator family \"%s\" of access method \"%s\".",
10527 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
10528 eqstrategy, opcintype, opcintype, opfamily);
10580 errmsg(
"foreign key constraint \"%s\" cannot be implemented",
10582 errdetail(
"Key columns \"%s\" of the referencing table and \"%s\" of the referenced table "
10583 "are of incompatible types: %s and %s.",
10594 elog(
ERROR,
"key columns are not both collatable");
10614 errmsg(
"foreign key constraint \"%s\" cannot be implemented",
fkconstraint->conname),
10615 errdetail(
"Key columns \"%s\" of the referencing table and \"%s\" of the referenced table "
10616 "have incompatible collations: \"%s\" and \"%s\". "
10617 "If either collation is nondeterministic, then both collations have to be the same.",
10821 errmsg(
"column \"%s\" referenced in ON DELETE SET action must be part of foreign key",
col)));
10893 errmsg(
"referenced relation \"%s\" is not a table",
10910 conname = constraintname;
10917 conislocal =
false;
11115 elog(
ERROR,
"index for %u not found in partition %s",
11205 errmsg(
"foreign key constraints are not supported on foreign tables")));
11244 newcon->refindid = indexOid;
11444 foreach(cell,
clone)
11534 elog(
ERROR,
"index for %u not found in partition %s",
11621 errmsg(
"cannot attach table \"%s\" as a partition because it is referenced by foreign key \"%s\"",
11638 errmsg(
"foreign key constraints are not supported on foreign tables")));
11658 foreach(cell,
clone)
11684 elog(
ERROR,
"cache lookup failed for constraint %u",
11888 elog(
ERROR,
"cache lookup failed for constraint %u",
fk->conoid);
11902 errmsg(
"constraint \"%s\" enforceability conflicts with constraint \"%s\" on relation \"%s\"",
12085 true,
NULL, 1, &key);
12091 if (
conform->conparentid != conoid)
12220 Oid conoid,
Oid confrelid,
Oid conrelid,
12240 if (
trgform->tgconstrrelid != conrelid)
12242 if (
trgform->tgrelid != confrelid)
12257#ifndef USE_ASSERT_CHECKING
12265 elog(
ERROR,
"could not find ON DELETE action trigger of foreign key constraint %u",
12268 elog(
ERROR,
"could not find ON UPDATE action trigger of foreign key constraint %u",
12281 Oid conoid,
Oid confrelid,
Oid conrelid,
12301 if (
trgform->tgconstrrelid != confrelid)
12303 if (
trgform->tgrelid != conrelid)
12318#ifndef USE_ASSERT_CHECKING
12326 elog(
ERROR,
"could not find ON INSERT check triggers of foreign key constraint %u",
12329 elog(
ERROR,
"could not find ON UPDATE check triggers of foreign key constraint %u",
12364 errmsg(
"constraint must be altered in child tables too"),
12365 errhint(
"Do not specify the ONLY keyword."));
12393 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
12400 errmsg(
"constraint \"%s\" of relation \"%s\" is not a foreign key constraint",
12402 if (
cmdcon->alterEnforceability &&
12406 errmsg(
"cannot alter enforceability of constraint \"%s\" of relation \"%s\"",
12408 errhint(
"Only foreign key and check constraints can change enforceability.")));
12409 if (
cmdcon->alterInheritability &&
12413 errmsg(
"constraint \"%s\" of relation \"%s\" is not a not-null constraint",
12415 if (
cmdcon->alterInheritability &&
12419 errmsg(
"not-null constraint \"%s\" on partitioned table \"%s\" cannot be NO INHERIT",
12423 if (
cmdcon->alterInheritability &&
12427 errmsg(
"cannot alter inherited constraint \"%s\" on relation \"%s\"",
12461 parent =
contup->conparentid;
12467 errmsg(
"cannot alter constraint \"%s\" on relation \"%s\"",
12470 errdetail(
"Constraint \"%s\" is derived from constraint \"%s\" of relation \"%s\".",
12472 errhint(
"You may alter the constraint it derives from instead.")));
12520 if (
cmdcon->alterEnforceability)
12534 else if (
cmdcon->alterDeferrability &&
12554 if (
cmdcon->alterInheritability &&
12609 if (!
cmdcon->is_enforced)
12719 bool recurse,
bool recursing,
12759 if (!
cmdcon->is_enforced &&
12760 (!recursing || !rel->
rd_rel->relispartition) &&
12768 errmsg(
"cannot mark inherited constraint \"%s\" as %s",
12771 errdetail(
"The matching constraint on parent table \"%s\" is %s.",
12807 if (!recursing && !
currcon->connoinherit)
12820 if (!
cmdcon->is_enforced)
12837 errmsg(
"constraint must be altered on child tables too"),
12838 errhint(
"Do not specify the ONLY keyword."));
12851 if (!
cmdcon->is_enforced)
12918 bool recurse,
bool recursing,
12945 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
12978 if (
currcon->coninhcount <= 0)
13014 true,
NULL, 3, pkey);
13033 elog(
ERROR,
"child table \"%s\" has different definition for check constraint \"%s\"",
13045 if (!rel->
rd_rel->relispartition &&
13107 refrelid =
currcon->confrelid;
13196 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation %u",
13210 colName,
true,
true, lockmode);
13229 bool deferrable,
bool initdeferred,
13273 copy_tg->tgdeferrable = deferrable;
13274 copy_tg->tginitdeferred = initdeferred;
13321 true,
NULL, 1, &pkey);
13366 true,
NULL, 1, &pkey);
13395 cmdcon->alterInheritability);
13400 if (
cmdcon->alterEnforceability)
13413 if (
cmdcon->alterDeferrability)
13418 if (
cmdcon->alterInheritability)
13443 bool recurse,
bool recursing,
LOCKMODE lockmode)
13476 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
13485 errmsg(
"cannot validate constraint \"%s\" of relation \"%s\"",
13487 errdetail(
"This operation is not supported for this type of constraint."));
13489 if (!con->conenforced)
13492 errmsg(
"cannot validate NOT ENFORCED constraint")));
13494 if (!con->convalidated)
13504 tuple, recurse, recursing, lockmode);
13509 tuple, recurse, recursing, lockmode);
13545 Assert(!con->convalidated);
13570 newcon->refrelid = con->confrelid;
13571 newcon->refindid = con->conindid;
13572 newcon->conid = con->oid;
13598 true,
NULL, 1, &pkey);
13656 bool recurse,
bool recursing,
LOCKMODE lockmode)
13677 if (!recursing && !con->connoinherit)
13688 foreach(child, children)
13704 errmsg(
"constraint must be validated on child tables too")));
13720 newcon->conid = con->oid;
13782 if (!recursing && !con->connoinherit)
13804 errmsg(
"constraint must be validated on child tables too"));
13812 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation \"%s\"",
13824 false,
true, lockmode);
13881 errmsg(
"column \"%s\" referenced in foreign key constraint does not exist",
13887 errmsg(
"system columns cannot be used in foreign keys")));
13891 errmsg(
"cannot have more than %d keys in a foreign key",
13947 elog(
ERROR,
"cache lookup failed for index %u", indexoid);
13959 errmsg(
"cannot use a deferrable primary key for referenced table \"%s\"",
13962 *indexOid = indexoid;
13976 errmsg(
"there is no primary key for referenced table \"%s\"",
14028 bool found =
false;
14046 if (attnums[
i] == attnums[
j])
14049 errmsg(
"foreign key referenced-columns list must not contain duplicates")));
14068 elog(
ERROR,
"cache lookup failed for index %u", indexoid);
14152 errmsg(
"cannot use a deferrable unique constraint for referenced table \"%s\"",
14157 errmsg(
"there is no unique constraint matching given keys for referenced table \"%s\"",
14188 elog(
ERROR,
"could not find cast from %u to %u",
14214 for (
i = 0;
i < natts;
i++)
14246 (
errmsg_internal(
"validating foreign key constraint \"%s\"", conname)));
14252 trig.tgname = conname;
14254 trig.tgisinternal =
true;
14258 trig.tgdeferrable =
false;
14259 trig.tginitdeferred =
false;
14281 "validateForeignKeyConstraint",
14309 fcinfo->context = (
Node *) &trigdata;
14350 fk_trigger->trigname =
"RI_ConstraintTrigger_c";
14409 fk_trigger->trigname =
"RI_ConstraintTrigger_a";
14448 elog(
ERROR,
"unrecognized FK action type: %d",
14469 fk_trigger->trigname =
"RI_ConstraintTrigger_a";
14508 elog(
ERROR,
"unrecognized FK action type: %d",
14551 bool missing_ok,
LOCKMODE lockmode)
14557 bool found =
false;
14583 missing_ok, lockmode);
14594 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
14598 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist, skipping",
14615 bool recurse,
bool recursing,
bool missing_ok,
14624 char *colname =
NULL;
14640 if (con->coninhcount > 0 && !recursing)
14643 errmsg(
"cannot drop inherited constraint \"%s\" of relation \"%s\"",
14684 for (
int i = 0;
i <
pk->rd_index->indnkeyatts;
i++)
14695 errmsg(
"column \"%s\" is in a primary key",
14703 errmsg(
"column \"%s\" is in index used as replica identity",
14709 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
14712 if (
attForm->attidentity !=
'\0')
14715 errmsg(
"column \"%s\" of relation \"%s\" is an identity column",
14796 elog(
ERROR,
"cache lookup failed for not-null constraint on column \"%s\" of relation %u",
14823 errmsg(
"constraint \"%s\" of relation \"%s\" does not exist",
14835 elog(
ERROR,
"inherited constraint is not a CHECK or not-null constraint");
14838 elog(
ERROR,
"relation %u has non-inherited constraint \"%s\"",
14851 recurse,
true, missing_ok,
14912 bool recurse,
bool recursing,
14924 int32 targettypmod;
14933 if (rel->
rd_rel->reloftype && !recursing)
14936 errmsg(
"cannot alter column type of typed table"),
14944 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
14964 errmsg(
"cannot specify USING when altering type of generated column"),
14973 if (
attTup->attinhcount > 0 && !recursing)
14985 errmsg(
"cannot alter column \"%s\" because it is part of the partition key of relation \"%s\"",
15030 targettype, targettypmod,
15034 if (transform ==
NULL)
15040 errmsg(
"result of USING clause for column \"%s\""
15041 " cannot be cast automatically to type %s",
15043 errhint(
"You might need to add an explicit cast.")));
15047 errmsg(
"column \"%s\" cannot be cast automatically to type %s",
15051 errhint(
"You might need to specify \"USING %s::%s\".",
15054 targettypmod)) : 0));
15073 newval->is_generated =
false;
15079 else if (transform)
15082 errmsg(
"\"%s\" is not a table",
15147 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
15154 errmsg(
"cannot alter inherited column \"%s\" of relation \"%s\"",
15166 bool found_whole_row;
15179 if (found_whole_row)
15182 errmsg(
"cannot convert whole-row table reference"),
15183 errdetail(
"USING expression contains a whole-row table reference.")));
15190 else if (!recursing &&
15194 errmsg(
"type of inherited column \"%s\" must be changed in child tables too",
15223 if (
IsA(expr,
Var) && ((
Var *) expr)->varattno == varattno)
15276 int32 targettypmod;
15308 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
15319 errmsg(
"cannot alter type of column \"%s\" twice",
15325 targettype =
tform->oid;
15348 targettype, targettypmod,
15354 if (
attTup->attgenerated)
15357 errmsg(
"generation expression for column \"%s\" cannot be cast automatically to type %s",
15362 errmsg(
"default for column \"%s\" cannot be cast automatically to type %s",
15413 elog(
ERROR,
"found unexpected dependency type '%c'",
15419 elog(
ERROR,
"found unexpected dependency for column: %s",
15434 if (
attTup->atthasmissing)
15493 attTup->atttypid = targettype;
15494 attTup->atttypmod = targettypmod;
15499 errmsg(
"too many array dimensions"));
15539 if (
attTup->attgenerated)
15544 elog(
ERROR,
"could not find attrdef tuple for relation %u attnum %d",
15640 elog(
ERROR,
"unexpected object depending on column: %s",
15666 errmsg(
"cannot alter type of a column used by a function or procedure"),
15667 errdetail(
"%s depends on column \"%s\"",
15681 errmsg(
"cannot alter type of a column used by a view or rule"),
15682 errdetail(
"%s depends on column \"%s\"",
15701 errmsg(
"cannot alter type of a column used in a trigger definition"),
15702 errdetail(
"%s depends on column \"%s\"",
15720 errmsg(
"cannot alter type of a column used in a policy definition"),
15721 errdetail(
"%s depends on column \"%s\"",
15751 errmsg(
"cannot alter type of a column used by a generated column"),
15752 errdetail(
"Column \"%s\" is used by generated column \"%s\".",
15779 errmsg(
"cannot alter type of a column used by a publication WHERE clause"),
15780 errdetail(
"%s depends on column \"%s\"",
15791 elog(
ERROR,
"unexpected object depending on column: %s",
15857 elog(
ERROR,
"null conbin for relation \"%s\"",
15980 elog(
ERROR,
"relation %u has multiple indexes marked as replica identity", tab->
relid);
15995 elog(
ERROR,
"relation %u has multiple clustered indexes", tab->
relid);
16186 relid = con->conrelid;
16192 elog(
ERROR,
"could not identify relation associated with constraint %u",
oldId);
16194 confrelid = con->confrelid;
16195 conislocal = con->conislocal;
16217 if (relid != tab->
relid)
16236 if (relid != tab->
relid)
16266 if (relid != tab->
relid)
16407 stmt->reset_default_tblspc =
true;
16439 indstmt->reset_default_tblspc =
true;
16460 !rewrite && tab->
rewrite == 0)
16484 elog(
ERROR,
"unexpected statement subtype: %d",
16511 elog(
ERROR,
"unexpected statement subtype: %d",
16512 (
int)
stmt->subtype);
16529 elog(
ERROR,
"unexpected statement type: %d",
16549 const char *conname)
16594 stmt->accessMethod,
16596 stmt->excludeOpNames,
16597 stmt->iswithoutoverlaps))
16644 elog(
ERROR,
"conpfeqop is not a 1-D Oid array");
16648 for (
i = 0;
i < numkeys;
i++)
16690 errmsg(
"foreign table \"%s\" does not exist",
16704 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
16733 fdw->fdwvalidator);
16795 elog(
ERROR,
"cache lookup failed for relation %u", relationOid);
16822 errmsg(
"cannot change owner of index \"%s\"",
16824 errhint(
"Change the ownership of the index's table instead.")));
16834 errmsg(
"cannot change owner of index \"%s\"",
16836 errhint(
"Change the ownership of the index's table instead.")));
16850 errmsg(
"cannot change owner of sequence \"%s\"",
16852 errdetail(
"Sequence \"%s\" is linked to table \"%s\".",
16862 errmsg(
"\"%s\" is a composite type",
16875 errmsg(
"cannot change owner of relation \"%s\"",
17032 true,
NULL, 1, key);
17045 if (att->attisdropped)
17116 if (
depForm->refobjsubid == 0 ||
17163 errmsg(
"index \"%s\" for table \"%s\" does not exist",
17206 if (amname !=
NULL)
17250 elog(
ERROR,
"cache lookup failed for relation %u", reloid);
17342 errmsg(
"cannot have multiple SET TABLESPACE subcommands")));
17374 elog(
ERROR,
"cache lookup failed for relation %u", relid);
17400 switch (rel->
rd_rel->relkind)
17421 errmsg(
"cannot set options for relation \"%s\"",
17433 bool check_option =
false;
17440 check_option =
true;
17455 errmsg(
"WITH CHECK OPTION is supported only on automatically updatable views"),
17597 rel->
rd_rel->relpersistence);
17708 errmsg(
"only tables, indexes, and materialized views exist in tablespaces")));
17720 errmsg(
"cannot move relations in to or out of pg_global tablespace")));
17814 if (
stmt->nowait &&
17818 errmsg(
"aborting because lock on relation \"%s.%s\" is not available",
17831 if (relations ==
NIL)
17834 errmsg(
"no matching relations in tablespace \"%s\" found",
17839 foreach(l, relations)
17845 cmd->
name =
stmt->new_tablespacename;
17882 rel->
rd_rel->relpersistence);
17901 rel->
rd_rel->relpersistence);
17954 errmsg(
"cannot change inheritance of typed table")));
17959 errmsg(
"cannot change inheritance of a partition")));
17993 errmsg(
"cannot inherit from temporary relation \"%s\"",
18000 errmsg(
"cannot inherit from temporary relation of another session")));
18006 errmsg(
"cannot inherit to temporary relation of another session")));
18012 errmsg(
"cannot inherit from partitioned table \"%s\"",
18019 errmsg(
"cannot inherit from a partition")));
18041 errmsg(
"circular inheritance not allowed"),
18042 errdetail(
"\"%s\" is already a child of \"%s\".",
18055 errmsg(
"trigger \"%s\" prevents table \"%s\" from becoming an inheritance child",
18057 errdetail(
"ROW triggers with transition tables are not supported in inheritance hierarchies.")));
18107 true,
NULL, 1, &key);
18118 errmsg(
"relation \"%s\" would be inherited from more than once",
18161 elog(
ERROR,
"null conbin for constraint %u", con->oid);
18184 if (
acon->condeferrable !=
bcon->condeferrable ||
18185 acon->condeferred !=
bcon->condeferred ||
18236 errmsg(
"child table \"%s\" has different type for column \"%s\"",
18242 errmsg(
"child table \"%s\" has different collation for column \"%s\"",
18261 errmsg(
"column \"%s\" in child table \"%s\" must be marked NOT NULL",
18281 errdetail(
"Parent column is %s, child column is %s.",
18301 errmsg(
"too many inheritance parents"));
18376 bool found =
false;
18431 elog(
ERROR,
"found not-null constraint on dropped columns");
18438 errmsg(
"child table \"%s\" has different definition for check constraint \"%s\"",
18447 errmsg(
"constraint \"%s\" conflicts with non-inherited constraint on child table \"%s\"",
18458 errmsg(
"constraint \"%s\" conflicts with NOT VALID constraint on child table \"%s\"",
18469 errmsg(
"constraint \"%s\" conflicts with NOT ENFORCED constraint on child table \"%s\"",
18483 errmsg(
"too many inheritance parents"));
18510 errmsg(
"column \"%s\" in child table \"%s\" must be marked NOT NULL",
18518 errmsg(
"child table is missing constraint \"%s\"",
18576 bool found =
false;
18590 true,
NULL, 1, &key);
18597 if (
inhForm->inhdetachpending)
18600 errmsg(
"partition \"%s\" already pending detach in partitioned table \"%s.%s\"",
18604 errhint(
"Use ALTER TABLE ... DETACH PARTITION ... FINALIZE to complete the pending detach operation."));
18629 errmsg(
"relation \"%s\" is not a partition of relation \"%s\"",
18677 errmsg(
"relation \"%s\" is not a partition of relation \"%s\"",
18683 errmsg(
"relation \"%s\" is not a parent of relation \"%s\"",
18697 true,
NULL, 1, key);
18703 if (att->attisdropped)
18705 if (att->attinhcount <= 0)
18745 true,
NULL, 1, key);
18754 if (con->connoinherit)
18775 true,
NULL, 1, key);
18780 bool match =
false;
18823 elog(
ERROR,
"relation %u has non-inherited constraint \"%s\"",
18837 elog(
ERROR,
"%d unmatched constraints while removing inheritance from \"%s\" to \"%s\"",
18898 dep->refobjid == refobjid &&
18899 dep->refobjsubid == 0 &&
18900 dep->deptype == deptype)
18950 true,
NULL, 1, &key);
18954 errmsg(
"typed tables cannot inherit")));
18984 errmsg(
"table is missing column \"%s\"",
18995 errmsg(
"table has column \"%s\" where type requires \"%s\"",
19004 errmsg(
"table \"%s\" has different type for column \"%s\"",
19018 errmsg(
"table has extra column \"%s\"",
19023 if (rel->
rd_rel->reloftype)
19040 elog(
ERROR,
"cache lookup failed for relation %u", relid);
19070 errmsg(
"\"%s\" is not a typed table",
19085 elog(
ERROR,
"cache lookup failed for relation %u", relid);
19123 elog(
ERROR,
"cache lookup failed for relation \"%s\"",
19141 bool dirty =
false;
19219 elog(
ERROR,
"unexpected identity type %u",
stmt->identity_type);
19226 errmsg(
"index \"%s\" for table \"%s\" does not exist",
19236 errmsg(
"\"%s\" is not an index for table \"%s\"",
19246 !indexRel->
rd_index->indisunique) &&
19250 errmsg(
"cannot use non-unique index \"%s\" as replica identity",
19253 if (!indexRel->
rd_index->indimmediate)
19256 errmsg(
"cannot use non-immediate index \"%s\" as replica identity",
19262 errmsg(
"cannot use expression index \"%s\" as replica identity",
19268 errmsg(
"cannot use partial index \"%s\" as replica identity",
19285 errmsg(
"index \"%s\" cannot be used as replica identity because column %d is a system column",
19289 if (!attr->attnotnull)
19292 errmsg(
"index \"%s\" cannot be used as replica identity because column \"%s\" is nullable",
19321 elog(
ERROR,
"cache lookup failed for relation %u", relid);
19350 elog(
ERROR,
"cache lookup failed for relation %u", relid);
19389 errmsg(
"foreign table \"%s\" does not exist",
19411 fdw->fdwvalidator);
19469 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
19478 errmsg(
"cannot alter system column \"%s\"",
column)));
19536 switch (rel->
rd_rel->relpersistence)
19541 errmsg(
"cannot change logged status of table \"%s\" because it is temporary",
19565 errmsg(
"cannot change table \"%s\" to unlogged because it is part of a publication",
19567 errdetail(
"Unlogged relations cannot be replicated.")));
19612 errmsg(
"could not change table \"%s\" to logged because it references unlogged table \"%s\"",
19622 errmsg(
"could not change table \"%s\" to unlogged because it references logged table \"%s\"",
19667 (
errmsg(
"relation \"%s\" does not exist, skipping",
19668 stmt->relation->relname)));
19686 errmsg(
"cannot move an owned sequence into another schema"),
19687 errdetail(
"Sequence \"%s\" is linked to table \"%s\".",
19770 elog(
ERROR,
"cache lookup failed for relation %u", relOid);
19794 errmsg(
"relation \"%s\" already exists in schema \"%s\"",
19812 elog(
ERROR,
"could not change schema dependency for relation \"%s\"",
19913 if (
depForm->refobjsubid == 0 ||
19980 oc->oncommit = action;
20008 if (
oc->relid == relid)
20037 switch (
oc->oncommit)
20080 object.objectSubId = 0;
20102#ifdef USE_ASSERT_CHECKING
20219 errmsg(
"\"%s\" is not a table or materialized view", relation->
relname)));
20244 elog(
ERROR,
"cache lookup failed for relation %u", relId);
20268 elog(
ERROR,
"cache lookup failed for relation %u", relId);
20282 errmsg(
"cannot change conflict log table \"%s\"",
20284 errdetail(
"Conflict log tables are system-managed tables for logical replication conflicts.")));
20290 errmsg(
"permission denied: \"%s\" is a system catalog",
20329 errmsg(
"cannot alter conflict log table \"%s\"",
20331 errdetail(
"Conflict log tables are system-managed tables for logical replication conflicts.")));
20337 errmsg(
"permission denied: \"%s\" is a system catalog",
20386 errmsg(
"\"%s\" is not a materialized view", rv->
relname)));
20431 errmsg(
"cannot change schema of index \"%s\"",
20433 errhint(
"Change the schema of the table instead.")));
20437 errmsg(
"cannot change schema of composite type \"%s\"",
20445 errmsg(
"cannot change schema of TOAST table \"%s\"",
20447 errhint(
"Change the schema of the table instead.")));
20477 errmsg(
"cannot use \"list\" partition strategy with more than one column")));
20485 NULL,
false,
true);
20526 foreach(
lc, partParams)
20543 errmsg(
"column \"%s\" named in partition key does not exist",
20551 errmsg(
"cannot use system column \"%s\" in partition key",
20565 errmsg(
"cannot use generated column in partition key"),
20566 errdetail(
"Column \"%s\" is a generated column.",
20572 attcollation =
attform->attcollation;
20595 atttype, attcollation,
20634 errmsg(
"partition key expressions cannot contain system column references")));
20647 errmsg(
"cannot use generated column in partition key"),
20648 errdetail(
"Column \"%s\" is a generated column.",
20654 ((
Var *) expr)->varattno > 0)
20661 partattrs[
attn] = ((
Var *) expr)->varattno;
20665 partattrs[
attn] = 0;
20666 *partexprs =
lappend(*partexprs, expr);
20698 errmsg(
"functions in partition key expression must be marked IMMUTABLE")));
20707 errmsg(
"cannot use constant expression as partition key")));
20714 if (
pelem->collation)
20728 errmsg(
"could not determine which collation to use for partition expression"),
20729 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
20736 errmsg(
"collations are not supported by type %s",
20740 partcollation[
attn] = attcollation;
20752 if (!
pelem->opclass)
20761 errmsg(
"data type %s has no default operator class for access method \"%s\"",
20763 errhint(
"You must specify a hash operator class or define a default hash operator class for the data type.")));
20767 errmsg(
"data type %s has no default operator class for access method \"%s\"",
20769 errhint(
"You must specify a btree operator class or define a default btree operator class for the data type.")));
20802 for (
i = 1;
i <= natts;
i++)
20825 ntest->argisrow =
false;
20854 for (
i = 0;
i < num_check;
i++)
20911 bool validate_default)
20919 if (!validate_default)
20921 (
errmsg_internal(
"partition constraint for table \"%s\" is implied by existing constraints",
20925 (
errmsg_internal(
"updated partition constraint for default partition \"%s\" is implied by existing constraints",
21064 errmsg(
"\"%s\" is already a partition",
21070 errmsg(
"cannot attach a typed table as partition")));
21098 errmsg_plural(
"cannot attach table \"%s\" as partition because it is referenced in publication %s EXCEPT clause",
21099 "cannot attach table \"%s\" as partition because it is referenced in publications %s EXCEPT clause",
21103 errdetail(
"The publication EXCEPT clause cannot contain tables that are partitions."),
21104 errhint(
"Change the publication's EXCEPT clause using ALTER PUBLICATION ... SET ALL TABLES."));
21123 errmsg(
"cannot attach inheritance child as partition")));
21137 errmsg(
"cannot attach inheritance parent as partition")));
21161 errmsg(
"circular inheritance not allowed"),
21162 errdetail(
"\"%s\" is already a child of \"%s\".",
21171 errmsg(
"cannot attach a temporary relation as partition of permanent relation \"%s\"",
21179 errmsg(
"cannot attach a permanent relation as partition of temporary relation \"%s\"",
21186 errmsg(
"cannot attach as partition of temporary relation of another session")));
21192 errmsg(
"cannot attach temporary relation of another session as partition")));
21200 for (attno = 1; attno <= natts; attno++)
21212 errmsg(
"table \"%s\" being attached contains an identity column \"%s\"",
21214 errdetail(
"The new partition may not contain an identity column."));
21222 errmsg(
"table \"%s\" contains column \"%s\" not found in parent \"%s\"",
21225 errdetail(
"The new partition may contain only the columns present in parent.")));
21237 errmsg(
"trigger \"%s\" prevents table \"%s\" from becoming a partition",
21239 errdetail(
"ROW triggers with transition tables are not supported on partitions.")));
21247 cmd->
bound, pstate);
21370 "AttachPartitionEnsureIndexes",
21396 foreach(cell,
idxes)
21401 if (
idxRel->rd_index->indisunique ||
21402 idxRel->rd_index->indisprimary)
21405 errmsg(
"cannot attach foreign table \"%s\" as partition of partitioned table \"%s\"",
21408 errdetail(
"Partitioned table \"%s\" contains unique indexes.",
21420 foreach(cell,
idxes)
21426 bool found =
false;
21466 idxRel->rd_indcollation,
21522 true,
false,
false,
false,
false);
21554 true,
NULL, 1, &key);
21588 elog(
ERROR,
"unexpected trigger \"%s\" found",
21636 elog(
ERROR,
"tgargs is null for trigger \"%s\" in partition \"%s\"",
21668 false,
true,
trigForm->tgenabled);
21732 errmsg(
"cannot detach partitions concurrently when a default partition exists")));
21830 if (partRel !=
NULL)
21831 elog(
WARNING,
"dangling partition \"%s\" remains, can't fix",
21835 errmsg(
"partitioned table \"%s\" was removed concurrently",
21838 if (partRel ==
NULL)
21931 elog(
ERROR,
"cache lookup failed for constraint %u",
fk->conoid);
21958 if (
fk->conenforced)
21964 fk->conoid,
fk->confrelid,
fk->conrelid,
22088 foreach(cell, indexes)
22126 elog(
ERROR,
"cache lookup failed for relation %u",
22152 if (!attr->attisdropped && attr->attidentity)
22192 foreach(cell, children)
22322 if (!
state->lockedParentTbl)
22325 state->lockedParentTbl =
true;
22386 state.lockedParentTbl =
false;
22395 errmsg(
"index \"%s\" does not exist",
name->relname)));
22432 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
22435 errdetail(
"Index \"%s\" is already attached to another index.",
22452 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
22455 errdetail(
"Index \"%s\" is not an index on any partition of table \"%s\".",
22473 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
22476 errdetail(
"The index definitions do not match.")));
22492 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
22495 errdetail(
"The index \"%s\" belongs to a constraint in table \"%s\" but no constraint exists for index \"%s\".",
22505 if (parentIdx->
rd_index->indisprimary)
22518 else if (!parentIdx->
rd_index->indisvalid)
22549 errmsg(
"cannot attach index \"%s\" as a partition of index \"%s\"",
22552 errdetail(
"Another index \"%s\" is already attached for partition \"%s\".",
22620 elog(
ERROR,
"cache lookup failed for index %u",
22668 for (
int i = 0;
i <
iinfo->ii_NumIndexKeyAttrs;
i++)
22671 iinfo->ii_IndexAttrNumbers[
i] - 1);
22673 if (!att->attnotnull)
22676 errmsg(
"invalid primary key definition"),
22677 errdetail(
"Column \"%s\" of relation \"%s\" is not marked NOT NULL.",
22732 return constraints;
22748 foreach(cell, constraints)
22770 trig.tgisinternal =
true;
22774 trig.tgdeferrable =
false;
22775 trig.tginitdeferred =
false;
22794 if (compression ==
NULL ||
strcmp(compression,
"default") == 0)
22812 errmsg(
"column data type %s does not support compression",
22819 errmsg(
"invalid compression method \"%s\"", compression)));
22845 errmsg(
"invalid storage type \"%s\"",
22855 errmsg(
"column data type %s can only have storage PLAIN",
22876 switch (con->contype)
22890 elog(
ERROR,
"unrecognized constraint type: %d",
22891 (
int) con->contype);
22915 if (!
ex->is_generated)
22926 switch (con->contype)
22929 if (!
ExecCheck(con->qualstate, econtext))
22932 errmsg(
"check constraint \"%s\" of relation \"%s\" is violated by some row",
22941 elog(
ERROR,
"unrecognized constraint type: %d",
22942 (
int) con->contype);
23044 bool found_whole_row;
23055 elog(
ERROR,
"default expression not found for attribute %d of relation \"%s\"",
23062 if (found_whole_row &&
attribute->attgenerated !=
'\0')
23063 elog(
ERROR,
"cannot convert whole-row table reference");
23094 bool found_whole_row;
23112 if (found_whole_row)
23113 elog(
ERROR,
"Constraint \"%s\" contains a whole-row reference to table \"%s\".",
23129 constraints =
lappend(constraints, con);
23134 false,
true,
false,
NULL);
23147 if (!
ccon->skip_validation)
23181 List *nnconstraints;
23229 errmsg(
"cannot create as partition of temporary relation of another session"));
23258 errmsg(
"cannot create a temporary relation as partition of permanent relation \"%s\"",
23266 errmsg(
"cannot create a permanent relation as partition of temporary relation \"%s\"",
23295 errmsg(
"only shared relations can be placed in pg_global tablespace")));
23452 sizeof(
bool) *
srcslot->tts_nvalid);
23475 ti_options, bistate);
23566 if (
ea->parentIndexOid !=
eb->parentIndexOid)
23613 Oid parentIndexOid;
23655 errmsg(
"cannot merge partitions with conflicting extension dependencies"),
23656 errdetail(
"Partition indexes \"%s\" and \"%s\" depend on different extensions.",
23766 int save_sec_context;
23767 int save_nestlevel;
23792 errmsg(
"partitions being merged have different owners"));
23886 object.objectSubId = 0;
23922 object.objectSubId = 0;
23978 pc->partRel = partRel;
24068 if (
sps->bound->is_default)
24095 pc->partqualstate =
24131 bool found =
false;
24144 if (
pc->partqualstate &&
ExecCheck(
pc->partqualstate, econtext))
24158 errmsg(
"cannot find partition for split partition row"),
24180 sizeof(
bool) *
srcslot->tts_nvalid);
24203 ti_options,
pc->bistate);
24242 int save_sec_context;
24243 int save_nestlevel;
24274 errmsg(
"relation \"%s\" already exists",
sps->name->relname));
24301 object.objectSubId = 0;
24383 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 IsConflictLogTableClass(Form_pg_class reltuple)
bool IsSystemRelation(Relation relation)
bool IsConflictLogTableNamespace(Oid namespaceId)
RelFileNumber GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
bool IsCatalogNamespace(Oid namespaceId)
bool IsSystemClass(Oid relid, Form_pg_class reltuple)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
bool contain_mutable_functions(Node *clause)
Node * eval_const_expressions(PlannerInfo *root, Node *node)
bool contain_volatile_functions(Node *clause)
void ResetSequence(Oid seq_relid)
void SequenceChangePersistence(Oid relid, char newrelpersistence)
static DataChecksumsWorkerOperation operation
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_AUTO_EXTENSION
@ 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 errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
int int int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
void EventTriggerTableRewrite(Node *parsetree, Oid tableOid, int reason)
void EventTriggerCollectAlterTableSubcmd(const Node *subcmd, ObjectAddress address)
void EventTriggerAlterTableRelid(Oid objectId)
void EventTriggerAlterTableStart(const Node *parsetree)
void EventTriggerAlterTableEnd(void)
#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)
List * AddRelationNotNullConstraints(Relation rel, List *constraints, List *old_notnulls, List *existing_constraints)
void heap_truncate_check_FKs(List *relations, bool tempTables)
void StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
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)
ObjectAddress index_constraint_create(Relation heapRelation, Oid indexRelationId, Oid parentConstraintId, const IndexInfo *indexInfo, const char *constraintName, char constraintType, uint16 constr_flags, bool allow_system_table_mods, bool is_internal)
IndexInfo * BuildIndexInfo(Relation index)
void index_check_primary_key(Relation heapRel, const IndexInfo *indexInfo, bool is_alter_table, const IndexStmt *stmt)
#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)
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)
ObjectAddress DefineIndex(ParseState *pstate, Oid tableId, const 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 CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
static int pg_cmp_u32(uint32 a, uint32 b)
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)
void list_sort(List *list, list_sort_comparator cmp)
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)
int list_oid_cmp(const ListCell *p1, const ListCell *p2)
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 AccessExclusiveLock
#define ShareRowExclusiveLock
#define InplaceUpdateTupleLock
#define ShareUpdateExclusiveLock
#define SET_LOCKTAG_RELATION(locktag, dboid, reloid)
char * get_rel_name(Oid relid)
bool get_rel_relispartition(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)
char * get_publication_name(Oid pubid, bool missing_ok)
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
Oid attnumCollationId(Relation rd, int attid)
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, LOCKMODE lockmode, Alias *alias, bool inh, bool inFromCl)
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)
END_CATALOG_STRUCT typedef 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)
List * getAutoExtensionsOfObject(Oid classId, Oid objectId)
END_CATALOG_STRUCT typedef FormData_pg_depend * Form_pg_depend
END_CATALOG_STRUCT typedef FormData_pg_foreign_table * Form_pg_foreign_table
END_CATALOG_STRUCT typedef 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)
END_CATALOG_STRUCT typedef 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)
END_CATALOG_STRUCT typedef FormData_pg_opclass * Form_pg_opclass
List * GetRelationIncludedPublications(Oid relid)
List * GetRelationExcludedPublications(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]
END_CATALOG_STRUCT typedef FormData_pg_trigger * Form_pg_trigger
void RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
END_CATALOG_STRUCT typedef 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 Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Pointer DatumGetPointer(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
#define PointerGetDatum(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 finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, bool is_system_catalog, bool swap_toast_by_content, bool check_constraints, bool is_internal, bool reindex, TransactionId frozenXid, MultiXactId cutoffMulti, char newrelpersistence)
void check_index_is_clusterable(Relation OldHeap, Oid indexOid, LOCKMODE lockmode)
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 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
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
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)
HeapTuple SearchSysCacheLockedCopy1(SysCacheIdentifier cacheId, Datum key1)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache2(SysCacheIdentifier cacheId, Datum key1, Datum key2)
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
HeapTuple SearchSysCacheLocked1(SysCacheIdentifier cacheId, Datum key1)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Datum SysCacheGetAttrNotNull(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
#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_finish_bulk_insert(Relation rel, uint32 options)
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, uint32 options, BulkInsertStateData *bistate)
static TableScanDesc table_beginscan(Relation rel, Snapshot snapshot, int nkeys, ScanKeyData *key, uint32 flags)
static void table_relation_copy_data(Relation rel, const RelFileLocator *newrlocator)
static bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
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 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 ATPrepChangeInherit(Relation child_rel)
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 AlterCheckConstrEnforceabilityRecurse(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Oid conrelid, bool recurse, bool recursing, List *changing_conids, 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)
static bool ATExecAlterFKConstrEnforceability(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, Relation tgrel, Oid fkrelid, Oid pkrelid, HeapTuple contuple, LOCKMODE lockmode, Oid ReferencedParentDelTrigger, Oid ReferencedParentUpdTrigger, Oid ReferencingParentInsTrigger, Oid ReferencingParentUpdTrigger)
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 applyPartitionIndexExtDeps(Oid newPartOid, List *extDepState)
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 void deleteSplitPartitionContext(SplitPartitionContext *pc, List **wqueue, uint32 ti_options)
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 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 void AlterFKConstrEnforceabilityRecurse(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 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 bool equal_oid_lists(const List *a, const List *b)
static void TryReuseForeignKey(Oid oldId, Constraint *con)
Oid AlterTableLookupRelation(AlterTableStmt *stmt, LOCKMODE lockmode)
static List * collectPartitionIndexExtDeps(List *partitionOids)
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 bool ATExecAlterCheckConstrEnforceability(List **wqueue, ATAlterConstraint *cmdcon, Relation conrel, HeapTuple contuple, bool recurse, bool recursing, List *changing_conids, LOCKMODE lockmode)
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 bool ATCheckCheckConstrHasEnforcedParent(Relation conrel, Relation rel, HeapTuple contuple, List *changing_conids, Oid *enforced_parentoid)
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 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 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 RememberWholeRowDependentForRebuilding(AlteredTableInfo *tab, AlterTableType subtype, Relation rel)
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 void freePartitionIndexExtDeps(List *extDepState)
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)
static int cmp_partition_index_ext_dep(const ListCell *a, const ListCell *b)
#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 NewRelationCreateToastTable(Oid relOid, Datum reloptions)
void AlterTableCreateToastTable(Oid relOid, Datum reloptions, LOCKMODE lockmode)
void ExecBSTruncateTriggers(EState *estate, ResultRelInfo *relinfo)
ObjectAddress CreateTriggerFiringOn(const 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)
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)
void TriggerSetParentTrigger(Relation trigRel, Oid childTrigId, Oid parentTrigId, Oid childTableId)
bool AfterTriggerPendingOnRel(Oid relid)
ObjectAddress CreateTrigger(const 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 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 TupleDescFinalize(TupleDesc tupdesc)
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)
bool DomainHasConstraints(Oid type_id, bool *has_volatile)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
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)