Commit 02af7857 authored by Robert Haas's avatar Robert Haas

Allow a rule on partitioned table to be renamed.

Commit f0e44751 should have updated
this code, but did not.

Amit Langote

Discussion: http://postgr.es/m/52d9c443-ec78-5c8a-7a77-0f34aad12b82@lab.ntt.co.jp
parent 6599c9ac
...@@ -900,7 +900,9 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid, ...@@ -900,7 +900,9 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid,
form = (Form_pg_class) GETSTRUCT(tuple); form = (Form_pg_class) GETSTRUCT(tuple);
/* only tables and views can have rules */ /* 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, ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE), (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table or view", rv->relname))); errmsg("\"%s\" is not a table or view", rv->relname)));
......
...@@ -3216,3 +3216,10 @@ SELECT pg_get_function_arg_default('pg_class'::regclass, 0); ...@@ -3216,3 +3216,10 @@ SELECT pg_get_function_arg_default('pg_class'::regclass, 0);
(1 row) (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;
...@@ -1158,3 +1158,11 @@ SELECT pg_get_function_identity_arguments(0); ...@@ -1158,3 +1158,11 @@ SELECT pg_get_function_identity_arguments(0);
SELECT pg_get_function_result(0); SELECT pg_get_function_result(0);
SELECT pg_get_function_arg_default(0, 0); SELECT pg_get_function_arg_default(0, 0);
SELECT pg_get_function_arg_default('pg_class'::regclass, 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment