From 865f132a908a35bc8777f7c548451e908e54cce5 Mon Sep 17 00:00:00 2001 From: Georgios Kokolatos Date: Wed, 16 Jan 2019 16:44:36 +0000 Subject: [PATCH] Remove duplicating code in vacuumStatement_Relation vacuum_rel already performs the tests and all current codepaths pass through it. Block decorated by GPDB_93_MERGE_FIXME tag. Reviewed-by: Heikki Linnakangas --- src/backend/commands/vacuum.c | 40 ------------------------- src/test/regress/expected/vacuum_gp.out | 5 ++++ src/test/regress/sql/vacuum_gp.sql | 5 ++++ 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 6b666e5b9a..7900c9115c 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -730,46 +730,6 @@ vacuumStatement_Relation(VacuumStmt *vacstmt, Oid relid, return; } - /* - * Check that it's a plain table; we used to do this in get_rel_oids() but - * seems safer to check after we've locked the relation. - */ - /* - * GPDB_93_MERGE_FIXME: this is the same test we have in vacuum_rel. Can we - * get rid of the redundancy? - */ - if ((onerel->rd_rel->relkind != RELKIND_RELATION && - onerel->rd_rel->relkind != RELKIND_MATVIEW && - onerel->rd_rel->relkind != RELKIND_TOASTVALUE && - onerel->rd_rel->relkind != RELKIND_AOSEGMENTS && - onerel->rd_rel->relkind != RELKIND_AOBLOCKDIR && - onerel->rd_rel->relkind != RELKIND_AOVISIMAP) - || RelationIsExternal(onerel)) - { - ereport(WARNING, - (errmsg("skipping \"%s\" --- cannot vacuum non-tables or special system tables", - RelationGetRelationName(onerel)))); - relation_close(onerel, lmode); - PopActiveSnapshot(); - CommitTransactionCommand(); - return; - } - - /* - * Silently ignore tables that are temp tables of other backends --- - * trying to vacuum these will lead to great unhappiness, since their - * contents are probably not up-to-date on disk. (We don't throw a - * warning here; it would just lead to chatter during a database-wide - * VACUUM.) - */ - if (isOtherTempNamespace(RelationGetNamespace(onerel))) - { - relation_close(onerel, lmode); - PopActiveSnapshot(); - CommitTransactionCommand(); - return; - } - /* * Get a session-level lock too. This will protect our access to the * relation across multiple transactions, so that we can vacuum the diff --git a/src/test/regress/expected/vacuum_gp.out b/src/test/regress/expected/vacuum_gp.out index 3b0666fb74..c52170a99c 100644 --- a/src/test/regress/expected/vacuum_gp.out +++ b/src/test/regress/expected/vacuum_gp.out @@ -328,3 +328,8 @@ SELECT relname, reltuples, relpages FROM pg_catalog.pg_class WHERE relname like (3 rows) reset gp_autostats_mode; +-- Check forbidden relkind for vacuum is correctly skipped +CREATE SEQUENCE s_serial START 100; +VACUUM (ANALYZE, VERBOSE) s_serial; +WARNING: skipping "s_serial" --- cannot vacuum non-tables or special system tables +DROP SEQUENCE s_serial; diff --git a/src/test/regress/sql/vacuum_gp.sql b/src/test/regress/sql/vacuum_gp.sql index 15eea2a6fa..d18d355da0 100644 --- a/src/test/regress/sql/vacuum_gp.sql +++ b/src/test/regress/sql/vacuum_gp.sql @@ -202,3 +202,8 @@ SELECT relname, reltuples, relpages FROM pg_catalog.pg_class WHERE relname like VACUUM ANALYZE vacuum_gp_pt; SELECT relname, reltuples, relpages FROM pg_catalog.pg_class WHERE relname like 'vacuum_gp_pt%'; reset gp_autostats_mode; + +-- Check forbidden relkind for vacuum is correctly skipped +CREATE SEQUENCE s_serial START 100; +VACUUM (ANALYZE, VERBOSE) s_serial; +DROP SEQUENCE s_serial; -- GitLab