Re: BUG #17486: [pg_restore] Restoring a view fails if this view contains an attribute without alias name. - Mailing list pgsql-bugs

From Daniel Gustafsson
Subject Re: BUG #17486: [pg_restore] Restoring a view fails if this view contains an attribute without alias name.
Date
Msg-id 792E8C73-EBE0-41FC-A83F-2F7A7AF4ABBB@yesql.se
Whole thread Raw
In response to BUG #17486: [pg_restore] Restoring a view fails if this view contains an attribute without alias name.  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17486: [pg_restore] Restoring a view fails if this view contains an attribute without alias name.
List pgsql-bugs
> 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/




pgsql-bugs by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Implicitly created operator family not listed by pg_event_trigger_ddl_commands
Next
From: PG Bug reporting form
Date:
Subject: BUG #17490: unconsistency between TRUNCATE RESTART IDENTITY and setval()