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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: n(dot)lutic(at)loxodata(dot)com
Subject: BUG #17486: [pg_restore] Restoring a view fails if this view contains an attribute without alias name.
Date: 2022-05-19 12:03:37
Message-ID: 17486-1ad6fd786728b8af@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17486
Logged by: Nicolas Lutic
Email address: n(dot)lutic(at)loxodata(dot)com
PostgreSQL version: 14.3
Operating system: Debian 11
Description:

Hi Team,

I found something weird. Restoring a view fails if this view contains an
attribute without alias name.

Please find below the details to reproduce the problem:

psql -h localhost -c 'CREATE DATABASE demo;'

psql -h localhost -d demo

demo=# CREATE VIEW v_static_select as
WITH static_select as (
select
1 as foo,
'text'
)
select * from static_select;


demo=# \d+ v_static_select
View "public.v_static_select"
Column | Type | Collation | Nullable | Default | Storage |
Description

----------+---------+-----------+----------+---------+----------+-------------
foo | integer | | | | plain |
?column? | text | | | | extended |
View definition:
WITH static_select AS (
SELECT 1 AS foo,
'text'::text
)
SELECT static_select.foo,
static_select."?column?"
FROM static_select;

demo=# select * from v_static_select;
foo | ?column?
-----+----------
1 | text
(1 row)

pg_dump -h localhost -p5432 -U postgres -d demo -Fc -f /tmp/demo.dump

psql -h localhost -p5432 -U postgres -d demo -c 'DROP VIEW
v_static_select ;'

pg_restore -s -h localhost -p5432 -U postgres -d demo /tmp/demo.dump

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;

Regards, Nicolas Lutic

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2022-05-19 12:03:56 Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY
Previous Message Andrey Lepikhov 2022-05-19 09:03:55 Re: Negative value of numGroups