mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 14:01:27 +02:00
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 table partition into a view. Amit Langote Discussion: https://postgr.es/m/CAEZATCVzFcAjZwC1bTFvJ09skB_sgkF4SwPKMywev-XTnimp9Q%40mail.gmail.com
This commit is contained in:
parent
ba1f017069
commit
bcbf392ec8
@ -428,6 +428,12 @@ DefineQueryRewrite(char *rulename,
|
|||||||
errmsg("could not convert partitioned table \"%s\" to a view",
|
errmsg("could not convert partitioned table \"%s\" to a view",
|
||||||
RelationGetRelationName(event_relation))));
|
RelationGetRelationName(event_relation))));
|
||||||
|
|
||||||
|
if (event_relation->rd_rel->relispartition)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||||
|
errmsg("could not convert partition \"%s\" to a view",
|
||||||
|
RelationGetRelationName(event_relation))));
|
||||||
|
|
||||||
snapshot = RegisterSnapshot(GetLatestSnapshot());
|
snapshot = RegisterSnapshot(GetLatestSnapshot());
|
||||||
scanDesc = heap_beginscan(event_relation, snapshot, 0, NULL);
|
scanDesc = heap_beginscan(event_relation, snapshot, 0, NULL);
|
||||||
if (heap_getnext(scanDesc, ForwardScanDirection) != NULL)
|
if (heap_getnext(scanDesc, ForwardScanDirection) != NULL)
|
||||||
|
@ -2572,6 +2572,11 @@ create table fooview (x int, y text) partition by list (x);
|
|||||||
create rule "_RETURN" as on select to fooview do instead
|
create rule "_RETURN" as on select to fooview do instead
|
||||||
select 1 as x, 'aaa'::text as y;
|
select 1 as x, 'aaa'::text as y;
|
||||||
ERROR: could not convert partitioned table "fooview" to a view
|
ERROR: could not convert partitioned table "fooview" to a view
|
||||||
|
-- nor can one convert a partition to view
|
||||||
|
create table fooview_part partition of fooview for values in (1);
|
||||||
|
create rule "_RETURN" as on select to fooview_part do instead
|
||||||
|
select 1 as x, 'aaa'::text as y;
|
||||||
|
ERROR: could not convert partition "fooview_part" to a view
|
||||||
--
|
--
|
||||||
-- check for planner problems with complex inherited UPDATES
|
-- check for planner problems with complex inherited UPDATES
|
||||||
--
|
--
|
||||||
|
@ -903,6 +903,11 @@ create table fooview (x int, y text) partition by list (x);
|
|||||||
create rule "_RETURN" as on select to fooview do instead
|
create rule "_RETURN" as on select to fooview do instead
|
||||||
select 1 as x, 'aaa'::text as y;
|
select 1 as x, 'aaa'::text as y;
|
||||||
|
|
||||||
|
-- nor can one convert a partition to view
|
||||||
|
create table fooview_part partition of fooview for values in (1);
|
||||||
|
create rule "_RETURN" as on select to fooview_part do instead
|
||||||
|
select 1 as x, 'aaa'::text as y;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- check for planner problems with complex inherited UPDATES
|
-- check for planner problems with complex inherited UPDATES
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user