Commit 98abc738 authored by Michael Paquier's avatar Michael Paquier

Add regression tests for VACUUM and ANALYZE with relation skips

When a user does not have ownership on a relation, then specific log
messages are generated.  This new test suite adds coverage for all the
possible log messages generated, which will be useful to check the
consistency of any refactoring related to ownership checks for relations
vacuumed or analyzed.

Author: Michael Paquier
Reviewed-by: Nathan Bossart
Discussion: https://postgr.es/m/20180812222142.GA6097@paquier.xyz
parent 55a0154e
...@@ -122,3 +122,31 @@ LINE 1: ANALYZE (nonexistant-arg) does_not_exist; ...@@ -122,3 +122,31 @@ LINE 1: ANALYZE (nonexistant-arg) does_not_exist;
DROP TABLE vaccluster; DROP TABLE vaccluster;
DROP TABLE vactst; DROP TABLE vactst;
DROP TABLE vacparted; DROP TABLE vacparted;
-- relation ownership, WARNING logs generated as all are skipped.
CREATE TABLE vacowned (a int);
CREATE ROLE regress_vacuum;
SET ROLE regress_vacuum;
-- Simple table
VACUUM vacowned;
WARNING: skipping "vacowned" --- only table or database owner can vacuum it
ANALYZE vacowned;
WARNING: skipping "vacowned" --- only table or database owner can analyze it
VACUUM (ANALYZE) vacowned;
WARNING: skipping "vacowned" --- only table or database owner can vacuum it
-- Catalog
VACUUM pg_catalog.pg_class;
WARNING: skipping "pg_class" --- only superuser or database owner can vacuum it
ANALYZE pg_catalog.pg_class;
WARNING: skipping "pg_class" --- only superuser or database owner can analyze it
VACUUM (ANALYZE) pg_catalog.pg_class;
WARNING: skipping "pg_class" --- only superuser or database owner can vacuum it
-- Shared catalog
VACUUM pg_catalog.pg_authid;
WARNING: skipping "pg_authid" --- only superuser can vacuum it
ANALYZE pg_catalog.pg_authid;
WARNING: skipping "pg_authid" --- only superuser can analyze it
VACUUM (ANALYZE) pg_catalog.pg_authid;
WARNING: skipping "pg_authid" --- only superuser can vacuum it
RESET ROLE;
DROP TABLE vacowned;
DROP ROLE regress_vacuum;
...@@ -96,3 +96,23 @@ ANALYZE (nonexistant-arg) does_not_exist; ...@@ -96,3 +96,23 @@ ANALYZE (nonexistant-arg) does_not_exist;
DROP TABLE vaccluster; DROP TABLE vaccluster;
DROP TABLE vactst; DROP TABLE vactst;
DROP TABLE vacparted; DROP TABLE vacparted;
-- relation ownership, WARNING logs generated as all are skipped.
CREATE TABLE vacowned (a int);
CREATE ROLE regress_vacuum;
SET ROLE regress_vacuum;
-- Simple table
VACUUM vacowned;
ANALYZE vacowned;
VACUUM (ANALYZE) vacowned;
-- Catalog
VACUUM pg_catalog.pg_class;
ANALYZE pg_catalog.pg_class;
VACUUM (ANALYZE) pg_catalog.pg_class;
-- Shared catalog
VACUUM pg_catalog.pg_authid;
ANALYZE pg_catalog.pg_authid;
VACUUM (ANALYZE) pg_catalog.pg_authid;
RESET ROLE;
DROP TABLE vacowned;
DROP ROLE regress_vacuum;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment