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

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: n(dot)lutic(at)loxodata(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17486: [pg_restore] Restoring a view fails if this view contains an attribute without alias name.
Date: 2022-05-20 12:51:08
Message-ID: 792E8C73-EBE0-41FC-A83F-2F7A7AF4ABBB@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On 19 May 2022, at 14:03, PG Bug reporting form <noreply(at)postgresql(dot)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/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-05-20 13:13:36 BUG #17490: unconsistency between TRUNCATE RESTART IDENTITY and setval()
Previous Message Masahiko Sawada 2022-05-20 11:36:33 Re: Implicitly created operator family not listed by pg_event_trigger_ddl_commands