Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iuPFy-0007pw-6d for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Jan 2020 23:17:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iuPFw-0006NK-Ts for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Jan 2020 23:17:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iuPFw-0006ND-Ld for pgsql-bugs@lists.postgresql.org; Wed, 22 Jan 2020 23:17:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iuPFt-00040L-Cc for pgsql-bugs@lists.postgresql.org; Wed, 22 Jan 2020 23:17:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 00MNHifj031929; Wed, 22 Jan 2020 18:17:44 -0500 From: Tom Lane To: "David G. Johnston" cc: Alvaro Herrera , Chris Drawater , "pgsql-bugs@lists.postgresql.org" Subject: Re: 12.1 Partitioned Table Creation Bug In-reply-to: References: <25735.1579722477@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Wed, 22 Jan 2020 14:39:32 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31927.1579735064.1@sss.pgh.pa.us> Date: Wed, 22 Jan 2020 18:17:44 -0500 Message-ID: <31928.1579735064@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > On Wed, Jan 22, 2020 at 12:48 PM Tom Lane wrote: >> Chris Drawater 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