> On 19 May 2022, at 14:03, PG Bug reporting form <noreply@postgresql.org> wrote:
> I found something weird. Restoring a view fails if this view contains an
> attribute without alias name.
This is not unique to 14, it can be reproduced further down as well.
> pg_restore: error: could not execute query: ERROR: column
> static_select.?column? does not exist
> LINE 7: static_select."?column?"
> ^
> Command was: CREATE VIEW public.v_static_select AS
> WITH static_select AS (
> SELECT 1 AS foo,
> 'text'::text
> )
> SELECT static_select.foo,
> static_select."?column?"
> FROM static_select;
Since there is no column name given, FigureColname() will do its best to figure
something out and the typecast to TEXT added will lead it to chose the column
type as the column name. This will lead the qualified "?column?" target col in
the view query to not resolve. When creating the view the ::text explicit cast
is added after column names are resolved so this only breaks on restoring the
view definition for the expanded SELECT *.
--
Daniel Gustafsson https://vmware.com/