Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
Date
Msg-id 312797.1665500865@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.  (Japin Li <japinli@hotmail.com>)
Responses Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
List pgsql-bugs
Japin Li <japinli@hotmail.com> writes:
> On Tue, 11 Oct 2022 at 21:16, Richard Guo <guofenglinux@gmail.com> wrote:
>> +1 for the idea. We need to identify the right target relation for each
>> product query and rt_entry_relation is not the right one.

> After some more thinking, I find the previous cannot work correctly.

Yeah.  The product query might not be an INSERT at all, yet
rewriteValuesRTE is assuming it is --- that whole business of
scanning the targetlist for referencing Vars and then saving
their resnos doesn't make sense otherwise.

I think the basic problem is that the two calls of rewriteValuesRTE
are really dealing with fundamentally different cases, and we should
probably not have tried to make the same function do both.  I'm going
to try splitting it into two functions, one for the force_nulls case
and one for the !force_nulls case.  The force_nulls case shouldn't
really need a target_relation parameter in the first place (since it
has no business assuming that the query is an INSERT).  I think it
should just replace each SetToDefault with a NULL of the same type
as the SetToDefault, and call it good.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17634: Inconsistent view_definition in information_schema.views
Next
From: Tom Lane
Date:
Subject: Re: BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.