mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Fix tablespace inheritance for partitioned rels
Commitca4103025d
left a few loose ends. The most important one (broken pg_dump output) is already fixed by virtue of commit3b23552ad8
, but some things remained: * When ALTER TABLE rewrites tables, the indexes must remain in the tablespace they were originally in. This didn't work because index recreation during ALTER TABLE runs manufactured SQL (yuck), which runs afoul of default_tablespace in competition with the parent relation tablespace. To fix, reset default_tablespace to the empty string temporarily, and add the TABLESPACE clause as appropriate. * 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. Add some docs and tests, too. Author: Álvaro Herrera Discussion: https://postgr.es/m/CAKJS1f_1c260nOt_vBJ067AZ3JXptXVRohDVMLEBmudX1YEx-A@mail.gmail.com
This commit is contained in:
@@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201904072
|
||||
#define CATALOG_VERSION_NO 201904251
|
||||
|
||||
#endif
|
||||
|
@@ -49,7 +49,7 @@ extern Oid AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt);
|
||||
|
||||
extern void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo);
|
||||
|
||||
extern Oid GetDefaultTablespace(char relpersistence);
|
||||
extern Oid GetDefaultTablespace(char relpersistence, bool partitioned);
|
||||
|
||||
extern void PrepareTempTablespaces(void);
|
||||
|
||||
|
@@ -2154,6 +2154,8 @@ typedef struct Constraint
|
||||
List *options; /* options from WITH clause */
|
||||
char *indexname; /* existing index to use; otherwise NULL */
|
||||
char *indexspace; /* index tablespace; NULL for default */
|
||||
bool reset_default_tblspc; /* reset default_tablespace prior to
|
||||
* creating the index */
|
||||
/* These could be, but currently are not, used for UNIQUE/PKEY: */
|
||||
char *access_method; /* index access method; NULL for default */
|
||||
Node *where_clause; /* partial index predicate */
|
||||
@@ -2769,6 +2771,8 @@ typedef struct IndexStmt
|
||||
bool transformed; /* true when transformIndexStmt is finished */
|
||||
bool concurrent; /* should this be a concurrent index build? */
|
||||
bool if_not_exists; /* just do nothing if index already exists? */
|
||||
bool reset_default_tblspc; /* reset default_tablespace prior to
|
||||
* executing */
|
||||
} IndexStmt;
|
||||
|
||||
/* ----------------------
|
||||
|
Reference in New Issue
Block a user