form = (Form_pg_class) GETSTRUCT(tuple);
/* only tables and views can have rules */
- if (form->relkind != RELKIND_RELATION && form->relkind != RELKIND_VIEW)
+ if (form->relkind != RELKIND_RELATION &&
+ form->relkind != RELKIND_VIEW &&
+ form->relkind != RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table or view", rv->relname)));
(1 row)
+-- test rename for a rule defined on a partitioned table
+CREATE TABLE parted_table (a int) PARTITION BY LIST (a);
+CREATE TABLE parted_table_1 PARTITION OF parted_table FOR VALUES IN (1);
+CREATE RULE parted_table_insert AS ON INSERT to parted_table
+ DO INSTEAD INSERT INTO parted_table_1 VALUES (NEW.*);
+ALTER RULE parted_table_insert ON parted_table RENAME TO parted_table_insert_redirect;
+DROP TABLE parted_table;
SELECT pg_get_function_result(0);
SELECT pg_get_function_arg_default(0, 0);
SELECT pg_get_function_arg_default('pg_class'::regclass, 0);
+
+-- test rename for a rule defined on a partitioned table
+CREATE TABLE parted_table (a int) PARTITION BY LIST (a);
+CREATE TABLE parted_table_1 PARTITION OF parted_table FOR VALUES IN (1);
+CREATE RULE parted_table_insert AS ON INSERT to parted_table
+ DO INSTEAD INSERT INTO parted_table_1 VALUES (NEW.*);
+ALTER RULE parted_table_insert ON parted_table RENAME TO parted_table_insert_redirect;
+DROP TABLE parted_table;