Fix dumping pre-10 DBs by pg_dump10 if table "name" exists

From: Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix dumping pre-10 DBs by pg_dump10 if table "name" exists
Date: 2017-10-31 12:08:49
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

Hello, hackers!

Recently my colleagues found a bug.
They could not migrate from PG9.5 to PG10 due to error during
pg_upgrage (the same as in the "reproduce" part below).
An investigation showed there is a table "name" in the same schema
where the dumped sequence is located and the PG tries to unpack the
literal "bigint" as a composite type and fails.

The bug was introduced by two commits, one of them changes
search_path, the second one introduces the "'bigint'::name"
without specifying schema:
da4d1c0c15ab9afdfeee8bad9a1a9989b6bd59b5 pg_dump: Fix some schema
issues when dumping sequences
2ea5b06c7a7056dca0af1610aadebe608fbcca08 Add CREATE SEQUENCE AS <data
type> clause

Steps to reproduce:
$ psql -h pre-10 postgres
Password for user postgres:
psql (11devel, server 9.5.8)
Type "help" for help.

postgres=# create table name(id serial);
postgres=# \q

$ pg_dump -h pre-10 postgres
pg_dump: [archiver (db)] query failed: ERROR: malformed record
literal: "bigint"
LINE 1: SELECT 'bigint'::name AS sequence_type, start_value, increme...
DETAIL: Missing left parenthesis.
pg_dump: [archiver (db)] query was: SELECT 'bigint'::name AS
sequence_type, start_value, increment_by, max_value, min_value,
cache_value, is_cycled FROM name_id_seq

I've implemented a little fix (attached), don't think there is
something to be written to docs and tests.

Best regards,
Vitaly Burovoy

Attachment Content-Type Size
0001-Fix-dumping-schema-if-a-table-named-name-exists.patch application/octet-stream 1.3 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2017-10-31 12:24:22 Re: Deadlock in ALTER SUBSCRIPTION REFRESH PUBLICATION
Previous Message Stephen Frost 2017-10-31 11:56:19 Re: MERGE SQL Statement for PG11