diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/tablecmds.c | 33 | ||||
-rw-r--r-- | src/backend/replication/logical/worker.c | 4 | ||||
-rw-r--r-- | src/include/commands/tablecmds.h | 11 | ||||
-rw-r--r-- | src/include/foreign/fdwapi.h | 1 |
4 files changed, 9 insertions, 40 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 7d00f4eb256..8e717ada28d 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -323,7 +323,6 @@ typedef struct ForeignTruncateInfo { Oid serverid; List *rels; - List *rels_extra; } ForeignTruncateInfo; /* @@ -1620,7 +1619,6 @@ ExecuteTruncate(TruncateStmt *stmt) { List *rels = NIL; List *relids = NIL; - List *relids_extra = NIL; List *relids_logged = NIL; ListCell *cell; @@ -1654,9 +1652,7 @@ ExecuteTruncate(TruncateStmt *stmt) rels = lappend(rels, rel); relids = lappend_oid(relids, myrelid); - relids_extra = lappend_int(relids_extra, (recurse ? - TRUNCATE_REL_CONTEXT_NORMAL : - TRUNCATE_REL_CONTEXT_ONLY)); + /* Log this relation only if needed for logical decoding */ if (RelationIsLogicallyLogged(rel)) relids_logged = lappend_oid(relids_logged, myrelid); @@ -1704,8 +1700,7 @@ ExecuteTruncate(TruncateStmt *stmt) rels = lappend(rels, rel); relids = lappend_oid(relids, childrelid); - relids_extra = lappend_int(relids_extra, - TRUNCATE_REL_CONTEXT_CASCADING); + /* Log this relation only if needed for logical decoding */ if (RelationIsLogicallyLogged(rel)) relids_logged = lappend_oid(relids_logged, childrelid); @@ -1718,7 +1713,7 @@ ExecuteTruncate(TruncateStmt *stmt) errhint("Do not specify the ONLY keyword, or use TRUNCATE ONLY on the partitions directly."))); } - ExecuteTruncateGuts(rels, relids, relids_extra, relids_logged, + ExecuteTruncateGuts(rels, relids, relids_logged, stmt->behavior, stmt->restart_seqs); /* And close the rels */ @@ -1739,15 +1734,13 @@ ExecuteTruncate(TruncateStmt *stmt) * * explicit_rels is the list of Relations to truncate that the command * specified. relids is the list of Oids corresponding to explicit_rels. - * relids_extra is the list of integer values that deliver extra information - * about relations in explicit_rels. relids_logged is the list of Oids - * (a subset of relids) that require WAL-logging. This is all a bit redundant, - * but the existing callers have this information handy in this form. + * relids_logged is the list of Oids (a subset of relids) that require + * WAL-logging. This is all a bit redundant, but the existing callers have + * this information handy in this form. */ void ExecuteTruncateGuts(List *explicit_rels, List *relids, - List *relids_extra, List *relids_logged, DropBehavior behavior, bool restart_seqs) { @@ -1760,8 +1753,6 @@ ExecuteTruncateGuts(List *explicit_rels, ResultRelInfo *resultRelInfo; SubTransactionId mySubid; ListCell *cell; - ListCell *lc1, - *lc2; Oid *logrelids; /* @@ -1799,8 +1790,7 @@ ExecuteTruncateGuts(List *explicit_rels, truncate_check_activity(rel); rels = lappend(rels, rel); relids = lappend_oid(relids, relid); - relids_extra = lappend_int(relids_extra, - TRUNCATE_REL_CONTEXT_CASCADING); + /* Log this relation only if needed for logical decoding */ if (RelationIsLogicallyLogged(rel)) relids_logged = lappend_oid(relids_logged, relid); @@ -1901,11 +1891,9 @@ ExecuteTruncateGuts(List *explicit_rels, */ mySubid = GetCurrentSubTransactionId(); - Assert(list_length(rels) == list_length(relids_extra)); - forboth(lc1, rels, lc2, relids_extra) + foreach(cell, rels) { - Relation rel = (Relation) lfirst(lc1); - int extra = lfirst_int(lc2); + Relation rel = (Relation) lfirst(cell); /* * Save OID of partitioned tables for later; nothing else to do for @@ -1952,7 +1940,6 @@ ExecuteTruncateGuts(List *explicit_rels, { ft_info->serverid = serverid; ft_info->rels = NIL; - ft_info->rels_extra = NIL; } /* @@ -1960,7 +1947,6 @@ ExecuteTruncateGuts(List *explicit_rels, * foreign table belongs to. */ ft_info->rels = lappend(ft_info->rels, rel); - ft_info->rels_extra = lappend_int(ft_info->rels_extra, extra); continue; } @@ -2044,7 +2030,6 @@ ExecuteTruncateGuts(List *explicit_rels, Assert(routine->ExecForeignTruncate != NULL); routine->ExecForeignTruncate(ft_info->rels, - ft_info->rels_extra, behavior, restart_seqs); } diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index d09703f7acd..d9f157172b2 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -1816,7 +1816,6 @@ apply_handle_truncate(StringInfo s) List *rels = NIL; List *part_rels = NIL; List *relids = NIL; - List *relids_extra = NIL; List *relids_logged = NIL; ListCell *lc; @@ -1846,7 +1845,6 @@ apply_handle_truncate(StringInfo s) remote_rels = lappend(remote_rels, rel); rels = lappend(rels, rel->localrel); relids = lappend_oid(relids, rel->localreloid); - relids_extra = lappend_int(relids_extra, TRUNCATE_REL_CONTEXT_NORMAL); if (RelationIsLogicallyLogged(rel->localrel)) relids_logged = lappend_oid(relids_logged, rel->localreloid); @@ -1885,7 +1883,6 @@ apply_handle_truncate(StringInfo s) rels = lappend(rels, childrel); part_rels = lappend(part_rels, childrel); relids = lappend_oid(relids, childrelid); - relids_extra = lappend_int(relids_extra, TRUNCATE_REL_CONTEXT_CASCADING); /* Log this relation only if needed for logical decoding */ if (RelationIsLogicallyLogged(childrel)) relids_logged = lappend_oid(relids_logged, childrelid); @@ -1900,7 +1897,6 @@ apply_handle_truncate(StringInfo s) */ ExecuteTruncateGuts(rels, relids, - relids_extra, relids_logged, DROP_RESTRICT, restart_seqs); diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index b808a07e461..14f4b4882ff 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -21,16 +21,6 @@ #include "storage/lock.h" #include "utils/relcache.h" -/* - * These values indicate how a relation was specified as the target to - * truncate in TRUNCATE command. - */ -#define TRUNCATE_REL_CONTEXT_NORMAL 1 /* specified without ONLY clause */ -#define TRUNCATE_REL_CONTEXT_ONLY 2 /* specified with ONLY clause */ -#define TRUNCATE_REL_CONTEXT_CASCADING 3 /* not specified but truncated - * due to dependency (e.g., - * partition table) */ - struct AlterTableUtilityContext; /* avoid including tcop/utility.h here */ @@ -68,7 +58,6 @@ extern void CheckTableNotInUse(Relation rel, const char *stmt); extern void ExecuteTruncate(TruncateStmt *stmt); extern void ExecuteTruncateGuts(List *explicit_rels, List *relids, - List *relids_extra, List *relids_logged, DropBehavior behavior, bool restart_seqs); diff --git a/src/include/foreign/fdwapi.h b/src/include/foreign/fdwapi.h index 4ebbca6de92..4f17becbb81 100644 --- a/src/include/foreign/fdwapi.h +++ b/src/include/foreign/fdwapi.h @@ -161,7 +161,6 @@ typedef List *(*ImportForeignSchema_function) (ImportForeignSchemaStmt *stmt, Oid serverOid); typedef void (*ExecForeignTruncate_function) (List *rels, - List *rels_extra, DropBehavior behavior, bool restart_seqs); |