diff options
| author | Tom Lane | 2004-06-18 06:14:31 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-06-18 06:14:31 +0000 |
| commit | 2467394ee1566e82d0314d12a0d1c0a5670a28c9 (patch) | |
| tree | 57b87b8c181a9c3eb0f33bf775a5f31b9de8b890 /src/include | |
| parent | 474875f4438ea0d18f9f4170117bc407e6812515 (diff) | |
Tablespaces. Alternate database locations are dead, long live tablespaces.
There are various things left to do: contrib dbsize and oid2name modules
need work, and so does the documentation. Also someone should think about
COMMENT ON TABLESPACE and maybe RENAME TABLESPACE. Also initlocation is
dead, it just doesn't know it yet.
Gavin Sherry and Tom Lane.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catalog.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/catname.h | 3 | ||||
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/heap.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/index.h | 3 | ||||
| -rw-r--r-- | src/include/catalog/indexing.h | 6 | ||||
| -rw-r--r-- | src/include/catalog/pg_attribute.h | 98 | ||||
| -rw-r--r-- | src/include/catalog/pg_class.h | 63 | ||||
| -rw-r--r-- | src/include/catalog/pg_database.h | 8 | ||||
| -rw-r--r-- | src/include/catalog/pg_namespace.h | 17 | ||||
| -rw-r--r-- | src/include/catalog/pg_tablespace.h | 66 | ||||
| -rw-r--r-- | src/include/catalog/pg_type.h | 17 | ||||
| -rw-r--r-- | src/include/commands/defrem.h | 3 | ||||
| -rw-r--r-- | src/include/commands/tablespace.h | 29 | ||||
| -rw-r--r-- | src/include/miscadmin.h | 6 | ||||
| -rw-r--r-- | src/include/nodes/nodes.h | 4 | ||||
| -rw-r--r-- | src/include/nodes/parsenodes.h | 30 | ||||
| -rw-r--r-- | src/include/storage/buf_internals.h | 5 | ||||
| -rw-r--r-- | src/include/storage/relfilenode.h | 56 | ||||
| -rw-r--r-- | src/include/utils/acl.h | 8 | ||||
| -rw-r--r-- | src/include/utils/lsyscache.h | 4 | ||||
| -rw-r--r-- | src/include/utils/relcache.h | 7 |
22 files changed, 327 insertions, 118 deletions
diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h index 293e11ef025..15cb6e7ca07 100644 --- a/src/include/catalog/catalog.h +++ b/src/include/catalog/catalog.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catalog.h,v 1.27 2003/11/29 22:40:58 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catalog.h,v 1.28 2004/06/18 06:14:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ extern char *relpath(RelFileNode rnode); -extern char *GetDatabasePath(Oid tblNode); +extern char *GetDatabasePath(Oid dbNode, Oid spcNode); extern bool IsSystemRelation(Relation relation); extern bool IsToastRelation(Relation relation); diff --git a/src/include/catalog/catname.h b/src/include/catalog/catname.h index 7b3b99701a9..240f4947082 100644 --- a/src/include/catalog/catname.h +++ b/src/include/catalog/catname.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catname.h,v 1.31 2003/11/29 22:40:58 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catname.h,v 1.32 2004/06/18 06:14:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -40,6 +40,7 @@ #define RewriteRelationName "pg_rewrite" #define ShadowRelationName "pg_shadow" #define StatisticRelationName "pg_statistic" +#define TableSpaceRelationName "pg_tablespace" #define TypeRelationName "pg_type" #define VersionRelationName "pg_version" #define AttrDefaultRelationName "pg_attrdef" diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 6fd25b54f7a..3ba63bbdea3 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.236 2004/06/16 01:26:49 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.237 2004/06/18 06:14:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200406151 +#define CATALOG_VERSION_NO 200406171 #endif diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 2913d53e521..4ead9728df0 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.66 2004/05/05 04:48:47 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.67 2004/06/18 06:14:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -37,6 +37,7 @@ typedef struct CookedConstraint extern Relation heap_create(const char *relname, Oid relnamespace, + Oid reltablespace, TupleDesc tupDesc, bool shared_relation, bool storage_create, @@ -46,6 +47,7 @@ extern void heap_storage_create(Relation rel); extern Oid heap_create_with_catalog(const char *relname, Oid relnamespace, + Oid reltablespace, TupleDesc tupdesc, char relkind, bool shared_relation, diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index 841387effcc..be27bb98eb6 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.56 2004/05/08 00:34:49 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.57 2004/06/18 06:14:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,7 @@ extern Oid index_create(Oid heapRelationId, const char *indexRelationName, IndexInfo *indexInfo, Oid accessMethodObjectId, + Oid tableSpaceId, Oid *classObjectId, bool primary, bool isconstraint, diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 33c0e0f6a2f..c6d2842c78e 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.81 2003/11/29 22:40:58 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.82 2004/06/18 06:14:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -70,6 +70,8 @@ #define ShadowNameIndex "pg_shadow_usename_index" #define ShadowSysidIndex "pg_shadow_usesysid_index" #define StatisticRelidAttnumIndex "pg_statistic_relid_att_index" +#define TablespaceNameIndex "pg_tablespace_spcname_index" +#define TablespaceOidIndex "pg_tablespace_oid_index" #define TriggerConstrNameIndex "pg_trigger_tgconstrname_index" #define TriggerConstrRelidIndex "pg_trigger_tgconstrrelid_index" #define TriggerRelidNameIndex "pg_trigger_tgrelid_tgname_index" @@ -166,6 +168,8 @@ DECLARE_UNIQUE_INDEX(pg_rewrite_rel_rulename_index on pg_rewrite using btree(ev_ DECLARE_UNIQUE_INDEX(pg_shadow_usename_index on pg_shadow using btree(usename name_ops)); DECLARE_UNIQUE_INDEX(pg_shadow_usesysid_index on pg_shadow using btree(usesysid int4_ops)); DECLARE_UNIQUE_INDEX(pg_statistic_relid_att_index on pg_statistic using btree(starelid oid_ops, staattnum int2_ops)); +DECLARE_UNIQUE_INDEX(pg_tablespace_oid_index on pg_tablespace using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_tablespace_spcname_index on pg_tablespace using btree(spcname name_ops)); /* This following index is not used for a cache and is not unique */ DECLARE_INDEX(pg_trigger_tgconstrname_index on pg_trigger using btree(tgconstrname name_ops)); /* This following index is not used for a cache and is not unique */ diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 896a06ada86..c3f7ead3af4 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.109 2004/04/01 21:28:45 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.110 2004/06/18 06:14:06 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -218,7 +218,7 @@ typedef FormData_pg_attribute *Form_pg_attribute; */ /* ---------------- - * pg_type schema + * pg_type * ---------------- */ #define Schema_pg_type \ @@ -290,8 +290,7 @@ DATA(insert ( 1262 datallowconn 16 -1 1 5 0 -1 -1 t p c t f f t 0)); DATA(insert ( 1262 datlastsysoid 26 -1 4 6 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1262 datvacuumxid 28 -1 4 7 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1262 datfrozenxid 28 -1 4 8 0 -1 -1 t p i t f f t 0)); -/* do not mark datpath as toastable; GetRawDatabaseInfo won't cope */ -DATA(insert ( 1262 datpath 25 -1 -1 9 0 -1 -1 f p i t f f t 0)); +DATA(insert ( 1262 dattablespace 26 -1 4 9 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1262 datconfig 1009 -1 -1 10 1 -1 -1 f x i f f f t 0)); DATA(insert ( 1262 datacl 1034 -1 -1 11 1 -1 -1 f x i f f f t 0)); DATA(insert ( 1262 ctid 27 0 6 -1 0 -1 -1 f p s t f f t 0)); @@ -442,24 +441,25 @@ DATA(insert ( 1249 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t 0)); { 1259, {"relowner"}, 23, -1, 4, 4, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ { 1259, {"relam"}, 26, -1, 4, 5, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ { 1259, {"relfilenode"}, 26, -1, 4, 6, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ -{ 1259, {"relpages"}, 23, -1, 4, 7, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ -{ 1259, {"reltuples"}, 700, -1, 4, 8, 0, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ -{ 1259, {"reltoastrelid"}, 26, -1, 4, 9, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ -{ 1259, {"reltoastidxid"}, 26, -1, 4, 10, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ -{ 1259, {"relhasindex"}, 16, -1, 1, 11, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"relisshared"}, 16, -1, 1, 12, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"relkind"}, 18, -1, 1, 13, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"relnatts"}, 21, -1, 2, 14, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ -{ 1259, {"relchecks"}, 21, -1, 2, 15, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ -{ 1259, {"reltriggers"}, 21, -1, 2, 16, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ -{ 1259, {"relukeys"}, 21, -1, 2, 17, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ -{ 1259, {"relfkeys"}, 21, -1, 2, 18, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ -{ 1259, {"relrefs"}, 21, -1, 2, 19, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ -{ 1259, {"relhasoids"}, 16, -1, 1, 20, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"relhaspkey"}, 16, -1, 1, 21, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"relhasrules"}, 16, -1, 1, 22, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"relhassubclass"},16, -1, 1, 23, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"relacl"}, 1034, -1, -1, 24, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 } +{ 1259, {"reltablespace"}, 26, -1, 4, 7, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ +{ 1259, {"relpages"}, 23, -1, 4, 8, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ +{ 1259, {"reltuples"}, 700, -1, 4, 9, 0, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ +{ 1259, {"reltoastrelid"}, 26, -1, 4, 10, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ +{ 1259, {"reltoastidxid"}, 26, -1, 4, 11, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ +{ 1259, {"relhasindex"}, 16, -1, 1, 12, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 1259, {"relisshared"}, 16, -1, 1, 13, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 1259, {"relkind"}, 18, -1, 1, 14, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 1259, {"relnatts"}, 21, -1, 2, 15, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ +{ 1259, {"relchecks"}, 21, -1, 2, 16, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ +{ 1259, {"reltriggers"}, 21, -1, 2, 17, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ +{ 1259, {"relukeys"}, 21, -1, 2, 18, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ +{ 1259, {"relfkeys"}, 21, -1, 2, 19, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ +{ 1259, {"relrefs"}, 21, -1, 2, 20, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ +{ 1259, {"relhasoids"}, 16, -1, 1, 21, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 1259, {"relhaspkey"}, 16, -1, 1, 22, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 1259, {"relhasrules"}, 16, -1, 1, 23, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 1259, {"relhassubclass"},16, -1, 1, 24, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 1259, {"relacl"}, 1034, -1, -1, 25, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 } DATA(insert ( 1259 relname 19 -1 NAMEDATALEN 1 0 -1 -1 f p i t f f t 0)); DATA(insert ( 1259 relnamespace 26 -1 4 2 0 -1 -1 t p i t f f t 0)); @@ -467,24 +467,25 @@ DATA(insert ( 1259 reltype 26 -1 4 3 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1259 relowner 23 -1 4 4 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1259 relam 26 -1 4 5 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1259 relfilenode 26 -1 4 6 0 -1 -1 t p i t f f t 0)); -DATA(insert ( 1259 relpages 23 -1 4 7 0 -1 -1 t p i t f f t 0)); -DATA(insert ( 1259 reltuples 700 -1 4 8 0 -1 -1 f p i t f f t 0)); -DATA(insert ( 1259 reltoastrelid 26 -1 4 9 0 -1 -1 t p i t f f t 0)); -DATA(insert ( 1259 reltoastidxid 26 -1 4 10 0 -1 -1 t p i t f f t 0)); -DATA(insert ( 1259 relhasindex 16 -1 1 11 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 relisshared 16 -1 1 12 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 relkind 18 -1 1 13 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 relnatts 21 -1 2 14 0 -1 -1 t p s t f f t 0)); -DATA(insert ( 1259 relchecks 21 -1 2 15 0 -1 -1 t p s t f f t 0)); -DATA(insert ( 1259 reltriggers 21 -1 2 16 0 -1 -1 t p s t f f t 0)); -DATA(insert ( 1259 relukeys 21 -1 2 17 0 -1 -1 t p s t f f t 0)); -DATA(insert ( 1259 relfkeys 21 -1 2 18 0 -1 -1 t p s t f f t 0)); -DATA(insert ( 1259 relrefs 21 -1 2 19 0 -1 -1 t p s t f f t 0)); -DATA(insert ( 1259 relhasoids 16 -1 1 20 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 relhaspkey 16 -1 1 21 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 relhasrules 16 -1 1 22 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 relhassubclass 16 -1 1 23 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 relacl 1034 -1 -1 24 1 -1 -1 f x i f f f t 0)); +DATA(insert ( 1259 reltablespace 26 -1 4 7 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1259 relpages 23 -1 4 8 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1259 reltuples 700 -1 4 9 0 -1 -1 f p i t f f t 0)); +DATA(insert ( 1259 reltoastrelid 26 -1 4 10 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1259 reltoastidxid 26 -1 4 11 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1259 relhasindex 16 -1 1 12 0 -1 -1 t p c t f f t 0)); +DATA(insert ( 1259 relisshared 16 -1 1 13 0 -1 -1 t p c t f f t 0)); +DATA(insert ( 1259 relkind 18 -1 1 14 0 -1 -1 t p c t f f t 0)); +DATA(insert ( 1259 relnatts 21 -1 2 15 0 -1 -1 t p s t f f t 0)); +DATA(insert ( 1259 relchecks 21 -1 2 16 0 -1 -1 t p s t f f t 0)); +DATA(insert ( 1259 reltriggers 21 -1 2 17 0 -1 -1 t p s t f f t 0)); +DATA(insert ( 1259 relukeys 21 -1 2 18 0 -1 -1 t p s t f f t 0)); +DATA(insert ( 1259 relfkeys 21 -1 2 19 0 -1 -1 t p s t f f t 0)); +DATA(insert ( 1259 relrefs 21 -1 2 20 0 -1 -1 t p s t f f t 0)); +DATA(insert ( 1259 relhasoids 16 -1 1 21 0 -1 -1 t p c t f f t 0)); +DATA(insert ( 1259 relhaspkey 16 -1 1 22 0 -1 -1 t p c t f f t 0)); +DATA(insert ( 1259 relhasrules 16 -1 1 23 0 -1 -1 t p c t f f t 0)); +DATA(insert ( 1259 relhassubclass 16 -1 1 24 0 -1 -1 t p c t f f t 0)); +DATA(insert ( 1259 relacl 1034 -1 -1 25 1 -1 -1 f x i f f f t 0)); DATA(insert ( 1259 ctid 27 0 6 -1 0 -1 -1 f p s t f f t 0)); DATA(insert ( 1259 oid 26 0 4 -2 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1259 xmin 28 0 4 -3 0 -1 -1 t p i t f f t 0)); @@ -494,6 +495,23 @@ DATA(insert ( 1259 cmax 29 0 4 -6 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1259 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t 0)); /* ---------------- + * pg_tablespace + * ---------------- + */ + +DATA(insert ( 1213 spcname 19 -1 NAMEDATALEN 1 0 -1 -1 f p i t f f t 0)); +DATA(insert ( 1213 spcowner 23 -1 4 2 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1213 spclocation 25 -1 -1 3 0 -1 -1 f x i t f f t 0)); +DATA(insert ( 1213 spcacl 1034 -1 -1 4 1 -1 -1 f x i f f f t 0)); +DATA(insert ( 1213 ctid 27 0 6 -1 0 -1 -1 f p s t f f t 0)); +DATA(insert ( 1213 oid 26 0 4 -2 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1213 xmin 28 0 4 -3 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1213 cmin 29 0 4 -4 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1213 xmax 28 0 4 -5 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1213 cmax 29 0 4 -6 0 -1 -1 t p i t f f t 0)); +DATA(insert ( 1213 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t 0)); + +/* ---------------- * pg_xactlock - this is not a real relation, but is a placeholder * to allow a relation OID to be used for transaction * waits. We need a pg_xactlock entry in pg_class only to diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 8f044b0459a..bebbc76fa58 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.81 2004/04/01 21:28:45 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.82 2004/06/18 06:14:06 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -48,6 +48,7 @@ CATALOG(pg_class) BOOTSTRAP int4 relowner; /* class owner */ Oid relam; /* index access method; 0 if not an index */ Oid relfilenode; /* identifier of physical storage file */ + Oid reltablespace; /* identifier of table space for relation */ int4 relpages; /* # of blocks (not always up-to-date) */ float4 reltuples; /* # of tuples (not always up-to-date) */ Oid reltoastrelid; /* OID of toast table; 0 if none */ @@ -100,32 +101,33 @@ typedef FormData_pg_class *Form_pg_class; * relacl field. This is a kluge. * ---------------- */ -#define Natts_pg_class_fixed 23 -#define Natts_pg_class 24 +#define Natts_pg_class_fixed 24 +#define Natts_pg_class 25 #define Anum_pg_class_relname 1 #define Anum_pg_class_relnamespace 2 #define Anum_pg_class_reltype 3 #define Anum_pg_class_relowner 4 #define Anum_pg_class_relam 5 #define Anum_pg_class_relfilenode 6 -#define Anum_pg_class_relpages 7 -#define Anum_pg_class_reltuples 8 -#define Anum_pg_class_reltoastrelid 9 -#define Anum_pg_class_reltoastidxid 10 -#define Anum_pg_class_relhasindex 11 -#define Anum_pg_class_relisshared 12 -#define Anum_pg_class_relkind 13 -#define Anum_pg_class_relnatts 14 -#define Anum_pg_class_relchecks 15 -#define Anum_pg_class_reltriggers 16 -#define Anum_pg_class_relukeys 17 -#define Anum_pg_class_relfkeys 18 -#define Anum_pg_class_relrefs 19 -#define Anum_pg_class_relhasoids 20 -#define Anum_pg_class_relhaspkey 21 -#define Anum_pg_class_relhasrules 22 -#define Anum_pg_class_relhassubclass 23 -#define Anum_pg_class_relacl 24 +#define Anum_pg_class_reltablespace 7 +#define Anum_pg_class_relpages 8 +#define Anum_pg_class_reltuples 9 +#define Anum_pg_class_reltoastrelid 10 +#define Anum_pg_class_reltoastidxid 11 +#define Anum_pg_class_relhasindex 12 +#define Anum_pg_class_relisshared 13 +#define Anum_pg_class_relkind 14 +#define Anum_pg_class_relnatts 15 +#define Anum_pg_class_relchecks 16 +#define Anum_pg_class_reltriggers 17 +#define Anum_pg_class_relukeys 18 +#define Anum_pg_class_relfkeys 19 +#define Anum_pg_class_relrefs 20 +#define Anum_pg_class_relhasoids 21 +#define Anum_pg_class_relhaspkey 22 +#define Anum_pg_class_relhasrules 23 +#define Anum_pg_class_relhassubclass 24 +#define Anum_pg_class_relacl 25 /* ---------------- * initial contents of pg_class @@ -134,21 +136,23 @@ typedef FormData_pg_class *Form_pg_class; * ---------------- */ -DATA(insert OID = 1247 ( pg_type PGNSP 71 PGUID 0 1247 0 0 0 0 f f r 23 0 0 0 0 0 t f f f _null_ )); +DATA(insert OID = 1247 ( pg_type PGNSP 71 PGUID 0 1247 0 0 0 0 0 f f r 23 0 0 0 0 0 t f f f _null_ )); DESCR(""); -DATA(insert OID = 1249 ( pg_attribute PGNSP 75 PGUID 0 1249 0 0 0 0 f f r 17 0 0 0 0 0 f f f f _null_ )); +DATA(insert OID = 1249 ( pg_attribute PGNSP 75 PGUID 0 1249 0 0 0 0 0 f f r 17 0 0 0 0 0 f f f f _null_ )); DESCR(""); -DATA(insert OID = 1255 ( pg_proc PGNSP 81 PGUID 0 1255 0 0 0 0 f f r 16 0 0 0 0 0 t f f f _null_ )); +DATA(insert OID = 1255 ( pg_proc PGNSP 81 PGUID 0 1255 0 0 0 0 0 f f r 16 0 0 0 0 0 t f f f _null_ )); DESCR(""); -DATA(insert OID = 1259 ( pg_class PGNSP 83 PGUID 0 1259 0 0 0 0 f f r 24 0 0 0 0 0 t f f f _null_ )); +DATA(insert OID = 1259 ( pg_class PGNSP 83 PGUID 0 1259 0 0 0 0 0 f f r 25 0 0 0 0 0 t f f f _null_ )); DESCR(""); -DATA(insert OID = 1260 ( pg_shadow PGNSP 86 PGUID 0 1260 0 0 0 0 f t r 8 0 0 0 0 0 f f f f _null_ )); +DATA(insert OID = 1260 ( pg_shadow PGNSP 86 PGUID 0 1260 1664 0 0 0 0 f t r 8 0 0 0 0 0 f f f f _null_ )); DESCR(""); -DATA(insert OID = 1261 ( pg_group PGNSP 87 PGUID 0 1261 0 0 0 0 f t r 3 0 0 0 0 0 f f f f _null_ )); +DATA(insert OID = 1261 ( pg_group PGNSP 87 PGUID 0 1261 1664 0 0 0 0 f t r 3 0 0 0 0 0 f f f f _null_ )); DESCR(""); -DATA(insert OID = 1262 ( pg_database PGNSP 88 PGUID 0 1262 0 0 0 0 f t r 11 0 0 0 0 0 t f f f _null_ )); +DATA(insert OID = 1262 ( pg_database PGNSP 88 PGUID 0 1262 1664 0 0 0 0 f t r 11 0 0 0 0 0 t f f f _null_ )); DESCR(""); -DATA(insert OID = 376 ( pg_xactlock PGNSP 0 PGUID 0 0 0 0 0 0 f t s 1 0 0 0 0 0 f f f f _null_ )); +DATA(insert OID = 1213 ( pg_tablespace PGNSP 90 PGUID 0 1213 1664 0 0 0 0 f t r 4 0 0 0 0 0 t f f f _null_ )); +DESCR(""); +DATA(insert OID = 376 ( pg_xactlock PGNSP 0 PGUID 0 0 1664 0 0 0 0 f t s 1 0 0 0 0 0 f f f f _null_ )); DESCR(""); #define RelOid_pg_type 1247 @@ -158,6 +162,7 @@ DESCR(""); #define RelOid_pg_shadow 1260 #define RelOid_pg_group 1261 #define RelOid_pg_database 1262 +#define RelOid_pg_tablespace 1213 /* Xact lock pseudo-table */ #define XactLockTableId 376 diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h index 226c5c2f99c..9504f1733b6 100644 --- a/src/include/catalog/pg_database.h +++ b/src/include/catalog/pg_database.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.31 2004/02/10 01:55:26 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.32 2004/06/18 06:14:06 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -41,7 +41,7 @@ CATALOG(pg_database) BOOTSTRAP BKI_SHARED_RELATION Oid datlastsysoid; /* highest OID to consider a system OID */ TransactionId datvacuumxid; /* all XIDs before this are vacuumed */ TransactionId datfrozenxid; /* all XIDs before this are frozen */ - text datpath; /* default database location (VAR LENGTH) */ + Oid dattablespace; /* default table space for this DB */ text datconfig[1]; /* database-specific GUC (VAR LENGTH) */ aclitem datacl[1]; /* access permissions (VAR LENGTH) */ } FormData_pg_database; @@ -66,11 +66,11 @@ typedef FormData_pg_database *Form_pg_database; #define Anum_pg_database_datlastsysoid 6 #define Anum_pg_database_datvacuumxid 7 #define Anum_pg_database_datfrozenxid 8 -#define Anum_pg_database_datpath 9 +#define Anum_pg_database_dattablespace 9 #define Anum_pg_database_datconfig 10 #define Anum_pg_database_datacl 11 -DATA(insert OID = 1 ( template1 PGUID ENCODING t t 0 0 0 "" _null_ _null_ )); +DATA(insert OID = 1 ( template1 PGUID ENCODING t t 0 0 0 1663 _null_ _null_ )); DESCR("Default template database"); #define TemplateDbOid 1 diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h index 68d8dd28fa6..63a4c708378 100644 --- a/src/include/catalog/pg_namespace.h +++ b/src/include/catalog/pg_namespace.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_namespace.h,v 1.11 2003/11/29 22:40:58 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_namespace.h,v 1.12 2004/06/18 06:14:06 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -40,6 +40,7 @@ CATALOG(pg_namespace) { NameData nspname; int4 nspowner; + Oid nsptablespace; /* default table space for name space */ aclitem nspacl[1]; /* VARIABLE LENGTH FIELD */ } FormData_pg_namespace; @@ -55,10 +56,11 @@ typedef FormData_pg_namespace *Form_pg_namespace; * ---------------- */ -#define Natts_pg_namespace 3 +#define Natts_pg_namespace 4 #define Anum_pg_namespace_nspname 1 #define Anum_pg_namespace_nspowner 2 -#define Anum_pg_namespace_nspacl 3 +#define Anum_pg_namespace_nsptablespace 3 +#define Anum_pg_namespace_nspacl 4 /* ---------------- @@ -66,13 +68,13 @@ typedef FormData_pg_namespace *Form_pg_namespace; * --------------- */ -DATA(insert OID = 11 ( "pg_catalog" PGUID _null_ )); +DATA(insert OID = 11 ( "pg_catalog" PGUID 0 _null_ )); DESCR("System catalog schema"); #define PG_CATALOG_NAMESPACE 11 -DATA(insert OID = 99 ( "pg_toast" PGUID _null_ )); +DATA(insert OID = 99 ( "pg_toast" PGUID 0 _null_ )); DESCR("Reserved schema for TOAST tables"); #define PG_TOAST_NAMESPACE 99 -DATA(insert OID = 2200 ( "public" PGUID _null_ )); +DATA(insert OID = 2200 ( "public" PGUID 0 _null_ )); DESCR("Standard public schema"); #define PG_PUBLIC_NAMESPACE 2200 @@ -80,6 +82,7 @@ DESCR("Standard public schema"); /* * prototypes for functions in pg_namespace.c */ -extern Oid NamespaceCreate(const char *nspName, int32 ownerSysId); +extern Oid NamespaceCreate(const char *nspName, int32 ownerSysId, + Oid nspTablespace); #endif /* PG_NAMESPACE_H */ diff --git a/src/include/catalog/pg_tablespace.h b/src/include/catalog/pg_tablespace.h new file mode 100644 index 00000000000..f05d3657704 --- /dev/null +++ b/src/include/catalog/pg_tablespace.h @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- + * + * pg_tablespace.h + * definition of the system "tablespace" relation (pg_tablespace) + * along with the relation's initial contents. + * + * + * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/catalog/pg_tablespace.h,v 1.1 2004/06/18 06:14:06 tgl Exp $ + * + * NOTES + * the genbki.sh script reads this file and generates .bki + * information from the DATA() statements. + * + *------------------------------------------------------------------------- + */ +#ifndef PG_TABLESPACE_H +#define PG_TABLESPACE_H + +/* ---------------- + * postgres.h contains the system type definitions and the + * CATALOG(), BOOTSTRAP and DATA() sugar words so this file + * can be read by both genbki.sh and the C compiler. + * ---------------- + */ + +/* ---------------- + * pg_tablespace definition. cpp turns this into + * typedef struct FormData_pg_tablespace + * ---------------- + */ +CATALOG(pg_tablespace) BOOTSTRAP BKI_SHARED_RELATION +{ + NameData spcname; /* tablespace name */ + int4 spcowner; /* sysid of owner */ + text spclocation; /* physical location (VAR LENGTH) */ + aclitem spcacl[1]; /* access permissions (VAR LENGTH) */ +} FormData_pg_tablespace; + +/* ---------------- + * Form_pg_tablespace corresponds to a pointer to a tuple with + * the format of pg_tablespace relation. + * ---------------- + */ +typedef FormData_pg_tablespace *Form_pg_tablespace; + +/* ---------------- + * compiler constants for pg_tablespace + * ---------------- + */ + +#define Natts_pg_tablespace 4 +#define Anum_pg_tablespace_spcname 1 +#define Anum_pg_tablespace_spcowner 2 +#define Anum_pg_tablespace_spclocation 3 +#define Anum_pg_tablespace_spcacl 4 + +DATA(insert OID = 1663 ( default PGUID "" _null_ )); +DATA(insert OID = 1664 ( global PGUID "" _null_ )); + +#define DEFAULTTABLESPACE_OID 1663 +#define GLOBALTABLESPACE_OID 1664 + +#endif /* PG_TABLESPACE_H */ diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 3b9b1dfd5db..45d92b36277 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.153 2004/06/06 19:07:01 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.154 2004/06/18 06:14:06 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -304,13 +304,14 @@ DATA(insert OID = 30 ( oidvector PGNSP PGUID INDEX_MAX_KEYS*4 f b t \054 0 26 DESCR("array of INDEX_MAX_KEYS oids, used in system tables"); #define OIDVECTOROID 30 -DATA(insert OID = 71 ( pg_type PGNSP PGUID -1 f c t \054 1247 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); -DATA(insert OID = 75 ( pg_attribute PGNSP PGUID -1 f c t \054 1249 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); -DATA(insert OID = 81 ( pg_proc PGNSP PGUID -1 f c t \054 1255 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); -DATA(insert OID = 83 ( pg_class PGNSP PGUID -1 f c t \054 1259 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); -DATA(insert OID = 86 ( pg_shadow PGNSP PGUID -1 f c t \054 1260 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); -DATA(insert OID = 87 ( pg_group PGNSP PGUID -1 f c t \054 1261 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); -DATA(insert OID = 88 ( pg_database PGNSP PGUID -1 f c t \054 1262 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 71 ( pg_type PGNSP PGUID -1 f c t \054 1247 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 75 ( pg_attribute PGNSP PGUID -1 f c t \054 1249 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 81 ( pg_proc PGNSP PGUID -1 f c t \054 1255 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 83 ( pg_class PGNSP PGUID -1 f c t \054 1259 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 86 ( pg_shadow PGNSP PGUID -1 f c t \054 1260 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 87 ( pg_group PGNSP PGUID -1 f c t \054 1261 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 88 ( pg_database PGNSP PGUID -1 f c t \054 1262 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 90 ( pg_tablespace PGNSP PGUID -1 f c t \054 1213 0 record_in record_out record_recv record_send - d x f 0 -1 0 _null_ _null_ )); /* OIDS 100 - 199 */ diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index ba7415a582d..8670a41a763 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.57 2004/06/10 17:55:59 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.58 2004/06/18 06:14:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -21,6 +21,7 @@ extern void DefineIndex(RangeVar *heapRelation, char *indexRelationName, char *accessMethodName, + char *tableSpaceName, List *attributeList, Expr *predicate, List *rangetable, diff --git a/src/include/commands/tablespace.h b/src/include/commands/tablespace.h new file mode 100644 index 00000000000..129413ac14b --- /dev/null +++ b/src/include/commands/tablespace.h @@ -0,0 +1,29 @@ +/*------------------------------------------------------------------------- + * + * tablespace.h + * prototypes for tablespace.c. + * + * + * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.1 2004/06/18 06:14:08 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef TABLESPACE_H +#define TABLESPACE_H + +#include "nodes/parsenodes.h" + +extern void CreateTableSpace(CreateTableSpaceStmt *stmt); + +extern void DropTableSpace(DropTableSpaceStmt *stmt); + +extern void TablespaceCreateDbspace(Oid spcNode, Oid dbNode); + +extern Oid get_tablespace_oid(const char *tablespacename); + +extern char *get_tablespace_name(Oid spc_oid); + +#endif /* TABLESPACE_H */ diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 4561d2fcfb7..0a508861b27 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.162 2004/05/29 22:48:22 tgl Exp $ + * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.163 2004/06/18 06:14:10 tgl Exp $ * * NOTES * some of the information in this file should be moved to other files. @@ -150,6 +150,8 @@ extern char postgres_exec_path[]; */ extern DLLIMPORT Oid MyDatabaseId; +extern DLLIMPORT Oid MyDatabaseTableSpace; + /* * Date/Time Configuration * @@ -224,7 +226,7 @@ extern void check_stack_depth(void); extern char *DatabasePath; /* in utils/misc/database.c */ -extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path); +extern void GetRawDatabaseInfo(const char *name, Oid *db_id, Oid *db_tablespace); /* now in utils/init/miscinit.c */ extern void SetDatabasePath(const char *path); diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index b719747e762..531b7e6c654 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.157 2004/06/09 19:08:18 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.158 2004/06/18 06:14:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -268,6 +268,8 @@ typedef enum NodeTag T_ExecuteStmt, T_DeallocateStmt, T_DeclareCursorStmt, + T_CreateTableSpaceStmt, + T_DropTableSpaceStmt, T_AlterDbOwnerStmt, T_A_Expr = 800, diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 0da9b379077..4c24fe9e27b 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.258 2004/06/09 19:08:18 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.259 2004/06/18 06:14:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -742,6 +742,7 @@ typedef enum ObjectType OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_TABLE, + OBJECT_TABLESPACE, OBJECT_TRIGGER, OBJECT_TYPE, OBJECT_USER, @@ -761,6 +762,7 @@ typedef struct CreateSchemaStmt NodeTag type; char *schemaname; /* the name of the schema to create */ char *authid; /* the owner of the created schema */ + char *tablespacename; /* default tablespace for schema, or NULL */ List *schemaElts; /* schema components (list of parsenodes) */ } CreateSchemaStmt; @@ -857,7 +859,8 @@ typedef enum GrantObjectType ACL_OBJECT_DATABASE, /* database */ ACL_OBJECT_FUNCTION, /* function */ ACL_OBJECT_LANGUAGE, /* procedural language */ - ACL_OBJECT_NAMESPACE /* namespace */ + ACL_OBJECT_NAMESPACE, /* namespace */ + ACL_OBJECT_TABLESPACE /* tablespace */ } GrantObjectType; typedef struct GrantStmt @@ -941,6 +944,7 @@ typedef struct CreateStmt List *constraints; /* constraints (list of Constraint nodes) */ ContainsOids hasoids; /* should it have OIDs? */ OnCommitAction oncommit; /* what do we do at COMMIT? */ + char *tablespacename; /* table space to use, or NULL */ } CreateStmt; /* ---------- @@ -1030,6 +1034,26 @@ typedef struct FkConstraint bool skip_validation; /* skip validation of existing rows? */ } FkConstraint; + +/* ---------------------- + * Create/Drop Table Space Statements + * ---------------------- + */ + +typedef struct CreateTableSpaceStmt +{ + NodeTag type; + char *tablespacename; + char *owner; + char *location; +} CreateTableSpaceStmt; + +typedef struct DropTableSpaceStmt +{ + NodeTag type; + char *tablespacename; +} DropTableSpaceStmt; + /* ---------------------- * Create/Drop TRIGGER Statements * ---------------------- @@ -1142,6 +1166,7 @@ typedef struct CreateSeqStmt NodeTag type; RangeVar *sequence; /* the sequence to create */ List *options; + char *tablespacename; /* tablespace, or NULL for default */ } CreateSeqStmt; typedef struct AlterSeqStmt @@ -1322,6 +1347,7 @@ typedef struct IndexStmt char *idxname; /* name of new index, or NULL for default */ RangeVar *relation; /* relation to build index on */ char *accessMethod; /* name of access method (eg. btree) */ + char *tableSpace; /* tablespace, or NULL to use parent's */ List *indexParams; /* a list of IndexElem */ Node *whereClause; /* qualification (partial-index predicate) */ List *rangetable; /* range table for qual and/or diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index 6db4afd58bd..4a8b20908e5 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.70 2004/04/21 18:06:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.71 2004/06/18 06:14:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,8 @@ typedef struct buftag #define CLEAR_BUFFERTAG(a) \ ( \ - (a).rnode.tblNode = InvalidOid, \ + (a).rnode.spcNode = InvalidOid, \ + (a).rnode.dbNode = InvalidOid, \ (a).rnode.relNode = InvalidOid, \ (a).blockNum = InvalidBlockNumber \ ) diff --git a/src/include/storage/relfilenode.h b/src/include/storage/relfilenode.h index 715dc00f7de..d430412e67f 100644 --- a/src/include/storage/relfilenode.h +++ b/src/include/storage/relfilenode.h @@ -1,22 +1,60 @@ +/*------------------------------------------------------------------------- + * + * relfilenode.h + * Physical access information for relations. + * + * + * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/storage/relfilenode.h,v 1.9 2004/06/18 06:14:13 tgl Exp $ + * + *------------------------------------------------------------------------- + */ #ifndef RELFILENODE_H #define RELFILENODE_H /* - * This is all what we need to know to find relation file. - * tblNode is identificator of tablespace and because of - * currently our tablespaces are equal to databases this is - * database OID. relNode is currently relation OID on creation - * but may be changed later if required. relNode is stored in - * pg_class.relfilenode. + * RelFileNode must provide all that we need to know to physically access + * a relation. + * + * spcNode identifies the tablespace of the relation. It corresponds to + * pg_tablespace.oid. + * + * dbNode identifies the database of the relation. It is zero for + * "shared" relations (those common to all databases of a cluster). + * Nonzero dbNode values correspond to pg_database.oid. + * + * relNode identifies the specific relation. relNode corresponds to + * pg_class.relfilenode (NOT pg_class.oid, because we need to be able + * to assign new physical files to relations in some situations). + * Notice that relNode is only unique within a particular database. + * + * Note: spcNode must be GLOBALTABLESPACE_OID if and only if dbNode is + * zero. We support shared relations only in the "global" tablespace. + * + * Note: in pg_class we allow reltablespace == 0 to denote that the + * relation is stored in its database's "default" tablespace (as + * identified by pg_database.dattablespace). However this shorthand + * is NOT allowed in RelFileNode structs --- the real tablespace ID + * must be supplied when setting spcNode. */ typedef struct RelFileNode { - Oid tblNode; /* tablespace */ + Oid spcNode; /* tablespace */ + Oid dbNode; /* database */ Oid relNode; /* relation */ } RelFileNode; +/* + * Note: RelFileNodeEquals compares relNode first since that is most likely + * to be different in two unequal RelFileNodes. It is probably redundant + * to compare spcNode if the other two fields are found equal, but do it + * anyway to be sure. + */ #define RelFileNodeEquals(node1, node2) \ ((node1).relNode == (node2).relNode && \ - (node1).tblNode == (node2).tblNode) + (node1).dbNode == (node2).dbNode && \ + (node1).spcNode == (node2).spcNode) -#endif /* RELFILENODE_H */ +#endif /* RELFILENODE_H */ diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index f5ac89e2579..f7779be589d 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.70 2004/06/01 21:49:22 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.71 2004/06/18 06:14:21 tgl Exp $ * * NOTES * An ACL array is simply an array of AclItems, representing the union @@ -184,6 +184,7 @@ typedef ArrayType IdList; #define ACL_ALL_RIGHTS_FUNCTION (ACL_EXECUTE) #define ACL_ALL_RIGHTS_LANGUAGE (ACL_USAGE) #define ACL_ALL_RIGHTS_NAMESPACE (ACL_USAGE|ACL_CREATE) +#define ACL_ALL_RIGHTS_TABLESPACE (ACL_CREATE) /* operation codes for pg_*_aclmask */ typedef enum @@ -213,6 +214,7 @@ typedef enum AclObjectKind ACL_KIND_NAMESPACE, /* pg_namespace */ ACL_KIND_OPCLASS, /* pg_opclass */ ACL_KIND_CONVERSION, /* pg_conversion */ + ACL_KIND_TABLESPACE, /* pg_tablespace */ MAX_ACL_KIND /* MUST BE LAST */ } AclObjectKind; @@ -254,12 +256,15 @@ extern AclMode pg_language_aclmask(Oid lang_oid, AclId userid, AclMode mask, AclMaskHow how); extern AclMode pg_namespace_aclmask(Oid nsp_oid, AclId userid, AclMode mask, AclMaskHow how); +extern AclMode pg_tablespace_aclmask(Oid spc_oid, AclId userid, + AclMode mask, AclMaskHow how); extern AclResult pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode); extern AclResult pg_database_aclcheck(Oid db_oid, AclId userid, AclMode mode); extern AclResult pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode); extern AclResult pg_language_aclcheck(Oid lang_oid, AclId userid, AclMode mode); extern AclResult pg_namespace_aclcheck(Oid nsp_oid, AclId userid, AclMode mode); +extern AclResult pg_tablespace_aclcheck(Oid spc_oid, AclId userid, AclMode mode); extern void aclcheck_error(AclResult aclerr, AclObjectKind objectkind, const char *objectname); @@ -270,6 +275,7 @@ extern bool pg_type_ownercheck(Oid type_oid, AclId userid); extern bool pg_oper_ownercheck(Oid oper_oid, AclId userid); extern bool pg_proc_ownercheck(Oid proc_oid, AclId userid); extern bool pg_namespace_ownercheck(Oid nsp_oid, AclId userid); +extern bool pg_tablespace_ownercheck(Oid spc_oid, AclId userid); extern bool pg_opclass_ownercheck(Oid opc_oid, AclId userid); extern bool pg_database_ownercheck(Oid db_oid, AclId userid); extern bool pg_conversion_ownercheck(Oid conv_oid, AclId userid); diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 68fab871bde..10d2104b8d0 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.87 2004/06/06 00:41:28 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.88 2004/06/18 06:14:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -63,6 +63,7 @@ extern Oid get_relname_relid(const char *relname, Oid relnamespace); extern Oid get_system_catalog_relid(const char *catname); extern char *get_rel_name(Oid relid); extern Oid get_rel_namespace(Oid relid); +extern Oid get_rel_tablespace(Oid relid); extern Oid get_rel_type_id(Oid relid); extern char get_rel_relkind(Oid relid); extern bool get_typisdefined(Oid typid); @@ -105,6 +106,7 @@ extern void free_attstatsslot(Oid atttype, Datum *values, int nvalues, float4 *numbers, int nnumbers); extern char *get_namespace_name(Oid nspid); +extern Oid get_namespace_tablespace(Oid nspid); extern int32 get_usesysid(const char *username); #define is_array_type(typid) (get_element_type(typid) != InvalidOid) diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 848d68b2077..da82f4f6137 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.39 2004/02/10 01:55:27 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.40 2004/06/18 06:14:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -51,8 +51,9 @@ extern void RelationCacheInitializePhase3(void); extern Relation RelationBuildLocalRelation(const char *relname, Oid relnamespace, TupleDesc tupDesc, - Oid relid, Oid dbid, - RelFileNode rnode, + Oid relid, + Oid reltablespace, + bool shared_relation, bool nailit); /* |
