Re: BUG #17486: [pg_restore] Restoring a view fails if this view contains an attribute without alias name.
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: n.lutic@loxodata.com,
pgsql-bugs@lists.postgresql.org
Date: 2022-05-20T12:51:08Z
Lists: 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/
Commits
-
Show 'AS "?column?"' explicitly when it's important.
- fefd5463173a 13.8 landed
- f3b8d7244ae1 11.17 landed
- c7461fc25558 15.0 landed
- bb2c04676be0 12.12 landed
- 7686403b43ca 10.22 landed
- 6f7eec1193f8 14.4 landed