Allow a rule on partitioned table to be renamed.
Commit f0e44751d7175fa3394da2c8f85e3ceb3cdbfe63 should have updated this code, but did not. Amit Langote Discussion: http://postgr.es/m/52d9c443-ec78-5c8a-7a77-0f34aad12b82@lab.ntt.co.jp
This commit is contained in:
parent
6599c9ac33
commit
02af7857e5
@ -900,7 +900,9 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
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)));
|
||||
|
@ -3216,3 +3216,10 @@ SELECT pg_get_function_arg_default('pg_class'::regclass, 0);
|
||||
|
||||
(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);
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user