Re: Saving view turns SELECT * into field list - Mailing list pgsql-general

From David G. Johnston
Subject Re: Saving view turns SELECT * into field list
Date
Msg-id CAKFQuwZ4cPRoaGx7N2dKmvYysJ5tBey+_nvWF0rkokYp21Eupw@mail.gmail.com
Whole thread Raw
In response to Saving view turns SELECT * into field list  (Ben Uphoff <buphoff@villagemd.com>)
List pgsql-general
On Monday, October 15, 2018, Ben Uphoff <buphoff@villagemd.com> wrote:


Why, when I save a simple view like:

 

SELECT * FROM a_table

 

…does PostgreSQL turn the * into a field list like:

 

SELECT field1, field2, field3, field4 FROM a_table



Yes, deeply nesting views is a maintenance concern.  It works this way so the view remains stable (there may be others, the reasoning no longer really matters...).  If you really want dynamic SQL you will need to use a function.

David J.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Saving view turns SELECT * into field list
Next
From: Adrian Klaver
Date:
Subject: Re: FATAL: terminating connection because protocol synchronizationwas lost