mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 19:01:19 +02:00
Do not filter by relkind in vacuumdb's catalog query if --table is used
If a user specifies a relation name which cannot be processed, then the
backend can warn directly about what is wrong with it. This fixes an
oversight from e0c2933
.
Author: Nathan Bossart
Discussion: https://postgr.es/m/32049A78-C429-4742-AEC1-941C9ABDE7B8@amazon.com
This commit is contained in:
parent
fa2cf164aa
commit
b8f73df0f8
@ -3,7 +3,7 @@ use warnings;
|
||||
|
||||
use PostgresNode;
|
||||
use TestLib;
|
||||
use Test::More tests => 35;
|
||||
use Test::More tests => 38;
|
||||
|
||||
program_help_ok('vacuumdb');
|
||||
program_version_ok('vacuumdb');
|
||||
@ -64,6 +64,7 @@ $node->safe_psql(
|
||||
'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)';
|
||||
@ -88,3 +89,9 @@ $node->issues_sql_like(
|
||||
[ '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');
|
||||
|
@ -484,6 +484,13 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
|
||||
appendPQExpBuffer(&catalog_query, " JOIN listed_tables"
|
||||
" ON listed_tables.table_oid OPERATOR(pg_catalog.=) c.oid\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");
|
||||
|
Loading…
Reference in New Issue
Block a user