Problem on pg_dump RANGE partition with expressions

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Problem on pg_dump RANGE partition with expressions
Date: 2018-07-12 07:59:39
Message-ID: 20180712165939.36b12aff.nagata@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

During looking into other thread[1], I found a problem on pg_dump of range
partition table using expressions. When we create a range partitioned table,
we cannot use a column more than once in the partition key.

postgres=# create table t (i int) partition by range(i,i);
ERROR: column "i" appears more than once in partition key

On the other hand, the following query using expression is allowed.

postgres=# create table test (i int) partition by range(i,(i));
CREATE TABLE

However, when we use pg_dump for this, we get

CREATE TABLE public.test (
i integer
)
PARTITION BY RANGE (i, i);

, and we cannot restore this due to the error.

I can consider three approaches to resolve this.

1) Allow to appear more than once in range partition key

I don't understand why there is this restriction. If we have no clear reason,
can we rip out this restrition?

2) Forbid this kind of partition key

If we can make more checks and forbid such partition keys as RANGE(i,(i)),
we can avoid the problem though it is a bit rigorous.

3) Treat expressions as it is

For some reasons, expressions like "(column)" or "(column COLLATE something)"
is treated like simple attributes in the current implementation
(in ComputePartitionAttr() ).

If we treat these expressions as it is, pg_dump result will be the same
expression as when the partition table is created, and we can restore this
successfully.

Could you give me your opinions aoubt which approach is appropriate?

Regards,

[1] https://www.postgresql.org/message-id/flat/20180712155808.49e712d8.nagata%40sraoss.co.jp#00bbfb5054c0a57f9a2fe48fae77b848

--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message samuel.coulee 2018-07-12 08:08:44 Binary difference in pg_internal.init after running pg_initdb multiple times
Previous Message Michael Paquier 2018-07-12 07:59:09 Re: pgsql: Allow using the updated tuple while moving it to a different par