Re: Unqualified relations in views
Pete O'Such <posuch@gmail.com>
From: "Pete O'Such" <posuch@gmail.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-general@lists.postgresql.org
Date: 2023-09-13T17:41:34Z
Lists: pgsql-general
> PostgreSQL resolves tables and other objects according to the setting of
> "search_path" at CREATE VIEW time. The query itself is stored in parsed
form.
>
> pg_get_viewdef() deparses the query and only prepends a schema name if the
> schema is not on the "search_path". So the solution is to set
"search_path"
> empty:
>
> SET search_path = '';
>
> SELECT pg_get_viewdef('myschema.myview');
Thank you! That is the perfect answer to my question!
Is Postgres hiding the ball a bit here? Is there a reason that obscuring
the
known and static schema is better than showing it? In my case (tracking
down
execution differences between local and FDW view use) this has occupied a
lot of
time.
Thanks again,
Pete O'Such