From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: hulehua@zoho.com
Subject: BUG #16928: pg_restore --clean/-c occurs ERROR for partitioned range table
Date: Tue, 16 Mar 2021 03:18:38 +0000
Message-ID: <16928-54e2ea7edca104c1@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16928
Logged by: hua
Email address: hulehua@zoho.com
PostgreSQL version: 13.1
Operating system: CentOS 7 x86_64
Description:
Hello, below is my steps for reproducing it:
1. setup data environment
./bin/psql -p 5444 -d postgres -U postgres
psql (13.1)
Type "help" for help.
postgres=# \d
Did not find any relations.
postgres=# create table table_range(id serial, user_id int4, create_time
timestamp(0) unique) partition by range(create_time);
CREATE TABLE
postgres=# create table table_range_1 partition of table_range for values
from ('2020-01-01') to ('2020-12-31');
CREATE TABLE
postgres=# \d+
List of relations
Schema | Name | Type | Owner | Persistence |
Size | Description
--------+--------------------+-------------------+----------+-------------+------------+-------------
public | table_range | partitioned table | postgres | permanent |
0 bytes |
public | table_range_1 | table | postgres | permanent |
0 bytes |
public | table_range_id_seq | sequence | postgres | permanent |
8192 bytes |
(3 rows)
postgres=# \q
2. use pg_dump to dump the postgres database to file postgres.dmp
./bin/pg_dump -p 5444 -d postgres -U postgres -Fc -f postgres.dmp
3. use pg_restore to restore the dump file directly to the original
database, with -c parameter
./bin/pg_restore -p 5444 -d postgres -U postgres -c -e postgres.dmp
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 2997; 2606 16413 CONSTRAINT table_range_1
table_range_1_create_time_key postgres
pg_restore: error: could not execute query: ERROR: cannot drop inherited
constraint "table_range_1_create_time_key" of relation "table_range_1"
Command was: ALTER TABLE ONLY public.table_range_1 DROP CONSTRAINT
table_range_1_create_time_key;
PS, I'm not familiar with database, especially for range table topic; and
not sure whether it's a bug or not. Sorry for your time if this scenario is
normal. And I made a temporary fix which looks work well.
src/bin/pg_dump/pg_dump.c
++ 16976 if (!tbinfo->ispartition)
++ 16977 {
16978 appendPQExpBuffer(delq, "ALTER %sTABLE ONLY %s ",
foreign,
16979
fmtQualifiedDumpable(tbinfo));
16980 appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
16981
fmtId(coninfo->dobj.name));
++ 16982 }
Thank you and sorry for disturbing,
Hua
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, hulehua@zoho.com
Subject: Re: BUG #16928: pg_restore --clean/-c occurs ERROR for partitioned range table
In-Reply-To: <16928-54e2ea7edca104c1@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