From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | hulehua(at)zoho(dot)com |
Subject: | BUG #16928: pg_restore --clean/-c occurs ERROR for partitioned range table |
Date: | 2021-03-16 03:18:38 |
Message-ID: | 16928-54e2ea7edca104c1@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: 16928
Logged by: hua
Email address: hulehua(at)zoho(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2021-03-16 05:09:29 | BUG #16929: The Enterprise DB installer file is available as binary and not as .dmg file for 12.6 |
Previous Message | Michael Paquier | 2021-03-16 01:53:46 | Re: BUG #16927: Postgres can`t access WAL files |