use PostgresNode;
use TestLib;
-use Test::More tests => 35;
+use Test::More tests => 38;
program_help_ok('vacuumdb');
program_version_ok('vacuumdb');
'postgres', q|
CREATE TABLE "need""q(uot" (")x" text);
CREATE TABLE vactable (a int, b int);
+ CREATE VIEW vacview AS SELECT 1 as a;
CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1';
CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQL AS 'SELECT f0($1)';
[ 'vacuumdb', '--analyze-only', '--table', 'vactable(b)', 'postgres' ],
qr/statement: ANALYZE public.vactable\(b\);/,
'vacuumdb --analyze-only with partial column list');
+$node->command_checks_all(
+ [ 'vacuumdb', '--analyze', '--table', 'vacview', 'postgres' ],
+ 0,
+ [qr/^.*vacuuming database "postgres"/],
+ [qr/^WARNING.*cannot vacuum non-tables or special system tables/s],
+ 'vacuumdb with view');
appendPQExpBuffer(&catalog_query, " JOIN listed_tables"
" ON listed_tables.table_oid OPERATOR(pg_catalog.=) c.oid\n");
- appendPQExpBuffer(&catalog_query, " WHERE c.relkind OPERATOR(pg_catalog.=) ANY (array["
- CppAsString2(RELKIND_RELATION) ", "
- CppAsString2(RELKIND_MATVIEW) "])\n");
+ /*
+ * If no tables were listed, filter for the relevant relation types. If
+ * tables were given via --table, don't bother filtering by relation type.
+ * Instead, let the server decide whether a given relation can be
+ * processed in which case the user will know about it.
+ */
+ if (!tables_listed)
+ appendPQExpBuffer(&catalog_query, " WHERE c.relkind OPERATOR(pg_catalog.=) ANY (array["
+ CppAsString2(RELKIND_RELATION) ", "
+ CppAsString2(RELKIND_MATVIEW) "])\n");
/*
* Execute the catalog query. We use the default search_path for this