Re: BUG #18763: pg_get_viewdef returns an old def with new relation name - Mailing list pgsql-bugs

From lyz
Subject Re: BUG #18763: pg_get_viewdef returns an old def with new relation name
Date
Msg-id CABRu854-EF3bgR-dAyapoyBz4m3sFvnT8Z_WY6RTARy-hjqFyg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18763: pg_get_viewdef returns an old def with new relation name  (Kirill Reshke <reshkekirill@gmail.com>)
List 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

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #18765: Inconsistent behaviour and errors with LIKE
Next
From: Richard Guo
Date:
Subject: Re: BUG #18764: server closed the connection unexpectedly