Re: 12.1 Partitioned Table Creation Bug

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Chris Drawater <Chris(dot)Drawater(at)viavisolutions(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: 12.1 Partitioned Table Creation Bug
Date: 2020-01-22 23:17:44
Message-ID: 31928.1579735064@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Wed, Jan 22, 2020 at 12:48 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Chris Drawater <Chris(dot)Drawater(at)viavisolutions(dot)com> writes:
>>> geo=> create table junk ( a int, b int) PARTITION BY RANGE (a);
>>> ERROR: cannot specify default tablespace for partitioned relations

>> I'm guessing you've got default_tablespace set to something nonempty.
>> I don't know why the decision was made to throw an error rather than
>> silently ignoring the setting ...

> Ignoring the setting seems to be what the documentation says we do:
> https://www.postgresql.org/docs/12/sql-createtable.html
> "For partitioned tables, since no storage is required for the table itself,
> the tablespace specified overrides default_tablespace as the default
> tablespace to use for any newly created partitions when no other tablespace
> is explicitly specified."
> So this seems like a regression in v12.

Poking into it, I can reproduce Chris' failure in the specific case
where default_tablespace is explicitly set to "pg_default" rather
than being left empty.

You're right that this is new behavior in v12; it seems to have been
introduced by commit 87259588d, which quoth

* Setting a partitioned rel's tablespace to the database default is
confusing; if it worked, it would direct the partitions to that
tablespace regardless of default_tablespace. But in reality it does
not work, and making it work is a larger project. Therefore, throw
an error when this condition is detected, to alert the unwary.

I wouldn't say that this behavior is "alerting the unwary"; it's just
confusing them --- and the case that this is less confusing than what
happened before seems pretty thin.

Maybe a better error message would improve matters. But I'm inclined
to say that reverting this aspect of the patch would be a better idea.
I find it particularly bletcherous that it made GetDefaultTablespace()
know whether it's operating to select a tablespace for a partitioned
relation or some other case --- that is just awful design, and it doesn't
make me feel that the whole idea was especially well thought out.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message selva kumar 2020-01-23 07:34:40 Query will execute when inner query have issue
Previous Message David G. Johnston 2020-01-22 21:39:32 Re: 12.1 Partitioned Table Creation Bug