* 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 $
*
*-------------------------------------------------------------------------
*/
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;
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
* 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];
* 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
}
}
- pfree(startKeys);
-
/*
* Examine the selected initial-positioning strategy to determine
* exactly where we need to start the scan, and set flag variables to
/* Only get here if index is completely empty */
ItemPointerSetInvalid(current);
so->btso_curbuf = InvalidBuffer;
- pfree(scankeys);
return false;
}
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