Re: BUG #18167: cannot create partitioned tables when default_tablespace is set

From: tender wang <tndrwang(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: mariusraicu(at)laposte(dot)net, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18167: cannot create partitioned tables when default_tablespace is set
Date: 2023-10-25 09:58:21
Message-ID: CAHewXNmE8uRHFBiMXT2o0s19=xHpyc0gTLOf1cdc1C6BwqAwGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> 于2023年10月25日周三 17:41写道:

> On 2023-Oct-24, PG Bug reporting form wrote:
>
> > marius(at)[local]:5434/postgres=# show default_tablespace;
> > default_tablespace
> > --------------------
> > tblspc1
> > (1 row)
> >
> > marius(at)[local]:5434/postgres=# create tablespace tblspc1 location
> > '/home/marius/pgcode/tblspc1';
> > CREATE TABLESPACE
> > marius(at)[local]:5434/postgres=# create database test tablespace tblspc1;
> > CREATE DATABASE
> > marius(at)[local]:5434/postgres=# \c test
> > You are now connected to database "test" as user "marius".
> > marius(at)[local]:5434/test=# create table toto(id numeric) partition by
> > list(id);
> > ERROR: cannot specify default tablespace for partitioned relations
>
> Oh, so the problem here is that *both* default_tablespace and the
> database's tablespace are set, and then a partitioned table creation
> fails when it doesn't specify any tablespace? That indeed sounds like a
> bug. I'll have a look, thanks. I'm surprised it took so long for this
> to be reported.
>

Oh, interesting issue!
I found another two case:
First: default_tablespace not set and create part rel failed
postgres=# create tablespace tbsp3 location '/tender/pgsql/tbsp3';
CREATE TABLESPACE
postgres=# create database test3 tablespace tbsp3;
CREATE DATABASE
postgres=# \c test3
You are now connected to database "test3" as user "gpadmin".
test3=# show default_tablespace ;
default_tablespace
--------------------

(1 row)

test3=# create table part1(a int) partition by list(a) tablespace tbsp3;
ERROR: cannot specify default tablespace for partitioned relations

Second: default_tablespace and database's tablespace both set, but part rel
created
test3=# set default_tablespace = tbsp2;
SET
test3=# create table part1(a int) partition by list(a);
CREATE TABLE

I'm not sure if the above two cases are a bug. If the document could
provide detailed explanations, that would be great.

> --
> Álvaro Herrera 48°01'N 7°57'E —
> https://www.EnterpriseDB.com/
> "Someone said that it is at least an order of magnitude more work to do
> production software than a prototype. I think he is wrong by at least
> an order of magnitude." (Brian Kernighan)
>
>
>
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-10-25 13:51:31 Re: AW: AW: BUG #18147: ERROR: invalid perminfoindex 0 in RTE with relid xxxxx
Previous Message Amit Langote 2023-10-25 08:16:22 Re: AW: AW: BUG #18147: ERROR: invalid perminfoindex 0 in RTE with relid xxxxx

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema 2023-10-25 10:05:41 Re: Add new for_each macros for iterating over a List that do not require ListCell pointer
Previous Message Drouvot, Bertrand 2023-10-25 09:48:33 Re: Synchronizing slots from primary to standby