Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
От | Japin Li |
---|---|
Тема | Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error. |
Дата | |
Msg-id | MEYP282MB1669B7492DAFE6913C127ED8B6239@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM обсуждение исходный текст |
Ответ на | Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error. (Richard Guo <guofenglinux@gmail.com>) |
Ответы |
Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
|
Список | pgsql-bugs |
On Tue, 11 Oct 2022 at 20:09, Richard Guo <guofenglinux@gmail.com> wrote: > > I think the problem exists for auto-updatable view, as we leave the > DEFAULT items untouched because we expect to apply the underlying base > rel's default. > > In this case there is a rewrite rule on the view. Applying the rule > we'd get a product query whose target entries referring to the VALUES > RTE have attribute 3 and 4 while the relation has only two attributes. > Then we proceed to replacing the remaining DEFAULT items with NULLs. > And when we try to access the relation's 3rd and 4th attributes, we are > accessing illegal memory areas. > Yeah, I also notice this, attch a patch to fix it. -- Regrads, Japin Li. ChengDu WenWu Information Technology Co.,Ltd. diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index d02fd83c0a..2f77ff87dc 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -3857,13 +3857,20 @@ RewriteQuery(Query *parsetree, List *rewrite_events) foreach(n, product_queries) { Query *pt = (Query *) lfirst(n); + Relation target_relation; + RangeTblEntry *target_entry; RangeTblEntry *values_rte = rt_fetch(values_rte_index, pt->rtable); + target_entry = rt_fetch(pt->resultRelation, pt->rtable); + target_relation = table_open(target_entry->relid, NoLock); + rewriteValuesRTE(pt, values_rte, values_rte_index, - rt_entry_relation, + target_relation, true, /* Force remaining defaults to NULL */ NULL); + + table_close(target_relation, NoLock); } }
В списке pgsql-bugs по дате отправления: