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

Japin Li <japinli@hotmail.com>

From: Japin Li <japinli@hotmail.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: jiye_sw@126.com, pgsql-bugs@lists.postgresql.org
Date: 2022-10-11T14:35:50Z
Lists: pgsql-bugs
On Tue, 11 Oct 2022 at 21:16, Richard Guo <guofenglinux@gmail.com> wrote:
> On Tue, Oct 11, 2022 at 8:29 PM Japin Li <japinli@hotmail.com> wrote:
>
>>
>> On Tue, 11 Oct 2022 at 20:09, Richard Guo <guofenglinux@gmail.com> wrote:
>>
>> Yeah, I also notice this, attch a patch to fix it.
>
>
> +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.
For example:

    CREATE OR REPLACE v1_r AS ON INSERT TO t1 DO ALSO SELECT * FROM t2;

> A minor comment is can we know the product query is not CMD_SELECT?
> If so I suggest we add an assertion before fetching the target relation,
> something like:
>
> Assert(pt->resultRelation != 0);
>

Oh, I think this might not be true.  The product query comes from rules,
which might be a SELECT query, IIUC.  See above example.


--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



Commits

  1. Yet further fixes for multi-row VALUES lists for updatable views.