Re: BUG #18763: pg_get_viewdef returns an old def with new relation name

From: lyz <linyuzhe(dot)lyz(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18763: pg_get_viewdef returns an old def with new relation name
Date: 2025-01-07 03:13:50
Message-ID: CABRu854-EF3bgR-dAyapoyBz4m3sFvnT8Z_WY6RTARy-hjqFyg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

It seems like an old, raw viewdef has already been obtained from pg_rewrite
before it was blocked by first connection.
Then in `get_query_def`, it tries to parse the raw viewdef.
Before finishing its work, `get_query_def` will acquire locks and wait
until first connection finishes.
After that, during the parsing process, relation names are finally
generated by `generate_relation_name` in ruleutils.c using
`SearchSysCache1`.
And `SearchSysCache1` will use the catalog snapshot to get the latest
relname.
Perhaps we should refer to the code of `pg_get_constraintdef_worker`,
directly using `systable_beginscan` with transaction snapshot?

Regards
Lin Yuzhe

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2025-01-07 07:00:21 Re: BUG #18764: server closed the connection unexpectedly
Previous Message David G. Johnston 2025-01-06 19:25:36 Re: BUG #18765: Inconsistent behaviour and errors with LIKE