1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

heap_fetch requires buffer pointer, must be released; heap_getnext

no longer returns buffer pointer, can be gotten from scan;
	descriptor; bootstrap can create multi-key indexes;
pg_procname index now is multi-key index; oidint2, oidint4, oidname
are gone (must be removed from regression tests); use System Cache
rather than sequential scan in many places; heap_modifytuple no
longer takes buffer parameter; remove unused buffer parameter in
a few other functions; oid8 is not index-able; remove some use of
single-character variable names; cleanup Buffer variables usage
and scan descriptor looping; cleaned up allocation and freeing of
tuples; 18k lines of diff;
This commit is contained in:
Bruce Momjian
1998-08-19 02:04:17 +00:00
parent 31de2c9461
commit 7971539020
123 changed files with 2139 additions and 3134 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.16 1998/04/26 04:05:19 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.17 1998/08/19 02:01:13 momjian Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
@@ -30,81 +30,96 @@
int32
btint2cmp(int16 a, int16 b)
{
return ((int32) (a - b));
return (int32) (a - b);
}
int32
btint4cmp(int32 a, int32 b)
{
return (a - b);
return a - b;
}
int32
btint24cmp(int16 a, int32 b)
{
return (((int32) a) - b);
return ((int32) a) - b;
}
int32
btint42cmp(int32 a, int16 b)
{
return (a - ((int32) b));
return a - ((int32) b);
}
int32
btfloat4cmp(float32 a, float32 b)
{
if (*a > *b)
return (1);
return 1;
else if (*a == *b)
return (0);
return 0;
else
return (-1);
return -1;
}
int32
btfloat8cmp(float64 a, float64 b)
{
if (*a > *b)
return (1);
return 1;
else if (*a == *b)
return (0);
return 0;
else
return (-1);
return -1;
}
int32
btoidcmp(Oid a, Oid b)
{
if (a > b)
return (1);
return 1;
else if (a == b)
return (0);
return 0;
else
return (-1);
return -1;
}
int32
btoid8cmp(Oid a[], Oid b[])
{
int i;
for (i=0; i < 8; i++)
/* we use this because we need the int4gt, etc */
if (!int4eq(a[i], b[i]))
if (int4gt(a[i], b[i]))
return 1;
else
return -1;
return 0;
}
int32
btabstimecmp(AbsoluteTime a, AbsoluteTime b)
{
if (AbsoluteTimeIsBefore(a, b))
return (-1);
return -1;
else if (AbsoluteTimeIsBefore(b, a))
return (1);
return 1;
else
return (0);
return 0;
}
int32
btcharcmp(char a, char b)
{
return ((int32) ((uint8) a - (uint8) b));
return (int32) ((uint8) a - (uint8) b);
}
int32
btnamecmp(NameData *a, NameData *b)
{
return (strncmp(a->data, b->data, NAMEDATALEN));
return strncmp(a->data, b->data, NAMEDATALEN);
}
int32
@@ -162,7 +177,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
#endif
if (res != 0 || VARSIZE(a) == VARSIZE(b))
return (res);
return res;
/*
* The two strings are the same in the first len bytes, and they are
@@ -170,7 +185,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
*/
if (VARSIZE(a) < VARSIZE(b))
return (-1);
return -1;
else
return (1);
return 1;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.27 1998/07/27 19:37:39 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.28 1998/08/19 02:01:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,7 +53,8 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
BlockNumber blkno;
int natts = rel->rd_rel->relnatts;
InsertIndexResult res;
Buffer buffer;
itup = &(btitem->bti_itup);
/* we need a scan key to do our search, so build one */
@@ -120,11 +121,12 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
{ /* they're equal */
btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
itup = &(btitem->bti_itup);
htup = heap_fetch(heapRel, SnapshotSelf, &(itup->t_tid), NULL);
htup = heap_fetch(heapRel, SnapshotSelf, &(itup->t_tid), &buffer);
if (htup != (HeapTuple) NULL)
{ /* it is a duplicate */
elog(ERROR, "Cannot insert a duplicate key into a unique index");
}
/* htup null so no buffer to release */
/* get next offnum */
if (offset < maxoff)
offset = OffsetNumberNext(offset);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.28 1998/07/30 05:04:49 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.29 1998/08/19 02:01:16 momjian Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -66,7 +66,6 @@ btbuild(Relation heap,
PredInfo *predInfo)
{
HeapScanDesc hscan;
Buffer buffer;
HeapTuple htup;
IndexTuple itup;
TupleDesc htupdesc,
@@ -113,7 +112,7 @@ btbuild(Relation heap,
#endif
/* see if index is unique */
isunique = IndexIsUniqueNoCache(RelationGetRelationId(index));
isunique = IndexIsUniqueNoCache(RelationGetRelid(index));
/* initialize the btree index metadata page (if this is a new index) */
if (oldPred == NULL)
@@ -155,9 +154,6 @@ btbuild(Relation heap,
#endif /* OMIT_PARTIAL_INDEX */
/* start a heap scan */
hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
htup = heap_getnext(hscan, 0, &buffer);
/* build the index */
nhtups = nitups = 0;
@@ -167,9 +163,10 @@ btbuild(Relation heap,
res = (InsertIndexResult) NULL;
}
for (; HeapTupleIsValid(htup); htup = heap_getnext(hscan, 0, &buffer))
{
hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
while (HeapTupleIsValid(htup = heap_getnext(hscan, 0)))
{
nhtups++;
/*
@@ -228,8 +225,7 @@ btbuild(Relation heap,
attoff,
attnum,
finfo,
&attnull,
buffer);
&attnull);
nulls[attoff] = (attnull ? 'n' : ' ');
}
@@ -323,8 +319,8 @@ btbuild(Relation heap,
*/
if (IsNormalProcessingMode())
{
hrelid = heap->rd_id;
irelid = index->rd_id;
hrelid = RelationGetRelid(heap);
irelid = RelationGetRelid(index);
heap_close(heap);
index_close(index);
UpdateStats(hrelid, nhtups, true);
@@ -371,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
btitem = _bt_formitem(itup);
res = _bt_doinsert(rel, btitem,
IndexIsUnique(RelationGetRelationId(rel)), heapRel);
IndexIsUnique(RelationGetRelid(rel)), heapRel);
pfree(btitem);
pfree(itup);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.15 1998/07/30 05:04:50 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.16 1998/08/19 02:01:17 momjian Exp $
*
*
* NOTES
@@ -96,10 +96,10 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op)
BTScanList l;
Oid relid;
relid = rel->rd_id;
relid = RelationGetRelid(rel);
for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next)
{
if (relid == l->btsl_scan->relation->rd_id)
if (relid == RelationGetRelid(l->btsl_scan->relation))
_bt_scandel(l->btsl_scan, op,
ItemPointerGetBlockNumber(tid),
ItemPointerGetOffsetNumber(tid));

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.20 1998/06/15 19:27:59 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.21 1998/08/19 02:01:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,8 +61,7 @@ _bt_mkscankey(Relation rel, IndexTuple itup)
proc = index_getprocid(rel, i + 1, BTORDER_PROC);
flag = 0x0;
}
ScanKeyEntryInitialize(&skey[i],
flag, (AttrNumber) (i + 1), proc, arg);
ScanKeyEntryInitialize(&skey[i], flag, (AttrNumber) (i + 1), proc, arg);
}
return (skey);