diff options
author | Dean Rasheed <dean.a.rasheed@gmail.com> | 2017-06-21 10:43:17 +0100 |
---|---|---|
committer | Dean Rasheed <dean.a.rasheed@gmail.com> | 2017-06-21 10:43:17 +0100 |
commit | bcbf392ec84362040faf72daad22c647c74e2b2a (patch) | |
tree | ffb74cdf9b3c488bdbe233e4a59a0ca9156aae0e /src/backend | |
parent | ba1f017069dd87d309e2716bf08a40df42b29baa (diff) | |
download | postgresql-bcbf392ec84362040faf72daad22c647c74e2b2a.tar.gz postgresql-bcbf392ec84362040faf72daad22c647c74e2b2a.zip |
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
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/rewrite/rewriteDefine.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index fd3768de171..4213bafa270 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -428,6 +428,12 @@ DefineQueryRewrite(char *rulename, errmsg("could not convert partitioned table \"%s\" to a view", 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()); scanDesc = heap_beginscan(event_relation, snapshot, 0, NULL); if (heap_getnext(scanDesc, ForwardScanDirection) != NULL) |