Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b7a5ef1

Browse filesBrowse files
committed
Simplify WARNING messages from skipped vacuum/analyze on a table
This will more easily accomodate adding new permissions for vacuum and analyze. Nathan Bossart following a suggestion from Kyotaro Horiguchi Discussion: https://postgr.es/m/20220726.104712.912995710251150228.horikyota.ntt@gmail.com
1 parent 7b37823 commit b7a5ef1
Copy full SHA for b7a5ef1

File tree

Expand file treeCollapse file tree

3 files changed

+65
-85
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+65
-85
lines changed

‎src/backend/commands/vacuum.c

Copy file name to clipboardExpand all lines: src/backend/commands/vacuum.c
+6-26Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -579,18 +579,9 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, bits32 options)
579579

580580
if ((options & VACOPT_VACUUM) != 0)
581581
{
582-
if (reltuple->relisshared)
583-
ereport(WARNING,
584-
(errmsg("skipping \"%s\" --- only superuser can vacuum it",
585-
relname)));
586-
else if (reltuple->relnamespace == PG_CATALOG_NAMESPACE)
587-
ereport(WARNING,
588-
(errmsg("skipping \"%s\" --- only superuser or database owner can vacuum it",
589-
relname)));
590-
else
591-
ereport(WARNING,
592-
(errmsg("skipping \"%s\" --- only table or database owner can vacuum it",
593-
relname)));
582+
ereport(WARNING,
583+
(errmsg("permission denied to vacuum \"%s\", skipping it",
584+
relname)));
594585

595586
/*
596587
* For VACUUM ANALYZE, both logs could show up, but just generate
@@ -601,20 +592,9 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, bits32 options)
601592
}
602593

603594
if ((options & VACOPT_ANALYZE) != 0)
604-
{
605-
if (reltuple->relisshared)
606-
ereport(WARNING,
607-
(errmsg("skipping \"%s\" --- only superuser can analyze it",
608-
relname)));
609-
else if (reltuple->relnamespace == PG_CATALOG_NAMESPACE)
610-
ereport(WARNING,
611-
(errmsg("skipping \"%s\" --- only superuser or database owner can analyze it",
612-
relname)));
613-
else
614-
ereport(WARNING,
615-
(errmsg("skipping \"%s\" --- only table or database owner can analyze it",
616-
relname)));
617-
}
595+
ereport(WARNING,
596+
(errmsg("permission denied to analyze \"%s\", skipping it",
597+
relname)));
618598

619599
return false;
620600
}

‎src/test/isolation/expected/vacuum-conflict.out

Copy file name to clipboardExpand all lines: src/test/isolation/expected/vacuum-conflict.out
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ starting permutation: s1_begin s1_lock s2_auth s2_vacuum s1_commit s2_reset
44
step s1_begin: BEGIN;
55
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;
66
step s2_auth: SET ROLE regress_vacuum_conflict;
7-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it
7+
s2: WARNING: permission denied to vacuum "vacuum_tab", skipping it
88
step s2_vacuum: VACUUM vacuum_tab;
99
step s1_commit: COMMIT;
1010
step s2_reset: RESET ROLE;
1111

1212
starting permutation: s1_begin s2_auth s2_vacuum s1_lock s1_commit s2_reset
1313
step s1_begin: BEGIN;
1414
step s2_auth: SET ROLE regress_vacuum_conflict;
15-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it
15+
s2: WARNING: permission denied to vacuum "vacuum_tab", skipping it
1616
step s2_vacuum: VACUUM vacuum_tab;
1717
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;
1818
step s1_commit: COMMIT;
@@ -22,14 +22,14 @@ starting permutation: s1_begin s2_auth s1_lock s2_vacuum s1_commit s2_reset
2222
step s1_begin: BEGIN;
2323
step s2_auth: SET ROLE regress_vacuum_conflict;
2424
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;
25-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it
25+
s2: WARNING: permission denied to vacuum "vacuum_tab", skipping it
2626
step s2_vacuum: VACUUM vacuum_tab;
2727
step s1_commit: COMMIT;
2828
step s2_reset: RESET ROLE;
2929

3030
starting permutation: s2_auth s2_vacuum s1_begin s1_lock s1_commit s2_reset
3131
step s2_auth: SET ROLE regress_vacuum_conflict;
32-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it
32+
s2: WARNING: permission denied to vacuum "vacuum_tab", skipping it
3333
step s2_vacuum: VACUUM vacuum_tab;
3434
step s1_begin: BEGIN;
3535
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;
@@ -40,15 +40,15 @@ starting permutation: s1_begin s1_lock s2_auth s2_analyze s1_commit s2_reset
4040
step s1_begin: BEGIN;
4141
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;
4242
step s2_auth: SET ROLE regress_vacuum_conflict;
43-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it
43+
s2: WARNING: permission denied to analyze "vacuum_tab", skipping it
4444
step s2_analyze: ANALYZE vacuum_tab;
4545
step s1_commit: COMMIT;
4646
step s2_reset: RESET ROLE;
4747

4848
starting permutation: s1_begin s2_auth s2_analyze s1_lock s1_commit s2_reset
4949
step s1_begin: BEGIN;
5050
step s2_auth: SET ROLE regress_vacuum_conflict;
51-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it
51+
s2: WARNING: permission denied to analyze "vacuum_tab", skipping it
5252
step s2_analyze: ANALYZE vacuum_tab;
5353
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;
5454
step s1_commit: COMMIT;
@@ -58,14 +58,14 @@ starting permutation: s1_begin s2_auth s1_lock s2_analyze s1_commit s2_reset
5858
step s1_begin: BEGIN;
5959
step s2_auth: SET ROLE regress_vacuum_conflict;
6060
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;
61-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it
61+
s2: WARNING: permission denied to analyze "vacuum_tab", skipping it
6262
step s2_analyze: ANALYZE vacuum_tab;
6363
step s1_commit: COMMIT;
6464
step s2_reset: RESET ROLE;
6565

6666
starting permutation: s2_auth s2_analyze s1_begin s1_lock s1_commit s2_reset
6767
step s2_auth: SET ROLE regress_vacuum_conflict;
68-
s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it
68+
s2: WARNING: permission denied to analyze "vacuum_tab", skipping it
6969
step s2_analyze: ANALYZE vacuum_tab;
7070
step s1_begin: BEGIN;
7171
step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE;

‎src/test/regress/expected/vacuum.out

Copy file name to clipboardExpand all lines: src/test/regress/expected/vacuum.out
+51-51Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -295,120 +295,120 @@ CREATE ROLE regress_vacuum;
295295
SET ROLE regress_vacuum;
296296
-- Simple table
297297
VACUUM vacowned;
298-
WARNING: skipping "vacowned" --- only table or database owner can vacuum it
298+
WARNING: permission denied to vacuum "vacowned", skipping it
299299
ANALYZE vacowned;
300-
WARNING: skipping "vacowned" --- only table or database owner can analyze it
300+
WARNING: permission denied to analyze "vacowned", skipping it
301301
VACUUM (ANALYZE) vacowned;
302-
WARNING: skipping "vacowned" --- only table or database owner can vacuum it
302+
WARNING: permission denied to vacuum "vacowned", skipping it
303303
-- Catalog
304304
VACUUM pg_catalog.pg_class;
305-
WARNING: skipping "pg_class" --- only superuser or database owner can vacuum it
305+
WARNING: permission denied to vacuum "pg_class", skipping it
306306
ANALYZE pg_catalog.pg_class;
307-
WARNING: skipping "pg_class" --- only superuser or database owner can analyze it
307+
WARNING: permission denied to analyze "pg_class", skipping it
308308
VACUUM (ANALYZE) pg_catalog.pg_class;
309-
WARNING: skipping "pg_class" --- only superuser or database owner can vacuum it
309+
WARNING: permission denied to vacuum "pg_class", skipping it
310310
-- Shared catalog
311311
VACUUM pg_catalog.pg_authid;
312-
WARNING: skipping "pg_authid" --- only superuser can vacuum it
312+
WARNING: permission denied to vacuum "pg_authid", skipping it
313313
ANALYZE pg_catalog.pg_authid;
314-
WARNING: skipping "pg_authid" --- only superuser can analyze it
314+
WARNING: permission denied to analyze "pg_authid", skipping it
315315
VACUUM (ANALYZE) pg_catalog.pg_authid;
316-
WARNING: skipping "pg_authid" --- only superuser can vacuum it
316+
WARNING: permission denied to vacuum "pg_authid", skipping it
317317
-- Partitioned table and its partitions, nothing owned by other user.
318318
-- Relations are not listed in a single command to test ownership
319319
-- independently.
320320
VACUUM vacowned_parted;
321-
WARNING: skipping "vacowned_parted" --- only table or database owner can vacuum it
322-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
323-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
321+
WARNING: permission denied to vacuum "vacowned_parted", skipping it
322+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
323+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
324324
VACUUM vacowned_part1;
325-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
325+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
326326
VACUUM vacowned_part2;
327-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
327+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
328328
ANALYZE vacowned_parted;
329-
WARNING: skipping "vacowned_parted" --- only table or database owner can analyze it
330-
WARNING: skipping "vacowned_part1" --- only table or database owner can analyze it
331-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
329+
WARNING: permission denied to analyze "vacowned_parted", skipping it
330+
WARNING: permission denied to analyze "vacowned_part1", skipping it
331+
WARNING: permission denied to analyze "vacowned_part2", skipping it
332332
ANALYZE vacowned_part1;
333-
WARNING: skipping "vacowned_part1" --- only table or database owner can analyze it
333+
WARNING: permission denied to analyze "vacowned_part1", skipping it
334334
ANALYZE vacowned_part2;
335-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
335+
WARNING: permission denied to analyze "vacowned_part2", skipping it
336336
VACUUM (ANALYZE) vacowned_parted;
337-
WARNING: skipping "vacowned_parted" --- only table or database owner can vacuum it
338-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
339-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
337+
WARNING: permission denied to vacuum "vacowned_parted", skipping it
338+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
339+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
340340
VACUUM (ANALYZE) vacowned_part1;
341-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
341+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
342342
VACUUM (ANALYZE) vacowned_part2;
343-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
343+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
344344
RESET ROLE;
345345
-- Partitioned table and one partition owned by other user.
346346
ALTER TABLE vacowned_parted OWNER TO regress_vacuum;
347347
ALTER TABLE vacowned_part1 OWNER TO regress_vacuum;
348348
SET ROLE regress_vacuum;
349349
VACUUM vacowned_parted;
350-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
350+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
351351
VACUUM vacowned_part1;
352352
VACUUM vacowned_part2;
353-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
353+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
354354
ANALYZE vacowned_parted;
355-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
355+
WARNING: permission denied to analyze "vacowned_part2", skipping it
356356
ANALYZE vacowned_part1;
357357
ANALYZE vacowned_part2;
358-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
358+
WARNING: permission denied to analyze "vacowned_part2", skipping it
359359
VACUUM (ANALYZE) vacowned_parted;
360-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
360+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
361361
VACUUM (ANALYZE) vacowned_part1;
362362
VACUUM (ANALYZE) vacowned_part2;
363-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
363+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
364364
RESET ROLE;
365365
-- Only one partition owned by other user.
366366
ALTER TABLE vacowned_parted OWNER TO CURRENT_USER;
367367
SET ROLE regress_vacuum;
368368
VACUUM vacowned_parted;
369-
WARNING: skipping "vacowned_parted" --- only table or database owner can vacuum it
370-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
369+
WARNING: permission denied to vacuum "vacowned_parted", skipping it
370+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
371371
VACUUM vacowned_part1;
372372
VACUUM vacowned_part2;
373-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
373+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
374374
ANALYZE vacowned_parted;
375-
WARNING: skipping "vacowned_parted" --- only table or database owner can analyze it
376-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
375+
WARNING: permission denied to analyze "vacowned_parted", skipping it
376+
WARNING: permission denied to analyze "vacowned_part2", skipping it
377377
ANALYZE vacowned_part1;
378378
ANALYZE vacowned_part2;
379-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
379+
WARNING: permission denied to analyze "vacowned_part2", skipping it
380380
VACUUM (ANALYZE) vacowned_parted;
381-
WARNING: skipping "vacowned_parted" --- only table or database owner can vacuum it
382-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
381+
WARNING: permission denied to vacuum "vacowned_parted", skipping it
382+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
383383
VACUUM (ANALYZE) vacowned_part1;
384384
VACUUM (ANALYZE) vacowned_part2;
385-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
385+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
386386
RESET ROLE;
387387
-- Only partitioned table owned by other user.
388388
ALTER TABLE vacowned_parted OWNER TO regress_vacuum;
389389
ALTER TABLE vacowned_part1 OWNER TO CURRENT_USER;
390390
SET ROLE regress_vacuum;
391391
VACUUM vacowned_parted;
392-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
393-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
392+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
393+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
394394
VACUUM vacowned_part1;
395-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
395+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
396396
VACUUM vacowned_part2;
397-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
397+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
398398
ANALYZE vacowned_parted;
399-
WARNING: skipping "vacowned_part1" --- only table or database owner can analyze it
400-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
399+
WARNING: permission denied to analyze "vacowned_part1", skipping it
400+
WARNING: permission denied to analyze "vacowned_part2", skipping it
401401
ANALYZE vacowned_part1;
402-
WARNING: skipping "vacowned_part1" --- only table or database owner can analyze it
402+
WARNING: permission denied to analyze "vacowned_part1", skipping it
403403
ANALYZE vacowned_part2;
404-
WARNING: skipping "vacowned_part2" --- only table or database owner can analyze it
404+
WARNING: permission denied to analyze "vacowned_part2", skipping it
405405
VACUUM (ANALYZE) vacowned_parted;
406-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
407-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
406+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
407+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
408408
VACUUM (ANALYZE) vacowned_part1;
409-
WARNING: skipping "vacowned_part1" --- only table or database owner can vacuum it
409+
WARNING: permission denied to vacuum "vacowned_part1", skipping it
410410
VACUUM (ANALYZE) vacowned_part2;
411-
WARNING: skipping "vacowned_part2" --- only table or database owner can vacuum it
411+
WARNING: permission denied to vacuum "vacowned_part2", skipping it
412412
RESET ROLE;
413413
DROP TABLE vacowned;
414414
DROP TABLE vacowned_parted;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.