From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Chris Drawater <Chris.Drawater@viavisolutions.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: 12.1 Partitioned Table Creation Bug
Date: Wed, 22 Jan 2020 18:17:44 -0500
Message-ID: <31928.1579735064@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZLsGaz2fS8F-sNxmZMRL=z=AA_BepmP3YxEyVxXEmqig@mail.gmail.com>
References: <BY5PR18MB3170E372542F34694E630B12F10C0@BY5PR18MB3170.namprd18.prod.outlook.com>
<25735.1579722477@sss.pgh.pa.us>
<CAKFQuwZLsGaz2fS8F-sNxmZMRL=z=AA_BepmP3YxEyVxXEmqig@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Jan 22, 2020 at 12:48 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Chris Drawater <Chris.Drawater@viavisolutions.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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, alvherre@2ndquadrant.com, Chris.Drawater@viavisolutions.com
Subject: Re: 12.1 Partitioned Table Creation Bug
In-Reply-To: <31928.1579735064@sss.pgh.pa.us>
References: <BY5PR18MB3170E372542F34694E630B12F10C0@BY5PR18MB3170.namprd18.prod.outlook.com> <25735.1579722477@sss.pgh.pa.us> <CAKFQuwZLsGaz2fS8F-sNxmZMRL=z=AA_BepmP3YxEyVxXEmqig@mail.gmail.com> <31928.1579735064@sss.pgh.pa.us>
* 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