mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.13 1997/09/07 04:37:49 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.14 1997/09/08 02:20:10 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains only the public interface routines.
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
bool BuildingHash = false;
|
||||
bool BuildingHash = false;
|
||||
|
||||
/*
|
||||
* hashbuild() -- build a new hash index.
|
||||
@@ -52,30 +52,30 @@ hashbuild(Relation heap,
|
||||
FuncIndexInfo * finfo,
|
||||
PredInfo * predInfo)
|
||||
{
|
||||
HeapScanDesc hscan;
|
||||
Buffer buffer;
|
||||
HeapTuple htup;
|
||||
IndexTuple itup;
|
||||
TupleDesc htupdesc,
|
||||
itupdesc;
|
||||
Datum *attdata;
|
||||
bool *nulls;
|
||||
HeapScanDesc hscan;
|
||||
Buffer buffer;
|
||||
HeapTuple htup;
|
||||
IndexTuple itup;
|
||||
TupleDesc htupdesc,
|
||||
itupdesc;
|
||||
Datum *attdata;
|
||||
bool *nulls;
|
||||
InsertIndexResult res;
|
||||
int nhtups,
|
||||
nitups;
|
||||
int i;
|
||||
HashItem hitem;
|
||||
int nhtups,
|
||||
nitups;
|
||||
int i;
|
||||
HashItem hitem;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
ExprContext *econtext;
|
||||
TupleTable tupleTable;
|
||||
ExprContext *econtext;
|
||||
TupleTable tupleTable;
|
||||
TupleTableSlot *slot;
|
||||
|
||||
#endif
|
||||
Oid hrelid,
|
||||
irelid;
|
||||
Node *pred,
|
||||
*oldPred;
|
||||
Oid hrelid,
|
||||
irelid;
|
||||
Node *pred,
|
||||
*oldPred;
|
||||
|
||||
/* note that this is a new btree */
|
||||
BuildingHash = true;
|
||||
@@ -171,8 +171,8 @@ hashbuild(Relation heap,
|
||||
*/
|
||||
for (i = 1; i <= natts; i++)
|
||||
{
|
||||
int attoff;
|
||||
bool attnull;
|
||||
int attoff;
|
||||
bool attnull;
|
||||
|
||||
/*
|
||||
* Offsets are from the start of the tuple, and are
|
||||
@@ -280,8 +280,8 @@ hashbuild(Relation heap,
|
||||
InsertIndexResult
|
||||
hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
||||
{
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
InsertIndexResult res;
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relati
|
||||
/*
|
||||
* hashgettuple() -- Get the next tuple in the scan.
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
hashgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
{
|
||||
RetrieveIndexResult res;
|
||||
@@ -329,14 +329,14 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
/*
|
||||
* hashbeginscan() -- start a scan on a hash index
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
hashbeginscan(Relation rel,
|
||||
bool fromEnd,
|
||||
uint16 keysz,
|
||||
ScanKey scankey)
|
||||
{
|
||||
IndexScanDesc scan;
|
||||
HashScanOpaque so;
|
||||
IndexScanDesc scan;
|
||||
HashScanOpaque so;
|
||||
|
||||
scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey);
|
||||
so = (HashScanOpaque) palloc(sizeof(HashScanOpaqueData));
|
||||
@@ -356,8 +356,8 @@ hashbeginscan(Relation rel,
|
||||
void
|
||||
hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
|
||||
so = (HashScanOpaque) scan->opaque;
|
||||
|
||||
@@ -391,8 +391,8 @@ void
|
||||
hashendscan(IndexScanDesc scan)
|
||||
{
|
||||
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
|
||||
so = (HashScanOpaque) scan->opaque;
|
||||
|
||||
@@ -426,8 +426,8 @@ hashendscan(IndexScanDesc scan)
|
||||
void
|
||||
hashmarkpos(IndexScanDesc scan)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
|
||||
/*
|
||||
* see if we ever call this code. if we do, then so_mrkbuf a useful
|
||||
@@ -463,8 +463,8 @@ hashmarkpos(IndexScanDesc scan)
|
||||
void
|
||||
hashrestrpos(IndexScanDesc scan)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
HashScanOpaque so;
|
||||
|
||||
/*
|
||||
* see if we ever call this code. if we do, then so_mrkbuf a useful
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.4 1997/09/07 04:37:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.5 1997/09/08 02:20:13 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These functions are stored in pg_amproc. For each operator class
|
||||
@@ -36,10 +36,10 @@ hashint4(uint32 key)
|
||||
uint32
|
||||
hashfloat4(float32 keyp)
|
||||
{
|
||||
int len;
|
||||
int loop;
|
||||
uint32 h;
|
||||
char *kp = (char *) keyp;
|
||||
int len;
|
||||
int loop;
|
||||
uint32 h;
|
||||
char *kp = (char *) keyp;
|
||||
|
||||
len = sizeof(float32data);
|
||||
|
||||
@@ -55,25 +55,25 @@ hashfloat4(float32 keyp)
|
||||
|
||||
switch (len & (8 - 1))
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASH4;
|
||||
case 7:
|
||||
HASH4;
|
||||
case 6:
|
||||
HASH4;
|
||||
case 5:
|
||||
HASH4;
|
||||
case 4:
|
||||
HASH4;
|
||||
case 3:
|
||||
HASH4;
|
||||
case 2:
|
||||
HASH4;
|
||||
case 1:
|
||||
HASH4;
|
||||
} while (--loop);
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASH4;
|
||||
case 7:
|
||||
HASH4;
|
||||
case 6:
|
||||
HASH4;
|
||||
case 5:
|
||||
HASH4;
|
||||
case 4:
|
||||
HASH4;
|
||||
case 3:
|
||||
HASH4;
|
||||
case 2:
|
||||
HASH4;
|
||||
case 1:
|
||||
HASH4;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
return (h);
|
||||
@@ -83,10 +83,10 @@ hashfloat4(float32 keyp)
|
||||
uint32
|
||||
hashfloat8(float64 keyp)
|
||||
{
|
||||
int len;
|
||||
int loop;
|
||||
uint32 h;
|
||||
char *kp = (char *) keyp;
|
||||
int len;
|
||||
int loop;
|
||||
uint32 h;
|
||||
char *kp = (char *) keyp;
|
||||
|
||||
len = sizeof(float64data);
|
||||
|
||||
@@ -102,25 +102,25 @@ hashfloat8(float64 keyp)
|
||||
|
||||
switch (len & (8 - 1))
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASH4;
|
||||
case 7:
|
||||
HASH4;
|
||||
case 6:
|
||||
HASH4;
|
||||
case 5:
|
||||
HASH4;
|
||||
case 4:
|
||||
HASH4;
|
||||
case 3:
|
||||
HASH4;
|
||||
case 2:
|
||||
HASH4;
|
||||
case 1:
|
||||
HASH4;
|
||||
} while (--loop);
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASH4;
|
||||
case 7:
|
||||
HASH4;
|
||||
case 6:
|
||||
HASH4;
|
||||
case 5:
|
||||
HASH4;
|
||||
case 4:
|
||||
HASH4;
|
||||
case 3:
|
||||
HASH4;
|
||||
case 2:
|
||||
HASH4;
|
||||
case 1:
|
||||
HASH4;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
return (h);
|
||||
@@ -137,8 +137,8 @@ hashoid(Oid key)
|
||||
uint32
|
||||
hashchar(char key)
|
||||
{
|
||||
int len;
|
||||
uint32 h;
|
||||
int len;
|
||||
uint32 h;
|
||||
|
||||
len = sizeof(char);
|
||||
|
||||
@@ -156,9 +156,9 @@ hashchar(char key)
|
||||
uint32
|
||||
hashchar2(uint16 intkey)
|
||||
{
|
||||
uint32 h;
|
||||
int len;
|
||||
char *key = (char *) &intkey;
|
||||
uint32 h;
|
||||
int len;
|
||||
char *key = (char *) &intkey;
|
||||
|
||||
h = 0;
|
||||
len = sizeof(uint16);
|
||||
@@ -173,9 +173,9 @@ hashchar2(uint16 intkey)
|
||||
uint32
|
||||
hashchar4(uint32 intkey)
|
||||
{
|
||||
uint32 h;
|
||||
int len;
|
||||
char *key = (char *) &intkey;
|
||||
uint32 h;
|
||||
int len;
|
||||
char *key = (char *) &intkey;
|
||||
|
||||
h = 0;
|
||||
len = sizeof(uint32);
|
||||
@@ -190,8 +190,8 @@ hashchar4(uint32 intkey)
|
||||
uint32
|
||||
hashchar8(char *key)
|
||||
{
|
||||
uint32 h;
|
||||
int len;
|
||||
uint32 h;
|
||||
int len;
|
||||
|
||||
h = 0;
|
||||
len = sizeof(char8);
|
||||
@@ -206,9 +206,9 @@ hashchar8(char *key)
|
||||
uint32
|
||||
hashname(NameData * n)
|
||||
{
|
||||
uint32 h;
|
||||
int len;
|
||||
char *key;
|
||||
uint32 h;
|
||||
int len;
|
||||
char *key;
|
||||
|
||||
key = n->data;
|
||||
|
||||
@@ -226,8 +226,8 @@ hashname(NameData * n)
|
||||
uint32
|
||||
hashchar16(char *key)
|
||||
{
|
||||
uint32 h;
|
||||
int len;
|
||||
uint32 h;
|
||||
int len;
|
||||
|
||||
h = 0;
|
||||
len = sizeof(char16);
|
||||
@@ -254,10 +254,10 @@ hashchar16(char *key)
|
||||
uint32
|
||||
hashtext(struct varlena * key)
|
||||
{
|
||||
int keylen;
|
||||
char *keydata;
|
||||
uint32 n;
|
||||
int loop;
|
||||
int keylen;
|
||||
char *keydata;
|
||||
uint32 n;
|
||||
int loop;
|
||||
|
||||
keydata = VARDATA(key);
|
||||
keylen = VARSIZE(key);
|
||||
@@ -274,25 +274,25 @@ hashtext(struct varlena * key)
|
||||
|
||||
switch (keylen & (8 - 1))
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASHC;
|
||||
case 7:
|
||||
HASHC;
|
||||
case 6:
|
||||
HASHC;
|
||||
case 5:
|
||||
HASHC;
|
||||
case 4:
|
||||
HASHC;
|
||||
case 3:
|
||||
HASHC;
|
||||
case 2:
|
||||
HASHC;
|
||||
case 1:
|
||||
HASHC;
|
||||
} while (--loop);
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASHC;
|
||||
case 7:
|
||||
HASHC;
|
||||
case 6:
|
||||
HASHC;
|
||||
case 5:
|
||||
HASHC;
|
||||
case 4:
|
||||
HASHC;
|
||||
case 3:
|
||||
HASHC;
|
||||
case 2:
|
||||
HASHC;
|
||||
case 1:
|
||||
HASHC;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
return (n);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.9 1997/09/07 04:37:56 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.10 1997/09/08 02:20:16 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,15 +32,15 @@ static OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey
|
||||
InsertIndexResult
|
||||
_hash_doinsert(Relation rel, HashItem hitem)
|
||||
{
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
BlockNumber blkno;
|
||||
HashMetaPage metap;
|
||||
IndexTuple itup;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
BlockNumber blkno;
|
||||
HashMetaPage metap;
|
||||
IndexTuple itup;
|
||||
InsertIndexResult res;
|
||||
ScanKey itup_scankey;
|
||||
int natts;
|
||||
Page page;
|
||||
ScanKey itup_scankey;
|
||||
int natts;
|
||||
Page page;
|
||||
|
||||
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ);
|
||||
metap = (HashMetaPage) BufferGetPage(metabuf);
|
||||
@@ -101,7 +101,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
|
||||
* we will have dropped both the pin and the write lock on the buffer.
|
||||
*
|
||||
*/
|
||||
static InsertIndexResult
|
||||
static InsertIndexResult
|
||||
_hash_insertonpg(Relation rel,
|
||||
Buffer buf,
|
||||
int keysz,
|
||||
@@ -110,15 +110,15 @@ _hash_insertonpg(Relation rel,
|
||||
Buffer metabuf)
|
||||
{
|
||||
InsertIndexResult res;
|
||||
Page page;
|
||||
BlockNumber itup_blkno;
|
||||
OffsetNumber itup_off;
|
||||
int itemsz;
|
||||
HashPageOpaque pageopaque;
|
||||
bool do_expand = false;
|
||||
Buffer ovflbuf;
|
||||
HashMetaPage metap;
|
||||
Bucket bucket;
|
||||
Page page;
|
||||
BlockNumber itup_blkno;
|
||||
OffsetNumber itup_off;
|
||||
int itemsz;
|
||||
HashPageOpaque pageopaque;
|
||||
bool do_expand = false;
|
||||
Buffer ovflbuf;
|
||||
HashMetaPage metap;
|
||||
Bucket bucket;
|
||||
|
||||
metap = (HashMetaPage) BufferGetPage(metabuf);
|
||||
_hash_checkpage((Page) metap, LH_META_PAGE);
|
||||
@@ -218,7 +218,7 @@ _hash_insertonpg(Relation rel,
|
||||
* write lock and reference associated with the page's buffer. It is
|
||||
* an error to call pgaddtup() without a write lock and reference.
|
||||
*/
|
||||
static OffsetNumber
|
||||
static OffsetNumber
|
||||
_hash_pgaddtup(Relation rel,
|
||||
Buffer buf,
|
||||
int keysz,
|
||||
@@ -226,8 +226,8 @@ _hash_pgaddtup(Relation rel,
|
||||
Size itemsize,
|
||||
HashItem hitem)
|
||||
{
|
||||
OffsetNumber itup_off;
|
||||
Page page;
|
||||
OffsetNumber itup_off;
|
||||
Page page;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
_hash_checkpage(page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.10 1997/09/07 04:37:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.11 1997/09/08 02:20:17 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Overflow pages look like ordinary relation pages.
|
||||
@@ -27,7 +27,7 @@
|
||||
#endif
|
||||
|
||||
static OverflowPageAddress _hash_getovfladdr(Relation rel, Buffer * metabufp);
|
||||
static uint32 _hash_firstfreebit(uint32 map);
|
||||
static uint32 _hash_firstfreebit(uint32 map);
|
||||
|
||||
/*
|
||||
* _hash_addovflpage
|
||||
@@ -44,13 +44,13 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf)
|
||||
{
|
||||
|
||||
OverflowPageAddress oaddr;
|
||||
BlockNumber ovflblkno;
|
||||
Buffer ovflbuf;
|
||||
HashMetaPage metap;
|
||||
HashPageOpaque ovflopaque;
|
||||
HashPageOpaque pageopaque;
|
||||
Page page;
|
||||
Page ovflpage;
|
||||
BlockNumber ovflblkno;
|
||||
Buffer ovflbuf;
|
||||
HashMetaPage metap;
|
||||
HashPageOpaque ovflopaque;
|
||||
HashPageOpaque pageopaque;
|
||||
Page page;
|
||||
Page ovflpage;
|
||||
|
||||
/* this had better be the last page in a bucket chain */
|
||||
page = BufferGetPage(buf);
|
||||
@@ -99,24 +99,24 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf)
|
||||
* is exchanged for a read lock.
|
||||
*
|
||||
*/
|
||||
static OverflowPageAddress
|
||||
static OverflowPageAddress
|
||||
_hash_getovfladdr(Relation rel, Buffer * metabufp)
|
||||
{
|
||||
HashMetaPage metap;
|
||||
Buffer mapbuf = 0;
|
||||
BlockNumber blkno;
|
||||
PageOffset offset;
|
||||
HashMetaPage metap;
|
||||
Buffer mapbuf = 0;
|
||||
BlockNumber blkno;
|
||||
PageOffset offset;
|
||||
OverflowPageAddress oaddr;
|
||||
SplitNumber splitnum;
|
||||
uint32 *freep = NULL;
|
||||
uint32 max_free;
|
||||
uint32 bit;
|
||||
uint32 first_page;
|
||||
uint32 free_bit;
|
||||
uint32 free_page;
|
||||
uint32 in_use_bits;
|
||||
uint32 i,
|
||||
j;
|
||||
SplitNumber splitnum;
|
||||
uint32 *freep = NULL;
|
||||
uint32 max_free;
|
||||
uint32 bit;
|
||||
uint32 first_page;
|
||||
uint32 free_bit;
|
||||
uint32 free_page;
|
||||
uint32 in_use_bits;
|
||||
uint32 i,
|
||||
j;
|
||||
|
||||
metap = (HashMetaPage) _hash_chgbufaccess(rel, metabufp, HASH_READ, HASH_WRITE);
|
||||
|
||||
@@ -130,7 +130,7 @@ _hash_getovfladdr(Relation rel, Buffer * metabufp)
|
||||
first_page = metap->LAST_FREED >> (metap->BSHIFT + BYTE_TO_BIT);
|
||||
for (i = first_page; i <= free_page; i++)
|
||||
{
|
||||
Page mappage;
|
||||
Page mappage;
|
||||
|
||||
blkno = metap->hashm_mapp[i];
|
||||
mapbuf = _hash_getbuf(rel, blkno, HASH_WRITE);
|
||||
@@ -279,11 +279,11 @@ found:
|
||||
* splitnumber.
|
||||
*
|
||||
*/
|
||||
static uint32
|
||||
static uint32
|
||||
_hash_firstfreebit(uint32 map)
|
||||
{
|
||||
uint32 i,
|
||||
mask;
|
||||
uint32 i,
|
||||
mask;
|
||||
|
||||
mask = 0x1;
|
||||
for (i = 0; i < BITS_PER_MAP; i++)
|
||||
@@ -306,22 +306,22 @@ _hash_firstfreebit(uint32 map)
|
||||
Buffer
|
||||
_hash_freeovflpage(Relation rel, Buffer ovflbuf)
|
||||
{
|
||||
HashMetaPage metap;
|
||||
Buffer metabuf;
|
||||
Buffer mapbuf;
|
||||
BlockNumber prevblkno;
|
||||
BlockNumber blkno;
|
||||
BlockNumber nextblkno;
|
||||
HashPageOpaque ovflopaque;
|
||||
Page ovflpage;
|
||||
Page mappage;
|
||||
HashMetaPage metap;
|
||||
Buffer metabuf;
|
||||
Buffer mapbuf;
|
||||
BlockNumber prevblkno;
|
||||
BlockNumber blkno;
|
||||
BlockNumber nextblkno;
|
||||
HashPageOpaque ovflopaque;
|
||||
Page ovflpage;
|
||||
Page mappage;
|
||||
OverflowPageAddress addr;
|
||||
SplitNumber splitnum;
|
||||
uint32 *freep;
|
||||
uint32 ovflpgno;
|
||||
int32 bitmappage,
|
||||
bitmapbit;
|
||||
Bucket bucket;
|
||||
SplitNumber splitnum;
|
||||
uint32 *freep;
|
||||
uint32 ovflpgno;
|
||||
int32 bitmappage,
|
||||
bitmapbit;
|
||||
Bucket bucket;
|
||||
|
||||
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE);
|
||||
metap = (HashMetaPage) BufferGetPage(metabuf);
|
||||
@@ -348,9 +348,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf)
|
||||
*/
|
||||
if (BlockNumberIsValid(prevblkno))
|
||||
{
|
||||
Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE);
|
||||
Page prevpage = BufferGetPage(prevbuf);
|
||||
HashPageOpaque prevopaque =
|
||||
Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE);
|
||||
Page prevpage = BufferGetPage(prevbuf);
|
||||
HashPageOpaque prevopaque =
|
||||
(HashPageOpaque) PageGetSpecialPointer(prevpage);
|
||||
|
||||
_hash_checkpage(prevpage, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
||||
@@ -360,9 +360,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf)
|
||||
}
|
||||
if (BlockNumberIsValid(nextblkno))
|
||||
{
|
||||
Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE);
|
||||
Page nextpage = BufferGetPage(nextbuf);
|
||||
HashPageOpaque nextopaque =
|
||||
Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE);
|
||||
Page nextpage = BufferGetPage(nextbuf);
|
||||
HashPageOpaque nextopaque =
|
||||
(HashPageOpaque) PageGetSpecialPointer(nextpage);
|
||||
|
||||
_hash_checkpage(nextpage, LH_OVERFLOW_PAGE);
|
||||
@@ -436,13 +436,13 @@ _hash_initbitmap(Relation rel,
|
||||
int32 nbits,
|
||||
int32 ndx)
|
||||
{
|
||||
Buffer buf;
|
||||
BlockNumber blkno;
|
||||
Page pg;
|
||||
HashPageOpaque op;
|
||||
uint32 *freep;
|
||||
int clearbytes,
|
||||
clearints;
|
||||
Buffer buf;
|
||||
BlockNumber blkno;
|
||||
Page pg;
|
||||
HashPageOpaque op;
|
||||
uint32 *freep;
|
||||
int clearbytes,
|
||||
clearints;
|
||||
|
||||
blkno = OADDR_TO_BLKNO(pnum);
|
||||
buf = _hash_getbuf(rel, blkno, HASH_WRITE);
|
||||
@@ -496,18 +496,18 @@ _hash_squeezebucket(Relation rel,
|
||||
HashMetaPage metap,
|
||||
Bucket bucket)
|
||||
{
|
||||
Buffer wbuf;
|
||||
Buffer rbuf = 0;
|
||||
BlockNumber wblkno;
|
||||
BlockNumber rblkno;
|
||||
Page wpage;
|
||||
Page rpage;
|
||||
HashPageOpaque wopaque;
|
||||
HashPageOpaque ropaque;
|
||||
OffsetNumber woffnum;
|
||||
OffsetNumber roffnum;
|
||||
HashItem hitem;
|
||||
int itemsz;
|
||||
Buffer wbuf;
|
||||
Buffer rbuf = 0;
|
||||
BlockNumber wblkno;
|
||||
BlockNumber rblkno;
|
||||
Page wpage;
|
||||
Page rpage;
|
||||
HashPageOpaque wopaque;
|
||||
HashPageOpaque ropaque;
|
||||
OffsetNumber woffnum;
|
||||
OffsetNumber roffnum;
|
||||
HashItem hitem;
|
||||
int itemsz;
|
||||
|
||||
/* elog(DEBUG, "_hash_squeezebucket: squeezing bucket %d", bucket); */
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.10 1997/09/07 04:38:00 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.11 1997/09/08 02:20:18 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Postgres hash pages look like ordinary relation pages. The opaque
|
||||
@@ -38,9 +38,9 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket);
|
||||
static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket);
|
||||
|
||||
/*
|
||||
* We use high-concurrency locking on hash indices. There are two cases in
|
||||
@@ -68,16 +68,16 @@ static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucke
|
||||
void
|
||||
_hash_metapinit(Relation rel)
|
||||
{
|
||||
HashMetaPage metap;
|
||||
HashPageOpaque pageopaque;
|
||||
Buffer metabuf;
|
||||
Buffer buf;
|
||||
Page pg;
|
||||
int nbuckets;
|
||||
uint32 nelem; /* number elements */
|
||||
uint32 lg2nelem; /* _hash_log2(nelem) */
|
||||
uint32 nblocks;
|
||||
uint16 i;
|
||||
HashMetaPage metap;
|
||||
HashPageOpaque pageopaque;
|
||||
Buffer metabuf;
|
||||
Buffer buf;
|
||||
Page pg;
|
||||
int nbuckets;
|
||||
uint32 nelem; /* number elements */
|
||||
uint32 lg2nelem; /* _hash_log2(nelem) */
|
||||
uint32 nblocks;
|
||||
uint16 i;
|
||||
|
||||
/* can't be sharing this with anyone, now... */
|
||||
if (USELOCKING)
|
||||
@@ -188,7 +188,7 @@ _hash_metapinit(Relation rel)
|
||||
Buffer
|
||||
_hash_getbuf(Relation rel, BlockNumber blkno, int access)
|
||||
{
|
||||
Buffer buf;
|
||||
Buffer buf;
|
||||
|
||||
if (blkno == P_NEW)
|
||||
{
|
||||
@@ -196,14 +196,14 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
|
||||
}
|
||||
switch (access)
|
||||
{
|
||||
case HASH_WRITE:
|
||||
case HASH_READ:
|
||||
_hash_setpagelock(rel, blkno, access);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s",
|
||||
access, RelationGetRelationName(rel));
|
||||
break;
|
||||
case HASH_WRITE:
|
||||
case HASH_READ:
|
||||
_hash_setpagelock(rel, blkno, access);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s",
|
||||
access, RelationGetRelationName(rel));
|
||||
break;
|
||||
}
|
||||
buf = ReadBuffer(rel, blkno);
|
||||
|
||||
@@ -217,19 +217,19 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access)
|
||||
void
|
||||
_hash_relbuf(Relation rel, Buffer buf, int access)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(buf);
|
||||
|
||||
switch (access)
|
||||
{
|
||||
case HASH_WRITE:
|
||||
case HASH_READ:
|
||||
_hash_unsetpagelock(rel, blkno, access);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s",
|
||||
access, blkno, RelationGetRelationName(rel));
|
||||
case HASH_WRITE:
|
||||
case HASH_READ:
|
||||
_hash_unsetpagelock(rel, blkno, access);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s",
|
||||
access, blkno, RelationGetRelationName(rel));
|
||||
}
|
||||
|
||||
ReleaseBuffer(buf);
|
||||
@@ -245,7 +245,7 @@ _hash_relbuf(Relation rel, Buffer buf, int access)
|
||||
void
|
||||
_hash_wrtbuf(Relation rel, Buffer buf)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(buf);
|
||||
WriteBuffer(buf);
|
||||
@@ -262,7 +262,7 @@ _hash_wrtbuf(Relation rel, Buffer buf)
|
||||
void
|
||||
_hash_wrtnorelbuf(Relation rel, Buffer buf)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(buf);
|
||||
WriteNoReleaseBuffer(buf);
|
||||
@@ -274,22 +274,22 @@ _hash_chgbufaccess(Relation rel,
|
||||
int from_access,
|
||||
int to_access)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(*bufp);
|
||||
|
||||
switch (from_access)
|
||||
{
|
||||
case HASH_WRITE:
|
||||
_hash_wrtbuf(rel, *bufp);
|
||||
break;
|
||||
case HASH_READ:
|
||||
_hash_relbuf(rel, *bufp, from_access);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s",
|
||||
from_access, blkno, RelationGetRelationName(rel));
|
||||
break;
|
||||
case HASH_WRITE:
|
||||
_hash_wrtbuf(rel, *bufp);
|
||||
break;
|
||||
case HASH_READ:
|
||||
_hash_relbuf(rel, *bufp, from_access);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s",
|
||||
from_access, blkno, RelationGetRelationName(rel));
|
||||
break;
|
||||
}
|
||||
*bufp = _hash_getbuf(rel, blkno, to_access);
|
||||
return (BufferGetPage(*bufp));
|
||||
@@ -328,16 +328,16 @@ _hash_setpagelock(Relation rel,
|
||||
|
||||
switch (access)
|
||||
{
|
||||
case HASH_WRITE:
|
||||
RelationSetSingleWLockPage(rel, &iptr);
|
||||
break;
|
||||
case HASH_READ:
|
||||
RelationSetSingleRLockPage(rel, &iptr);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s",
|
||||
access, blkno, RelationGetRelationName(rel));
|
||||
break;
|
||||
case HASH_WRITE:
|
||||
RelationSetSingleWLockPage(rel, &iptr);
|
||||
break;
|
||||
case HASH_READ:
|
||||
RelationSetSingleRLockPage(rel, &iptr);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s",
|
||||
access, blkno, RelationGetRelationName(rel));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,16 +355,16 @@ _hash_unsetpagelock(Relation rel,
|
||||
|
||||
switch (access)
|
||||
{
|
||||
case HASH_WRITE:
|
||||
RelationUnsetSingleWLockPage(rel, &iptr);
|
||||
break;
|
||||
case HASH_READ:
|
||||
RelationUnsetSingleRLockPage(rel, &iptr);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s",
|
||||
access, blkno, RelationGetRelationName(rel));
|
||||
break;
|
||||
case HASH_WRITE:
|
||||
RelationUnsetSingleWLockPage(rel, &iptr);
|
||||
break;
|
||||
case HASH_READ:
|
||||
RelationUnsetSingleRLockPage(rel, &iptr);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s",
|
||||
access, blkno, RelationGetRelationName(rel));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,13 +372,13 @@ _hash_unsetpagelock(Relation rel,
|
||||
void
|
||||
_hash_pagedel(Relation rel, ItemPointer tid)
|
||||
{
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
Page page;
|
||||
BlockNumber blkno;
|
||||
OffsetNumber offno;
|
||||
HashMetaPage metap;
|
||||
HashPageOpaque opaque;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
Page page;
|
||||
BlockNumber blkno;
|
||||
OffsetNumber offno;
|
||||
HashMetaPage metap;
|
||||
HashPageOpaque opaque;
|
||||
|
||||
blkno = ItemPointerGetBlockNumber(tid);
|
||||
offno = ItemPointerGetOffsetNumber(tid);
|
||||
@@ -414,10 +414,10 @@ _hash_pagedel(Relation rel, ItemPointer tid)
|
||||
void
|
||||
_hash_expandtable(Relation rel, Buffer metabuf)
|
||||
{
|
||||
HashMetaPage metap;
|
||||
Bucket old_bucket;
|
||||
Bucket new_bucket;
|
||||
uint32 spare_ndx;
|
||||
HashMetaPage metap;
|
||||
Bucket old_bucket;
|
||||
Bucket new_bucket;
|
||||
uint32 spare_ndx;
|
||||
|
||||
/* elog(DEBUG, "_hash_expandtable: expanding..."); */
|
||||
|
||||
@@ -472,26 +472,26 @@ _hash_splitpage(Relation rel,
|
||||
Bucket obucket,
|
||||
Bucket nbucket)
|
||||
{
|
||||
Bucket bucket;
|
||||
Buffer obuf;
|
||||
Buffer nbuf;
|
||||
Buffer ovflbuf;
|
||||
BlockNumber oblkno;
|
||||
BlockNumber nblkno;
|
||||
bool null;
|
||||
Datum datum;
|
||||
HashItem hitem;
|
||||
HashPageOpaque oopaque;
|
||||
HashPageOpaque nopaque;
|
||||
HashMetaPage metap;
|
||||
IndexTuple itup;
|
||||
int itemsz;
|
||||
OffsetNumber ooffnum;
|
||||
OffsetNumber noffnum;
|
||||
OffsetNumber omaxoffnum;
|
||||
Page opage;
|
||||
Page npage;
|
||||
TupleDesc itupdesc;
|
||||
Bucket bucket;
|
||||
Buffer obuf;
|
||||
Buffer nbuf;
|
||||
Buffer ovflbuf;
|
||||
BlockNumber oblkno;
|
||||
BlockNumber nblkno;
|
||||
bool null;
|
||||
Datum datum;
|
||||
HashItem hitem;
|
||||
HashPageOpaque oopaque;
|
||||
HashPageOpaque nopaque;
|
||||
HashMetaPage metap;
|
||||
IndexTuple itup;
|
||||
int itemsz;
|
||||
OffsetNumber ooffnum;
|
||||
OffsetNumber noffnum;
|
||||
OffsetNumber omaxoffnum;
|
||||
Page opage;
|
||||
Page npage;
|
||||
TupleDesc itupdesc;
|
||||
|
||||
/* elog(DEBUG, "_hash_splitpage: splitting %d into %d,%d",
|
||||
obucket, obucket, nbucket);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.9 1997/09/07 04:38:01 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.10 1997/09/08 02:20:20 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Because we can be doing an index scan on a relation while we
|
||||
@@ -31,14 +31,14 @@
|
||||
|
||||
#include <access/hash.h>
|
||||
|
||||
static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||
static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||
static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||
static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||
|
||||
typedef struct HashScanListData
|
||||
{
|
||||
IndexScanDesc hashsl_scan;
|
||||
IndexScanDesc hashsl_scan;
|
||||
struct HashScanListData *hashsl_next;
|
||||
} HashScanListData;
|
||||
} HashScanListData;
|
||||
|
||||
typedef HashScanListData *HashScanList;
|
||||
|
||||
@@ -50,7 +50,7 @@ static HashScanList HashScans = (HashScanList) NULL;
|
||||
void
|
||||
_hash_regscan(IndexScanDesc scan)
|
||||
{
|
||||
HashScanList new_el;
|
||||
HashScanList new_el;
|
||||
|
||||
new_el = (HashScanList) palloc(sizeof(HashScanListData));
|
||||
new_el->hashsl_scan = scan;
|
||||
@@ -64,8 +64,8 @@ _hash_regscan(IndexScanDesc scan)
|
||||
void
|
||||
_hash_dropscan(IndexScanDesc scan)
|
||||
{
|
||||
HashScanList chk,
|
||||
last;
|
||||
HashScanList chk,
|
||||
last;
|
||||
|
||||
last = (HashScanList) NULL;
|
||||
for (chk = HashScans;
|
||||
@@ -89,8 +89,8 @@ _hash_dropscan(IndexScanDesc scan)
|
||||
void
|
||||
_hash_adjscans(Relation rel, ItemPointer tid)
|
||||
{
|
||||
HashScanList l;
|
||||
Oid relid;
|
||||
HashScanList l;
|
||||
Oid relid;
|
||||
|
||||
relid = rel->rd_id;
|
||||
for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next)
|
||||
@@ -104,10 +104,10 @@ _hash_adjscans(Relation rel, ItemPointer tid)
|
||||
static void
|
||||
_hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
|
||||
{
|
||||
ItemPointer current;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
HashScanOpaque so;
|
||||
ItemPointer current;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
HashScanOpaque so;
|
||||
|
||||
if (!_hash_scantouched(scan, blkno, offno))
|
||||
return;
|
||||
@@ -144,12 +144,12 @@ _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno)
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
static bool
|
||||
_hash_scantouched(IndexScanDesc scan,
|
||||
BlockNumber blkno,
|
||||
OffsetNumber offno)
|
||||
{
|
||||
ItemPointer current;
|
||||
ItemPointer current;
|
||||
|
||||
current = &(scan->currentItemData);
|
||||
if (ItemPointerIsValid(current)
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.11 1997/09/07 04:38:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.12 1997/09/08 02:20:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -34,9 +34,9 @@ _hash_search(Relation rel,
|
||||
Buffer * bufP,
|
||||
HashMetaPage metap)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
Datum keyDatum;
|
||||
Bucket bucket;
|
||||
BlockNumber blkno;
|
||||
Datum keyDatum;
|
||||
Bucket bucket;
|
||||
|
||||
if (scankey == (ScanKey) NULL ||
|
||||
(keyDatum = scankey[0].sk_argument) == (Datum) NULL)
|
||||
@@ -70,16 +70,16 @@ _hash_search(Relation rel,
|
||||
RetrieveIndexResult
|
||||
_hash_next(IndexScanDesc scan, ScanDirection dir)
|
||||
{
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
Page page;
|
||||
OffsetNumber offnum;
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
Page page;
|
||||
OffsetNumber offnum;
|
||||
RetrieveIndexResult res;
|
||||
ItemPointer current;
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
HashScanOpaque so;
|
||||
ItemPointer current;
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
HashScanOpaque so;
|
||||
|
||||
rel = scan->relation;
|
||||
so = (HashScanOpaque) scan->opaque;
|
||||
@@ -129,7 +129,7 @@ static void
|
||||
_hash_readnext(Relation rel,
|
||||
Buffer * bufp, Page * pagep, HashPageOpaque * opaquep)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = (*opaquep)->hasho_nextblkno;
|
||||
_hash_relbuf(rel, *bufp, HASH_READ);
|
||||
@@ -148,7 +148,7 @@ static void
|
||||
_hash_readprev(Relation rel,
|
||||
Buffer * bufp, Page * pagep, HashPageOpaque * opaquep)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = (*opaquep)->hasho_prevblkno;
|
||||
_hash_relbuf(rel, *bufp, HASH_READ);
|
||||
@@ -180,18 +180,18 @@ _hash_readprev(Relation rel,
|
||||
RetrieveIndexResult
|
||||
_hash_first(IndexScanDesc scan, ScanDirection dir)
|
||||
{
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
Page page;
|
||||
HashPageOpaque opaque;
|
||||
HashMetaPage metap;
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
ItemPointer current;
|
||||
OffsetNumber offnum;
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Buffer metabuf;
|
||||
Page page;
|
||||
HashPageOpaque opaque;
|
||||
HashMetaPage metap;
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
ItemPointer current;
|
||||
OffsetNumber offnum;
|
||||
RetrieveIndexResult res;
|
||||
HashScanOpaque so;
|
||||
HashScanOpaque so;
|
||||
|
||||
rel = scan->relation;
|
||||
so = (HashScanOpaque) scan->opaque;
|
||||
@@ -286,20 +286,20 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
|
||||
bool
|
||||
_hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf)
|
||||
{
|
||||
Relation rel;
|
||||
ItemPointer current;
|
||||
HashScanOpaque so;
|
||||
int allbuckets;
|
||||
HashMetaPage metap;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
HashPageOpaque opaque;
|
||||
OffsetNumber maxoff;
|
||||
OffsetNumber offnum;
|
||||
Bucket bucket;
|
||||
BlockNumber blkno;
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
Relation rel;
|
||||
ItemPointer current;
|
||||
HashScanOpaque so;
|
||||
int allbuckets;
|
||||
HashMetaPage metap;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
HashPageOpaque opaque;
|
||||
OffsetNumber maxoff;
|
||||
OffsetNumber offnum;
|
||||
Bucket bucket;
|
||||
BlockNumber blkno;
|
||||
HashItem hitem;
|
||||
IndexTuple itup;
|
||||
|
||||
rel = scan->relation;
|
||||
current = &(scan->currentItemData);
|
||||
@@ -341,107 +341,107 @@ _hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf)
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case ForwardScanDirection:
|
||||
if (offnum != InvalidOffsetNumber)
|
||||
{
|
||||
offnum = OffsetNumberNext(offnum); /* move forward */
|
||||
}
|
||||
else
|
||||
{
|
||||
offnum = FirstOffsetNumber; /* new page */
|
||||
}
|
||||
while (offnum > maxoff)
|
||||
{
|
||||
case ForwardScanDirection:
|
||||
if (offnum != InvalidOffsetNumber)
|
||||
{
|
||||
offnum = OffsetNumberNext(offnum); /* move forward */
|
||||
}
|
||||
else
|
||||
{
|
||||
offnum = FirstOffsetNumber; /* new page */
|
||||
}
|
||||
while (offnum > maxoff)
|
||||
{
|
||||
|
||||
/*
|
||||
* either this page is empty (maxoff ==
|
||||
* InvalidOffsetNumber) or we ran off the end.
|
||||
*/
|
||||
_hash_readnext(rel, &buf, &page, &opaque);
|
||||
if (BufferIsInvalid(buf))
|
||||
{ /* end of chain */
|
||||
if (allbuckets && bucket < metap->hashm_maxbucket)
|
||||
{
|
||||
++bucket;
|
||||
blkno = BUCKET_TO_BLKNO(bucket);
|
||||
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
||||
page = BufferGetPage(buf);
|
||||
_hash_checkpage(page, LH_BUCKET_PAGE);
|
||||
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
||||
Assert(opaque->hasho_bucket == bucket);
|
||||
while (PageIsEmpty(page) &&
|
||||
BlockNumberIsValid(opaque->hasho_nextblkno))
|
||||
/*
|
||||
* either this page is empty (maxoff ==
|
||||
* InvalidOffsetNumber) or we ran off the end.
|
||||
*/
|
||||
_hash_readnext(rel, &buf, &page, &opaque);
|
||||
if (BufferIsInvalid(buf))
|
||||
{ /* end of chain */
|
||||
if (allbuckets && bucket < metap->hashm_maxbucket)
|
||||
{
|
||||
_hash_readnext(rel, &buf, &page, &opaque);
|
||||
++bucket;
|
||||
blkno = BUCKET_TO_BLKNO(bucket);
|
||||
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
||||
page = BufferGetPage(buf);
|
||||
_hash_checkpage(page, LH_BUCKET_PAGE);
|
||||
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
||||
Assert(opaque->hasho_bucket == bucket);
|
||||
while (PageIsEmpty(page) &&
|
||||
BlockNumberIsValid(opaque->hasho_nextblkno))
|
||||
{
|
||||
_hash_readnext(rel, &buf, &page, &opaque);
|
||||
}
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
offnum = FirstOffsetNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxoff = offnum = InvalidOffsetNumber;
|
||||
break; /* while */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* _hash_readnext never returns an empty page */
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
offnum = FirstOffsetNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxoff = offnum = InvalidOffsetNumber;
|
||||
break; /* while */
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BackwardScanDirection:
|
||||
if (offnum != InvalidOffsetNumber)
|
||||
{
|
||||
offnum = OffsetNumberPrev(offnum); /* move back */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* _hash_readnext never returns an empty page */
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
offnum = FirstOffsetNumber;
|
||||
offnum = maxoff; /* new page */
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BackwardScanDirection:
|
||||
if (offnum != InvalidOffsetNumber)
|
||||
{
|
||||
offnum = OffsetNumberPrev(offnum); /* move back */
|
||||
}
|
||||
else
|
||||
{
|
||||
offnum = maxoff;/* new page */
|
||||
}
|
||||
while (offnum < FirstOffsetNumber)
|
||||
{
|
||||
while (offnum < FirstOffsetNumber)
|
||||
{
|
||||
|
||||
/*
|
||||
* either this page is empty (offnum ==
|
||||
* InvalidOffsetNumber) or we ran off the end.
|
||||
*/
|
||||
_hash_readprev(rel, &buf, &page, &opaque);
|
||||
if (BufferIsInvalid(buf))
|
||||
{ /* end of chain */
|
||||
if (allbuckets && bucket > 0)
|
||||
{
|
||||
--bucket;
|
||||
blkno = BUCKET_TO_BLKNO(bucket);
|
||||
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
||||
page = BufferGetPage(buf);
|
||||
_hash_checkpage(page, LH_BUCKET_PAGE);
|
||||
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
||||
Assert(opaque->hasho_bucket == bucket);
|
||||
while (BlockNumberIsValid(opaque->hasho_nextblkno))
|
||||
/*
|
||||
* either this page is empty (offnum ==
|
||||
* InvalidOffsetNumber) or we ran off the end.
|
||||
*/
|
||||
_hash_readprev(rel, &buf, &page, &opaque);
|
||||
if (BufferIsInvalid(buf))
|
||||
{ /* end of chain */
|
||||
if (allbuckets && bucket > 0)
|
||||
{
|
||||
_hash_readnext(rel, &buf, &page, &opaque);
|
||||
--bucket;
|
||||
blkno = BUCKET_TO_BLKNO(bucket);
|
||||
buf = _hash_getbuf(rel, blkno, HASH_READ);
|
||||
page = BufferGetPage(buf);
|
||||
_hash_checkpage(page, LH_BUCKET_PAGE);
|
||||
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
||||
Assert(opaque->hasho_bucket == bucket);
|
||||
while (BlockNumberIsValid(opaque->hasho_nextblkno))
|
||||
{
|
||||
_hash_readnext(rel, &buf, &page, &opaque);
|
||||
}
|
||||
maxoff = offnum = PageGetMaxOffsetNumber(page);
|
||||
}
|
||||
else
|
||||
{
|
||||
maxoff = offnum = InvalidOffsetNumber;
|
||||
break; /* while */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* _hash_readprev never returns an empty page */
|
||||
maxoff = offnum = PageGetMaxOffsetNumber(page);
|
||||
}
|
||||
else
|
||||
{
|
||||
maxoff = offnum = InvalidOffsetNumber;
|
||||
break; /* while */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* _hash_readprev never returns an empty page */
|
||||
maxoff = offnum = PageGetMaxOffsetNumber(page);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* NoMovementScanDirection */
|
||||
/* this should not be reached */
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
/* NoMovementScanDirection */
|
||||
/* this should not be reached */
|
||||
break;
|
||||
}
|
||||
|
||||
/* we ran off the end of the world without finding a match */
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.10 1997/09/07 04:38:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.11 1997/09/08 02:20:21 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,12 +52,12 @@ static StrategyEvaluationData HTEvaluationData = {
|
||||
*/
|
||||
|
||||
#ifdef NOT_USED
|
||||
static StrategyNumber
|
||||
static StrategyNumber
|
||||
_hash_getstrat(Relation rel,
|
||||
AttrNumber attno,
|
||||
RegProcedure proc)
|
||||
{
|
||||
StrategyNumber strat;
|
||||
StrategyNumber strat;
|
||||
|
||||
strat = RelationGetStrategy(rel, attno, &HTEvaluationData, proc);
|
||||
|
||||
@@ -69,7 +69,7 @@ _hash_getstrat(Relation rel,
|
||||
#endif
|
||||
|
||||
#ifdef NOT_USED
|
||||
static bool
|
||||
static bool
|
||||
_hash_invokestrat(Relation rel,
|
||||
AttrNumber attno,
|
||||
StrategyNumber strat,
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.10 1997/09/07 04:38:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.11 1997/09/08 02:20:25 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -28,13 +28,13 @@
|
||||
ScanKey
|
||||
_hash_mkscankey(Relation rel, IndexTuple itup, HashMetaPage metap)
|
||||
{
|
||||
ScanKey skey;
|
||||
TupleDesc itupdesc;
|
||||
int natts;
|
||||
AttrNumber i;
|
||||
Datum arg;
|
||||
RegProcedure proc;
|
||||
bool null;
|
||||
ScanKey skey;
|
||||
TupleDesc itupdesc;
|
||||
int natts;
|
||||
AttrNumber i;
|
||||
Datum arg;
|
||||
RegProcedure proc;
|
||||
bool null;
|
||||
|
||||
natts = rel->rd_rel->relnatts;
|
||||
itupdesc = RelationGetTupleDescriptor(rel);
|
||||
@@ -73,9 +73,9 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
|
||||
HashItem
|
||||
_hash_formitem(IndexTuple itup)
|
||||
{
|
||||
int nbytes_hitem;
|
||||
HashItem hitem;
|
||||
Size tuplen;
|
||||
int nbytes_hitem;
|
||||
HashItem hitem;
|
||||
Size tuplen;
|
||||
|
||||
/* disallow nulls in hash keys */
|
||||
if (itup->t_info & INDEX_NULL_MASK)
|
||||
@@ -95,9 +95,9 @@ _hash_formitem(IndexTuple itup)
|
||||
Bucket
|
||||
_hash_call(Relation rel, HashMetaPage metap, Datum key)
|
||||
{
|
||||
uint32 n;
|
||||
Bucket bucket;
|
||||
RegProcedure proc;
|
||||
uint32 n;
|
||||
Bucket bucket;
|
||||
RegProcedure proc;
|
||||
|
||||
proc = metap->hashm_procid;
|
||||
n = (uint32) fmgr(proc, key);
|
||||
@@ -113,8 +113,8 @@ _hash_call(Relation rel, HashMetaPage metap, Datum key)
|
||||
uint32
|
||||
_hash_log2(uint32 num)
|
||||
{
|
||||
uint32 i,
|
||||
limit;
|
||||
uint32 i,
|
||||
limit;
|
||||
|
||||
limit = 1;
|
||||
for (i = 0; limit < num; limit = limit << 1, i++)
|
||||
@@ -128,7 +128,7 @@ _hash_log2(uint32 num)
|
||||
void
|
||||
_hash_checkpage(Page page, int flags)
|
||||
{
|
||||
HashPageOpaque opaque;
|
||||
HashPageOpaque opaque;
|
||||
|
||||
Assert(page);
|
||||
Assert(((PageHeader) (page))->pd_lower >= (sizeof(PageHeaderData) - sizeof(ItemIdData)));
|
||||
|
Reference in New Issue
Block a user