Re: How to keep format of views source code as entered?

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: How to keep format of views source code as entered?
Дата
Msg-id 05bbb83f4efe2eb860c701e77557c7cc6c9356fa.camel@cybertec.at
обсуждение исходный текст
Ответ на Re: How to keep format of views source code as entered?  (Adam Brusselback <adambrusselback@gmail.com>)
Ответы Re: How to keep format of views source code as entered?  (Paul Förster <paul.foerster@gmail.com>)
Список pgsql-general
On Wed, 2021-01-13 at 20:39 -0500, Adam Brusselback wrote:
> > Admittedly, the system probably should be made to save the text, should someone wish to write such a patch. 
> 
> It has been a major annoyance for views with complex subqueries or where clauses, the PG representation is absolutely
unreadable.

This is not going to happen, and I dare say that such a patch would be rejected.

Since PostgreSQL stores view definitions in their parsed form, the query does
not contain the name of the used objects, but only their object ID.

This allows you for example to rename the underlying objects, because that
does not change the object ID:

CREATE TABLE t (id integer);

CREATE VIEW v AS SELECT * FROM t;

\d+ v
[...]
View definition:
 SELECT t.id
   FROM t;

ALTER TABLE t RENAME TO quaxi;

\d+ v
[...]
View definition:
 SELECT quaxi.id
   FROM quaxi;

If PostgreSQL were to store the original text, either that text would become
wrong, or you would have to forbid renaming of anything that is referenced
by a view.

A database is no source versioning system.  The next thing someone will request
is that the original CREATE TABLE or CREATE INDEX statements should be preserved.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




В списке pgsql-general по дате отправления:

Предыдущее
От: Adam Brusselback
Дата:
Сообщение: Re: How to keep format of views source code as entered?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: How to keep format of views source code as entered?