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/nbtree/nbtcompare.c,v 1.11 1997/09/07 04:38:39 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.12 1997/09/08 02:20:44 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These functions are stored in pg_amproc. For each operator class
|
||||
@@ -134,13 +134,13 @@ btnamecmp(NameData * a, NameData * b)
|
||||
int32
|
||||
bttextcmp(struct varlena * a, struct varlena * b)
|
||||
{
|
||||
int res;
|
||||
unsigned char *ap,
|
||||
*bp;
|
||||
int res;
|
||||
unsigned char *ap,
|
||||
*bp;
|
||||
|
||||
#ifdef USE_LOCALE
|
||||
int la = VARSIZE(a) - VARHDRSZ;
|
||||
int lb = VARSIZE(b) - VARHDRSZ;
|
||||
int la = VARSIZE(a) - VARHDRSZ;
|
||||
int lb = VARSIZE(b) - VARHDRSZ;
|
||||
|
||||
ap = (unsigned char *) palloc(la + 1);
|
||||
bp = (unsigned char *) palloc(lb + 1);
|
||||
@@ -156,7 +156,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
|
||||
pfree(bp);
|
||||
|
||||
#else
|
||||
int len = VARSIZE(a);
|
||||
int len = VARSIZE(a);
|
||||
|
||||
/* len is the length of the shorter of the two strings */
|
||||
if (len > VARSIZE(b))
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.18 1997/09/07 04:38:45 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.19 1997/09/08 02:20:46 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -28,13 +28,13 @@
|
||||
#endif
|
||||
|
||||
static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem);
|
||||
static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright);
|
||||
static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright);
|
||||
static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start, OffsetNumber maxoff, Size llimit);
|
||||
static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf);
|
||||
static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf);
|
||||
static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem);
|
||||
static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem);
|
||||
static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem);
|
||||
static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey);
|
||||
static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem);
|
||||
static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem);
|
||||
static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey);
|
||||
|
||||
/*
|
||||
* _bt_doinsert() -- Handle insertion of a single btitem in the tree.
|
||||
@@ -46,12 +46,12 @@ static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int
|
||||
InsertIndexResult
|
||||
_bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel)
|
||||
{
|
||||
ScanKey itup_scankey;
|
||||
IndexTuple itup;
|
||||
BTStack stack;
|
||||
Buffer buf;
|
||||
BlockNumber blkno;
|
||||
int natts = rel->rd_rel->relnatts;
|
||||
ScanKey itup_scankey;
|
||||
IndexTuple itup;
|
||||
BTStack stack;
|
||||
Buffer buf;
|
||||
BlockNumber blkno;
|
||||
int natts = rel->rd_rel->relnatts;
|
||||
InsertIndexResult res;
|
||||
|
||||
itup = &(btitem->bti_itup);
|
||||
@@ -82,9 +82,9 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
|
||||
/* already in the node */
|
||||
if (index_is_unique)
|
||||
{
|
||||
OffsetNumber offset,
|
||||
maxoff;
|
||||
Page page;
|
||||
OffsetNumber offset,
|
||||
maxoff;
|
||||
Page page;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
@@ -95,13 +95,13 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
|
||||
/* key on the page before trying to compare it */
|
||||
if (!PageIsEmpty(page) && offset <= maxoff)
|
||||
{
|
||||
TupleDesc itupdesc;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
HeapTuple htup;
|
||||
BTPageOpaque opaque;
|
||||
Buffer nbuf;
|
||||
BlockNumber blkno;
|
||||
TupleDesc itupdesc;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
HeapTuple htup;
|
||||
BTPageOpaque opaque;
|
||||
Buffer nbuf;
|
||||
BlockNumber blkno;
|
||||
|
||||
itupdesc = RelationGetTupleDescriptor(rel);
|
||||
nbuf = InvalidBuffer;
|
||||
@@ -213,7 +213,7 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
|
||||
* 'afteritem' parameter to position ourselves correctly for the
|
||||
* insertion on internal pages.
|
||||
*/
|
||||
static InsertIndexResult
|
||||
static InsertIndexResult
|
||||
_bt_insertonpg(Relation rel,
|
||||
Buffer buf,
|
||||
BTStack stack,
|
||||
@@ -223,14 +223,14 @@ _bt_insertonpg(Relation rel,
|
||||
BTItem afteritem)
|
||||
{
|
||||
InsertIndexResult res;
|
||||
Page page;
|
||||
BTPageOpaque lpageop;
|
||||
BlockNumber itup_blkno;
|
||||
OffsetNumber itup_off;
|
||||
OffsetNumber firstright = InvalidOffsetNumber;
|
||||
int itemsz;
|
||||
bool do_split = false;
|
||||
bool keys_equal = false;
|
||||
Page page;
|
||||
BTPageOpaque lpageop;
|
||||
BlockNumber itup_blkno;
|
||||
OffsetNumber itup_off;
|
||||
OffsetNumber firstright = InvalidOffsetNumber;
|
||||
int itemsz;
|
||||
bool do_split = false;
|
||||
bool keys_equal = false;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
lpageop = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||
@@ -251,9 +251,9 @@ _bt_insertonpg(Relation rel,
|
||||
*/
|
||||
if (lpageop->btpo_flags & BTP_CHAIN)
|
||||
{
|
||||
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
||||
ItemId hitemid;
|
||||
BTItem hitem;
|
||||
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
||||
ItemId hitemid;
|
||||
BTItem hitem;
|
||||
|
||||
Assert(!P_RIGHTMOST(lpageop));
|
||||
hitemid = PageGetItemId(page, P_HIKEY);
|
||||
@@ -280,8 +280,8 @@ _bt_insertonpg(Relation rel,
|
||||
else
|
||||
/* "eat" page */
|
||||
{
|
||||
Buffer pbuf;
|
||||
Page ppage;
|
||||
Buffer pbuf;
|
||||
Page ppage;
|
||||
|
||||
itup_blkno = BufferGetBlockNumber(buf);
|
||||
itup_off = PageAddItem(page, (Item) btitem, itemsz,
|
||||
@@ -315,13 +315,13 @@ _bt_insertonpg(Relation rel,
|
||||
do_split = true;
|
||||
else if (PageGetFreeSpace(page) < 3 * itemsz + 2 * sizeof(ItemIdData))
|
||||
{
|
||||
OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
||||
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
||||
ItemId itid;
|
||||
BTItem previtem,
|
||||
chkitem;
|
||||
Size maxsize;
|
||||
Size currsize;
|
||||
OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
||||
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
|
||||
ItemId itid;
|
||||
BTItem previtem,
|
||||
chkitem;
|
||||
Size maxsize;
|
||||
Size currsize;
|
||||
|
||||
itid = PageGetItemId(page, offnum);
|
||||
previtem = (BTItem) PageGetItem(page, itid);
|
||||
@@ -351,19 +351,19 @@ _bt_insertonpg(Relation rel,
|
||||
|
||||
if (do_split)
|
||||
{
|
||||
Buffer rbuf;
|
||||
Page rpage;
|
||||
BTItem ritem;
|
||||
BlockNumber rbknum;
|
||||
BTPageOpaque rpageop;
|
||||
Buffer pbuf;
|
||||
Page ppage;
|
||||
BTPageOpaque ppageop;
|
||||
BlockNumber bknum = BufferGetBlockNumber(buf);
|
||||
BTItem lowLeftItem;
|
||||
OffsetNumber maxoff;
|
||||
bool shifted = false;
|
||||
bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false;
|
||||
Buffer rbuf;
|
||||
Page rpage;
|
||||
BTItem ritem;
|
||||
BlockNumber rbknum;
|
||||
BTPageOpaque rpageop;
|
||||
Buffer pbuf;
|
||||
Page ppage;
|
||||
BTPageOpaque ppageop;
|
||||
BlockNumber bknum = BufferGetBlockNumber(buf);
|
||||
BTItem lowLeftItem;
|
||||
OffsetNumber maxoff;
|
||||
bool shifted = false;
|
||||
bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false;
|
||||
|
||||
/*
|
||||
* If we have to split leaf page in the chain of duplicates by new
|
||||
@@ -372,7 +372,7 @@ _bt_insertonpg(Relation rel,
|
||||
if ((lpageop->btpo_flags & BTP_CHAIN) &&
|
||||
(lpageop->btpo_flags & BTP_LEAF) && keys_equal)
|
||||
{
|
||||
bool use_left = true;
|
||||
bool use_left = true;
|
||||
|
||||
rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE);
|
||||
rpage = BufferGetPage(rbuf);
|
||||
@@ -429,8 +429,8 @@ _bt_insertonpg(Relation rel,
|
||||
*/
|
||||
else if (!(lpageop->btpo_flags & BTP_CHAIN))
|
||||
{
|
||||
OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
||||
Size llimit;
|
||||
OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY;
|
||||
Size llimit;
|
||||
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
llimit = PageGetPageSize(page) - sizeof(PageHeaderData) -
|
||||
@@ -547,13 +547,13 @@ _bt_insertonpg(Relation rel,
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanKey newskey;
|
||||
ScanKey newskey;
|
||||
InsertIndexResult newres;
|
||||
BTItem new_item;
|
||||
OffsetNumber upditem_offset = P_HIKEY;
|
||||
bool do_update = false;
|
||||
bool update_in_place = true;
|
||||
bool parent_chained;
|
||||
BTItem new_item;
|
||||
OffsetNumber upditem_offset = P_HIKEY;
|
||||
bool do_update = false;
|
||||
bool update_in_place = true;
|
||||
bool parent_chained;
|
||||
|
||||
/* form a index tuple that points at the new right page */
|
||||
rbknum = BufferGetBlockNumber(rbuf);
|
||||
@@ -790,27 +790,27 @@ _bt_insertonpg(Relation rel,
|
||||
* Returns the new right sibling of buf, pinned and write-locked. The
|
||||
* pin and lock on buf are maintained.
|
||||
*/
|
||||
static Buffer
|
||||
static Buffer
|
||||
_bt_split(Relation rel, Buffer buf, OffsetNumber firstright)
|
||||
{
|
||||
Buffer rbuf;
|
||||
Page origpage;
|
||||
Page leftpage,
|
||||
rightpage;
|
||||
BTPageOpaque ropaque,
|
||||
lopaque,
|
||||
oopaque;
|
||||
Buffer sbuf;
|
||||
Page spage;
|
||||
BTPageOpaque sopaque;
|
||||
Size itemsz;
|
||||
ItemId itemid;
|
||||
BTItem item;
|
||||
OffsetNumber leftoff,
|
||||
rightoff;
|
||||
OffsetNumber start;
|
||||
OffsetNumber maxoff;
|
||||
OffsetNumber i;
|
||||
Buffer rbuf;
|
||||
Page origpage;
|
||||
Page leftpage,
|
||||
rightpage;
|
||||
BTPageOpaque ropaque,
|
||||
lopaque,
|
||||
oopaque;
|
||||
Buffer sbuf;
|
||||
Page spage;
|
||||
BTPageOpaque sopaque;
|
||||
Size itemsz;
|
||||
ItemId itemid;
|
||||
BTItem item;
|
||||
OffsetNumber leftoff,
|
||||
rightoff;
|
||||
OffsetNumber start;
|
||||
OffsetNumber maxoff;
|
||||
OffsetNumber i;
|
||||
|
||||
rbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
|
||||
origpage = BufferGetPage(buf);
|
||||
@@ -871,7 +871,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright)
|
||||
maxoff = PageGetMaxOffsetNumber(origpage);
|
||||
if (firstright == InvalidOffsetNumber)
|
||||
{
|
||||
Size llimit = PageGetFreeSpace(leftpage) / 2;
|
||||
Size llimit = PageGetFreeSpace(leftpage) / 2;
|
||||
|
||||
firstright = _bt_findsplitloc(rel, origpage, start, maxoff, llimit);
|
||||
}
|
||||
@@ -987,21 +987,21 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright)
|
||||
* may be split as
|
||||
* [2 2 2 2] [2 3 4].
|
||||
*/
|
||||
static OffsetNumber
|
||||
static OffsetNumber
|
||||
_bt_findsplitloc(Relation rel,
|
||||
Page page,
|
||||
OffsetNumber start,
|
||||
OffsetNumber maxoff,
|
||||
Size llimit)
|
||||
{
|
||||
OffsetNumber i;
|
||||
OffsetNumber saferight;
|
||||
ItemId nxtitemid,
|
||||
safeitemid;
|
||||
BTItem safeitem,
|
||||
nxtitem;
|
||||
Size nbytes;
|
||||
int natts;
|
||||
OffsetNumber i;
|
||||
OffsetNumber saferight;
|
||||
ItemId nxtitemid,
|
||||
safeitemid;
|
||||
BTItem safeitem,
|
||||
nxtitem;
|
||||
Size nbytes;
|
||||
int natts;
|
||||
|
||||
if (start >= maxoff)
|
||||
elog(FATAL, "btree: cannot split if start (%d) >= maxoff (%d)",
|
||||
@@ -1072,18 +1072,18 @@ _bt_findsplitloc(Relation rel,
|
||||
static void
|
||||
_bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
|
||||
{
|
||||
Buffer rootbuf;
|
||||
Page lpage,
|
||||
rpage,
|
||||
rootpage;
|
||||
BlockNumber lbkno,
|
||||
rbkno;
|
||||
BlockNumber rootbknum;
|
||||
BTPageOpaque rootopaque;
|
||||
ItemId itemid;
|
||||
BTItem item;
|
||||
Size itemsz;
|
||||
BTItem new_item;
|
||||
Buffer rootbuf;
|
||||
Page lpage,
|
||||
rpage,
|
||||
rootpage;
|
||||
BlockNumber lbkno,
|
||||
rbkno;
|
||||
BlockNumber rootbknum;
|
||||
BTPageOpaque rootopaque;
|
||||
ItemId itemid;
|
||||
BTItem item;
|
||||
Size itemsz;
|
||||
BTItem new_item;
|
||||
|
||||
/* get a new root page */
|
||||
rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE);
|
||||
@@ -1158,7 +1158,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
|
||||
* to follow. Otherwise, we do a binary search for the correct place
|
||||
* and insert the new item there.
|
||||
*/
|
||||
static OffsetNumber
|
||||
static OffsetNumber
|
||||
_bt_pgaddtup(Relation rel,
|
||||
Buffer buf,
|
||||
int keysz,
|
||||
@@ -1167,11 +1167,11 @@ _bt_pgaddtup(Relation rel,
|
||||
BTItem btitem,
|
||||
BTItem afteritem)
|
||||
{
|
||||
OffsetNumber itup_off;
|
||||
OffsetNumber first;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
BTItem chkitem;
|
||||
OffsetNumber itup_off;
|
||||
OffsetNumber first;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
BTItem chkitem;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||
@@ -1213,20 +1213,20 @@ _bt_pgaddtup(Relation rel,
|
||||
* + the item it is to follow ("afteritem") appears on this
|
||||
* page.
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
_bt_goesonpg(Relation rel,
|
||||
Buffer buf,
|
||||
Size keysz,
|
||||
ScanKey scankey,
|
||||
BTItem afteritem)
|
||||
{
|
||||
Page page;
|
||||
ItemId hikey;
|
||||
BTPageOpaque opaque;
|
||||
BTItem chkitem;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
bool found;
|
||||
Page page;
|
||||
ItemId hikey;
|
||||
BTPageOpaque opaque;
|
||||
BTItem chkitem;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
bool found;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
|
||||
@@ -1314,16 +1314,16 @@ _bt_itemcmp(Relation rel,
|
||||
BTItem item2,
|
||||
StrategyNumber strat)
|
||||
{
|
||||
TupleDesc tupDes;
|
||||
IndexTuple indexTuple1,
|
||||
indexTuple2;
|
||||
Datum attrDatum1,
|
||||
attrDatum2;
|
||||
int i;
|
||||
bool isFirstNull,
|
||||
isSecondNull;
|
||||
bool compare;
|
||||
bool useEqual = false;
|
||||
TupleDesc tupDes;
|
||||
IndexTuple indexTuple1,
|
||||
indexTuple2;
|
||||
Datum attrDatum1,
|
||||
attrDatum2;
|
||||
int i;
|
||||
bool isFirstNull,
|
||||
isSecondNull;
|
||||
bool compare;
|
||||
bool useEqual = false;
|
||||
|
||||
if (strat == BTLessEqualStrategyNumber)
|
||||
{
|
||||
@@ -1406,14 +1406,14 @@ _bt_updateitem(Relation rel,
|
||||
BTItem oldItem,
|
||||
BTItem newItem)
|
||||
{
|
||||
Page page;
|
||||
OffsetNumber maxoff;
|
||||
OffsetNumber i;
|
||||
Page page;
|
||||
OffsetNumber maxoff;
|
||||
OffsetNumber i;
|
||||
ItemPointerData itemPtrData;
|
||||
BTItem item;
|
||||
IndexTuple oldIndexTuple,
|
||||
newIndexTuple;
|
||||
int first;
|
||||
BTItem item;
|
||||
IndexTuple oldIndexTuple,
|
||||
newIndexTuple;
|
||||
int first;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
@@ -1460,18 +1460,18 @@ _bt_updateitem(Relation rel,
|
||||
*
|
||||
* Rule is simple: NOT_NULL not equal NULL, NULL not_equal NULL too.
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
_bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
|
||||
int keysz, ScanKey scankey)
|
||||
{
|
||||
Datum datum;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
ScanKey entry;
|
||||
AttrNumber attno;
|
||||
long result;
|
||||
int i;
|
||||
bool null;
|
||||
Datum datum;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
ScanKey entry;
|
||||
AttrNumber attno;
|
||||
long result;
|
||||
int i;
|
||||
bool null;
|
||||
|
||||
btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offnum));
|
||||
itup = &(btitem->bti_itup);
|
||||
@@ -1504,27 +1504,27 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
|
||||
*
|
||||
* NOTE: tested for shifting leftmost page only, having btitem < hikey.
|
||||
*/
|
||||
static InsertIndexResult
|
||||
static InsertIndexResult
|
||||
_bt_shift(Relation rel, Buffer buf, BTStack stack, int keysz,
|
||||
ScanKey scankey, BTItem btitem, BTItem hikey)
|
||||
{
|
||||
InsertIndexResult res;
|
||||
int itemsz;
|
||||
Page page;
|
||||
BlockNumber bknum;
|
||||
BTPageOpaque pageop;
|
||||
Buffer rbuf;
|
||||
Page rpage;
|
||||
BTPageOpaque rpageop;
|
||||
Buffer pbuf;
|
||||
Page ppage;
|
||||
BTPageOpaque ppageop;
|
||||
Buffer nbuf;
|
||||
Page npage;
|
||||
BTPageOpaque npageop;
|
||||
BlockNumber nbknum;
|
||||
BTItem nitem;
|
||||
OffsetNumber afteroff;
|
||||
int itemsz;
|
||||
Page page;
|
||||
BlockNumber bknum;
|
||||
BTPageOpaque pageop;
|
||||
Buffer rbuf;
|
||||
Page rpage;
|
||||
BTPageOpaque rpageop;
|
||||
Buffer pbuf;
|
||||
Page ppage;
|
||||
BTPageOpaque ppageop;
|
||||
Buffer nbuf;
|
||||
Page npage;
|
||||
BTPageOpaque npageop;
|
||||
BlockNumber nbknum;
|
||||
BTItem nitem;
|
||||
OffsetNumber afteroff;
|
||||
|
||||
btitem = _bt_formitem(&(btitem->bti_itup));
|
||||
hikey = _bt_formitem(&(hikey->bti_itup));
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.10 1997/09/07 04:38:52 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.11 1997/09/08 02:20:49 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Postgres btree pages look like ordinary relation pages. The opaque
|
||||
@@ -36,8 +36,8 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
|
||||
#define BTREE_METAPAGE 0
|
||||
#define BTREE_MAGIC 0x053162
|
||||
@@ -50,18 +50,18 @@ static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access);
|
||||
|
||||
typedef struct BTMetaPageData
|
||||
{
|
||||
uint32 btm_magic;
|
||||
uint32 btm_version;
|
||||
BlockNumber btm_root;
|
||||
uint32 btm_magic;
|
||||
uint32 btm_version;
|
||||
BlockNumber btm_root;
|
||||
#ifdef BTREE_VERSION_1
|
||||
int32 btm_level;
|
||||
int32 btm_level;
|
||||
#endif
|
||||
} BTMetaPageData;
|
||||
} BTMetaPageData;
|
||||
|
||||
#define BTPageGetMeta(p) \
|
||||
((BTMetaPageData *) &((PageHeader) p)->pd_linp[0])
|
||||
|
||||
extern bool BuildingBtree;
|
||||
extern bool BuildingBtree;
|
||||
|
||||
/*
|
||||
* We use high-concurrency locking on btrees. There are two cases in
|
||||
@@ -85,11 +85,11 @@ extern bool BuildingBtree;
|
||||
void
|
||||
_bt_metapinit(Relation rel)
|
||||
{
|
||||
Buffer buf;
|
||||
Page pg;
|
||||
int nblocks;
|
||||
BTMetaPageData metad;
|
||||
BTPageOpaque op;
|
||||
Buffer buf;
|
||||
Page pg;
|
||||
int nblocks;
|
||||
BTMetaPageData metad;
|
||||
BTPageOpaque op;
|
||||
|
||||
/* can't be sharing this with anyone, now... */
|
||||
if (USELOCKING)
|
||||
@@ -131,11 +131,11 @@ _bt_metapinit(Relation rel)
|
||||
void
|
||||
_bt_checkmeta(Relation rel)
|
||||
{
|
||||
Buffer metabuf;
|
||||
Page metap;
|
||||
Buffer metabuf;
|
||||
Page metap;
|
||||
BTMetaPageData *metad;
|
||||
BTPageOpaque op;
|
||||
int nblocks;
|
||||
BTPageOpaque op;
|
||||
int nblocks;
|
||||
|
||||
/* if the relation is empty, this is init time; don't complain */
|
||||
if ((nblocks = RelationGetNumberOfBlocks(rel)) == 0)
|
||||
@@ -187,13 +187,13 @@ _bt_checkmeta(Relation rel)
|
||||
Buffer
|
||||
_bt_getroot(Relation rel, int access)
|
||||
{
|
||||
Buffer metabuf;
|
||||
Page metapg;
|
||||
BTPageOpaque metaopaque;
|
||||
Buffer rootbuf;
|
||||
Page rootpg;
|
||||
BTPageOpaque rootopaque;
|
||||
BlockNumber rootblkno;
|
||||
Buffer metabuf;
|
||||
Page metapg;
|
||||
BTPageOpaque metaopaque;
|
||||
Buffer rootbuf;
|
||||
Page rootpg;
|
||||
BTPageOpaque rootopaque;
|
||||
BlockNumber rootblkno;
|
||||
BTMetaPageData *metad;
|
||||
|
||||
metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
|
||||
@@ -319,8 +319,8 @@ _bt_getroot(Relation rel, int access)
|
||||
Buffer
|
||||
_bt_getbuf(Relation rel, BlockNumber blkno, int access)
|
||||
{
|
||||
Buffer buf;
|
||||
Page page;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
|
||||
/*
|
||||
* If we want a new block, we can't set a lock of the appropriate type
|
||||
@@ -359,7 +359,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
|
||||
void
|
||||
_bt_relbuf(Relation rel, Buffer buf, int access)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(buf);
|
||||
|
||||
@@ -382,7 +382,7 @@ _bt_relbuf(Relation rel, Buffer buf, int access)
|
||||
void
|
||||
_bt_wrtbuf(Relation rel, Buffer buf)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(buf);
|
||||
WriteBuffer(buf);
|
||||
@@ -399,7 +399,7 @@ _bt_wrtbuf(Relation rel, Buffer buf)
|
||||
void
|
||||
_bt_wrtnorelbuf(Relation rel, Buffer buf)
|
||||
{
|
||||
BlockNumber blkno;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(buf);
|
||||
WriteNoReleaseBuffer(buf);
|
||||
@@ -439,9 +439,9 @@ _bt_pageinit(Page page, Size size)
|
||||
void
|
||||
_bt_metaproot(Relation rel, BlockNumber rootbknum, int level)
|
||||
{
|
||||
Buffer metabuf;
|
||||
Page metap;
|
||||
BTPageOpaque metaopaque;
|
||||
Buffer metabuf;
|
||||
Page metap;
|
||||
BTPageOpaque metaopaque;
|
||||
BTMetaPageData *metad;
|
||||
|
||||
metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE);
|
||||
@@ -473,18 +473,18 @@ _bt_metaproot(Relation rel, BlockNumber rootbknum, int level)
|
||||
Buffer
|
||||
_bt_getstackbuf(Relation rel, BTStack stack, int access)
|
||||
{
|
||||
Buffer buf;
|
||||
BlockNumber blkno;
|
||||
OffsetNumber start,
|
||||
offnum,
|
||||
maxoff;
|
||||
OffsetNumber i;
|
||||
Page page;
|
||||
ItemId itemid;
|
||||
BTItem item;
|
||||
BTPageOpaque opaque;
|
||||
BTItem item_save;
|
||||
int item_nbytes;
|
||||
Buffer buf;
|
||||
BlockNumber blkno;
|
||||
OffsetNumber start,
|
||||
offnum,
|
||||
maxoff;
|
||||
OffsetNumber i;
|
||||
Page page;
|
||||
ItemId itemid;
|
||||
BTItem item;
|
||||
BTPageOpaque opaque;
|
||||
BTItem item_save;
|
||||
int item_nbytes;
|
||||
|
||||
blkno = stack->bts_blkno;
|
||||
buf = _bt_getbuf(rel, blkno, access);
|
||||
@@ -603,10 +603,10 @@ _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access)
|
||||
void
|
||||
_bt_pagedel(Relation rel, ItemPointer tid)
|
||||
{
|
||||
Buffer buf;
|
||||
Page page;
|
||||
BlockNumber blkno;
|
||||
OffsetNumber offno;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
BlockNumber blkno;
|
||||
OffsetNumber offno;
|
||||
|
||||
blkno = ItemPointerGetBlockNumber(tid);
|
||||
offno = ItemPointerGetOffsetNumber(tid);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.20 1997/09/07 04:38:54 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.21 1997/09/08 02:20:50 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains only the public interface routines.
|
||||
@@ -35,14 +35,14 @@
|
||||
|
||||
#ifdef BTREE_BUILD_STATS
|
||||
#include <tcop/tcopprot.h>
|
||||
extern int ShowExecutorStats;
|
||||
extern int ShowExecutorStats;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
bool BuildingBtree = false; /* see comment in btbuild() */
|
||||
bool FastBuild = true; /* use sort/build instead of
|
||||
* insertion build */
|
||||
bool BuildingBtree = false; /* see comment in btbuild() */
|
||||
bool FastBuild = true; /* use sort/build instead of insertion
|
||||
* build */
|
||||
|
||||
/*
|
||||
* btbuild() -- build a new btree index.
|
||||
@@ -63,33 +63,33 @@ btbuild(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 = 0;
|
||||
int nhtups,
|
||||
nitups;
|
||||
int i;
|
||||
BTItem btitem;
|
||||
int nhtups,
|
||||
nitups;
|
||||
int i;
|
||||
BTItem btitem;
|
||||
|
||||
#ifndef OMIT_PARTIAL_INDEX
|
||||
ExprContext *econtext = (ExprContext *) NULL;
|
||||
TupleTable tupleTable = (TupleTable) NULL;
|
||||
ExprContext *econtext = (ExprContext *) NULL;
|
||||
TupleTable tupleTable = (TupleTable) NULL;
|
||||
TupleTableSlot *slot = (TupleTableSlot *) NULL;
|
||||
|
||||
#endif
|
||||
Oid hrelid,
|
||||
irelid;
|
||||
Node *pred,
|
||||
*oldPred;
|
||||
void *spool = (void *) NULL;
|
||||
bool isunique;
|
||||
bool usefast;
|
||||
Oid hrelid,
|
||||
irelid;
|
||||
Node *pred,
|
||||
*oldPred;
|
||||
void *spool = (void *) NULL;
|
||||
bool isunique;
|
||||
bool usefast;
|
||||
|
||||
/* note that this is a new btree */
|
||||
BuildingBtree = true;
|
||||
@@ -211,8 +211,8 @@ btbuild(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
|
||||
@@ -358,8 +358,8 @@ btbuild(Relation heap,
|
||||
InsertIndexResult
|
||||
btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
|
||||
{
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
InsertIndexResult res;
|
||||
|
||||
/* generate an index tuple */
|
||||
@@ -389,7 +389,7 @@ btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation
|
||||
/*
|
||||
* btgettuple() -- Get the next tuple in the scan.
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
btgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
{
|
||||
RetrieveIndexResult res;
|
||||
@@ -411,10 +411,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
/*
|
||||
* btbeginscan() -- start a scan on a btree index
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
|
||||
{
|
||||
IndexScanDesc scan;
|
||||
IndexScanDesc scan;
|
||||
|
||||
/* get the scan */
|
||||
scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey);
|
||||
@@ -431,8 +431,8 @@ btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
|
||||
void
|
||||
btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
|
||||
@@ -483,8 +483,8 @@ btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
|
||||
void
|
||||
btmovescan(IndexScanDesc scan, Datum v)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
|
||||
@@ -506,8 +506,8 @@ btmovescan(IndexScanDesc scan, Datum v)
|
||||
void
|
||||
btendscan(IndexScanDesc scan)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
|
||||
@@ -541,8 +541,8 @@ btendscan(IndexScanDesc scan)
|
||||
void
|
||||
btmarkpos(IndexScanDesc scan)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
|
||||
@@ -570,8 +570,8 @@ btmarkpos(IndexScanDesc scan)
|
||||
void
|
||||
btrestrpos(IndexScanDesc scan)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
ItemPointer iptr;
|
||||
BTScanOpaque so;
|
||||
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.8 1997/09/07 04:38:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.9 1997/09/08 02:20:52 momjian Exp $
|
||||
*
|
||||
*
|
||||
* NOTES
|
||||
@@ -34,16 +34,16 @@
|
||||
|
||||
typedef struct BTScanListData
|
||||
{
|
||||
IndexScanDesc btsl_scan;
|
||||
IndexScanDesc btsl_scan;
|
||||
struct BTScanListData *btsl_next;
|
||||
} BTScanListData;
|
||||
} BTScanListData;
|
||||
|
||||
typedef BTScanListData *BTScanList;
|
||||
|
||||
static BTScanList BTScans = (BTScanList) NULL;
|
||||
|
||||
static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno);
|
||||
static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||
static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno);
|
||||
static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
|
||||
|
||||
/*
|
||||
* _bt_regscan() -- register a new scan.
|
||||
@@ -51,7 +51,7 @@ static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber
|
||||
void
|
||||
_bt_regscan(IndexScanDesc scan)
|
||||
{
|
||||
BTScanList new_el;
|
||||
BTScanList new_el;
|
||||
|
||||
new_el = (BTScanList) palloc(sizeof(BTScanListData));
|
||||
new_el->btsl_scan = scan;
|
||||
@@ -65,8 +65,8 @@ _bt_regscan(IndexScanDesc scan)
|
||||
void
|
||||
_bt_dropscan(IndexScanDesc scan)
|
||||
{
|
||||
BTScanList chk,
|
||||
last;
|
||||
BTScanList chk,
|
||||
last;
|
||||
|
||||
last = (BTScanList) NULL;
|
||||
for (chk = BTScans;
|
||||
@@ -94,8 +94,8 @@ _bt_dropscan(IndexScanDesc scan)
|
||||
void
|
||||
_bt_adjscans(Relation rel, ItemPointer tid, int op)
|
||||
{
|
||||
BTScanList l;
|
||||
Oid relid;
|
||||
BTScanList l;
|
||||
Oid relid;
|
||||
|
||||
relid = rel->rd_id;
|
||||
for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next)
|
||||
@@ -130,9 +130,9 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op)
|
||||
static void
|
||||
_bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
||||
{
|
||||
ItemPointer current;
|
||||
Buffer buf;
|
||||
BTScanOpaque so;
|
||||
ItemPointer current;
|
||||
Buffer buf;
|
||||
BTScanOpaque so;
|
||||
|
||||
if (!_bt_scantouched(scan, blkno, offno))
|
||||
return;
|
||||
@@ -147,15 +147,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case BT_INSERT:
|
||||
_bt_step(scan, &buf, ForwardScanDirection);
|
||||
break;
|
||||
case BT_DELETE:
|
||||
_bt_step(scan, &buf, BackwardScanDirection);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
||||
/* NOTREACHED */
|
||||
case BT_INSERT:
|
||||
_bt_step(scan, &buf, ForwardScanDirection);
|
||||
break;
|
||||
case BT_DELETE:
|
||||
_bt_step(scan, &buf, BackwardScanDirection);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
so->btso_curbuf = buf;
|
||||
}
|
||||
@@ -172,15 +172,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
||||
scan->currentItemData = tmp;
|
||||
switch (op)
|
||||
{
|
||||
case BT_INSERT:
|
||||
_bt_step(scan, &buf, ForwardScanDirection);
|
||||
break;
|
||||
case BT_DELETE:
|
||||
_bt_step(scan, &buf, BackwardScanDirection);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
||||
/* NOTREACHED */
|
||||
case BT_INSERT:
|
||||
_bt_step(scan, &buf, ForwardScanDirection);
|
||||
break;
|
||||
case BT_DELETE:
|
||||
_bt_step(scan, &buf, BackwardScanDirection);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "_bt_scandel: bad operation '%d'", op);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
so->btso_mrkbuf = buf;
|
||||
tmp = *current;
|
||||
@@ -193,10 +193,10 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno)
|
||||
* _bt_scantouched() -- check to see if a scan is affected by a given
|
||||
* change to the index
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
_bt_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/nbtree/nbtsearch.c,v 1.24 1997/09/07 04:38:58 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.25 1997/09/08 02:20:57 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -28,19 +28,19 @@
|
||||
#endif
|
||||
|
||||
|
||||
static BTStack
|
||||
static BTStack
|
||||
_bt_searchr(Relation rel, int keysz, ScanKey scankey,
|
||||
Buffer * bufP, BTStack stack_in);
|
||||
static OffsetNumber
|
||||
static OffsetNumber
|
||||
_bt_firsteq(Relation rel, TupleDesc itupdesc, Page page,
|
||||
Size keysz, ScanKey scankey, OffsetNumber offnum);
|
||||
static int
|
||||
_bt_compare(Relation rel, TupleDesc itupdesc, Page page,
|
||||
int keysz, ScanKey scankey, OffsetNumber offnum);
|
||||
static bool
|
||||
_bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir);
|
||||
static RetrieveIndexResult
|
||||
_bt_endpoint(IndexScanDesc scan, ScanDirection dir);
|
||||
static bool
|
||||
_bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir);
|
||||
static RetrieveIndexResult
|
||||
_bt_endpoint(IndexScanDesc scan, ScanDirection dir);
|
||||
|
||||
/*
|
||||
* _bt_search() -- Search for a scan key in the index.
|
||||
@@ -58,24 +58,24 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, Buffer * bufP)
|
||||
/*
|
||||
* _bt_searchr() -- Search the tree recursively for a particular scankey.
|
||||
*/
|
||||
static BTStack
|
||||
static BTStack
|
||||
_bt_searchr(Relation rel,
|
||||
int keysz,
|
||||
ScanKey scankey,
|
||||
Buffer * bufP,
|
||||
BTStack stack_in)
|
||||
{
|
||||
BTStack stack;
|
||||
OffsetNumber offnum;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
BlockNumber par_blkno;
|
||||
BlockNumber blkno;
|
||||
ItemId itemid;
|
||||
BTItem btitem;
|
||||
BTItem item_save;
|
||||
int item_nbytes;
|
||||
IndexTuple itup;
|
||||
BTStack stack;
|
||||
OffsetNumber offnum;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
BlockNumber par_blkno;
|
||||
BlockNumber blkno;
|
||||
ItemId itemid;
|
||||
BTItem btitem;
|
||||
BTItem item_save;
|
||||
int item_nbytes;
|
||||
IndexTuple itup;
|
||||
|
||||
/* if this is a leaf page, we're done */
|
||||
page = BufferGetPage(*bufP);
|
||||
@@ -155,11 +155,11 @@ _bt_moveright(Relation rel,
|
||||
ScanKey scankey,
|
||||
int access)
|
||||
{
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
ItemId hikey;
|
||||
BlockNumber rblkno;
|
||||
int natts = rel->rd_rel->relnatts;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
ItemId hikey;
|
||||
BlockNumber rblkno;
|
||||
int natts = rel->rd_rel->relnatts;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||
@@ -183,7 +183,7 @@ _bt_moveright(Relation rel,
|
||||
/* move right as long as we need to */
|
||||
do
|
||||
{
|
||||
OffsetNumber offmax = PageGetMaxOffsetNumber(page);
|
||||
OffsetNumber offmax = PageGetMaxOffsetNumber(page);
|
||||
|
||||
/*
|
||||
* If this page consists of all duplicate keys (hikey and
|
||||
@@ -197,8 +197,8 @@ _bt_moveright(Relation rel,
|
||||
* if number of attrs > keysize. Example: (2,0) - last items
|
||||
* on this page, (2,1) - first item on next page (hikey), our
|
||||
* scankey is x = 2. Scankey == (2,1) because of we compare
|
||||
* first attrs only, but we shouldn't to move right of here.
|
||||
* - vadim 04/15/97
|
||||
* first attrs only, but we shouldn't to move right of here. -
|
||||
* vadim 04/15/97
|
||||
*/
|
||||
|
||||
if (_bt_skeycmp(rel, keysz, scankey, page, hikey,
|
||||
@@ -268,17 +268,17 @@ _bt_skeycmp(Relation rel,
|
||||
ItemId itemid,
|
||||
StrategyNumber strat)
|
||||
{
|
||||
BTItem item;
|
||||
IndexTuple indexTuple;
|
||||
TupleDesc tupDes;
|
||||
ScanKey entry;
|
||||
int i;
|
||||
Datum attrDatum;
|
||||
Datum keyDatum;
|
||||
bool compare;
|
||||
bool isNull;
|
||||
bool useEqual = false;
|
||||
bool keyNull;
|
||||
BTItem item;
|
||||
IndexTuple indexTuple;
|
||||
TupleDesc tupDes;
|
||||
ScanKey entry;
|
||||
int i;
|
||||
Datum attrDatum;
|
||||
Datum keyDatum;
|
||||
bool compare;
|
||||
bool isNull;
|
||||
bool useEqual = false;
|
||||
bool keyNull;
|
||||
|
||||
if (strat == BTLessEqualStrategyNumber)
|
||||
{
|
||||
@@ -382,14 +382,14 @@ _bt_binsrch(Relation rel,
|
||||
ScanKey scankey,
|
||||
int srchtype)
|
||||
{
|
||||
TupleDesc itupdesc;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber low,
|
||||
mid,
|
||||
high;
|
||||
int natts = rel->rd_rel->relnatts;
|
||||
int result;
|
||||
TupleDesc itupdesc;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber low,
|
||||
mid,
|
||||
high;
|
||||
int natts = rel->rd_rel->relnatts;
|
||||
int result;
|
||||
|
||||
itupdesc = RelationGetTupleDescriptor(rel);
|
||||
page = BufferGetPage(buf);
|
||||
@@ -515,7 +515,7 @@ _bt_binsrch(Relation rel,
|
||||
}
|
||||
}
|
||||
|
||||
static OffsetNumber
|
||||
static OffsetNumber
|
||||
_bt_firsteq(Relation rel,
|
||||
TupleDesc itupdesc,
|
||||
Page page,
|
||||
@@ -523,8 +523,8 @@ _bt_firsteq(Relation rel,
|
||||
ScanKey scankey,
|
||||
OffsetNumber offnum)
|
||||
{
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber limit;
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber limit;
|
||||
|
||||
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
|
||||
|
||||
@@ -572,16 +572,16 @@ _bt_compare(Relation rel,
|
||||
ScanKey scankey,
|
||||
OffsetNumber offnum)
|
||||
{
|
||||
Datum datum;
|
||||
BTItem btitem;
|
||||
ItemId itemid;
|
||||
IndexTuple itup;
|
||||
BTPageOpaque opaque;
|
||||
ScanKey entry;
|
||||
AttrNumber attno;
|
||||
int result;
|
||||
int i;
|
||||
bool null;
|
||||
Datum datum;
|
||||
BTItem btitem;
|
||||
ItemId itemid;
|
||||
IndexTuple itup;
|
||||
BTPageOpaque opaque;
|
||||
ScanKey entry;
|
||||
AttrNumber attno;
|
||||
int result;
|
||||
int i;
|
||||
bool null;
|
||||
|
||||
/*
|
||||
* If this is a leftmost internal page, and if our comparison is with
|
||||
@@ -650,7 +650,7 @@ _bt_compare(Relation rel,
|
||||
|
||||
for (i = 1; i <= keysz; i++)
|
||||
{
|
||||
long tmpres;
|
||||
long tmpres;
|
||||
|
||||
entry = &scankey[i - 1];
|
||||
attno = entry->sk_attno;
|
||||
@@ -697,16 +697,16 @@ _bt_compare(Relation rel,
|
||||
RetrieveIndexResult
|
||||
_bt_next(IndexScanDesc scan, ScanDirection dir)
|
||||
{
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
OffsetNumber offnum;
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
OffsetNumber offnum;
|
||||
RetrieveIndexResult res;
|
||||
ItemPointer current;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
BTScanOpaque so;
|
||||
Size keysok;
|
||||
ItemPointer current;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
BTScanOpaque so;
|
||||
Size keysok;
|
||||
|
||||
rel = scan->relation;
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
@@ -769,26 +769,26 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
|
||||
RetrieveIndexResult
|
||||
_bt_first(IndexScanDesc scan, ScanDirection dir)
|
||||
{
|
||||
Relation rel;
|
||||
TupleDesc itupdesc;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
BTPageOpaque pop;
|
||||
BTStack stack;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
bool offGmax = false;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
ItemPointer current;
|
||||
BlockNumber blkno;
|
||||
StrategyNumber strat;
|
||||
Relation rel;
|
||||
TupleDesc itupdesc;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
BTPageOpaque pop;
|
||||
BTStack stack;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
bool offGmax = false;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
ItemPointer current;
|
||||
BlockNumber blkno;
|
||||
StrategyNumber strat;
|
||||
RetrieveIndexResult res;
|
||||
RegProcedure proc;
|
||||
int result;
|
||||
BTScanOpaque so;
|
||||
ScanKeyData skdata;
|
||||
Size keysok;
|
||||
RegProcedure proc;
|
||||
int result;
|
||||
BTScanOpaque so;
|
||||
ScanKeyData skdata;
|
||||
Size keysok;
|
||||
|
||||
rel = scan->relation;
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
@@ -915,69 +915,69 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
|
||||
|
||||
switch (strat)
|
||||
{
|
||||
case BTLessStrategyNumber:
|
||||
if (result <= 0)
|
||||
{
|
||||
do
|
||||
case BTLessStrategyNumber:
|
||||
if (result <= 0)
|
||||
{
|
||||
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
||||
break;
|
||||
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
page = BufferGetPage(buf);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result <= 0);
|
||||
|
||||
/* if this is true, the key we just looked at is gone */
|
||||
if (result > 0)
|
||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||
}
|
||||
break;
|
||||
|
||||
case BTLessEqualStrategyNumber:
|
||||
if (result >= 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
||||
break;
|
||||
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
page = BufferGetPage(buf);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result >= 0);
|
||||
|
||||
if (result < 0)
|
||||
_bt_twostep(scan, &buf, BackwardScanDirection);
|
||||
}
|
||||
break;
|
||||
|
||||
case BTEqualStrategyNumber:
|
||||
if (result != 0)
|
||||
{
|
||||
_bt_relbuf(scan->relation, buf, BT_READ);
|
||||
so->btso_curbuf = InvalidBuffer;
|
||||
ItemPointerSetInvalid(&(scan->currentItemData));
|
||||
return ((RetrieveIndexResult) NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case BTGreaterEqualStrategyNumber:
|
||||
if (offGmax)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY);
|
||||
if (!_bt_step(scan, &buf, ForwardScanDirection))
|
||||
do
|
||||
{
|
||||
_bt_relbuf(scan->relation, buf, BT_READ);
|
||||
so->btso_curbuf = InvalidBuffer;
|
||||
ItemPointerSetInvalid(&(scan->currentItemData));
|
||||
return ((RetrieveIndexResult) NULL);
|
||||
}
|
||||
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
||||
break;
|
||||
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
page = BufferGetPage(buf);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result <= 0);
|
||||
|
||||
/* if this is true, the key we just looked at is gone */
|
||||
if (result > 0)
|
||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||
}
|
||||
else if (result > 0)
|
||||
{ /* Just remember: _bt_binsrch() returns
|
||||
break;
|
||||
|
||||
case BTLessEqualStrategyNumber:
|
||||
if (result >= 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
||||
break;
|
||||
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
page = BufferGetPage(buf);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result >= 0);
|
||||
|
||||
if (result < 0)
|
||||
_bt_twostep(scan, &buf, BackwardScanDirection);
|
||||
}
|
||||
break;
|
||||
|
||||
case BTEqualStrategyNumber:
|
||||
if (result != 0)
|
||||
{
|
||||
_bt_relbuf(scan->relation, buf, BT_READ);
|
||||
so->btso_curbuf = InvalidBuffer;
|
||||
ItemPointerSetInvalid(&(scan->currentItemData));
|
||||
return ((RetrieveIndexResult) NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case BTGreaterEqualStrategyNumber:
|
||||
if (offGmax)
|
||||
{
|
||||
if (result < 0)
|
||||
{
|
||||
Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY);
|
||||
if (!_bt_step(scan, &buf, ForwardScanDirection))
|
||||
{
|
||||
_bt_relbuf(scan->relation, buf, BT_READ);
|
||||
so->btso_curbuf = InvalidBuffer;
|
||||
ItemPointerSetInvalid(&(scan->currentItemData));
|
||||
return ((RetrieveIndexResult) NULL);
|
||||
}
|
||||
}
|
||||
else if (result > 0)
|
||||
{ /* Just remember: _bt_binsrch() returns
|
||||
* the OffsetNumber of the first matching
|
||||
* key on the page, or the OffsetNumber at
|
||||
* which the matching key WOULD APPEAR IF
|
||||
@@ -985,41 +985,41 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
|
||||
* page, but offnum from _bt_binsrch()
|
||||
* greater maxoff - have to move right. -
|
||||
* vadim 12/06/96 */
|
||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (result < 0)
|
||||
{
|
||||
do
|
||||
else if (result < 0)
|
||||
{
|
||||
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
||||
break;
|
||||
do
|
||||
{
|
||||
if (!_bt_twostep(scan, &buf, BackwardScanDirection))
|
||||
break;
|
||||
|
||||
page = BufferGetPage(buf);
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result < 0);
|
||||
page = BufferGetPage(buf);
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result < 0);
|
||||
|
||||
if (result > 0)
|
||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||
}
|
||||
break;
|
||||
if (result > 0)
|
||||
_bt_twostep(scan, &buf, ForwardScanDirection);
|
||||
}
|
||||
break;
|
||||
|
||||
case BTGreaterStrategyNumber:
|
||||
/* offGmax helps as above */
|
||||
if (result >= 0 || offGmax)
|
||||
{
|
||||
do
|
||||
case BTGreaterStrategyNumber:
|
||||
/* offGmax helps as above */
|
||||
if (result >= 0 || offGmax)
|
||||
{
|
||||
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
||||
break;
|
||||
do
|
||||
{
|
||||
if (!_bt_twostep(scan, &buf, ForwardScanDirection))
|
||||
break;
|
||||
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
page = BufferGetPage(buf);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result >= 0);
|
||||
}
|
||||
break;
|
||||
offnum = ItemPointerGetOffsetNumber(current);
|
||||
page = BufferGetPage(buf);
|
||||
result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum);
|
||||
} while (result >= 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* okay, current item pointer for the scan is right */
|
||||
@@ -1062,16 +1062,16 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
|
||||
bool
|
||||
_bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
||||
{
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
OffsetNumber start;
|
||||
BlockNumber blkno;
|
||||
BlockNumber obknum;
|
||||
BTScanOpaque so;
|
||||
ItemPointer current;
|
||||
Relation rel;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
OffsetNumber start;
|
||||
BlockNumber blkno;
|
||||
BlockNumber obknum;
|
||||
BTScanOpaque so;
|
||||
ItemPointer current;
|
||||
Relation rel;
|
||||
|
||||
rel = scan->relation;
|
||||
current = &(scan->currentItemData);
|
||||
@@ -1235,20 +1235,20 @@ _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
||||
* proper state and acquires a lock and pin on *bufP. If the twostep
|
||||
* succeeded, we return true; otherwise, we return false.
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
_bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
||||
{
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
OffsetNumber start;
|
||||
ItemPointer current;
|
||||
ItemId itemid;
|
||||
int itemsz;
|
||||
BTItem btitem;
|
||||
BTItem svitem;
|
||||
BlockNumber blkno;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
OffsetNumber start;
|
||||
ItemPointer current;
|
||||
ItemId itemid;
|
||||
int itemsz;
|
||||
BTItem btitem;
|
||||
BTItem svitem;
|
||||
BlockNumber blkno;
|
||||
|
||||
blkno = BufferGetBlockNumber(*bufP);
|
||||
page = BufferGetPage(*bufP);
|
||||
@@ -1333,23 +1333,23 @@ _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir)
|
||||
/*
|
||||
* _bt_endpoint() -- Find the first or last key in the index.
|
||||
*/
|
||||
static RetrieveIndexResult
|
||||
static RetrieveIndexResult
|
||||
_bt_endpoint(IndexScanDesc scan, ScanDirection dir)
|
||||
{
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
ItemPointer current;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
OffsetNumber start = 0;
|
||||
BlockNumber blkno;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
BTScanOpaque so;
|
||||
Relation rel;
|
||||
Buffer buf;
|
||||
Page page;
|
||||
BTPageOpaque opaque;
|
||||
ItemPointer current;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
OffsetNumber start = 0;
|
||||
BlockNumber blkno;
|
||||
BTItem btitem;
|
||||
IndexTuple itup;
|
||||
BTScanOpaque so;
|
||||
RetrieveIndexResult res;
|
||||
Size keysok;
|
||||
Size keysok;
|
||||
|
||||
rel = scan->relation;
|
||||
current = &(scan->currentItemData);
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Id: nbtsort.c,v 1.20 1997/09/07 04:39:02 momjian Exp $
|
||||
* $Id: nbtsort.c,v 1.21 1997/09/08 02:20:58 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -65,14 +65,14 @@
|
||||
|
||||
#ifdef BTREE_BUILD_STATS
|
||||
#include <tcop/tcopprot.h>
|
||||
extern int ShowExecutorStats;
|
||||
extern int ShowExecutorStats;
|
||||
|
||||
#endif
|
||||
|
||||
static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags);
|
||||
static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend);
|
||||
static void *_bt_pagestate(Relation index, int flags, int level, bool doupper);
|
||||
static void _bt_uppershutdown(Relation index, BTPageState * state);
|
||||
static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags);
|
||||
static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend);
|
||||
static void *_bt_pagestate(Relation index, int flags, int level, bool doupper);
|
||||
static void _bt_uppershutdown(Relation index, BTPageState * state);
|
||||
|
||||
/*
|
||||
* turn on debugging output.
|
||||
@@ -88,9 +88,9 @@ static void _bt_uppershutdown(Relation index, BTPageState * state);
|
||||
#define TAPEBLCKSZ (MAXBLCKSZ << 2)
|
||||
#define TAPETEMP "pg_btsortXXXXXX"
|
||||
|
||||
extern int NDirectFileRead;
|
||||
extern int NDirectFileWrite;
|
||||
extern char *mktemp(char *template);
|
||||
extern int NDirectFileRead;
|
||||
extern int NDirectFileWrite;
|
||||
extern char *mktemp(char *template);
|
||||
|
||||
/*
|
||||
* this is what we use to shovel BTItems in and out of memory. it's
|
||||
@@ -107,13 +107,13 @@ extern char *mktemp(char *template);
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int bttb_magic; /* magic number */
|
||||
int bttb_fd; /* file descriptor */
|
||||
int bttb_top; /* top of free space within bttb_data */
|
||||
short bttb_ntup; /* number of tuples in this block */
|
||||
short bttb_eor; /* End-Of-Run marker */
|
||||
char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)];
|
||||
} BTTapeBlock;
|
||||
int bttb_magic; /* magic number */
|
||||
int bttb_fd; /* file descriptor */
|
||||
int bttb_top; /* top of free space within bttb_data */
|
||||
short bttb_ntup; /* number of tuples in this block */
|
||||
short bttb_eor; /* End-Of-Run marker */
|
||||
char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)];
|
||||
} BTTapeBlock;
|
||||
|
||||
/*
|
||||
* this structure holds the bookkeeping for a simple balanced multiway
|
||||
@@ -124,12 +124,12 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int bts_ntapes;
|
||||
int bts_tape;
|
||||
BTTapeBlock **bts_itape; /* input tape blocks */
|
||||
BTTapeBlock **bts_otape; /* output tape blocks */
|
||||
bool isunique;
|
||||
} BTSpool;
|
||||
int bts_ntapes;
|
||||
int bts_tape;
|
||||
BTTapeBlock **bts_itape; /* input tape blocks */
|
||||
BTTapeBlock **bts_otape; /* output tape blocks */
|
||||
bool isunique;
|
||||
} BTSpool;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* sorting comparison routine - returns {-1,0,1} depending on whether
|
||||
@@ -151,13 +151,13 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
Datum *btsk_datum;
|
||||
char *btsk_nulls;
|
||||
BTItem btsk_item;
|
||||
} BTSortKey;
|
||||
Datum *btsk_datum;
|
||||
char *btsk_nulls;
|
||||
BTItem btsk_item;
|
||||
} BTSortKey;
|
||||
|
||||
static Relation _bt_sortrel;
|
||||
static int _bt_nattr;
|
||||
static int _bt_nattr;
|
||||
static BTSpool *_bt_inspool;
|
||||
|
||||
static void
|
||||
@@ -171,12 +171,12 @@ _bt_isortcmpinit(Relation index, BTSpool * spool)
|
||||
static int
|
||||
_bt_isortcmp(BTSortKey * k1, BTSortKey * k2)
|
||||
{
|
||||
Datum *k1_datum = k1->btsk_datum;
|
||||
Datum *k2_datum = k2->btsk_datum;
|
||||
char *k1_nulls = k1->btsk_nulls;
|
||||
char *k2_nulls = k2->btsk_nulls;
|
||||
bool equal_isnull = false;
|
||||
int i;
|
||||
Datum *k1_datum = k1->btsk_datum;
|
||||
Datum *k2_datum = k2->btsk_datum;
|
||||
char *k1_nulls = k1->btsk_nulls;
|
||||
char *k2_nulls = k2->btsk_nulls;
|
||||
bool equal_isnull = false;
|
||||
int i;
|
||||
|
||||
if (k1->btsk_item == (BTItem) NULL)
|
||||
{
|
||||
@@ -226,12 +226,12 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk)
|
||||
|
||||
if (bti != (BTItem) NULL)
|
||||
{
|
||||
IndexTuple it = &(bti->bti_itup);
|
||||
TupleDesc itdesc = index->rd_att;
|
||||
Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum));
|
||||
char *np = (char *) palloc(_bt_nattr * sizeof(char));
|
||||
bool isnull;
|
||||
int i;
|
||||
IndexTuple it = &(bti->bti_itup);
|
||||
TupleDesc itdesc = index->rd_att;
|
||||
Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum));
|
||||
char *np = (char *) palloc(_bt_nattr * sizeof(char));
|
||||
bool isnull;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _bt_nattr; i++)
|
||||
{
|
||||
@@ -260,17 +260,17 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int btpqe_tape; /* tape identifier */
|
||||
BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */
|
||||
} BTPriQueueElem;
|
||||
int btpqe_tape; /* tape identifier */
|
||||
BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */
|
||||
} BTPriQueueElem;
|
||||
|
||||
#define MAXELEM MAXTAPES
|
||||
typedef struct
|
||||
{
|
||||
int btpq_nelem;
|
||||
BTPriQueueElem btpq_queue[MAXELEM];
|
||||
Relation btpq_rel;
|
||||
} BTPriQueue;
|
||||
int btpq_nelem;
|
||||
BTPriQueueElem btpq_queue[MAXELEM];
|
||||
Relation btpq_rel;
|
||||
} BTPriQueue;
|
||||
|
||||
/* be sure to call _bt_isortcmpinit first */
|
||||
#define GREATER(a, b) \
|
||||
@@ -279,8 +279,8 @@ typedef struct
|
||||
static void
|
||||
_bt_pqsift(BTPriQueue * q, int parent)
|
||||
{
|
||||
int child;
|
||||
BTPriQueueElem e;
|
||||
int child;
|
||||
BTPriQueueElem e;
|
||||
|
||||
for (child = parent * 2 + 1;
|
||||
child < q->btpq_nelem;
|
||||
@@ -328,8 +328,8 @@ _bt_pqnext(BTPriQueue * q, BTPriQueueElem * e)
|
||||
static void
|
||||
_bt_pqadd(BTPriQueue * q, BTPriQueueElem * e)
|
||||
{
|
||||
int child,
|
||||
parent;
|
||||
int child,
|
||||
parent;
|
||||
|
||||
if (q->btpq_nelem >= MAXELEM)
|
||||
{
|
||||
@@ -422,7 +422,7 @@ _bt_tapeclear(BTTapeBlock * tape)
|
||||
static BTTapeBlock *
|
||||
_bt_tapecreate(char *fname)
|
||||
{
|
||||
BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock));
|
||||
BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock));
|
||||
|
||||
if (tape == (BTTapeBlock *) NULL)
|
||||
{
|
||||
@@ -474,8 +474,8 @@ _bt_tapewrite(BTTapeBlock * tape, int eor)
|
||||
static int
|
||||
_bt_taperead(BTTapeBlock * tape)
|
||||
{
|
||||
int fd;
|
||||
int nread;
|
||||
int fd;
|
||||
int nread;
|
||||
|
||||
if (tape->bttb_eor)
|
||||
{
|
||||
@@ -510,11 +510,11 @@ _bt_taperead(BTTapeBlock * tape)
|
||||
* side effects:
|
||||
* - sets 'pos' to the current position within the block.
|
||||
*/
|
||||
static BTItem
|
||||
static BTItem
|
||||
_bt_tapenext(BTTapeBlock * tape, char **pos)
|
||||
{
|
||||
Size itemsz;
|
||||
BTItem bti;
|
||||
Size itemsz;
|
||||
BTItem bti;
|
||||
|
||||
if (*pos >= tape->bttb_data + tape->bttb_top)
|
||||
{
|
||||
@@ -554,12 +554,12 @@ _bt_tapeadd(BTTapeBlock * tape, BTItem item, int itemsz)
|
||||
* create and initialize a spool structure, including the underlying
|
||||
* files.
|
||||
*/
|
||||
void *
|
||||
void *
|
||||
_bt_spoolinit(Relation index, int ntapes, bool isunique)
|
||||
{
|
||||
BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool));
|
||||
int i;
|
||||
char *fname = (char *) palloc(sizeof(TAPETEMP) + 1);
|
||||
BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool));
|
||||
int i;
|
||||
char *fname = (char *) palloc(sizeof(TAPETEMP) + 1);
|
||||
|
||||
if (btspool == (BTSpool *) NULL || fname == (char *) NULL)
|
||||
{
|
||||
@@ -600,8 +600,8 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique)
|
||||
void
|
||||
_bt_spooldestroy(void *spool)
|
||||
{
|
||||
BTSpool *btspool = (BTSpool *) spool;
|
||||
int i;
|
||||
BTSpool *btspool = (BTSpool *) spool;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < btspool->bts_ntapes; ++i)
|
||||
{
|
||||
@@ -617,7 +617,7 @@ _bt_spooldestroy(void *spool)
|
||||
static void
|
||||
_bt_spoolflush(BTSpool * btspool)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < btspool->bts_ntapes; ++i)
|
||||
{
|
||||
@@ -637,10 +637,10 @@ _bt_spoolflush(BTSpool * btspool)
|
||||
static void
|
||||
_bt_spoolswap(BTSpool * btspool)
|
||||
{
|
||||
File tmpfd;
|
||||
BTTapeBlock *itape;
|
||||
BTTapeBlock *otape;
|
||||
int i;
|
||||
File tmpfd;
|
||||
BTTapeBlock *itape;
|
||||
BTTapeBlock *otape;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < btspool->bts_ntapes; ++i)
|
||||
{
|
||||
@@ -682,9 +682,9 @@ _bt_spoolswap(BTSpool * btspool)
|
||||
void
|
||||
_bt_spool(Relation index, BTItem btitem, void *spool)
|
||||
{
|
||||
BTSpool *btspool = (BTSpool *) spool;
|
||||
BTTapeBlock *itape;
|
||||
Size itemsz;
|
||||
BTSpool *btspool = (BTSpool *) spool;
|
||||
BTTapeBlock *itape;
|
||||
Size itemsz;
|
||||
|
||||
_bt_isortcmpinit(index, btspool);
|
||||
|
||||
@@ -699,13 +699,13 @@ _bt_spool(Relation index, BTItem btitem, void *spool)
|
||||
*/
|
||||
if (btitem == (BTItem) NULL || SPCLEFT(itape) < itemsz)
|
||||
{
|
||||
BTSortKey *parray = (BTSortKey *) NULL;
|
||||
BTTapeBlock *otape;
|
||||
BTItem bti;
|
||||
char *pos;
|
||||
int btisz;
|
||||
int it_ntup = itape->bttb_ntup;
|
||||
int i;
|
||||
BTSortKey *parray = (BTSortKey *) NULL;
|
||||
BTTapeBlock *otape;
|
||||
BTItem bti;
|
||||
char *pos;
|
||||
int btisz;
|
||||
int it_ntup = itape->bttb_ntup;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* build an array of pointers to the BTItemDatas on the input
|
||||
@@ -745,9 +745,9 @@ _bt_spool(Relation index, BTItem btitem, void *spool)
|
||||
_bt_tapeadd(otape, bti, btisz);
|
||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_SPOOL)
|
||||
{
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att,
|
||||
&isnull);
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att,
|
||||
&isnull);
|
||||
|
||||
printf("_bt_spool: inserted <%x> into output tape %d\n",
|
||||
d, btspool->bts_tape);
|
||||
@@ -802,7 +802,7 @@ _bt_spool(Relation index, BTItem btitem, void *spool)
|
||||
static void
|
||||
_bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags)
|
||||
{
|
||||
BTPageOpaque opaque;
|
||||
BTPageOpaque opaque;
|
||||
|
||||
*buf = _bt_getbuf(index, P_NEW, BT_WRITE);
|
||||
#if 0
|
||||
@@ -824,10 +824,10 @@ _bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags)
|
||||
static void
|
||||
_bt_slideleft(Relation index, Buffer buf, Page page)
|
||||
{
|
||||
OffsetNumber off;
|
||||
OffsetNumber maxoff;
|
||||
ItemId previi;
|
||||
ItemId thisii;
|
||||
OffsetNumber off;
|
||||
OffsetNumber maxoff;
|
||||
ItemId previi;
|
||||
ItemId thisii;
|
||||
|
||||
if (!PageIsEmpty(page))
|
||||
{
|
||||
@@ -847,10 +847,10 @@ _bt_slideleft(Relation index, Buffer buf, Page page)
|
||||
* allocate and initialize a new BTPageState. the returned structure
|
||||
* is suitable for immediate use by _bt_buildadd.
|
||||
*/
|
||||
static void *
|
||||
static void *
|
||||
_bt_pagestate(Relation index, int flags, int level, bool doupper)
|
||||
{
|
||||
BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState));
|
||||
BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState));
|
||||
|
||||
memset((char *) state, 0, sizeof(BTPageState));
|
||||
_bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags);
|
||||
@@ -870,12 +870,12 @@ _bt_pagestate(Relation index, int flags, int level, bool doupper)
|
||||
* the page to which the item used to point, e.g., a heap page if
|
||||
* 'opage' is a leaf page).
|
||||
*/
|
||||
static BTItem
|
||||
static BTItem
|
||||
_bt_minitem(Page opage, BlockNumber oblkno, int atend)
|
||||
{
|
||||
OffsetNumber off;
|
||||
BTItem obti;
|
||||
BTItem nbti;
|
||||
OffsetNumber off;
|
||||
BTItem obti;
|
||||
BTItem nbti;
|
||||
|
||||
off = atend ? P_HIKEY : P_FIRSTKEY;
|
||||
obti = (BTItem) PageGetItem(opage, PageGetItemId(opage, off));
|
||||
@@ -924,18 +924,18 @@ _bt_minitem(Page opage, BlockNumber oblkno, int atend)
|
||||
*
|
||||
* if all keys are unique, 'first' will always be the same as 'last'.
|
||||
*/
|
||||
static BTItem
|
||||
static BTItem
|
||||
_bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||
{
|
||||
BTPageState *state = (BTPageState *) pstate;
|
||||
Buffer nbuf;
|
||||
Page npage;
|
||||
BTItem last_bti;
|
||||
OffsetNumber first_off;
|
||||
OffsetNumber last_off;
|
||||
OffsetNumber off;
|
||||
Size pgspc;
|
||||
Size btisz;
|
||||
BTPageState *state = (BTPageState *) pstate;
|
||||
Buffer nbuf;
|
||||
Page npage;
|
||||
BTItem last_bti;
|
||||
OffsetNumber first_off;
|
||||
OffsetNumber last_off;
|
||||
OffsetNumber off;
|
||||
Size pgspc;
|
||||
Size btisz;
|
||||
|
||||
nbuf = state->btps_buf;
|
||||
npage = state->btps_page;
|
||||
@@ -948,12 +948,12 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||
btisz = DOUBLEALIGN(btisz);
|
||||
if (pgspc < btisz)
|
||||
{
|
||||
Buffer obuf = nbuf;
|
||||
Page opage = npage;
|
||||
OffsetNumber o,
|
||||
n;
|
||||
ItemId ii;
|
||||
ItemId hii;
|
||||
Buffer obuf = nbuf;
|
||||
Page opage = npage;
|
||||
OffsetNumber o,
|
||||
n;
|
||||
ItemId ii;
|
||||
ItemId hii;
|
||||
|
||||
_bt_blnewpage(index, &nbuf, &npage, flags);
|
||||
|
||||
@@ -989,11 +989,11 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||
#if 0
|
||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||
{
|
||||
bool isnull;
|
||||
BTItem tmpbti =
|
||||
bool isnull;
|
||||
BTItem tmpbti =
|
||||
(BTItem) PageGetItem(npage, PageGetItemId(npage, n));
|
||||
Datum d = index_getattr(&(tmpbti->bti_itup), 1,
|
||||
index->rd_att, &isnull);
|
||||
Datum d = index_getattr(&(tmpbti->bti_itup), 1,
|
||||
index->rd_att, &isnull);
|
||||
|
||||
printf("_bt_buildadd: moved <%x> to offset %d at level %d\n",
|
||||
d, n, state->btps_level);
|
||||
@@ -1026,8 +1026,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||
* set the page (side link) pointers.
|
||||
*/
|
||||
{
|
||||
BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage);
|
||||
BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage);
|
||||
BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage);
|
||||
BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage);
|
||||
|
||||
oopaque->btpo_next = BufferGetBlockNumber(nbuf);
|
||||
nopaque->btpo_prev = BufferGetBlockNumber(obuf);
|
||||
@@ -1047,7 +1047,7 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||
*/
|
||||
if (state->btps_doupper)
|
||||
{
|
||||
BTItem nbti;
|
||||
BTItem nbti;
|
||||
|
||||
if (state->btps_next == (BTPageState *) NULL)
|
||||
{
|
||||
@@ -1077,8 +1077,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||
#if 0
|
||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||
{
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull);
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull);
|
||||
|
||||
printf("_bt_buildadd: inserted <%x> at offset %d at level %d\n",
|
||||
d, off, state->btps_level);
|
||||
@@ -1109,10 +1109,10 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
||||
static void
|
||||
_bt_uppershutdown(Relation index, BTPageState * state)
|
||||
{
|
||||
BTPageState *s;
|
||||
BlockNumber blkno;
|
||||
BTPageOpaque opaque;
|
||||
BTItem bti;
|
||||
BTPageState *s;
|
||||
BlockNumber blkno;
|
||||
BTPageOpaque opaque;
|
||||
BTItem bti;
|
||||
|
||||
for (s = state; s != (BTPageState *) NULL; s = s->btps_next)
|
||||
{
|
||||
@@ -1160,21 +1160,21 @@ _bt_uppershutdown(Relation index, BTPageState * state)
|
||||
static void
|
||||
_bt_merge(Relation index, BTSpool * btspool)
|
||||
{
|
||||
BTPageState *state;
|
||||
BTPriQueue q;
|
||||
BTPriQueueElem e;
|
||||
BTSortKey btsk;
|
||||
BTItem bti;
|
||||
BTTapeBlock *itape;
|
||||
BTTapeBlock *otape;
|
||||
char *tapepos[MAXTAPES];
|
||||
int tapedone[MAXTAPES];
|
||||
int t;
|
||||
int goodtapes;
|
||||
int npass;
|
||||
int nruns;
|
||||
Size btisz;
|
||||
bool doleaf = false;
|
||||
BTPageState *state;
|
||||
BTPriQueue q;
|
||||
BTPriQueueElem e;
|
||||
BTSortKey btsk;
|
||||
BTItem bti;
|
||||
BTTapeBlock *itape;
|
||||
BTTapeBlock *otape;
|
||||
char *tapepos[MAXTAPES];
|
||||
int tapedone[MAXTAPES];
|
||||
int t;
|
||||
int goodtapes;
|
||||
int npass;
|
||||
int nruns;
|
||||
Size btisz;
|
||||
bool doleaf = false;
|
||||
|
||||
/*
|
||||
* initialize state needed for the merge into the btree leaf pages.
|
||||
@@ -1279,8 +1279,8 @@ _bt_merge(Relation index, BTSpool * btspool)
|
||||
_bt_buildadd(index, state, bti, BTP_LEAF);
|
||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||
{
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1,
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1,
|
||||
index->rd_att, &isnull);
|
||||
|
||||
printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into block %d\n",
|
||||
@@ -1308,8 +1308,8 @@ _bt_merge(Relation index, BTSpool * btspool)
|
||||
_bt_tapeadd(otape, bti, btisz);
|
||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||
{
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1,
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(bti->bti_itup), 1,
|
||||
index->rd_att, &isnull);
|
||||
|
||||
printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into output tape %d\n",
|
||||
@@ -1328,7 +1328,7 @@ _bt_merge(Relation index, BTSpool * btspool)
|
||||
itape = btspool->bts_itape[t];
|
||||
if (!tapedone[t])
|
||||
{
|
||||
BTItem newbti = _bt_tapenext(itape, &tapepos[t]);
|
||||
BTItem newbti = _bt_tapenext(itape, &tapepos[t]);
|
||||
|
||||
if (newbti == (BTItem) NULL)
|
||||
{
|
||||
@@ -1347,7 +1347,7 @@ _bt_merge(Relation index, BTSpool * btspool)
|
||||
}
|
||||
if (newbti != (BTItem) NULL)
|
||||
{
|
||||
BTPriQueueElem nexte;
|
||||
BTPriQueueElem nexte;
|
||||
|
||||
nexte.btpqe_tape = t;
|
||||
_bt_setsortkey(index, newbti, &(nexte.btpqe_item));
|
||||
@@ -1397,12 +1397,12 @@ _bt_merge(Relation index, BTSpool * btspool)
|
||||
void
|
||||
_bt_upperbuild(Relation index)
|
||||
{
|
||||
Buffer rbuf;
|
||||
BlockNumber blk;
|
||||
Page rpage;
|
||||
BTPageOpaque ropaque;
|
||||
BTPageState *state;
|
||||
BTItem nbti;
|
||||
Buffer rbuf;
|
||||
BlockNumber blk;
|
||||
Page rpage;
|
||||
BTPageOpaque ropaque;
|
||||
BTPageState *state;
|
||||
BTItem nbti;
|
||||
|
||||
/*
|
||||
* find the first leaf block. while we're at it, clear the BTP_ROOT
|
||||
@@ -1438,9 +1438,9 @@ _bt_upperbuild(Relation index)
|
||||
nbti = _bt_minitem(rpage, blk, P_RIGHTMOST(ropaque));
|
||||
#if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE)
|
||||
{
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att,
|
||||
&isnull);
|
||||
bool isnull;
|
||||
Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att,
|
||||
&isnull);
|
||||
|
||||
printf("_bt_upperbuild: inserting <%x> at %d\n",
|
||||
d, state->btps_level);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.5 1997/09/07 04:39:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.6 1997/09/08 02:20:59 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ static StrategyNumber BTNegateCommute[5] = {
|
||||
BTGreaterEqualStrategyNumber
|
||||
};
|
||||
|
||||
static uint16 BTLessTermData[] = { /* XXX type clash */
|
||||
static uint16 BTLessTermData[] = { /* XXX type clash */
|
||||
2,
|
||||
BTLessStrategyNumber,
|
||||
SK_NEGATE,
|
||||
@@ -55,7 +55,7 @@ static uint16 BTLessTermData[] = { /* XXX type clash */
|
||||
SK_NEGATE | SK_COMMUTE
|
||||
};
|
||||
|
||||
static uint16 BTLessEqualTermData[] = { /* XXX type clash */
|
||||
static uint16 BTLessEqualTermData[] = { /* XXX type clash */
|
||||
2,
|
||||
BTLessEqualStrategyNumber,
|
||||
0x0,
|
||||
@@ -63,7 +63,7 @@ static uint16 BTLessEqualTermData[] = { /* XXX type clash */
|
||||
SK_COMMUTE
|
||||
};
|
||||
|
||||
static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */
|
||||
static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */
|
||||
2,
|
||||
BTGreaterEqualStrategyNumber,
|
||||
0x0,
|
||||
@@ -71,7 +71,7 @@ static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */
|
||||
SK_COMMUTE
|
||||
};
|
||||
|
||||
static uint16 BTGreaterTermData[] = { /* XXX type clash */
|
||||
static uint16 BTGreaterTermData[] = { /* XXX type clash */
|
||||
2,
|
||||
BTGreaterStrategyNumber,
|
||||
SK_NEGATE,
|
||||
@@ -109,7 +109,7 @@ _bt_getstrat(Relation rel,
|
||||
AttrNumber attno,
|
||||
RegProcedure proc)
|
||||
{
|
||||
StrategyNumber strat;
|
||||
StrategyNumber strat;
|
||||
|
||||
strat = RelationGetStrategy(rel, attno, &BTEvaluationData, proc);
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.12 1997/09/07 04:39:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.13 1997/09/08 02:21:01 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <catalog/pg_proc.h>
|
||||
#include <executor/execdebug.h>
|
||||
|
||||
extern int NIndexTupleProcessed;
|
||||
extern int NIndexTupleProcessed;
|
||||
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
@@ -35,14 +35,14 @@ extern int NIndexTupleProcessed;
|
||||
ScanKey
|
||||
_bt_mkscankey(Relation rel, IndexTuple itup)
|
||||
{
|
||||
ScanKey skey;
|
||||
TupleDesc itupdesc;
|
||||
int natts;
|
||||
int i;
|
||||
Datum arg;
|
||||
RegProcedure proc;
|
||||
bool null;
|
||||
bits16 flag;
|
||||
ScanKey skey;
|
||||
TupleDesc itupdesc;
|
||||
int natts;
|
||||
int i;
|
||||
Datum arg;
|
||||
RegProcedure proc;
|
||||
bool null;
|
||||
bits16 flag;
|
||||
|
||||
natts = rel->rd_rel->relnatts;
|
||||
itupdesc = RelationGetTupleDescriptor(rel);
|
||||
@@ -78,7 +78,7 @@ _bt_freeskey(ScanKey skey)
|
||||
void
|
||||
_bt_freestack(BTStack stack)
|
||||
{
|
||||
BTStack ostack;
|
||||
BTStack ostack;
|
||||
|
||||
while (stack != (BTStack) NULL)
|
||||
{
|
||||
@@ -99,18 +99,18 @@ _bt_freestack(BTStack stack)
|
||||
void
|
||||
_bt_orderkeys(Relation relation, BTScanOpaque so)
|
||||
{
|
||||
ScanKey xform;
|
||||
ScanKeyData *cur;
|
||||
StrategyMap map;
|
||||
int nbytes;
|
||||
long test;
|
||||
int i,
|
||||
j;
|
||||
int init[BTMaxStrategyNumber + 1];
|
||||
ScanKey key;
|
||||
uint16 numberOfKeys = so->numberOfKeys;
|
||||
uint16 new_numberOfKeys = 0;
|
||||
AttrNumber attno = 1;
|
||||
ScanKey xform;
|
||||
ScanKeyData *cur;
|
||||
StrategyMap map;
|
||||
int nbytes;
|
||||
long test;
|
||||
int i,
|
||||
j;
|
||||
int init[BTMaxStrategyNumber + 1];
|
||||
ScanKey key;
|
||||
uint16 numberOfKeys = so->numberOfKeys;
|
||||
uint16 new_numberOfKeys = 0;
|
||||
AttrNumber attno = 1;
|
||||
|
||||
if (numberOfKeys < 1)
|
||||
return;
|
||||
@@ -169,8 +169,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
||||
*/
|
||||
if (init[BTEqualStrategyNumber - 1])
|
||||
{
|
||||
ScanKeyData *eq,
|
||||
*chk;
|
||||
ScanKeyData *eq,
|
||||
*chk;
|
||||
|
||||
eq = &xform[BTEqualStrategyNumber - 1];
|
||||
for (j = BTMaxStrategyNumber; --j >= 0;)
|
||||
@@ -192,8 +192,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
||||
if (init[BTLessStrategyNumber - 1]
|
||||
&& init[BTLessEqualStrategyNumber - 1])
|
||||
{
|
||||
ScanKeyData *lt,
|
||||
*le;
|
||||
ScanKeyData *lt,
|
||||
*le;
|
||||
|
||||
lt = &xform[BTLessStrategyNumber - 1];
|
||||
le = &xform[BTLessEqualStrategyNumber - 1];
|
||||
@@ -216,8 +216,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
||||
if (init[BTGreaterStrategyNumber - 1]
|
||||
&& init[BTGreaterEqualStrategyNumber - 1])
|
||||
{
|
||||
ScanKeyData *gt,
|
||||
*ge;
|
||||
ScanKeyData *gt,
|
||||
*ge;
|
||||
|
||||
gt = &xform[BTGreaterStrategyNumber - 1];
|
||||
ge = &xform[BTGreaterEqualStrategyNumber - 1];
|
||||
@@ -288,10 +288,10 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
|
||||
BTItem
|
||||
_bt_formitem(IndexTuple itup)
|
||||
{
|
||||
int nbytes_btitem;
|
||||
BTItem btitem;
|
||||
Size tuplen;
|
||||
extern Oid newoid();
|
||||
int nbytes_btitem;
|
||||
BTItem btitem;
|
||||
Size tuplen;
|
||||
extern Oid newoid();
|
||||
|
||||
/*
|
||||
* see comments in btbuild
|
||||
@@ -318,7 +318,7 @@ _bt_formitem(IndexTuple itup)
|
||||
bool
|
||||
_bt_checkqual(IndexScanDesc scan, IndexTuple itup)
|
||||
{
|
||||
BTScanOpaque so;
|
||||
BTScanOpaque so;
|
||||
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
if (so->numberOfKeys > 0)
|
||||
@@ -334,7 +334,7 @@ _bt_checkqual(IndexScanDesc scan, IndexTuple itup)
|
||||
bool
|
||||
_bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz)
|
||||
{
|
||||
BTScanOpaque so;
|
||||
BTScanOpaque so;
|
||||
|
||||
so = (BTScanOpaque) scan->opaque;
|
||||
if (keysz > 0 && so->numberOfKeys >= keysz)
|
||||
@@ -349,13 +349,13 @@ _bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz)
|
||||
bool
|
||||
_bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size * keysok)
|
||||
{
|
||||
BTScanOpaque so = (BTScanOpaque) scan->opaque;
|
||||
Size keysz = so->numberOfKeys;
|
||||
TupleDesc tupdesc;
|
||||
ScanKey key;
|
||||
Datum datum;
|
||||
bool isNull;
|
||||
int test;
|
||||
BTScanOpaque so = (BTScanOpaque) scan->opaque;
|
||||
Size keysz = so->numberOfKeys;
|
||||
TupleDesc tupdesc;
|
||||
ScanKey key;
|
||||
Datum datum;
|
||||
bool isNull;
|
||||
int test;
|
||||
|
||||
*keysok = 0;
|
||||
if (keysz == 0)
|
||||
|
Reference in New Issue
Block a user