Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit02af785

Browse files
committed
Allow a rule on partitioned table to be renamed.
Commitf0e4475 should have updatedthis code, but did not.Amit LangoteDiscussion:http://postgr.es/m/52d9c443-ec78-5c8a-7a77-0f34aad12b82@lab.ntt.co.jp
1 parent6599c9a commit02af785

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

‎src/backend/rewrite/rewriteDefine.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid,
900900
form= (Form_pg_class)GETSTRUCT(tuple);
901901

902902
/* only tables and views can have rules */
903-
if (form->relkind!=RELKIND_RELATION&&form->relkind!=RELKIND_VIEW)
903+
if (form->relkind!=RELKIND_RELATION&&
904+
form->relkind!=RELKIND_VIEW&&
905+
form->relkind!=RELKIND_PARTITIONED_TABLE)
904906
ereport(ERROR,
905907
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
906908
errmsg("\"%s\" is not a table or view",rv->relname)));

‎src/test/regress/expected/rules.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3216,3 +3216,10 @@ SELECT pg_get_function_arg_default('pg_class'::regclass, 0);
32163216

32173217
(1 row)
32183218

3219+
-- test rename for a rule defined on a partitioned table
3220+
CREATE TABLE parted_table (a int) PARTITION BY LIST (a);
3221+
CREATE TABLE parted_table_1 PARTITION OF parted_table FOR VALUES IN (1);
3222+
CREATE RULE parted_table_insert AS ON INSERT to parted_table
3223+
DO INSTEAD INSERT INTO parted_table_1 VALUES (NEW.*);
3224+
ALTER RULE parted_table_insert ON parted_table RENAME TO parted_table_insert_redirect;
3225+
DROP TABLE parted_table;

‎src/test/regress/sql/rules.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,3 +1158,11 @@ SELECT pg_get_function_identity_arguments(0);
11581158
SELECT pg_get_function_result(0);
11591159
SELECT pg_get_function_arg_default(0,0);
11601160
SELECT pg_get_function_arg_default('pg_class'::regclass,0);
1161+
1162+
-- test rename for a rule defined on a partitioned table
1163+
CREATETABLEparted_table (aint) PARTITION BY LIST (a);
1164+
CREATETABLEparted_table_1 PARTITION OF parted_table FORVALUESIN (1);
1165+
CREATERULEparted_table_insertASON INSERT to parted_table
1166+
DO INSTEADINSERT INTO parted_table_1VALUES (NEW.*);
1167+
ALTERRULE parted_table_insertON parted_table RENAME TO parted_table_insert_redirect;
1168+
DROPTABLE parted_table;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp