1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Ye-old pgindent run. Same 4-space tabs.

This commit is contained in:
Bruce Momjian
2000-04-12 17:17:23 +00:00
parent db4518729d
commit 52f77df613
434 changed files with 24799 additions and 21246 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.33 2000/02/10 19:51:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.34 2000/04/12 17:14:49 momjian Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
@@ -35,12 +35,12 @@ btint2cmp(int16 a, int16 b)
int32
btint4cmp(int32 a, int32 b)
{
if (a > b)
return 1;
else if (a == b)
return 0;
else
return -1;
if (a > b)
return 1;
else if (a == b)
return 0;
else
return -1;
}
int32

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.56 2000/03/17 02:36:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.57 2000/04/12 17:14:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,10 +21,10 @@
static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem);
static Buffer _bt_split(Relation rel, Size keysz, ScanKey scankey,
Buffer buf, OffsetNumber firstright);
Buffer buf, OffsetNumber firstright);
static OffsetNumber _bt_findsplitloc(Relation rel, Size keysz, ScanKey scankey,
Page page, OffsetNumber start,
OffsetNumber maxoff, Size llimit);
Page page, OffsetNumber start,
OffsetNumber maxoff, Size llimit);
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);
@@ -267,21 +267,20 @@ _bt_insertonpg(Relation rel,
itemsz = IndexTupleDSize(btitem->bti_itup)
+ (sizeof(BTItemData) - sizeof(IndexTupleData));
itemsz = MAXALIGN(itemsz); /* be safe, PageAddItem will do
* this but we need to be
* consistent */
itemsz = MAXALIGN(itemsz); /* be safe, PageAddItem will do this but
* we need to be consistent */
/*
* Check whether the item can fit on a btree page at all.
* (Eventually, we ought to try to apply TOAST methods if not.)
* We actually need to be able to fit three items on every page,
* so restrict any one item to 1/3 the per-page available space.
* Note that at this point, itemsz doesn't include the ItemId.
* Check whether the item can fit on a btree page at all. (Eventually,
* we ought to try to apply TOAST methods if not.) We actually need to
* be able to fit three items on every page, so restrict any one item
* to 1/3 the per-page available space. Note that at this point,
* itemsz doesn't include the ItemId.
*/
if (itemsz > (PageGetPageSize(page)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData))
if (itemsz > (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
elog(ERROR, "btree: index item size %u exceeds maximum %lu",
itemsz,
(PageGetPageSize(page)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData));
(PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));
/*
* If we have to insert item on the leftmost page which is the first
@@ -415,8 +414,8 @@ _bt_insertonpg(Relation rel,
bool is_root = lpageop->btpo_flags & BTP_ROOT;
/*
* Instead of splitting leaf page in the chain of duplicates
* by new duplicate, insert it into some right page.
* Instead of splitting leaf page in the chain of duplicates by
* new duplicate, insert it into some right page.
*/
if ((lpageop->btpo_flags & BTP_CHAIN) &&
(lpageop->btpo_flags & BTP_LEAF) && keys_equal)
@@ -424,8 +423,9 @@ _bt_insertonpg(Relation rel,
rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE);
rpage = BufferGetPage(rbuf);
rpageop = (BTPageOpaque) PageGetSpecialPointer(rpage);
/*
* some checks
/*
* some checks
*/
if (!P_RIGHTMOST(rpageop)) /* non-rightmost page */
{ /* If we have the same hikey here then
@@ -442,6 +442,7 @@ _bt_insertonpg(Relation rel,
BTGreaterStrategyNumber))
elog(FATAL, "btree: hikey is out of order");
else if (rpageop->btpo_flags & BTP_CHAIN)
/*
* If hikey > scankey then it's last page in chain and
* BTP_CHAIN must be OFF
@@ -450,9 +451,7 @@ _bt_insertonpg(Relation rel,
}
else
/* rightmost page */
{
Assert(!(rpageop->btpo_flags & BTP_CHAIN));
}
_bt_relbuf(rel, buf, BT_WRITE);
return (_bt_insertonpg(rel, rbuf, stack, keysz,
scankey, btitem, afteritem));
@@ -708,7 +707,7 @@ l_spl: ;
*/
if (!parent_chained &&
MAXALIGN(IndexTupleDSize(lowLeftItem->bti_itup)) ==
MAXALIGN(IndexTupleDSize(stack->bts_btitem->bti_itup)))
MAXALIGN(IndexTupleDSize(stack->bts_btitem->bti_itup)))
{
_bt_updateitem(rel, keysz, pbuf,
stack->bts_btitem, lowLeftItem);

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.35 2000/01/26 05:55:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.36 2000/04/12 17:14:49 momjian Exp $
*
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
@@ -257,7 +257,7 @@ _bt_getroot(Relation rel, int access)
else
{
rootblkno = metad->btm_root;
_bt_relbuf(rel, metabuf, BT_READ); /* done with the meta page */
_bt_relbuf(rel, metabuf, BT_READ); /* done with the meta page */
rootbuf = _bt_getbuf(rel, rootblkno, access);
}

View File

@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.53 2000/02/18 09:29:54 inoue Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.54 2000/04/12 17:14:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,7 +77,7 @@ btbuild(Relation heap,
#endif
Node *pred,
*oldPred;
BTSpool *spool = NULL;
BTSpool *spool = NULL;
bool isunique;
bool usefast;
@@ -185,7 +185,7 @@ btbuild(Relation heap,
#ifndef OMIT_PARTIAL_INDEX
/* SetSlotContents(slot, htup); */
slot->val = htup;
if (! ExecQual((List *) pred, econtext, false))
if (!ExecQual((List *) pred, econtext, false))
continue;
#endif /* OMIT_PARTIAL_INDEX */
}
@@ -276,9 +276,9 @@ btbuild(Relation heap,
}
/*
* if we are doing bottom-up btree build, finish the build by
* (1) completing the sort of the spool file, (2) inserting the
* sorted tuples into btree pages and (3) building the upper levels.
* if we are doing bottom-up btree build, finish the build by (1)
* completing the sort of the spool file, (2) inserting the sorted
* tuples into btree pages and (3) building the upper levels.
*/
if (usefast)
{
@@ -298,26 +298,27 @@ btbuild(Relation heap,
/*
* Since we just counted the tuples in the heap, we update its stats
* in pg_class to guarantee that the planner takes advantage of the
* index we just created. But, only update statistics during
* normal index definitions, not for indices on system catalogs
* created during bootstrap processing. We must close the relations
* before updating statistics to guarantee that the relcache entries
* are flushed when we increment the command counter in UpdateStats().
* But we do not release any locks on the relations; those will be
* held until end of transaction.
* index we just created. But, only update statistics during normal
* index definitions, not for indices on system catalogs created
* during bootstrap processing. We must close the relations before
* updating statistics to guarantee that the relcache entries are
* flushed when we increment the command counter in UpdateStats(). But
* we do not release any locks on the relations; those will be held
* until end of transaction.
*/
if (IsNormalProcessingMode())
{
Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index);
Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index);
bool inplace = IsReindexProcessing();
heap_close(heap, NoLock);
index_close(index);
/*
UpdateStats(hrelid, nhtups, true);
UpdateStats(irelid, nitups, false);
*/
* UpdateStats(hrelid, nhtups, true); UpdateStats(irelid, nitups,
* false);
*/
UpdateStats(hrelid, nhtups, inplace);
UpdateStats(irelid, nitups, inplace);
if (oldPred != NULL)
@@ -623,7 +624,7 @@ _bt_restscan(IndexScanDesc scan)
BTItem item;
BlockNumber blkno;
LockBuffer(buf, BT_READ); /* lock buffer first! */
LockBuffer(buf, BT_READ); /* lock buffer first! */
page = BufferGetPage(buf);
maxoff = PageGetMaxOffsetNumber(page);
opaque = (BTPageOpaque) PageGetSpecialPointer(page);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.30 2000/01/26 05:55:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.31 2000/04/12 17:14:49 momjian Exp $
*
*
* NOTES
@@ -52,13 +52,16 @@ static void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offn
void
AtEOXact_nbtree(void)
{
/* Note: these actions should only be necessary during xact abort;
* but they can't hurt during a commit.
/*
* Note: these actions should only be necessary during xact abort; but
* they can't hurt during a commit.
*/
/* Reset the active-scans list to empty.
* We do not need to free the list elements, because they're all
* palloc()'d, so they'll go away at end of transaction anyway.
/*
* Reset the active-scans list to empty. We do not need to free the
* list elements, because they're all palloc()'d, so they'll go away
* at end of transaction anyway.
*/
BTScans = NULL;
@@ -96,7 +99,7 @@ _bt_dropscan(IndexScanDesc scan)
last = chk;
if (chk == (BTScanList) NULL)
elog(ERROR, "btree scan list trashed; can't find 0x%p", (void*)scan);
elog(ERROR, "btree scan list trashed; can't find 0x%p", (void *) scan);
if (last == (BTScanList) NULL)
BTScans = chk->btsl_next;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.58 2000/03/17 02:36:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.59 2000/04/12 17:14:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -299,9 +299,7 @@ _bt_skeycmp(Relation rel,
compare = -1; /* not-NULL key "<" NULL datum */
}
else
{
compare = (int32) FMGR_PTR2(&entry->sk_func, keyDatum, attrDatum);
}
if (compare != 0)
break; /* done when we find unequal attributes */
@@ -368,26 +366,26 @@ _bt_binsrch(Relation rel,
/*
* If there are no keys on the page, return the first available slot.
* Note this covers two cases: the page is really empty (no keys),
* or it contains only a high key. The latter case is possible after
* Note this covers two cases: the page is really empty (no keys), or
* it contains only a high key. The latter case is possible after
* vacuuming.
*/
if (high < low)
return low;
/*
* Binary search to find the first key on the page >= scan key.
* Loop invariant: all slots before 'low' are < scan key, all slots
* at or after 'high' are >= scan key. Also, haveEq is true if the
* tuple at 'high' is == scan key.
* We can fall out when high == low.
* Binary search to find the first key on the page >= scan key. Loop
* invariant: all slots before 'low' are < scan key, all slots at or
* after 'high' are >= scan key. Also, haveEq is true if the tuple at
* 'high' is == scan key. We can fall out when high == low.
*/
high++; /* establish the loop invariant for high */
haveEq = false;
while (high > low)
{
OffsetNumber mid = low + ((high - low) / 2);
OffsetNumber mid = low + ((high - low) / 2);
/* We have low <= mid < high, so mid points at a real slot */
result = _bt_compare(rel, itupdesc, page, keysz, scankey, mid);
@@ -403,7 +401,7 @@ _bt_binsrch(Relation rel,
/*--------------------
* At this point we have high == low, but be careful: they could point
* past the last slot on the page. We also know that haveEq is true
* past the last slot on the page. We also know that haveEq is true
* if and only if there is an equal key (in which case high&low point
* at the first equal key).
*
@@ -443,18 +441,20 @@ _bt_binsrch(Relation rel,
if (haveEq)
{
/*
* There is an equal key. We return either the first equal key
* (which we just found), or the last lesser key.
*
* We need not check srchtype != BT_DESCENT here, since if that
* is true then natts == keysz by assumption.
* We need not check srchtype != BT_DESCENT here, since if that is
* true then natts == keysz by assumption.
*/
if (natts == keysz)
return low; /* return first equal key */
}
else
{
/*
* There is no equal key. We return either the first greater key
* (which we just found), or the last lesser key.
@@ -524,6 +524,7 @@ _bt_compare(Relation rel,
&& P_LEFTMOST(opaque)
&& offnum == P_HIKEY)
{
/*
* we just have to believe that this will only be called with
* offnum == P_HIKEY when P_HIKEY is the OffsetNumber of the first
@@ -702,11 +703,12 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
bool strategyCheck;
ScanKey scankeys = 0;
int keysCount = 0;
int *nKeyIs = 0;
int i, j;
StrategyNumber strat_total;
int keysCount = 0;
int *nKeyIs = 0;
int i,
j;
StrategyNumber strat_total;
rel = scan->relation;
so = (BTScanOpaque) scan->opaque;
@@ -723,15 +725,15 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
_bt_orderkeys(rel, so);
if (so->qual_ok)
strategyCheck = true;
}
strategyCheck = true;
}
strat_total = BTEqualStrategyNumber;
if (strategyCheck)
{
AttrNumber attno;
nKeyIs = (int *)palloc(so->numberOfKeys*sizeof(int));
for (i=0; i < so->numberOfKeys; i++)
nKeyIs = (int *) palloc(so->numberOfKeys * sizeof(int));
for (i = 0; i < so->numberOfKeys; i++)
{
attno = so->keyData[i].sk_attno;
if (attno == keysCount)
@@ -739,16 +741,16 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
if (attno > keysCount + 1)
break;
strat = _bt_getstrat(rel, attno,
so->keyData[i].sk_procedure);
so->keyData[i].sk_procedure);
if (strat == strat_total ||
strat == BTEqualStrategyNumber)
strat == BTEqualStrategyNumber)
{
nKeyIs[keysCount++] = i;
continue;
}
if (ScanDirectionIsBackward(dir) &&
(strat == BTLessStrategyNumber ||
strat == BTLessEqualStrategyNumber) )
(strat == BTLessStrategyNumber ||
strat == BTLessEqualStrategyNumber))
{
nKeyIs[keysCount++] = i;
strat_total = strat;
@@ -757,8 +759,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
continue;
}
if (ScanDirectionIsForward(dir) &&
(strat == BTGreaterStrategyNumber ||
strat == BTGreaterEqualStrategyNumber) )
(strat == BTGreaterStrategyNumber ||
strat == BTGreaterEqualStrategyNumber))
{
nKeyIs[keysCount++] = i;
strat_total = strat;
@@ -794,8 +796,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
* at the right place in the scan.
*/
/* _bt_orderkeys disallows it, but it's place to add some code latter */
scankeys = (ScanKey)palloc(keysCount*sizeof(ScanKeyData));
for (i=0; i < keysCount; i++)
scankeys = (ScanKey) palloc(keysCount * sizeof(ScanKeyData));
for (i = 0; i < keysCount; i++)
{
j = nKeyIs[i];
if (so->keyData[j].sk_flags & SK_ISNULL)
@@ -804,12 +806,13 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
pfree(scankeys);
elog(ERROR, "_bt_first: btree doesn't support is(not)null, yet");
return ((RetrieveIndexResult) NULL);
}
proc = index_getprocid(rel, i+1, BTORDER_PROC);
ScanKeyEntryInitialize(scankeys+i, so->keyData[j].sk_flags,
i+1, proc, so->keyData[j].sk_argument);
}
proc = index_getprocid(rel, i + 1, BTORDER_PROC);
ScanKeyEntryInitialize(scankeys + i, so->keyData[j].sk_flags,
i + 1, proc, so->keyData[j].sk_argument);
}
if (nKeyIs) pfree(nKeyIs);
if (nKeyIs)
pfree(nKeyIs);
stack = _bt_search(rel, keysCount, scankeys, &buf);
_bt_freestack(stack);

View File

@@ -6,7 +6,7 @@
*
* We use tuplesort.c to sort the given index tuples into order.
* Then we scan the index tuples in order and build the btree pages
* for each level. When we have only one page on a level, it must be the
* for each level. When we have only one page on a level, it must be the
* root -- it can be attached to the btree metapage and we are done.
*
* this code is moderately slow (~10% slower) compared to the regular
@@ -28,7 +28,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.51 2000/02/18 06:32:39 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.52 2000/04/12 17:14:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,12 +70,12 @@ struct BTSpool
static void _bt_load(Relation index, BTSpool *btspool);
static BTItem _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
BTPageState *state, BTItem bti, int flags);
BTPageState *state, BTItem bti, int flags);
static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend);
static BTPageState *_bt_pagestate(Relation index, int flags,
int level, bool doupper);
int level, bool doupper);
static void _bt_uppershutdown(Relation index, Size keysz, ScanKey scankey,
BTPageState *state);
BTPageState *state);
/*
@@ -86,7 +86,7 @@ static void _bt_uppershutdown(Relation index, Size keysz, ScanKey scankey,
/*
* create and initialize a spool structure
*/
BTSpool *
BTSpool *
_bt_spoolinit(Relation index, bool isunique)
{
BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool));
@@ -99,9 +99,9 @@ _bt_spoolinit(Relation index, bool isunique)
btspool->sortstate = tuplesort_begin_index(index, isunique, false);
/*
* Currently, tuplesort provides sort functions on IndexTuples.
* If we kept anything in a BTItem other than a regular IndexTuple,
* we'd need to modify tuplesort to understand BTItems as such.
* Currently, tuplesort provides sort functions on IndexTuples. If we
* kept anything in a BTItem other than a regular IndexTuple, we'd
* need to modify tuplesort to understand BTItems as such.
*/
Assert(sizeof(BTItemData) == sizeof(IndexTupleData));
@@ -306,20 +306,20 @@ _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
btisz = MAXALIGN(btisz);
/*
* Check whether the item can fit on a btree page at all.
* (Eventually, we ought to try to apply TOAST methods if not.)
* We actually need to be able to fit three items on every page,
* so restrict any one item to 1/3 the per-page available space.
* Note that at this point, btisz doesn't include the ItemId.
* Check whether the item can fit on a btree page at all. (Eventually,
* we ought to try to apply TOAST methods if not.) We actually need to
* be able to fit three items on every page, so restrict any one item
* to 1/3 the per-page available space. Note that at this point, btisz
* doesn't include the ItemId.
*
* NOTE: similar code appears in _bt_insertonpg() to defend against
* oversize items being inserted into an already-existing index.
* But during creation of an index, we don't go through there.
* oversize items being inserted into an already-existing index. But
* during creation of an index, we don't go through there.
*/
if (btisz > (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData))
if (btisz > (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData))
elog(ERROR, "btree: index item size %d exceeds maximum %ld",
btisz,
(PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3 - sizeof(ItemIdData));
(PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));
if (pgspc < btisz)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.35 2000/02/18 06:32:39 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.36 2000/04/12 17:14:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -141,7 +141,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
uint16 numberOfKeys = so->numberOfKeys;
uint16 new_numberOfKeys = 0;
AttrNumber attno = 1;
bool equalStrategyEnd, underEqualStrategy;
bool equalStrategyEnd,
underEqualStrategy;
if (numberOfKeys < 1)
return;
@@ -194,6 +195,7 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
elog(ERROR, "_bt_orderkeys: key(s) for attribute %d missed", attno + 1);
underEqualStrategy = (!equalStrategyEnd);
/*
* If = has been specified, no other key will be used. In case
* of key < 2 && key == 1 and so on we have to set qual_ok to