summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-01-17 16:35:46 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-01-17 16:46:16 +0200
commit9ee4d06f3fdde37b063b8a0f0fa0a2113ac12303 (patch)
tree692e6a1de1a5a48872958ab8554a57889be2c6ba /src/include
parentbba486f372ffa28d6a0b70a6b0ad7065429213d0 (diff)
downloadpostgresql-9ee4d06f3fdde37b063b8a0f0fa0a2113ac12303.tar.gz
Make GiST indexes on-disk compatible with 9.2 again.
The patch that turned XLogRecPtr into a uint64 inadvertently changed the on-disk format of GiST indexes, because the NSN field in the GiST page opaque is an XLogRecPtr. That breaks pg_upgrade. Revert the format of that field back to the two-field struct that XLogRecPtr was before. This is the same we did to LSNs in the page header to avoid changing on-disk format. Bump catversion, as this invalidates any existing GiST indexes built on 9.3devel.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/gist.h10
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/storage/bufpage.h30
3 files changed, 29 insertions, 13 deletions
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index 69e4ec03fb..a487a0be3a 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -64,10 +64,15 @@
#define F_FOLLOW_RIGHT (1 << 3) /* page to the right has no downlink */
typedef XLogRecPtr GistNSN;
+/*
+ * For on-disk compatibility with pre-9.3 servers, NSN is stored as two
+ * 32-bit fields on disk, same as LSNs.
+ */
+typedef PageXLogRecPtr PageGistNSN;
typedef struct GISTPageOpaqueData
{
- GistNSN nsn; /* this value must change on page split */
+ PageGistNSN nsn; /* this value must change on page split */
BlockNumber rightlink; /* next page if any */
uint16 flags; /* see bit definitions above */
uint16 gist_page_id; /* for identification of GiST indexes */
@@ -137,6 +142,9 @@ typedef struct GISTENTRY
#define GistMarkFollowRight(page) ( GistPageGetOpaque(page)->flags |= F_FOLLOW_RIGHT)
#define GistClearFollowRight(page) ( GistPageGetOpaque(page)->flags &= ~F_FOLLOW_RIGHT)
+#define GistPageGetNSN(page) ( PageXLogRecPtrGet(GistPageGetOpaque(page)->nsn))
+#define GistPageSetNSN(page, val) ( PageXLogRecPtrSet(GistPageGetOpaque(page)->nsn, val))
+
/*
* Vector of GISTENTRY structs; user-defined methods union and picksplit
* take it as one of their arguments
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 1e235c6d1e..cd562ef40c 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201212081
+#define CATALOG_VERSION_NO 201301171
#endif
diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h
index 7758407098..8c887cab73 100644
--- a/src/include/storage/bufpage.h
+++ b/src/include/storage/bufpage.h
@@ -83,6 +83,21 @@ typedef uint16 LocationIndex;
/*
+ * For historical reasons, the 64-bit LSN value is stored as two 32-bit
+ * values.
+ */
+typedef struct
+{
+ uint32 xlogid; /* high bits */
+ uint32 xrecoff; /* low bits */
+} PageXLogRecPtr;
+
+#define PageXLogRecPtrGet(val) \
+ ((uint64) (val).xlogid << 32 | (val).xrecoff)
+#define PageXLogRecPtrSet(ptr, lsn) \
+ ((ptr).xlogid = (uint32) ((lsn) >> 32), (ptr).xrecoff = (uint32) (lsn))
+
+/*
* disk page organization
*
* space management information generic to any page
@@ -120,13 +135,6 @@ typedef uint16 LocationIndex;
* are 15 bits.
*/
-/* for historical reasons, the LSN is stored as two 32-bit values. */
-typedef struct
-{
- uint32 xlogid; /* high bits */
- uint32 xrecoff; /* low bits */
-} PageXLogRecPtr;
-
typedef struct PageHeaderData
{
/* XXX LSN is member of *any* block, not only page-organized ones */
@@ -319,13 +327,13 @@ typedef PageHeaderData *PageHeader;
/ sizeof(ItemIdData)))
/*
- * Additional macros for access to page headers
+ * Additional macros for access to page headers. (Beware multiple evaluation
+ * of the arguments!)
*/
#define PageGetLSN(page) \
- ((uint64) ((PageHeader) (page))->pd_lsn.xlogid << 32 | ((PageHeader) (page))->pd_lsn.xrecoff)
+ PageXLogRecPtrGet(((PageHeader) (page))->pd_lsn)
#define PageSetLSN(page, lsn) \
- (((PageHeader) (page))->pd_lsn.xlogid = (uint32) ((lsn) >> 32), \
- ((PageHeader) (page))->pd_lsn.xrecoff = (uint32) (lsn))
+ PageXLogRecPtrSet(((PageHeader) (page))->pd_lsn, lsn)
/* NOTE: only the 16 least significant bits are stored */
#define PageGetTLI(page) \