1 /*-------------------------------------------------------------------------
2  *
3  * tablespace.h
4  *		Tablespace management commands (create/drop tablespace).
5  *
6  *
7  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/commands/tablespace.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef TABLESPACE_H
15 #define TABLESPACE_H
16 
17 #include "access/xlogreader.h"
18 #include "catalog/objectaddress.h"
19 #include "lib/stringinfo.h"
20 #include "nodes/parsenodes.h"
21 
22 /* XLOG stuff */
23 #define XLOG_TBLSPC_CREATE		0x00
24 #define XLOG_TBLSPC_DROP		0x10
25 
26 typedef struct xl_tblspc_create_rec
27 {
28 	Oid			ts_id;
29 	char		ts_path[FLEXIBLE_ARRAY_MEMBER]; /* null-terminated string */
30 } xl_tblspc_create_rec;
31 
32 typedef struct xl_tblspc_drop_rec
33 {
34 	Oid			ts_id;
35 } xl_tblspc_drop_rec;
36 
37 typedef struct TableSpaceOpts
38 {
39 	int32		vl_len_;		/* varlena header (do not touch directly!) */
40 	float8		random_page_cost;
41 	float8		seq_page_cost;
42 	int			effective_io_concurrency;
43 } TableSpaceOpts;
44 
45 extern Oid	CreateTableSpace(CreateTableSpaceStmt *stmt);
46 extern void DropTableSpace(DropTableSpaceStmt *stmt);
47 extern ObjectAddress RenameTableSpace(const char *oldname, const char *newname);
48 extern Oid	AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt);
49 
50 extern void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo);
51 
52 extern Oid	GetDefaultTablespace(char relpersistence, bool partitioned);
53 
54 extern void PrepareTempTablespaces(void);
55 
56 extern Oid	get_tablespace_oid(const char *tablespacename, bool missing_ok);
57 extern char *get_tablespace_name(Oid spc_oid);
58 
59 extern bool directory_is_empty(const char *path);
60 extern void remove_tablespace_symlink(const char *linkloc);
61 
62 extern void tblspc_redo(XLogReaderState *rptr);
63 extern void tblspc_desc(StringInfo buf, XLogReaderState *rptr);
64 extern const char *tblspc_identify(uint8 info);
65 
66 #endif							/* TABLESPACE_H */
67