aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/access/nbtree/nbtsearch.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index 824d5ea70e6..42bd6574aaf 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.92 2005/06/13 23:14:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.93 2005/06/19 22:41:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -495,8 +495,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
bool nextkey;
bool goback;
bool continuescan;
- ScanKey scankeys;
- ScanKey *startKeys = NULL;
+ ScanKey startKeys[INDEX_MAX_KEYS];
+ ScanKeyData scankeys[INDEX_MAX_KEYS];
int keysCount = 0;
int i;
StrategyNumber strat_total;
@@ -552,8 +552,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
ScanKey chosen;
ScanKey cur;
- startKeys = (ScanKey *) palloc(so->numberOfKeys * sizeof(ScanKey));
-
/*
* chosen is the so-far-chosen key for the current attribute, if
* any. We don't cast the decision in stone until we reach keys
@@ -636,18 +634,14 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
* scan from there.
*/
if (keysCount == 0)
- {
- if (startKeys)
- pfree(startKeys);
return _bt_endpoint(scan, dir);
- }
/*
* We want to start the scan somewhere within the index. Set up a
* 3-way-comparison scankey we can use to search for the boundary
* point we identified above.
*/
- scankeys = (ScanKey) palloc(keysCount * sizeof(ScanKeyData));
+ Assert(keysCount <= INDEX_MAX_KEYS);
for (i = 0; i < keysCount; i++)
{
ScanKey cur = startKeys[i];
@@ -657,12 +651,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
* code later
*/
if (cur->sk_flags & SK_ISNULL)
- {
- pfree(startKeys);
- pfree(scankeys);
elog(ERROR, "btree doesn't support is(not)null, yet");
- return false;
- }
/*
* If scankey operator is of default subtype, we can use the
@@ -699,8 +688,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
}
}
- pfree(startKeys);
-
/*
* Examine the selected initial-positioning strategy to determine
* exactly where we need to start the scan, and set flag variables to
@@ -809,7 +796,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
/* Only get here if index is completely empty */
ItemPointerSetInvalid(current);
so->btso_curbuf = InvalidBuffer;
- pfree(scankeys);
return false;
}
@@ -823,9 +809,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
blkno = BufferGetBlockNumber(buf);
ItemPointerSet(current, blkno, offnum);
- /* done with manufactured scankey, now */
- pfree(scankeys);
-
/*
* If nextkey = false, we are positioned at the first item >= scan
* key, or possibly at the end of a page on which all the existing