pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: dmitry.telpt@gmail.com
Subject: BUG #16119: pg_dump omits columns specification for matviews
Date: Fri, 15 Nov 2019 22:16:51 +0000
Message-ID: <16119-e64823f30a45a754@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16119
Logged by:          Dmitry Telpt
Email address:      dmitry.telpt@gmail.com
PostgreSQL version: 9.4.25
Operating system:   Linux/Docker
Description:        

Hi there,

We've faced up with an issue how pg_dump exports materialzed views, it
doesn't export columns declaration that is legal parameter of CREATE DDL
instruction.
As I can see from db_dump source, it's intent behaviour and supposed that
columns declarion will be picked up from query statement when matview is
created by target instance. However, if matview is 'static' (doesn't have a
query statement), it sets default column names (column1, column2, etc) that
breaks all dependent tables/views/matviews, for instance:

postgres=> CREATE MATERIALIZED VIEW test_mv
  (id, alias) AS
  VALUES (1, 5), (2, 6), (3, 17)
;
SELECT 3
postgres=> \d+ test_mv
                 Materialized view "public.test_mv"
 Column |  Type   | Modifiers | Storage | Stats target | Description 
--------+---------+-----------+---------+--------------+-------------
 id     | integer |           | plain   |              | 
 alias  | integer |           | plain   |              | 
View definition:
 VALUES (1,5), (2,6), (3,17);


but pg_dump produces the following DDL statement:
--
-- Name: test_mv; Type: MATERIALIZED VIEW; Schema: public; Owner: postgres
--

CREATE MATERIALIZED VIEW public.test_mv AS
 VALUES (1,5), (2,6), (3,17)
  WITH NO DATA;

that leads to the following declaration in target instance:
postgres=> \d+ test_mv
         Materialized view "public.test_mv"
 Column  |  Type   | Modifiers | Storage | Stats target | Description 
---------+---------+-----------+---------+--------------+-------------
 column1 | integer |           | plain   |              | 
 column2 | integer |           | plain   |              | 
View definition:
 VALUES (1,5), (2,6), (3,17);

the version of engine or db_dump doesn't matter, the same behavior.

it's minor bug, since dump file may be fixed manually before restoring but
when you don't have access to file (for instance, AWS RDS upgrade
procedure), it becomes very painful.

Thanks,
Dmitry



view thread (6+ messages)  latest in thread

Message-ID: <16119-e64823f30a45a754@postgresql.org>
Permalink:  ../16119-e64823f30a45a754@postgresql.org/
Also on:    postgresql.org/message-id/16119-e64823f30a45a754@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, dmitry.telpt@gmail.com
  Subject: Re: BUG #16119: pg_dump omits columns specification for matviews
  In-Reply-To: <16119-e64823f30a45a754@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox