summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-07 20:48:13 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-07 20:48:13 +0000
commitb9b8831ad60f6e4bd580fe6dbe9749359298a3c4 (patch)
treeaf6948498f13a43edd982b05808ed89b5b8191ab /src/include
parent7fc30c488fc6e9674564206193c29b1a657a818f (diff)
downloadpostgresql-b9b8831ad60f6e4bd580fe6dbe9749359298a3c4.tar.gz
Create a "relation mapping" infrastructure to support changing the relfilenodes
of shared or nailed system catalogs. This has two key benefits: * The new CLUSTER-based VACUUM FULL can be applied safely to all catalogs. * We no longer have to use an unsafe reindex-in-place approach for reindexing shared catalogs. CLUSTER on nailed catalogs now works too, although I left it disabled on shared catalogs because the resulting pg_index.indisclustered update would only be visible in one database. Since reindexing shared system catalogs is now fully transactional and crash-safe, the former special cases in REINDEX behavior have been removed; shared catalogs are treated the same as non-shared. This commit does not do anything about the recently-discussed problem of deadlocks between VACUUM FULL/CLUSTER on a system catalog and other concurrent queries; will address that in a separate patch. As a stopgap, parallel_schedule has been tweaked to run vacuum.sql by itself, to avoid such failures during the regression tests.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/rmgr.h3
-rw-r--r--src/include/catalog/catalog.h5
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/heap.h10
-rw-r--r--src/include/catalog/index.h7
-rw-r--r--src/include/catalog/pg_class.h11
-rw-r--r--src/include/catalog/pg_proc.h6
-rw-r--r--src/include/catalog/storage.h3
-rw-r--r--src/include/commands/cluster.h10
-rw-r--r--src/include/miscadmin.h6
-rw-r--r--src/include/storage/lwlock.h3
-rw-r--r--src/include/storage/relfilenode.h6
-rw-r--r--src/include/storage/sinval.h53
-rw-r--r--src/include/utils/builtins.h4
-rw-r--r--src/include/utils/catcache.h3
-rw-r--r--src/include/utils/inval.h8
-rw-r--r--src/include/utils/rel.h12
-rw-r--r--src/include/utils/relcache.h7
-rw-r--r--src/include/utils/relmapper.h62
19 files changed, 176 insertions, 47 deletions
diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h
index 32b1bd535c..72ee757f70 100644
--- a/src/include/access/rmgr.h
+++ b/src/include/access/rmgr.h
@@ -3,7 +3,7 @@
*
* Resource managers definition
*
- * $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.20 2009/12/19 01:32:42 sriggs Exp $
+ * $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.21 2010/02/07 20:48:11 tgl Exp $
*/
#ifndef RMGR_H
#define RMGR_H
@@ -23,6 +23,7 @@ typedef uint8 RmgrId;
#define RM_DBASE_ID 4
#define RM_TBLSPC_ID 5
#define RM_MULTIXACT_ID 6
+#define RM_RELMAP_ID 7
#define RM_STANDBY_ID 8
#define RM_HEAP2_ID 9
#define RM_HEAP_ID 10
diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h
index 236983fe07..b8401df772 100644
--- a/src/include/catalog/catalog.h
+++ b/src/include/catalog/catalog.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catalog.h,v 1.47 2010/01/12 02:42:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catalog.h,v 1.48 2010/02/07 20:48:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,6 @@ extern bool IsSharedRelation(Oid relationId);
extern Oid GetNewOid(Relation relation);
extern Oid GetNewOidWithIndex(Relation relation, Oid indexId,
AttrNumber oidcolumn);
-extern Oid GetNewRelFileNode(Oid reltablespace, bool relisshared,
- Relation pg_class);
+extern Oid GetNewRelFileNode(Oid reltablespace, Relation pg_class);
#endif /* CATALOG_H */
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index e12ec58ed6..4a4ea6b492 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.582 2010/02/01 03:14:43 itagaki Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.583 2010/02/07 20:48:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201002011
+#define CATALOG_VERSION_NO 201002071
#endif
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h
index 9c16737ada..d733dbb32e 100644
--- a/src/include/catalog/heap.h
+++ b/src/include/catalog/heap.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.96 2010/01/28 23:21:12 petere Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.97 2010/02/07 20:48:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -41,6 +41,7 @@ extern Relation heap_create(const char *relname,
TupleDesc tupDesc,
char relkind,
bool shared_relation,
+ bool mapped_relation,
bool allow_system_table_mods);
extern Oid heap_create_with_catalog(const char *relname,
@@ -54,6 +55,7 @@ extern Oid heap_create_with_catalog(const char *relname,
List *cooked_constraints,
char relkind,
bool shared_relation,
+ bool mapped_relation,
bool oidislocal,
int oidinhcount,
OnCommitAction oncommit,
@@ -109,8 +111,10 @@ extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno,
extern Form_pg_attribute SystemAttributeByName(const char *attname,
bool relhasoids);
-extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind);
+extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
+ bool allow_system_table_mods);
-extern void CheckAttributeType(const char *attname, Oid atttypid);
+extern void CheckAttributeType(const char *attname, Oid atttypid,
+ bool allow_system_table_mods);
#endif /* HEAP_H */
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index bdb1c71a73..2bacf827c9 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.81 2010/02/03 01:14:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.82 2010/02/07 20:48:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -71,6 +71,9 @@ extern double IndexBuildHeapScan(Relation heapRelation,
extern void validate_index(Oid heapId, Oid indexId, Snapshot snapshot);
extern void reindex_index(Oid indexId);
-extern bool reindex_relation(Oid relid, bool toast_too);
+extern bool reindex_relation(Oid relid, bool toast_too, bool heap_rebuilt);
+
+extern bool ReindexIsProcessingHeap(Oid heapOid);
+extern bool ReindexIsProcessingIndex(Oid indexOid);
#endif /* INDEX_H */
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index aa35109edc..00d0dbc975 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.120 2010/01/28 23:21:12 petere Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.121 2010/02/07 20:48:11 tgl Exp $
*
* NOTES
* the genbki.pl script reads this file and generates .bki
@@ -38,6 +38,7 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
Oid relowner; /* class owner */
Oid relam; /* index access method; 0 if not an index */
Oid relfilenode; /* identifier of physical storage file */
+ /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
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) */
@@ -128,13 +129,13 @@ typedef FormData_pg_class *Form_pg_class;
*/
/* Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId */
-DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 1247 0 0 0 0 0 f f f r 28 0 t f f f f f 3 _null_ _null_ ));
+DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f f r 28 0 t f f f f f 3 _null_ _null_ ));
DESCR("");
-DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 1249 0 0 0 0 0 f f f r 19 0 f f f f f f 3 _null_ _null_ ));
+DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f f r 19 0 f f f f f f 3 _null_ _null_ ));
DESCR("");
-DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 1255 0 0 0 0 0 f f f r 25 0 t f f f f f 3 _null_ _null_ ));
+DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f f r 25 0 t f f f f f 3 _null_ _null_ ));
DESCR("");
-DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 1259 0 0 0 0 0 f f f r 27 0 t f f f f f 3 _null_ _null_ ));
+DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f f r 27 0 t f f f f f 3 _null_ _null_ ));
DESCR("");
#define RELKIND_INDEX 'i' /* secondary index */
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index ec45367b4a..727b13e264 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.567 2010/02/01 03:14:44 itagaki Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.568 2010/02/07 20:48:11 tgl Exp $
*
* NOTES
* The script catalog/genbki.pl reads this file and generates .bki
@@ -3741,6 +3741,10 @@ DATA(insert OID = 2997 ( pg_table_size PGNSP PGUID 12 1 0 0 f f f t f v 1 0 20
DESCR("disk space usage for the specified table, including TOAST, free space and visibility map");
DATA(insert OID = 2998 ( pg_indexes_size PGNSP PGUID 12 1 0 0 f f f t f v 1 0 20 "2205" _null_ _null_ _null_ _null_ pg_indexes_size _null_ _null_ _null_ ));
DESCR("disk space usage for all indexes attached to the specified table");
+DATA(insert OID = 2999 ( pg_relation_filenode PGNSP PGUID 12 1 0 0 f f f t f s 1 0 26 "2205" _null_ _null_ _null_ _null_ pg_relation_filenode _null_ _null_ _null_ ));
+DESCR("filenode identifier of relation");
+DATA(insert OID = 3034 ( pg_relation_filepath PGNSP PGUID 12 1 0 0 f f f t f s 1 0 25 "2205" _null_ _null_ _null_ _null_ pg_relation_filepath _null_ _null_ _null_ ));
+DESCR("file path of relation");
DATA(insert OID = 2316 ( postgresql_fdw_validator PGNSP PGUID 12 1 0 0 f f f t f i 2 0 16 "1009 26" _null_ _null_ _null_ _null_ postgresql_fdw_validator _null_ _null_ _null_));
diff --git a/src/include/catalog/storage.h b/src/include/catalog/storage.h
index e6cafd8216..f86cf9bbf5 100644
--- a/src/include/catalog/storage.h
+++ b/src/include/catalog/storage.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/storage.h,v 1.4 2010/01/02 16:58:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/storage.h,v 1.5 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,6 +22,7 @@
extern void RelationCreateStorage(RelFileNode rnode, bool istemp);
extern void RelationDropStorage(Relation rel);
+extern void RelationPreserveStorage(RelFileNode rnode);
extern void RelationTruncate(Relation rel, BlockNumber nblocks);
/*
diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h
index f535781436..0fecd1986a 100644
--- a/src/include/commands/cluster.h
+++ b/src/include/commands/cluster.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/cluster.h,v 1.39 2010/02/04 00:09:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/cluster.h,v 1.40 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,9 +25,9 @@ extern void check_index_is_clusterable(Relation OldHeap, Oid indexOid,
extern void mark_index_clustered(Relation rel, Oid indexOid);
extern Oid make_new_heap(Oid OIDOldHeap, Oid NewTableSpace);
-extern void swap_relation_files(Oid r1, Oid r2, bool swap_toast_by_content,
- TransactionId frozenXid);
-extern void cleanup_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
- bool swap_toast_by_content);
+extern void finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
+ bool is_system_catalog,
+ bool swap_toast_by_content,
+ TransactionId frozenXid);
#endif /* CLUSTER_H */
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index f47106f6cc..2face3a3bd 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.217 2010/01/02 16:58:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.218 2010/02/07 20:48:13 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to other files.
@@ -347,10 +347,6 @@ extern PGDLLIMPORT bool process_shared_preload_libraries_in_progress;
extern char *shared_preload_libraries_string;
extern char *local_preload_libraries_string;
-extern void SetReindexProcessing(Oid heapOid, Oid indexOid);
-extern void ResetReindexProcessing(void);
-extern bool ReindexIsProcessingHeap(Oid heapOid);
-extern bool ReindexIsProcessingIndex(Oid indexOid);
extern void CreateDataDirLockFile(bool amPostmaster);
extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster);
extern void TouchSocketLockFile(void);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index 74e98eca54..f0beb20a24 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.43 2010/01/02 16:58:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.44 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -67,6 +67,7 @@ typedef enum LWLockId
AutovacuumLock,
AutovacuumScheduleLock,
SyncScanLock,
+ RelationMappingLock,
/* Individual lock IDs end here */
FirstBufMappingLock,
FirstLockMgrLock = FirstBufMappingLock + NUM_BUFFER_PARTITIONS,
diff --git a/src/include/storage/relfilenode.h b/src/include/storage/relfilenode.h
index e2088270d0..b5e4e1134d 100644
--- a/src/include/storage/relfilenode.h
+++ b/src/include/storage/relfilenode.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/relfilenode.h,v 1.24 2010/01/02 16:58:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/relfilenode.h,v 1.25 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,6 +61,10 @@ typedef enum ForkNumber
* identified by pg_database.dattablespace). However this shorthand
* is NOT allowed in RelFileNode structs --- the real tablespace ID
* must be supplied when setting spcNode.
+ *
+ * Note: in pg_class, relfilenode can be zero to denote that the relation
+ * is a "mapped" relation, whose current true filenode number is available
+ * from relmapper.c. Again, this case is NOT allowed in RelFileNodes.
*/
typedef struct RelFileNode
{
diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h
index 9f7bb2b2ee..bad8f50542 100644
--- a/src/include/storage/sinval.h
+++ b/src/include/storage/sinval.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.56 2010/01/09 16:49:27 sriggs Exp $
+ * $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.57 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,14 +19,16 @@
/*
- * We currently support three types of shared-invalidation messages: one that
- * invalidates an entry in a catcache, one that invalidates a relcache entry,
- * and one that invalidates an smgr cache entry. More types could be added
- * if needed. The message type is identified by the first "int16" field of
- * the message struct. Zero or positive means a catcache inval message (and
- * also serves as the catcache ID field). -1 means a relcache inval message.
- * -2 means an smgr inval message. Other negative values are available to
- * identify other inval message types.
+ * We support several types of shared-invalidation messages:
+ * * invalidate a specific tuple in a specific catcache
+ * * invalidate all catcache entries from a given system catalog
+ * * invalidate a relcache entry for a specific logical relation
+ * * invalidate an smgr cache entry for a specific physical relation
+ * * invalidate the mapped-relation mapping for a given database
+ * More types could be added if needed. The message type is identified by
+ * the first "int16" field of the message struct. Zero or positive means a
+ * specific-catcache inval message (and also serves as the catcache ID field).
+ * Negative values identify the other message types, as per codes below.
*
* Catcache inval events are initially driven by detecting tuple inserts,
* updates and deletions in system catalogs (see CacheInvalidateHeapTuple).
@@ -46,6 +48,16 @@
* and so that negative cache entries can be recognized with good accuracy.
* (Of course this assumes that all the backends are using identical hashing
* code, but that should be OK.)
+ *
+ * Catcache and relcache invalidations are transactional, and so are sent
+ * to other backends upon commit. Internally to the generating backend,
+ * they are also processed at CommandCounterIncrement so that later commands
+ * in the same transaction see the new state. The generating backend also
+ * has to process them at abort, to flush out any cache state it's loaded
+ * from no-longer-valid entries.
+ *
+ * smgr and relation mapping invalidations are non-transactional: they are
+ * sent immediately when the underlying file change is made.
*/
typedef struct
@@ -57,7 +69,16 @@ typedef struct
uint32 hashValue; /* hash value of key for this catcache */
} SharedInvalCatcacheMsg;
-#define SHAREDINVALRELCACHE_ID (-1)
+#define SHAREDINVALCATALOG_ID (-1)
+
+typedef struct
+{
+ int16 id; /* type field --- must be first */
+ Oid dbId; /* database ID, or 0 if a shared catalog */
+ Oid catId; /* ID of catalog whose contents are invalid */
+} SharedInvalCatalogMsg;
+
+#define SHAREDINVALRELCACHE_ID (-2)
typedef struct
{
@@ -66,7 +87,7 @@ typedef struct
Oid relId; /* relation ID */
} SharedInvalRelcacheMsg;
-#define SHAREDINVALSMGR_ID (-2)
+#define SHAREDINVALSMGR_ID (-3)
typedef struct
{
@@ -74,12 +95,22 @@ typedef struct
RelFileNode rnode; /* physical file ID */
} SharedInvalSmgrMsg;
+#define SHAREDINVALRELMAP_ID (-4)
+
+typedef struct
+{
+ int16 id; /* type field --- must be first */
+ Oid dbId; /* database ID, or 0 for shared catalogs */
+} SharedInvalRelmapMsg;
+
typedef union
{
int16 id; /* type field --- must be first */
SharedInvalCatcacheMsg cc;
+ SharedInvalCatalogMsg cat;
SharedInvalRelcacheMsg rc;
SharedInvalSmgrMsg sm;
+ SharedInvalRelmapMsg rm;
} SharedInvalidationMessage;
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 6381c3d735..a6a4284b44 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.346 2010/02/01 03:14:45 itagaki Exp $
+ * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.347 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -435,6 +435,8 @@ extern Datum pg_total_relation_size(PG_FUNCTION_ARGS);
extern Datum pg_size_pretty(PG_FUNCTION_ARGS);
extern Datum pg_table_size(PG_FUNCTION_ARGS);
extern Datum pg_indexes_size(PG_FUNCTION_ARGS);
+extern Datum pg_relation_filenode(PG_FUNCTION_ARGS);
+extern Datum pg_relation_filepath(PG_FUNCTION_ARGS);
/* genfile.c */
extern Datum pg_stat_file(PG_FUNCTION_ARGS);
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h
index b8e945e8cc..6d77c4a7d1 100644
--- a/src/include/utils/catcache.h
+++ b/src/include/utils/catcache.h
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.69 2010/01/02 16:58:10 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.70 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -180,6 +180,7 @@ extern void ReleaseCatCacheList(CatCList *list);
extern void ResetCatalogCaches(void);
extern void CatalogCacheFlushRelation(Oid relId);
+extern void CatalogCacheFlushCatalog(Oid catId);
extern void CatalogCacheIdInvalidate(int cacheId, uint32 hashValue,
ItemPointer pointer);
extern void PrepareToInvalidateCacheTuple(Relation relation,
diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h
index dc35160ffe..1a9bbe5b38 100644
--- a/src/include/utils/inval.h
+++ b/src/include/utils/inval.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.47 2010/02/03 01:14:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.48 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,6 +45,8 @@ extern void EndNonTransactionalInvalidation(void);
extern void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple);
+extern void CacheInvalidateCatalog(Oid catalogId);
+
extern void CacheInvalidateRelcache(Relation relation);
extern void CacheInvalidateRelcacheByTuple(HeapTuple classTuple);
@@ -53,6 +55,8 @@ extern void CacheInvalidateRelcacheByRelid(Oid relid);
extern void CacheInvalidateSmgr(RelFileNode rnode);
+extern void CacheInvalidateRelmap(Oid databaseId);
+
extern void CacheRegisterSyscacheCallback(int cacheid,
SyscacheCallbackFunction func,
Datum arg);
@@ -60,6 +64,8 @@ extern void CacheRegisterSyscacheCallback(int cacheid,
extern void CacheRegisterRelcacheCallback(RelcacheCallbackFunction func,
Datum arg);
+extern void CallSyscacheCallbacks(int cacheid, ItemPointer tuplePtr);
+
extern void inval_twophase_postcommit(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 3f5795d0ea..c4a1fcf7b6 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.121 2010/02/04 00:09:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.122 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -340,6 +340,16 @@ typedef struct StdRdOptions
((relation)->rd_rel->relnamespace)
/*
+ * RelationIsMapped
+ * True if the relation uses the relfilenode map.
+ *
+ * NB: this is only meaningful for relkinds that have storage, else it
+ * will misleadingly say "true".
+ */
+#define RelationIsMapped(relation) \
+ ((relation)->rd_rel->relfilenode == InvalidOid)
+
+/*
* RelationOpenSmgr
* Open the relation at the smgr level, if not already done.
*/
diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h
index 2e48250cbf..74d6af01ba 100644
--- a/src/include/utils/relcache.h
+++ b/src/include/utils/relcache.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.67 2010/02/03 01:14:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.68 2010/02/07 20:48:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -68,7 +68,8 @@ extern Relation RelationBuildLocalRelation(const char *relname,
TupleDesc tupDesc,
Oid relid,
Oid reltablespace,
- bool shared_relation);
+ bool shared_relation,
+ bool mapped_relation);
/*
* Routine to manage assignment of new relfilenode to a relation
@@ -85,6 +86,8 @@ extern void RelationCacheInvalidateEntry(Oid relationId);
extern void RelationCacheInvalidate(void);
+extern void RelationCloseSmgrByOid(Oid relationId);
+
extern void AtEOXact_RelationCache(bool isCommit);
extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
SubTransactionId parentSubid);
diff --git a/src/include/utils/relmapper.h b/src/include/utils/relmapper.h
new file mode 100644
index 0000000000..6bd1f6ba40
--- /dev/null
+++ b/src/include/utils/relmapper.h
@@ -0,0 +1,62 @@
+/*-------------------------------------------------------------------------
+ *
+ * relmapper.h
+ * Catalog-to-filenode mapping
+ *
+ *
+ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $PostgreSQL: pgsql/src/include/utils/relmapper.h,v 1.1 2010/02/07 20:48:13 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef RELMAPPER_H
+#define RELMAPPER_H
+
+#include "access/xlog.h"
+
+/* ----------------
+ * relmap-related XLOG entries
+ * ----------------
+ */
+
+#define XLOG_RELMAP_UPDATE 0x00
+
+typedef struct xl_relmap_update
+{
+ Oid dbid; /* database ID, or 0 for shared map */
+ Oid tsid; /* database's tablespace, or pg_global */
+ int32 nbytes; /* size of relmap data */
+ char data[1]; /* VARIABLE LENGTH ARRAY */
+} xl_relmap_update;
+
+#define MinSizeOfRelmapUpdate offsetof(xl_relmap_update, data)
+
+
+extern Oid RelationMapOidToFilenode(Oid relationId, bool shared);
+
+extern void RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared,
+ bool immediate);
+
+extern void RelationMapRemoveMapping(Oid relationId);
+
+extern void RelationMapInvalidate(bool shared);
+extern void RelationMapInvalidateAll(void);
+
+extern void AtCCI_RelationMap(void);
+extern void AtEOXact_RelationMap(bool isCommit);
+extern void AtPrepare_RelationMap(void);
+
+extern void CheckPointRelationMap(void);
+
+extern void RelationMapFinishBootstrap(void);
+
+extern void RelationMapInitialize(void);
+extern void RelationMapInitializePhase2(void);
+extern void RelationMapInitializePhase3(void);
+
+extern void relmap_redo(XLogRecPtr lsn, XLogRecord *record);
+extern void relmap_desc(StringInfo buf, uint8 xl_info, char *rec);
+
+#endif /* RELMAPPER_H */