mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
Commitca4103025dleft 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
67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* tablespace.h
|
|
* Tablespace management commands (create/drop tablespace).
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/commands/tablespace.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef TABLESPACE_H
|
|
#define TABLESPACE_H
|
|
|
|
#include "access/xlogreader.h"
|
|
#include "catalog/objectaddress.h"
|
|
#include "lib/stringinfo.h"
|
|
#include "nodes/parsenodes.h"
|
|
|
|
/* XLOG stuff */
|
|
#define XLOG_TBLSPC_CREATE 0x00
|
|
#define XLOG_TBLSPC_DROP 0x10
|
|
|
|
typedef struct xl_tblspc_create_rec
|
|
{
|
|
Oid ts_id;
|
|
char ts_path[FLEXIBLE_ARRAY_MEMBER]; /* null-terminated string */
|
|
} xl_tblspc_create_rec;
|
|
|
|
typedef struct xl_tblspc_drop_rec
|
|
{
|
|
Oid ts_id;
|
|
} xl_tblspc_drop_rec;
|
|
|
|
typedef struct TableSpaceOpts
|
|
{
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
|
float8 random_page_cost;
|
|
float8 seq_page_cost;
|
|
int effective_io_concurrency;
|
|
} TableSpaceOpts;
|
|
|
|
extern Oid CreateTableSpace(CreateTableSpaceStmt *stmt);
|
|
extern void DropTableSpace(DropTableSpaceStmt *stmt);
|
|
extern ObjectAddress RenameTableSpace(const char *oldname, const char *newname);
|
|
extern Oid AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt);
|
|
|
|
extern void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo);
|
|
|
|
extern Oid GetDefaultTablespace(char relpersistence, bool partitioned);
|
|
|
|
extern void PrepareTempTablespaces(void);
|
|
|
|
extern Oid get_tablespace_oid(const char *tablespacename, bool missing_ok);
|
|
extern char *get_tablespace_name(Oid spc_oid);
|
|
|
|
extern bool directory_is_empty(const char *path);
|
|
extern void remove_tablespace_symlink(const char *linkloc);
|
|
|
|
extern void tblspc_redo(XLogReaderState *rptr);
|
|
extern void tblspc_desc(StringInfo buf, XLogReaderState *rptr);
|
|
extern const char *tblspc_identify(uint8 info);
|
|
|
|
#endif /* TABLESPACE_H */
|