mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
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
This commit is contained in:
@ -2388,6 +2388,13 @@ rewriteTargetView(Query *parsetree, Relation view)
|
||||
parsetree->rtable = lappend(parsetree->rtable, new_rte);
|
||||
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
|
||||
|
Reference in New Issue
Block a user