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

Commitbcbf392

Browse files
committed
Prevent table partitions from being turned into views.
A table partition must be a table, not a view, so don't allow a"_RETURN" rule to be added that would convert an existing tablepartition into a view.Amit LangoteDiscussion:https://postgr.es/m/CAEZATCVzFcAjZwC1bTFvJ09skB_sgkF4SwPKMywev-XTnimp9Q%40mail.gmail.com
1 parentba1f017 commitbcbf392

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

‎src/backend/rewrite/rewriteDefine.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ DefineQueryRewrite(char *rulename,
428428
errmsg("could not convert partitioned table \"%s\" to a view",
429429
RelationGetRelationName(event_relation))));
430430

431+
if (event_relation->rd_rel->relispartition)
432+
ereport(ERROR,
433+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
434+
errmsg("could not convert partition \"%s\" to a view",
435+
RelationGetRelationName(event_relation))));
436+
431437
snapshot=RegisterSnapshot(GetLatestSnapshot());
432438
scanDesc=heap_beginscan(event_relation,snapshot,0,NULL);
433439
if (heap_getnext(scanDesc,ForwardScanDirection)!=NULL)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,6 +2572,11 @@ create table fooview (x int, y text) partition by list (x);
25722572
create rule "_RETURN" as on select to fooview do instead
25732573
select 1 as x, 'aaa'::text as y;
25742574
ERROR: could not convert partitioned table "fooview" to a view
2575+
-- nor can one convert a partition to view
2576+
create table fooview_part partition of fooview for values in (1);
2577+
create rule "_RETURN" as on select to fooview_part do instead
2578+
select 1 as x, 'aaa'::text as y;
2579+
ERROR: could not convert partition "fooview_part" to a view
25752580
--
25762581
-- check for planner problems with complex inherited UPDATES
25772582
--

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@ create table fooview (x int, y text) partition by list (x);
903903
createrule "_RETURN"asonselect to fooview do instead
904904
select1as x,'aaa'::textas y;
905905

906+
-- nor can one convert a partition to view
907+
createtablefooview_part partition of fooview forvaluesin (1);
908+
createrule "_RETURN"asonselect to fooview_part do instead
909+
select1as x,'aaa'::textas y;
910+
906911
--
907912
-- check for planner problems with complex inherited UPDATES
908913
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp