diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-02 18:13:32 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-02 18:13:32 +0000 |
| commit | d70610c4eec6f6b7ca332086fdd9c91871a4718d (patch) | |
| tree | 4f61c67edf995d832789b9295149286e331acb6b /src/backend/access/hash/hashutil.c | |
| parent | 8b2450c831df5c28bb20d10d2a023ecf2349ee5b (diff) | |
| download | postgresql-d70610c4eec6f6b7ca332086fdd9c91871a4718d.tar.gz | |
Several fixes for hash indexes that involve changing the on-disk index
layout; therefore, this change forces REINDEX of hash indexes (though
not a full initdb). Widen hashm_ntuples to double so that hash space
management doesn't get confused by more than 4G entries; enlarge the
allowed number of free-space-bitmap pages; replace the useless bshift
field with a useful bmshift field; eliminate 4 bytes of wasted space
in the per-page special area.
Diffstat (limited to 'src/backend/access/hash/hashutil.c')
| -rw-r--r-- | src/backend/access/hash/hashutil.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c index 76d9bc5f4e..ce62a3a844 100644 --- a/src/backend/access/hash/hashutil.c +++ b/src/backend/access/hash/hashutil.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.34 2003/09/02 02:18:38 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.35 2003/09/02 18:13:31 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -143,10 +143,33 @@ _hash_log2(uint32 num) * _hash_checkpage -- sanity checks on the format of all hash pages */ void -_hash_checkpage(Page page, int flags) +_hash_checkpage(Relation rel, Page page, int flags) { -#ifdef USE_ASSERT_CHECKING Assert(page); + /* + * When checking the metapage, always verify magic number and version. + */ + if (flags == LH_META_PAGE) + { + HashMetaPage metap = (HashMetaPage) page; + + if (metap->hashm_magic != HASH_MAGIC) + ereport(ERROR, + (errcode(ERRCODE_INDEX_CORRUPTED), + errmsg("index \"%s\" is not a hash index", + RelationGetRelationName(rel)))); + + if (metap->hashm_version != HASH_VERSION) + ereport(ERROR, + (errcode(ERRCODE_INDEX_CORRUPTED), + errmsg("index \"%s\" has wrong hash version, please REINDEX it", + RelationGetRelationName(rel)))); + } + + /* + * These other checks are for debugging purposes only. + */ +#ifdef USE_ASSERT_CHECKING Assert(((PageHeader) (page))->pd_lower >= SizeOfPageHeaderData); Assert(((PageHeader) (page))->pd_upper <= (BLCKSZ - MAXALIGN(sizeof(HashPageOpaqueData)))); |
