pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix tablespace handling for partitioned indexes
5+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2018-11-23 a5586a0e0b de38ce1b83  Don't allow partitioned indexes in pg_global tablespace
* pgsql: Fix tablespace handling for partitioned indexes
@ 2018-11-03 16:33 Alvaro Herrera <alvherre@alvh.no-ip.org>
  2018-11-23 03:35 ` Re: pgsql: Fix tablespace handling for partitioned indexes David Rowley <david.rowley@2ndquadrant.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Alvaro Herrera @ 2018-11-03 16:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix tablespace handling for partitioned indexes

When creating partitioned indexes, the tablespace was not being saved
for the parent index. This meant that subsequently created partitions
would not use the right tablespace for their indexes.

ALTER INDEX SET TABLESPACE and ALTER INDEX ALL IN TABLESPACE raised
errors when tried; fix them too.  This requires bespoke code for
ATExecCmd() that applies to the special case when the tablespace move is
just a catalog change.

Discussion: https://postgr.es/m/20181102003138.uxpaca6qfxzskepi@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dfa6081419829ef60d6bc02691616337eeb7f988

Modified Files
--------------
src/backend/catalog/heap.c                | 10 +++++-
src/backend/commands/tablecmds.c          | 60 +++++++++++++++++++++++++++++--
src/test/regress/input/tablespace.source  | 10 ++++++
src/test/regress/output/tablespace.source | 19 +++++++++-
4 files changed, 94 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Fix tablespace handling for partitioned indexes
  2018-11-03 16:33 pgsql: Fix tablespace handling for partitioned indexes Alvaro Herrera <alvherre@alvh.no-ip.org>
@ 2018-11-23 03:35 ` David Rowley <david.rowley@2ndquadrant.com>
  2018-11-23 11:53   ` Re: pgsql: Fix tablespace handling for partitioned indexes Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 5+ messages in thread

From: David Rowley @ 2018-11-23 03:35 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-committers@lists.postgresql.org

On Sun, 4 Nov 2018 at 05:33, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> Fix tablespace handling for partitioned indexes

While working on something else, I noticed this:

# create table listp (a int) partition by list(a);
CREATE TABLE
# create index on listp (a) tablespace pg_global; -- properly disallowed
ERROR:  only shared relations can be placed in pg_global tablespace
# create index on listp (a);
CREATE INDEX
# alter index listp_a_idx set tablespace pg_global; -- should be disallowed
ALTER INDEX
# create table listp1 partition of listp for values in(1);
ERROR:  only shared relations can be placed in pg_global tablespace

A patch to fix is attached.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachments:

disallow_partitioned_indexes_from_being_put_in_pg_global.patch (application/octet-stream, 642B) download diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index a1137a3bf0..843ed48aa7 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -10939,6 +10939,12 @@ ATExecPartedIdxSetTableSpace(Relation rel, Oid newTableSpace) Assert(rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX); + /* Can't allow a non-shared relation in pg_global */ + if (newTableSpace == GLOBALTABLESPACE_OID) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("only shared relations can be placed in pg_global tablespace"))); + /* * No work if no change in tablespace. */
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: pgsql: Fix tablespace handling for partitioned indexes
  2018-11-03 16:33 pgsql: Fix tablespace handling for partitioned indexes Alvaro Herrera <alvherre@alvh.no-ip.org>
  2018-11-23 03:35 ` Re: pgsql: Fix tablespace handling for partitioned indexes David Rowley <david.rowley@2ndquadrant.com>
@ 2018-11-23 11:53   ` Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2018-11-23 11:53 UTC (permalink / raw)
  To: David Rowley <david.rowley@2ndquadrant.com>; +Cc: pgsql-committers@lists.postgresql.org

On 2018-Nov-23, David Rowley wrote:

> A patch to fix is attached.

Oops!  Thanks.  Pushed.  I added a test line to verify that the error is
thrown.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Fix tablespace handling for partitioned indexes
@ 2018-11-03 16:33 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2018-11-03 16:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix tablespace handling for partitioned indexes

When creating partitioned indexes, the tablespace was not being saved
for the parent index. This meant that subsequently created partitions
would not use the right tablespace for their indexes.

ALTER INDEX SET TABLESPACE and ALTER INDEX ALL IN TABLESPACE raised
errors when tried; fix them too.  This requires bespoke code for
ATExecCmd() that applies to the special case when the tablespace move is
just a catalog change.

Discussion: https://postgr.es/m/20181102003138.uxpaca6qfxzskepi@alvherre.pgsql

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/33e6c34c32677a168bee4bc6c335aa8d73211a56

Modified Files
--------------
src/backend/catalog/heap.c                | 10 +++++-
src/backend/commands/tablecmds.c          | 60 +++++++++++++++++++++++++++++--
src/test/regress/input/tablespace.source  | 10 ++++++
src/test/regress/output/tablespace.source | 19 +++++++++-
4 files changed, 94 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Fix tablespace handling for partitioned tables
@ 2018-12-17 18:44 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2018-12-17 18:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix tablespace handling for partitioned tables

When partitioned tables were introduced, we failed to realize that by
copying the tablespace handling for other relation kinds with no
physical storage we were causing the secondary effect that their
partitions would not automatically inherit the tablespace setting.  This
is surprising and unhelpful, so change it to adopt the behavior
introduced in pg11 (commit 33e6c34c3267) for partitioned indexes: the
parent relation remembers the tablespace specification, which is then
used for any new partitions that don't declare one.

Because this commit changes behavior of the TABLESPACE clause for
partitioned tables (it's no longer a no-op), it is not backpatched.

Author: David Rowley, Álvaro Herrera
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/CAKJS1f9SxVzqDrGD1teosFd6jBMM0UEaa14_8mRvcWE19Tu0hA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ca4103025dfe26eaaf6a500dec9170fbb176eebc

Modified Files
--------------
doc/src/sgml/ref/create_table.sgml        |   6 +-
src/backend/catalog/heap.c                |   6 +-
src/backend/commands/tablecmds.c          | 152 +++++++++++++++++++-----------
src/include/catalog/pg_class.h            |  13 +++
src/test/regress/input/tablespace.source  |  12 +++
src/test/regress/output/tablespace.source |  19 ++++
6 files changed, 147 insertions(+), 61 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2018-12-17 18:44 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-11-03 16:33 pgsql: Fix tablespace handling for partitioned indexes Alvaro Herrera <alvherre@alvh.no-ip.org>
2018-11-23 03:35 ` David Rowley <david.rowley@2ndquadrant.com>
2018-11-23 11:53   ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-11-03 16:33 pgsql: Fix tablespace handling for partitioned indexes Alvaro Herrera <alvherre@alvh.no-ip.org>
2018-12-17 18:44 pgsql: Fix tablespace handling for partitioned tables Alvaro Herrera <alvherre@alvh.no-ip.org>

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