aboutsummaryrefslogtreecommitdiff
path: root/src/backend/rewrite/rewriteHandler.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-07-03 12:26:33 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2013-07-03 12:26:33 -0400
commit654b702a1c01fa047a363a887f957886503ea67c (patch)
tree2cfc3904e85f6dce92bd516b9051abfb19976209 /src/backend/rewrite/rewriteHandler.c
parentc21bb48d6fc1827e117e2667e0a5d9d96d984f46 (diff)
downloadpostgresql-654b702a1c01fa047a363a887f957886503ea67c.tar.gz
postgresql-654b702a1c01fa047a363a887f957886503ea67c.zip
Fix handling of auto-updatable views on inherited tables.
An INSERT into such a view should work just like an INSERT into its base table, ie the insertion should go directly into that table ... not be duplicated into each child table, as was happening before, per bug #8275 from Rushabh Lathia. On the other hand, the current behavior for UPDATE/DELETE seems reasonable: the update/delete traverses the child tables, or not, depending on whether the view specifies ONLY or not. Add some regression tests covering this area. Dean Rasheed
Diffstat (limited to 'src/backend/rewrite/rewriteHandler.c')
-rw-r--r--src/backend/rewrite/rewriteHandler.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index a467588e50e..4163301542a 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -2389,6 +2389,13 @@ rewriteTargetView(Query *parsetree, Relation view)
new_rt_index = list_length(parsetree->rtable);
/*
+ * INSERTs never inherit. For UPDATE/DELETE, we use the view query's
+ * inheritance flag for the base relation.
+ */
+ if (parsetree->commandType == CMD_INSERT)
+ new_rte->inh = false;
+
+ /*
* Make a copy of the view's targetlist, adjusting its Vars to reference
* the new target RTE, ie make their varnos be new_rt_index instead of
* base_rt_index. There can be no Vars for other rels in the tlist, so