diff --git a/src/backend/distributed/commands/vacuum.c b/src/backend/distributed/commands/vacuum.c index f6fabfe2b..37acfd6ba 100644 --- a/src/backend/distributed/commands/vacuum.c +++ b/src/backend/distributed/commands/vacuum.c @@ -388,7 +388,12 @@ DeparseVacuumStmtPrefix(CitusVacuumParams vacuumParams) { appendStringInfoString(vacuumPrefix, "SKIP_LOCKED,"); } - + #if PG_VERSION_NUM >= PG_VERSION_14 + if (vacuumFlags & VACOPT_PROCESS_TOAST) + { + appendStringInfoString(vacuumPrefix, "PROCESS_TOAST,"); + } + #endif if (vacuumParams.truncate != VACOPTVALUE_UNSPECIFIED) { appendStringInfoString(vacuumPrefix, @@ -504,6 +509,9 @@ VacuumStmtParams(VacuumStmt *vacstmt) bool freeze = false; bool full = false; bool disable_page_skipping = false; + #if PG_VERSION_NUM >= PG_VERSION_14 + bool process_toast = false; + #endif /* Set default value */ params.index_cleanup = VACOPTVALUE_UNSPECIFIED; @@ -549,6 +557,12 @@ VacuumStmtParams(VacuumStmt *vacstmt) { disable_page_skipping = defGetBoolean(opt); } + #if PG_VERSION_NUM >= PG_VERSION_14 + else if (strcmp(opt->defname, "process_toast") == 0) + { + process_toast = defGetBoolean(opt); + } + #endif else if (strcmp(opt->defname, "index_cleanup") == 0) { params.index_cleanup = defGetBoolean(opt) ? VACOPTVALUE_ENABLED : @@ -599,6 +613,9 @@ VacuumStmtParams(VacuumStmt *vacstmt) (analyze ? VACOPT_ANALYZE : 0) | (freeze ? VACOPT_FREEZE : 0) | (full ? VACOPT_FULL : 0) | + #if PG_VERSION_NUM >= PG_VERSION_14 + (process_toast ? VACOPT_PROCESS_TOAST : 0) | + #endif (disable_page_skipping ? VACOPT_DISABLE_PAGE_SKIPPING : 0); return params; } diff --git a/src/test/regress/expected/pg14.out b/src/test/regress/expected/pg14.out index 6e42f4fbc..954680ccd 100644 --- a/src/test/regress/expected/pg14.out +++ b/src/test/regress/expected/pg14.out @@ -7,6 +7,56 @@ SELECT substring(:'server_version', '\d+')::int > 13 AS server_version_above_thi \endif create schema pg14; set search_path to pg14; +SET citus.next_shard_id TO 980000; +SET citus.shard_count TO 2; +-- test the new vacuum option, process_toast +CREATE TABLE t1 (a int); +SELECT create_distributed_table('t1','a'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +SET citus.log_remote_commands TO ON; +VACUUM (FULL) t1; +NOTICE: issuing VACUUM (FULL) pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL) pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL) pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL) pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +VACUUM (FULL, PROCESS_TOAST) t1; +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +VACUUM (FULL, PROCESS_TOAST true) t1; +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM (FULL,PROCESS_TOAST) pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +VACUUM (FULL, PROCESS_TOAST false) t1; +ERROR: PROCESS_TOAST required with VACUUM FULL +VACUUM (PROCESS_TOAST false) t1; +NOTICE: issuing VACUUM pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM pg14.t1_980000 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +NOTICE: issuing VACUUM pg14.t1_980001 +DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +SET citus.log_remote_commands TO OFF; create table dist(a int, b int); select create_distributed_table('dist','a'); create_distributed_table @@ -32,14 +82,6 @@ NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT @@ -58,14 +100,6 @@ NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT @@ -83,14 +117,6 @@ NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT @@ -109,14 +135,6 @@ NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing REINDEX (VERBOSE, TABLESPACE test_tablespace) INDEX pg14.xxxxx -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing COMMIT diff --git a/src/test/regress/sql/pg14.sql b/src/test/regress/sql/pg14.sql index 84107791a..24a2dac66 100644 --- a/src/test/regress/sql/pg14.sql +++ b/src/test/regress/sql/pg14.sql @@ -9,6 +9,20 @@ SELECT substring(:'server_version', '\d+')::int > 13 AS server_version_above_thi create schema pg14; set search_path to pg14; +SET citus.next_shard_id TO 980000; +SET citus.shard_count TO 2; + +-- test the new vacuum option, process_toast +CREATE TABLE t1 (a int); +SELECT create_distributed_table('t1','a'); +SET citus.log_remote_commands TO ON; +VACUUM (FULL) t1; +VACUUM (FULL, PROCESS_TOAST) t1; +VACUUM (FULL, PROCESS_TOAST true) t1; +VACUUM (FULL, PROCESS_TOAST false) t1; +VACUUM (PROCESS_TOAST false) t1; +SET citus.log_remote_commands TO OFF; + create table dist(a int, b int); select create_distributed_table('dist','a'); create index idx on dist(a); @@ -28,6 +42,3 @@ set citus.log_remote_commands to off; set client_min_messages to error; drop schema pg14 cascade; - - -