Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1548c3a

Browse files
committed
Remove direct handling of reloptions for toast tables
It doesn't actually work, even with allow_system_table_mods turned on: the ALTER TABLE operation is rejected by ATSimplePermissions(), so even the error message we're adding in this commit is unreachable. Add a test case for it. Author: Nikolay Shaplov <dhyan@nataraj.su> Discussion: https://postgr.es/m/1913854.tdWV9SEqCh@thinkpad-pgpro
1 parent 92fc685 commit 1548c3a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/backend/commands/tablecmds.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -15963,7 +15963,6 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1596315963
switch (rel->rd_rel->relkind)
1596415964
{
1596515965
case RELKIND_RELATION:
15966-
case RELKIND_TOASTVALUE:
1596715966
case RELKIND_MATVIEW:
1596815967
(void) heap_reloptions(rel->rd_rel->relkind, newOptions, true);
1596915968
break;
@@ -15977,6 +15976,8 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1597715976
case RELKIND_PARTITIONED_INDEX:
1597815977
(void) index_reloptions(rel->rd_indam->amoptions, newOptions, true);
1597915978
break;
15979+
case RELKIND_TOASTVALUE:
15980+
/* fall through to error -- shouldn't ever get here */
1598015981
default:
1598115982
ereport(ERROR,
1598215983
(errcode(ERRCODE_WRONG_OBJECT_TYPE),

src/test/modules/unsafe_tests/expected/alter_system_table.out

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ ERROR: permission denied: "pg_description" is a system catalog
9191
SET allow_system_table_mods TO on;
9292
DROP RULE r2 ON pg_description;
9393
RESET allow_system_table_mods;
94+
-- Reloptions on TOAST tables
95+
ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
96+
ERROR: permission denied: "pg_toast_2615" is a system catalog
9497
SET allow_system_table_mods = on;
9598
-- create new table in pg_catalog
9699
BEGIN;
@@ -173,6 +176,10 @@ DROP TRIGGER t2 ON pg_description;
173176
CREATE RULE r1 AS ON INSERT TO pg_description DO INSTEAD NOTHING;
174177
ALTER RULE r1 ON pg_description RENAME TO r2;
175178
DROP RULE r2 ON pg_description;
179+
-- Reloptions on TOAST tables
180+
ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
181+
ERROR: ALTER action SET cannot be performed on relation "pg_toast_2615"
182+
DETAIL: This operation is not supported for TOAST tables.
176183
-- cleanup
177184
REVOKE ALL ON pg_description FROM regress_user_ast;
178185
DROP USER regress_user_ast;

src/test/modules/unsafe_tests/sql/alter_system_table.sql

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ SET allow_system_table_mods TO on;
8989
DROP RULE r2 ON pg_description;
9090
RESET allow_system_table_mods;
9191

92+
-- Reloptions on TOAST tables
93+
ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
9294

9395
SET allow_system_table_mods = on;
9496

@@ -187,6 +189,8 @@ CREATE RULE r1 AS ON INSERT TO pg_description DO INSTEAD NOTHING;
187189
ALTER RULE r1 ON pg_description RENAME TO r2;
188190
DROP RULE r2 ON pg_description;
189191

192+
-- Reloptions on TOAST tables
193+
ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
190194

191195
-- cleanup
192196
REVOKE ALL ON pg_description FROM regress_user_ast;

0 commit comments

Comments
 (0)