]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove direct handling of reloptions for toast tables
authorÁlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 14 Mar 2025 08:28:51 +0000 (09:28 +0100)
committerÁlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 14 Mar 2025 08:28:51 +0000 (09:28 +0100)
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

src/backend/commands/tablecmds.c
src/test/modules/unsafe_tests/expected/alter_system_table.out
src/test/modules/unsafe_tests/sql/alter_system_table.sql

index d3edd879654e3cb1b8d6632c9036677b2286c79c..129c97fdf28f253b9e87b6f73d36ccb9cc304853 100644 (file)
@@ -15963,7 +15963,6 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
        switch (rel->rd_rel->relkind)
        {
                case RELKIND_RELATION:
-               case RELKIND_TOASTVALUE:
                case RELKIND_MATVIEW:
                        (void) heap_reloptions(rel->rd_rel->relkind, newOptions, true);
                        break;
@@ -15977,6 +15976,8 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
                case RELKIND_PARTITIONED_INDEX:
                        (void) index_reloptions(rel->rd_indam->amoptions, newOptions, true);
                        break;
+               case RELKIND_TOASTVALUE:
+                       /* fall through to error -- shouldn't ever get here */
                default:
                        ereport(ERROR,
                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
index be0559503b6ff3bf14e79e0d0c82a3c1094eca1f..b73b9442b8d4d5549ade2a0b572ec69e0e0160c1 100644 (file)
@@ -91,6 +91,9 @@ ERROR:  permission denied: "pg_description" is a system catalog
 SET allow_system_table_mods TO on;
 DROP RULE r2 ON pg_description;
 RESET allow_system_table_mods;
+-- Reloptions on TOAST tables
+ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
+ERROR:  permission denied: "pg_toast_2615" is a system catalog
 SET allow_system_table_mods = on;
 -- create new table in pg_catalog
 BEGIN;
@@ -173,6 +176,10 @@ DROP TRIGGER t2 ON pg_description;
 CREATE RULE r1 AS ON INSERT TO pg_description DO INSTEAD NOTHING;
 ALTER RULE r1 ON pg_description RENAME TO r2;
 DROP RULE r2 ON pg_description;
+-- Reloptions on TOAST tables
+ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
+ERROR:  ALTER action SET cannot be performed on relation "pg_toast_2615"
+DETAIL:  This operation is not supported for TOAST tables.
 -- cleanup
 REVOKE ALL ON pg_description FROM regress_user_ast;
 DROP USER regress_user_ast;
index b77b68c946a1044ba4fcebf3e06d3c2a2ca219d8..c1515100845cd64d2e2b12eb813601a30225516f 100644 (file)
@@ -89,6 +89,8 @@ SET allow_system_table_mods TO on;
 DROP RULE r2 ON pg_description;
 RESET allow_system_table_mods;
 
+-- Reloptions on TOAST tables
+ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
 
 SET allow_system_table_mods = on;
 
@@ -187,6 +189,8 @@ CREATE RULE r1 AS ON INSERT TO pg_description DO INSTEAD NOTHING;
 ALTER RULE r1 ON pg_description RENAME TO r2;
 DROP RULE r2 ON pg_description;
 
+-- Reloptions on TOAST tables
+ALTER TABLE pg_toast.pg_toast_2615 SET (fillfactor = '90');
 
 -- cleanup
 REVOKE ALL ON pg_description FROM regress_user_ast;