Commit 79715390 authored by Bruce Momjian's avatar Bruce Momjian

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;
parent 31de2c94
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.38 1998/06/15 19:27:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.39 1998/08/19 02:00:53 momjian Exp $
* *
* NOTES * NOTES
* The old interface functions have been converted to macros * The old interface functions have been converted to macros
...@@ -736,13 +736,6 @@ heap_copytuple(HeapTuple tuple) ...@@ -736,13 +736,6 @@ heap_copytuple(HeapTuple tuple)
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
return (NULL); return (NULL);
/* XXX For now, just prevent an undetectable executor related error */
if (tuple->t_len > MAXTUPLEN)
{
elog(ERROR, "palloctup: cannot handle length %d tuples",
tuple->t_len);
}
newTuple = (HeapTuple) palloc(tuple->t_len); newTuple = (HeapTuple) palloc(tuple->t_len);
memmove((char *) newTuple, (char *) tuple, (int) tuple->t_len); memmove((char *) newTuple, (char *) tuple, (int) tuple->t_len);
return (newTuple); return (newTuple);
...@@ -863,11 +856,11 @@ heap_formtuple(TupleDesc tupleDescriptor, ...@@ -863,11 +856,11 @@ heap_formtuple(TupleDesc tupleDescriptor,
* heap_modifytuple * heap_modifytuple
* *
* forms a new tuple from an old tuple and a set of replacement values. * forms a new tuple from an old tuple and a set of replacement values.
* returns a new palloc'ed tuple.
* ---------------- * ----------------
*/ */
HeapTuple HeapTuple
heap_modifytuple(HeapTuple tuple, heap_modifytuple(HeapTuple tuple,
Buffer buffer,
Relation relation, Relation relation,
Datum replValue[], Datum replValue[],
char replNull[], char replNull[],
...@@ -879,7 +872,6 @@ heap_modifytuple(HeapTuple tuple, ...@@ -879,7 +872,6 @@ heap_modifytuple(HeapTuple tuple,
char *nulls; char *nulls;
bool isNull; bool isNull;
HeapTuple newTuple; HeapTuple newTuple;
int madecopy;
uint8 infomask; uint8 infomask;
/* ---------------- /* ----------------
...@@ -887,26 +879,11 @@ heap_modifytuple(HeapTuple tuple, ...@@ -887,26 +879,11 @@ heap_modifytuple(HeapTuple tuple,
* ---------------- * ----------------
*/ */
Assert(HeapTupleIsValid(tuple)); Assert(HeapTupleIsValid(tuple));
Assert(BufferIsValid(buffer) || RelationIsValid(relation)); Assert(RelationIsValid(relation));
Assert(HeapTupleIsValid(tuple));
Assert(PointerIsValid(replValue)); Assert(PointerIsValid(replValue));
Assert(PointerIsValid(replNull)); Assert(PointerIsValid(replNull));
Assert(PointerIsValid(repl)); Assert(PointerIsValid(repl));
/* ----------------
* if we're pointing to a disk page, then first
* make a copy of our tuple so that all the attributes
* are available. XXX this is inefficient -cim
* ----------------
*/
madecopy = 0;
if (BufferIsValid(buffer) == true)
{
relation = (Relation) BufferGetRelation(buffer);
tuple = heap_copytuple(tuple);
madecopy = 1;
}
numberOfAttributes = RelationGetRelationTupleForm(relation)->relnatts; numberOfAttributes = RelationGetRelationTupleForm(relation)->relnatts;
/* ---------------- /* ----------------
...@@ -933,10 +910,7 @@ heap_modifytuple(HeapTuple tuple, ...@@ -933,10 +910,7 @@ heap_modifytuple(HeapTuple tuple,
} }
else if (repl[attoff] != 'r') else if (repl[attoff] != 'r')
{
elog(ERROR, "heap_modifytuple: repl is \\%3d", repl[attoff]); elog(ERROR, "heap_modifytuple: repl is \\%3d", repl[attoff]);
}
else else
{ /* == 'r' */ { /* == 'r' */
value[attoff] = replValue[attoff]; value[attoff] = replValue[attoff];
...@@ -961,18 +935,8 @@ heap_modifytuple(HeapTuple tuple, ...@@ -961,18 +935,8 @@ heap_modifytuple(HeapTuple tuple,
(char *) &tuple->t_oid, (char *) &tuple->t_oid,
((char *) &tuple->t_hoff - (char *) &tuple->t_oid)); /* XXX */ ((char *) &tuple->t_hoff - (char *) &tuple->t_oid)); /* XXX */
newTuple->t_infomask = infomask; newTuple->t_infomask = infomask;
newTuple->t_natts = numberOfAttributes; /* fix t_natts just in newTuple->t_natts = numberOfAttributes; /* fix t_natts just in case */
* case */ return newTuple;
/* ----------------
* if we made a copy of the tuple, then free it.
* ----------------
*/
if (madecopy)
pfree(tuple);
return
newTuple;
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.31 1998/07/26 04:30:16 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.32 1998/08/19 02:00:54 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -46,8 +46,7 @@ typtoout(Oid type) ...@@ -46,8 +46,7 @@ typtoout(Oid type)
0, 0, 0); 0, 0, 0);
if (HeapTupleIsValid(typeTuple)) if (HeapTupleIsValid(typeTuple))
return ((Oid) return ((Oid) ((TypeTupleForm) GETSTRUCT(typeTuple))->typoutput);
((TypeTupleForm) GETSTRUCT(typeTuple))->typoutput);
elog(ERROR, "typtoout: Cache lookup of type %d failed", type); elog(ERROR, "typtoout: Cache lookup of type %d failed", type);
return (InvalidOid); return (InvalidOid);
...@@ -63,8 +62,7 @@ gettypelem(Oid type) ...@@ -63,8 +62,7 @@ gettypelem(Oid type)
0, 0, 0); 0, 0, 0);
if (HeapTupleIsValid(typeTuple)) if (HeapTupleIsValid(typeTuple))
return ((Oid) return ((Oid) ((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
elog(ERROR, "typtoout: Cache lookup of type %d failed", type); elog(ERROR, "typtoout: Cache lookup of type %d failed", type);
return (InvalidOid); return (InvalidOid);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.41 1998/07/12 21:29:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.42 1998/08/19 02:00:56 momjian Exp $
* *
* NOTES * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
...@@ -327,7 +327,8 @@ TupleDescInitEntry(TupleDesc desc, ...@@ -327,7 +327,8 @@ TupleDescInitEntry(TupleDesc desc,
* -cim 6/14/90 * -cim 6/14/90
* ---------------- * ----------------
*/ */
tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typeid), tuple = SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(typeid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
{ {
......
...@@ -87,7 +87,6 @@ gistbuild(Relation heap, ...@@ -87,7 +87,6 @@ gistbuild(Relation heap,
PredInfo *predInfo) PredInfo *predInfo)
{ {
HeapScanDesc scan; HeapScanDesc scan;
Buffer buffer;
AttrNumber i; AttrNumber i;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
...@@ -112,14 +111,15 @@ gistbuild(Relation heap, ...@@ -112,14 +111,15 @@ gistbuild(Relation heap,
*oldPred; *oldPred;
GISTSTATE giststate; GISTSTATE giststate;
GISTENTRY tmpcentry; GISTENTRY tmpcentry;
Buffer buffer = InvalidBuffer;
bool *compvec; bool *compvec;
/* GiSTs only know how to do stupid locking now */ /* GiSTs only know how to do stupid locking now */
RelationSetLockForWrite(index); RelationSetLockForWrite(index);
setheapoverride(TRUE); /* so we can see the new pg_index tuple */ setheapoverride(true); /* so we can see the new pg_index tuple */
initGISTstate(&giststate, index); initGISTstate(&giststate, index);
setheapoverride(FALSE); setheapoverride(false);
pred = predInfo->pred; pred = predInfo->pred;
oldPred = predInfo->oldPred; oldPred = predInfo->oldPred;
...@@ -170,15 +170,13 @@ gistbuild(Relation heap, ...@@ -170,15 +170,13 @@ gistbuild(Relation heap,
econtext = NULL; econtext = NULL;
} }
#endif /* OMIT_PARTIAL_INDEX */ #endif /* OMIT_PARTIAL_INDEX */
scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
htup = heap_getnext(scan, 0, &buffer);
/* int the tuples as we insert them */ /* int the tuples as we insert them */
nh = ni = 0; nh = ni = 0;
for (; HeapTupleIsValid(htup); htup = heap_getnext(scan, 0, &buffer)) scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
{
while (HeapTupleIsValid(htup = heap_getnext(scan, 0)))
{
nh++; nh++;
/* /*
...@@ -240,8 +238,7 @@ gistbuild(Relation heap, ...@@ -240,8 +238,7 @@ gistbuild(Relation heap,
attoff, attoff,
attnum, attnum,
finfo, finfo,
&attnull, &attnull);
buffer);
nulls[attoff] = (attnull ? 'n' : ' '); nulls[attoff] = (attnull ? 'n' : ' ');
} }
...@@ -302,8 +299,8 @@ gistbuild(Relation heap, ...@@ -302,8 +299,8 @@ gistbuild(Relation heap,
* flushed. We close them to guarantee that they will be. * flushed. We close them to guarantee that they will be.
*/ */
hrelid = heap->rd_id; hrelid = RelationGetRelid(heap);
irelid = index->rd_id; irelid = RelationGetRelid(index);
heap_close(heap); heap_close(heap);
index_close(index); index_close(index);
...@@ -1165,11 +1162,13 @@ initGISTstate(GISTSTATE *giststate, Relation index) ...@@ -1165,11 +1162,13 @@ initGISTstate(GISTSTATE *giststate, Relation index)
fmgr_info(equal_proc, &giststate->equalFn); fmgr_info(equal_proc, &giststate->equalFn);
/* see if key type is different from type of attribute being indexed */ /* see if key type is different from type of attribute being indexed */
htup = SearchSysCacheTuple(INDEXRELID, ObjectIdGetDatum(index->rd_id), htup = SearchSysCacheTuple(INDEXRELID,
ObjectIdGetDatum(RelationGetRelid(index)),
0, 0, 0); 0, 0, 0);
itupform = (IndexTupleForm) GETSTRUCT(htup); itupform = (IndexTupleForm) GETSTRUCT(htup);
if (!HeapTupleIsValid(htup)) if (!HeapTupleIsValid(htup))
elog(ERROR, "initGISTstate: index %d not found", index->rd_id); elog(ERROR, "initGISTstate: index %d not found",
RelationGetRelid(index));
giststate->haskeytype = itupform->indhaskeytype; giststate->haskeytype = itupform->indhaskeytype;
if (giststate->haskeytype) if (giststate->haskeytype)
{ {
......
...@@ -284,12 +284,12 @@ gistdropscan(IndexScanDesc s) ...@@ -284,12 +284,12 @@ gistdropscan(IndexScanDesc s)
} }
void void
gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum) gistadjscans(Relation rel, int op, BlockNumber blkno, OffsetNumber offnum)
{ {
GISTScanList l; GISTScanList l;
Oid relid; Oid relid;
relid = r->rd_id; relid = RelationGetRelid(rel);
for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next) for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next)
{ {
if (l->gsl_scan->relation->rd_id == relid) if (l->gsl_scan->relation->rd_id == relid)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.19 1998/07/27 19:37:35 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.20 1998/08/19 02:01:00 momjian Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
...@@ -53,7 +53,6 @@ hashbuild(Relation heap, ...@@ -53,7 +53,6 @@ hashbuild(Relation heap,
PredInfo *predInfo) PredInfo *predInfo)
{ {
HeapScanDesc hscan; HeapScanDesc hscan;
Buffer buffer;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
TupleDesc htupdesc, TupleDesc htupdesc,
...@@ -65,6 +64,7 @@ hashbuild(Relation heap, ...@@ -65,6 +64,7 @@ hashbuild(Relation heap,
nitups; nitups;
int i; int i;
HashItem hitem; HashItem hitem;
Buffer buffer = InvalidBuffer;
#ifndef OMIT_PARTIAL_INDEX #ifndef OMIT_PARTIAL_INDEX
ExprContext *econtext; ExprContext *econtext;
...@@ -120,14 +120,13 @@ hashbuild(Relation heap, ...@@ -120,14 +120,13 @@ hashbuild(Relation heap,
} }
#endif /* OMIT_PARTIAL_INDEX */ #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 */ /* build the index */
nhtups = nitups = 0; nhtups = nitups = 0;
for (; HeapTupleIsValid(htup); htup = heap_getnext(hscan, 0, &buffer)) /* start a heap scan */
hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
while (HeapTupleIsValid(htup = heap_getnext(hscan, 0)))
{ {
nhtups++; nhtups++;
...@@ -193,8 +192,7 @@ hashbuild(Relation heap, ...@@ -193,8 +192,7 @@ hashbuild(Relation heap,
attoff, attoff,
attnum, attnum,
finfo, finfo,
&attnull, &attnull);
buffer);
nulls[attoff] = (attnull ? 'n' : ' '); nulls[attoff] = (attnull ? 'n' : ' ');
} }
...@@ -248,8 +246,8 @@ hashbuild(Relation heap, ...@@ -248,8 +246,8 @@ hashbuild(Relation heap,
*/ */
if (IsNormalProcessingMode()) if (IsNormalProcessingMode())
{ {
hrelid = heap->rd_id; hrelid = RelationGetRelid(heap);
irelid = index->rd_id; irelid = RelationGetRelid(index);
heap_close(heap); heap_close(heap);
index_close(index); index_close(index);
UpdateStats(hrelid, nhtups, true); UpdateStats(hrelid, nhtups, true);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.9 1998/04/26 04:05:08 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.10 1998/08/19 02:01:02 momjian Exp $
* *
* NOTES * NOTES
* These functions are stored in pg_amproc. For each operator class * These functions are stored in pg_amproc. For each operator class
...@@ -133,6 +133,18 @@ hashoid(Oid key) ...@@ -133,6 +133,18 @@ hashoid(Oid key)
return ((uint32) ~key); return ((uint32) ~key);
} }
uint32
hashoid8(Oid key[])
{
int i;
uint32 result = 0;
for (i=0; i < 8; i++)
result = result ^ (~(uint32)key[i]);
return result;
}
#define PRIME1 37 #define PRIME1 37
#define PRIME2 1048583 #define PRIME2 1048583
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.14 1998/06/15 19:27:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.15 1998/08/19 02:01:04 momjian Exp $
* *
* NOTES * NOTES
* Because we can be doing an index scan on a relation while we * Because we can be doing an index scan on a relation while we
...@@ -90,7 +90,7 @@ _hash_adjscans(Relation rel, ItemPointer tid) ...@@ -90,7 +90,7 @@ _hash_adjscans(Relation rel, ItemPointer tid)
HashScanList l; HashScanList l;
Oid relid; Oid relid;
relid = rel->rd_id; relid = RelationGetRelid(rel);
for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next) for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next)
{ {
if (relid == l->hashsl_scan->relation->rd_id) if (relid == l->hashsl_scan->relation->rd_id)
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.12 1998/06/15 19:27:53 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.13 1998/08/19 02:01:09 momjian Exp $
* *
* NOTES * NOTES
* many of the old access method routines have been turned into * many of the old access method routines have been turned into
...@@ -216,14 +216,15 @@ IndexScanMarkPosition(IndexScanDesc scan) ...@@ -216,14 +216,15 @@ IndexScanMarkPosition(IndexScanDesc scan)
if (scan->flags & ScanUncheckedPrevious) if (scan->flags & ScanUncheckedPrevious)
{ {
result = result = index_getnext(scan, BackwardScanDirection);
index_getnext(scan, BackwardScanDirection);
if (result != NULL) if (result != NULL)
{
scan->previousItemData = result->index_iptr; scan->previousItemData = result->index_iptr;
pfree(result);
}
else else
ItemPointerSetInvalid(&scan->previousItemData); ItemPointerSetInvalid(&scan->previousItemData);
} }
else if (scan->flags & ScanUncheckedNext) else if (scan->flags & ScanUncheckedNext)
{ {
...@@ -231,7 +232,10 @@ IndexScanMarkPosition(IndexScanDesc scan) ...@@ -231,7 +232,10 @@ IndexScanMarkPosition(IndexScanDesc scan)
index_getnext(scan, ForwardScanDirection); index_getnext(scan, ForwardScanDirection);
if (result != NULL) if (result != NULL)
{
scan->nextItemData = result->index_iptr; scan->nextItemData = result->index_iptr;
pfree(result);
}
else else
ItemPointerSetInvalid(&scan->nextItemData); ItemPointerSetInvalid(&scan->nextItemData);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.22 1998/06/15 18:39:23 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.23 1998/08/19 02:01:10 momjian Exp $
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* index_open - open an index relation by relationId * index_open - open an index relation by relationId
...@@ -331,8 +331,7 @@ index_getnext(IndexScanDesc scan, ...@@ -331,8 +331,7 @@ index_getnext(IndexScanDesc scan,
* have the am's gettuple proc do all the work. * have the am's gettuple proc do all the work.
* ---------------- * ----------------
*/ */
result = (RetrieveIndexResult) result = (RetrieveIndexResult)fmgr(procedure, scan, direction);
fmgr(procedure, scan, direction);
return result; return result;
} }
...@@ -376,8 +375,7 @@ GetIndexValue(HeapTuple tuple, ...@@ -376,8 +375,7 @@ GetIndexValue(HeapTuple tuple,
int attOff, int attOff,
AttrNumber attrNums[], AttrNumber attrNums[],
FuncIndexInfo *fInfo, FuncIndexInfo *fInfo,
bool *attNull, bool *attNull)
Buffer buffer)
{ {
Datum returnVal; Datum returnVal;
bool isNull; bool isNull;
......
...@@ -8,13 +8,14 @@ ...@@ -8,13 +8,14 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.25 1998/08/11 22:39:32 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.26 1998/08/19 02:01:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h"
#include "access/heapam.h" #include "access/heapam.h"
#include "access/istrat.h" #include "access/istrat.h"
#include "catalog/catname.h" #include "catalog/catname.h"
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include "catalog/pg_amproc.h" #include "catalog/pg_amproc.h"
#include "catalog/pg_index.h" #include "catalog/pg_index.h"
#include "catalog/pg_operator.h" #include "catalog/pg_operator.h"
#include "utils/syscache.h"
#include "fmgr.h" #include "fmgr.h"
#include "utils/memutils.h" /* could have been access/itup.h */ #include "utils/memutils.h" /* could have been access/itup.h */
...@@ -30,8 +32,7 @@ static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation); ...@@ -30,8 +32,7 @@ static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation);
static bool static bool
StrategyExpressionIsValid(StrategyExpression expression, StrategyExpressionIsValid(StrategyExpression expression,
StrategyNumber maxStrategy); StrategyNumber maxStrategy);
static ScanKey static ScanKey StrategyMapGetScanKeyEntry(StrategyMap map,
StrategyMapGetScanKeyEntry(StrategyMap map,
StrategyNumber strategyNumber); StrategyNumber strategyNumber);
static bool static bool
StrategyOperatorIsValid(StrategyOperator operator, StrategyOperatorIsValid(StrategyOperator operator,
...@@ -95,8 +96,7 @@ IndexStrategyGetStrategyMap(IndexStrategy indexStrategy, ...@@ -95,8 +96,7 @@ IndexStrategyGetStrategyMap(IndexStrategy indexStrategy,
Assert(AttributeNumberIsValid(attrNum)); Assert(AttributeNumberIsValid(attrNum));
maxStrategyNum = AMStrategies(maxStrategyNum); /* XXX */ maxStrategyNum = AMStrategies(maxStrategyNum); /* XXX */
return return &indexStrategy->strategyMapData[maxStrategyNum * (attrNum - 1)];
&indexStrategy->strategyMapData[maxStrategyNum * (attrNum - 1)];
} }
/* /*
...@@ -108,8 +108,7 @@ AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber, ...@@ -108,8 +108,7 @@ AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber,
StrategyNumber maxStrategyNumber) StrategyNumber maxStrategyNumber)
{ {
maxStrategyNumber = AMStrategies(maxStrategyNumber); /* XXX */ maxStrategyNumber = AMStrategies(maxStrategyNumber); /* XXX */
return return maxAttributeNumber * maxStrategyNumber * sizeof(ScanKeyData);
maxAttributeNumber * maxStrategyNumber * sizeof(ScanKeyData);
} }
#ifdef USE_ASSERT_CHECKING #ifdef USE_ASSERT_CHECKING
...@@ -483,39 +482,52 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation, ...@@ -483,39 +482,52 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
Oid operatorObjectId, Oid operatorObjectId,
ScanKey entry) ScanKey entry)
{ {
HeapScanDesc scan;
ScanKeyData scanKeyData;
HeapTuple tuple; HeapTuple tuple;
HeapScanDesc scan = NULL;
ScanKeyEntryInitialize(&scanKeyData, 0, if (!IsBootstrapProcessingMode())
ObjectIdAttributeNumber, {
F_OIDEQ, tuple = SearchSysCacheTuple(OPROID,
ObjectIdGetDatum(operatorObjectId)); ObjectIdGetDatum(operatorObjectId),
0, 0, 0);
}
else
{
ScanKeyData scanKeyData;
ScanKeyEntryInitialize(&scanKeyData, 0,
ObjectIdAttributeNumber,
F_OIDEQ,
ObjectIdGetDatum(operatorObjectId));
scan = heap_beginscan(operatorRelation, false, SnapshotNow, scan = heap_beginscan(operatorRelation, false, SnapshotNow,
1, &scanKeyData); 1, &scanKeyData);
tuple = heap_getnext(scan, 0);
}
tuple = heap_getnext(scan, false, (Buffer *) NULL);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
{ {
if (IsBootstrapProcessingMode())
heap_endscan(scan);
elog(ERROR, "OperatorObjectIdFillScanKeyEntry: unknown operator %lu", elog(ERROR, "OperatorObjectIdFillScanKeyEntry: unknown operator %lu",
(uint32) operatorObjectId); (uint32) operatorObjectId);
} }
entry->sk_flags = 0; entry->sk_flags = 0;
entry->sk_procedure = entry->sk_procedure = ((OperatorTupleForm) GETSTRUCT(tuple))->oprcode;
((OperatorTupleForm) GETSTRUCT(tuple))->oprcode;
fmgr_info(entry->sk_procedure, &entry->sk_func); fmgr_info(entry->sk_procedure, &entry->sk_func);
entry->sk_nargs = entry->sk_func.fn_nargs; entry->sk_nargs = entry->sk_func.fn_nargs;
if (IsBootstrapProcessingMode())
heap_endscan(scan);
if (!RegProcedureIsValid(entry->sk_procedure)) if (!RegProcedureIsValid(entry->sk_procedure))
{ {
elog(ERROR, elog(ERROR,
"OperatorObjectIdFillScanKeyEntry: no procedure for operator %lu", "OperatorObjectIdFillScanKeyEntry: no procedure for operator %lu",
(uint32) operatorObjectId); (uint32) operatorObjectId);
} }
heap_endscan(scan);
} }
...@@ -532,28 +544,38 @@ IndexSupportInitialize(IndexStrategy indexStrategy, ...@@ -532,28 +544,38 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
StrategyNumber maxSupportNumber, StrategyNumber maxSupportNumber,
AttrNumber maxAttributeNumber) AttrNumber maxAttributeNumber)
{ {
Relation relation; Relation relation = NULL;
HeapScanDesc scan = NULL;
ScanKeyData entry[2];
Relation operatorRelation; Relation operatorRelation;
HeapScanDesc scan;
HeapTuple tuple; HeapTuple tuple;
ScanKeyData entry[2];
StrategyMap map; StrategyMap map;
AttrNumber attributeNumber; AttrNumber attributeNumber;
int attributeIndex; int attributeIndex;
Oid operatorClassObjectId[MaxIndexAttributeNumber]; Oid operatorClassObjectId[MaxIndexAttributeNumber];
maxStrategyNumber = AMStrategies(maxStrategyNumber); if (!IsBootstrapProcessingMode())
{
ScanKeyEntryInitialize(&entry[0], 0, Anum_pg_index_indexrelid, tuple = SearchSysCacheTuple(INDEXRELID,
F_OIDEQ, ObjectIdGetDatum(indexObjectId),
ObjectIdGetDatum(indexObjectId)); 0, 0, 0);
}
else
{
ScanKeyEntryInitialize(&entry[0], 0, Anum_pg_index_indexrelid,
F_OIDEQ,
ObjectIdGetDatum(indexObjectId));
relation = heap_openr(IndexRelationName);
scan = heap_beginscan(relation, false, SnapshotNow, 1, entry);
tuple = heap_getnext(scan, 0);
}
relation = heap_openr(IndexRelationName);
scan = heap_beginscan(relation, false, SnapshotNow, 1, entry);
tuple = heap_getnext(scan, 0, (Buffer *) NULL);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "IndexSupportInitialize: corrupted catalogs"); elog(ERROR, "IndexSupportInitialize: corrupted catalogs");
maxStrategyNumber = AMStrategies(maxStrategyNumber);
/* /*
* XXX note that the following assumes the INDEX tuple is well formed * XXX note that the following assumes the INDEX tuple is well formed
* and that the key[] and class[] are 0 terminated. * and that the key[] and class[] are 0 terminated.
...@@ -574,9 +596,12 @@ IndexSupportInitialize(IndexStrategy indexStrategy, ...@@ -574,9 +596,12 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
operatorClassObjectId[attributeIndex] = iform->indclass[attributeIndex]; operatorClassObjectId[attributeIndex] = iform->indclass[attributeIndex];
} }
heap_endscan(scan); if (IsBootstrapProcessingMode())
heap_close(relation); {
heap_endscan(scan);
heap_close(relation);
}
/* if support routines exist for this access method, load them */ /* if support routines exist for this access method, load them */
if (maxSupportNumber > 0) if (maxSupportNumber > 0)
{ {
...@@ -606,8 +631,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, ...@@ -606,8 +631,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
scan = heap_beginscan(relation, false, SnapshotNow, 2, entry); scan = heap_beginscan(relation, false, SnapshotNow, 2, entry);
while (tuple = heap_getnext(scan, 0, (Buffer *) NULL), while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
HeapTupleIsValid(tuple))
{ {
form = (Form_pg_amproc) GETSTRUCT(tuple); form = (Form_pg_amproc) GETSTRUCT(tuple);
loc[(form->amprocnum - 1)] = form->amproc; loc[(form->amprocnum - 1)] = form->amproc;
...@@ -647,8 +671,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, ...@@ -647,8 +671,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
scan = heap_beginscan(relation, false, SnapshotNow, 2, entry); scan = heap_beginscan(relation, false, SnapshotNow, 2, entry);
while (tuple = heap_getnext(scan, 0, (Buffer *) NULL), while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
HeapTupleIsValid(tuple))
{ {
Form_pg_amop form; Form_pg_amop form;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* These functions are stored in pg_amproc. For each operator class * These functions are stored in pg_amproc. For each operator class
...@@ -30,81 +30,96 @@ ...@@ -30,81 +30,96 @@
int32 int32
btint2cmp(int16 a, int16 b) btint2cmp(int16 a, int16 b)
{ {
return ((int32) (a - b)); return (int32) (a - b);
} }
int32 int32
btint4cmp(int32 a, int32 b) btint4cmp(int32 a, int32 b)
{ {
return (a - b); return a - b;
} }
int32 int32
btint24cmp(int16 a, int32 b) btint24cmp(int16 a, int32 b)
{ {
return (((int32) a) - b); return ((int32) a) - b;
} }
int32 int32
btint42cmp(int32 a, int16 b) btint42cmp(int32 a, int16 b)
{ {
return (a - ((int32) b)); return a - ((int32) b);
} }
int32 int32
btfloat4cmp(float32 a, float32 b) btfloat4cmp(float32 a, float32 b)
{ {
if (*a > *b) if (*a > *b)
return (1); return 1;
else if (*a == *b) else if (*a == *b)
return (0); return 0;
else else
return (-1); return -1;
} }
int32 int32
btfloat8cmp(float64 a, float64 b) btfloat8cmp(float64 a, float64 b)
{ {
if (*a > *b) if (*a > *b)
return (1); return 1;
else if (*a == *b) else if (*a == *b)
return (0); return 0;
else else
return (-1); return -1;
} }
int32 int32
btoidcmp(Oid a, Oid b) btoidcmp(Oid a, Oid b)
{ {
if (a > b) if (a > b)
return (1); return 1;
else if (a == b) else if (a == b)
return (0); return 0;
else 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 int32
btabstimecmp(AbsoluteTime a, AbsoluteTime b) btabstimecmp(AbsoluteTime a, AbsoluteTime b)
{ {
if (AbsoluteTimeIsBefore(a, b)) if (AbsoluteTimeIsBefore(a, b))
return (-1); return -1;
else if (AbsoluteTimeIsBefore(b, a)) else if (AbsoluteTimeIsBefore(b, a))
return (1); return 1;
else else
return (0); return 0;
} }
int32 int32
btcharcmp(char a, char b) btcharcmp(char a, char b)
{ {
return ((int32) ((uint8) a - (uint8) b)); return (int32) ((uint8) a - (uint8) b);
} }
int32 int32
btnamecmp(NameData *a, NameData *b) btnamecmp(NameData *a, NameData *b)
{ {
return (strncmp(a->data, b->data, NAMEDATALEN)); return strncmp(a->data, b->data, NAMEDATALEN);
} }
int32 int32
...@@ -162,7 +177,7 @@ bttextcmp(struct varlena * a, struct varlena * b) ...@@ -162,7 +177,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
#endif #endif
if (res != 0 || VARSIZE(a) == VARSIZE(b)) 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 * 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) ...@@ -170,7 +185,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
*/ */
if (VARSIZE(a) < VARSIZE(b)) if (VARSIZE(a) < VARSIZE(b))
return (-1); return -1;
else else
return (1); return 1;
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 ...@@ -53,7 +53,8 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
BlockNumber blkno; BlockNumber blkno;
int natts = rel->rd_rel->relnatts; int natts = rel->rd_rel->relnatts;
InsertIndexResult res; InsertIndexResult res;
Buffer buffer;
itup = &(btitem->bti_itup); itup = &(btitem->bti_itup);
/* we need a scan key to do our search, so build one */ /* 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 ...@@ -120,11 +121,12 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
{ /* they're equal */ { /* they're equal */
btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offset)); btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
itup = &(btitem->bti_itup); 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) if (htup != (HeapTuple) NULL)
{ /* it is a duplicate */ { /* it is a duplicate */
elog(ERROR, "Cannot insert a duplicate key into a unique index"); elog(ERROR, "Cannot insert a duplicate key into a unique index");
} }
/* htup null so no buffer to release */
/* get next offnum */ /* get next offnum */
if (offset < maxoff) if (offset < maxoff)
offset = OffsetNumberNext(offset); offset = OffsetNumberNext(offset);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
...@@ -66,7 +66,6 @@ btbuild(Relation heap, ...@@ -66,7 +66,6 @@ btbuild(Relation heap,
PredInfo *predInfo) PredInfo *predInfo)
{ {
HeapScanDesc hscan; HeapScanDesc hscan;
Buffer buffer;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
TupleDesc htupdesc, TupleDesc htupdesc,
...@@ -113,7 +112,7 @@ btbuild(Relation heap, ...@@ -113,7 +112,7 @@ btbuild(Relation heap,
#endif #endif
/* see if index is unique */ /* 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) */ /* initialize the btree index metadata page (if this is a new index) */
if (oldPred == NULL) if (oldPred == NULL)
...@@ -155,9 +154,6 @@ btbuild(Relation heap, ...@@ -155,9 +154,6 @@ btbuild(Relation heap,
#endif /* OMIT_PARTIAL_INDEX */ #endif /* OMIT_PARTIAL_INDEX */
/* start a heap scan */ /* start a heap scan */
hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
htup = heap_getnext(hscan, 0, &buffer);
/* build the index */ /* build the index */
nhtups = nitups = 0; nhtups = nitups = 0;
...@@ -167,9 +163,10 @@ btbuild(Relation heap, ...@@ -167,9 +163,10 @@ btbuild(Relation heap,
res = (InsertIndexResult) NULL; 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++; nhtups++;
/* /*
...@@ -228,8 +225,7 @@ btbuild(Relation heap, ...@@ -228,8 +225,7 @@ btbuild(Relation heap,
attoff, attoff,
attnum, attnum,
finfo, finfo,
&attnull, &attnull);
buffer);
nulls[attoff] = (attnull ? 'n' : ' '); nulls[attoff] = (attnull ? 'n' : ' ');
} }
...@@ -323,8 +319,8 @@ btbuild(Relation heap, ...@@ -323,8 +319,8 @@ btbuild(Relation heap,
*/ */
if (IsNormalProcessingMode()) if (IsNormalProcessingMode())
{ {
hrelid = heap->rd_id; hrelid = RelationGetRelid(heap);
irelid = index->rd_id; irelid = RelationGetRelid(index);
heap_close(heap); heap_close(heap);
index_close(index); index_close(index);
UpdateStats(hrelid, nhtups, true); UpdateStats(hrelid, nhtups, true);
...@@ -371,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation ...@@ -371,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
btitem = _bt_formitem(itup); btitem = _bt_formitem(itup);
res = _bt_doinsert(rel, btitem, res = _bt_doinsert(rel, btitem,
IndexIsUnique(RelationGetRelationId(rel)), heapRel); IndexIsUnique(RelationGetRelid(rel)), heapRel);
pfree(btitem); pfree(btitem);
pfree(itup); pfree(itup);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
...@@ -96,10 +96,10 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op) ...@@ -96,10 +96,10 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op)
BTScanList l; BTScanList l;
Oid relid; Oid relid;
relid = rel->rd_id; relid = RelationGetRelid(rel);
for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next) 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, _bt_scandel(l->btsl_scan, op,
ItemPointerGetBlockNumber(tid), ItemPointerGetBlockNumber(tid),
ItemPointerGetOffsetNumber(tid)); ItemPointerGetOffsetNumber(tid));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -61,8 +61,7 @@ _bt_mkscankey(Relation rel, IndexTuple itup)
proc = index_getprocid(rel, i + 1, BTORDER_PROC); proc = index_getprocid(rel, i + 1, BTORDER_PROC);
flag = 0x0; flag = 0x0;
} }
ScanKeyEntryInitialize(&skey[i], ScanKeyEntryInitialize(&skey[i], flag, (AttrNumber) (i + 1), proc, arg);
flag, (AttrNumber) (i + 1), proc, arg);
} }
return (skey); return (skey);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.25 1998/07/27 19:37:41 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.26 1998/08/19 02:01:20 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -86,7 +86,6 @@ rtbuild(Relation heap, ...@@ -86,7 +86,6 @@ rtbuild(Relation heap,
PredInfo *predInfo) PredInfo *predInfo)
{ {
HeapScanDesc scan; HeapScanDesc scan;
Buffer buffer;
AttrNumber i; AttrNumber i;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
...@@ -95,6 +94,7 @@ rtbuild(Relation heap, ...@@ -95,6 +94,7 @@ rtbuild(Relation heap,
InsertIndexResult res; InsertIndexResult res;
Datum *d; Datum *d;
bool *nulls; bool *nulls;
Buffer buffer = InvalidBuffer;
int nb, int nb,
nh, nh,
ni; ni;
...@@ -164,15 +164,14 @@ rtbuild(Relation heap, ...@@ -164,15 +164,14 @@ rtbuild(Relation heap,
slot = NULL; slot = NULL;
} }
#endif /* OMIT_PARTIAL_INDEX */ #endif /* OMIT_PARTIAL_INDEX */
scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
htup = heap_getnext(scan, 0, &buffer);
/* count the tuples as we insert them */ /* count the tuples as we insert them */
nh = ni = 0; nh = ni = 0;
for (; HeapTupleIsValid(htup); htup = heap_getnext(scan, 0, &buffer)) scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
{
while (HeapTupleIsValid(htup = heap_getnext(scan, 0)))
{
nh++; nh++;
/* /*
...@@ -234,8 +233,7 @@ rtbuild(Relation heap, ...@@ -234,8 +233,7 @@ rtbuild(Relation heap,
attoff, attoff,
attnum, attnum,
finfo, finfo,
&attnull, &attnull);
buffer);
nulls[attoff] = (attnull ? 'n' : ' '); nulls[attoff] = (attnull ? 'n' : ' ');
} }
...@@ -278,8 +276,8 @@ rtbuild(Relation heap, ...@@ -278,8 +276,8 @@ rtbuild(Relation heap,
* flushed. We close them to guarantee that they will be. * flushed. We close them to guarantee that they will be.
*/ */
hrelid = heap->rd_id; hrelid = RelationGetRelid(heap);
irelid = index->rd_id; irelid = RelationGetRelid(index);
heap_close(heap); heap_close(heap);
index_close(index); index_close(index);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.16 1998/06/15 19:28:01 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.17 1998/08/19 02:01:21 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -290,10 +290,10 @@ rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum) ...@@ -290,10 +290,10 @@ rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
RTScanList l; RTScanList l;
Oid relid; Oid relid;
relid = r->rd_id; relid = RelationGetRelid(r);
for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next) for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next)
{ {
if (l->rtsl_scan->relation->rd_id == relid) if (RelationGetRelid(l->rtsl_scan->relation) == relid)
rtadjone(l->rtsl_scan, op, blkno, offnum); rtadjone(l->rtsl_scan, op, blkno, offnum);
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.19 1998/08/06 05:12:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.20 1998/08/19 02:01:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -78,8 +78,8 @@ static Oid objectid; ...@@ -78,8 +78,8 @@ static Oid objectid;
int ival; int ival;
} }
%type <list> boot_arg_list %type <list> boot_index_params
%type <ielem> boot_index_params boot_index_on %type <ielem> boot_index_param
%type <ival> boot_const boot_ident %type <ival> boot_const boot_ident
%type <ival> optbootstrap optoideq boot_tuple boot_tuplelist %type <ival> optbootstrap optoideq boot_tuple boot_tuplelist
...@@ -225,15 +225,12 @@ Boot_InsertStmt: ...@@ -225,15 +225,12 @@ Boot_InsertStmt:
Boot_DeclareIndexStmt: Boot_DeclareIndexStmt:
XDECLARE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN XDECLARE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
{ {
List *params;
DO_START; DO_START;
params = lappend(NIL, (List*)$9);
DefineIndex(LexIDStr($5), DefineIndex(LexIDStr($5),
LexIDStr($3), LexIDStr($3),
LexIDStr($7), LexIDStr($7),
params, NIL, 0, 0, NIL); $9, NIL, 0, 0, NIL);
DO_END; DO_END;
} }
; ;
...@@ -241,39 +238,21 @@ Boot_DeclareIndexStmt: ...@@ -241,39 +238,21 @@ Boot_DeclareIndexStmt:
Boot_BuildIndsStmt: Boot_BuildIndsStmt:
XBUILD INDICES { build_indices(); } XBUILD INDICES { build_indices(); }
boot_index_params: boot_index_params:
boot_index_on boot_ident boot_index_params COMMA boot_index_param { $$ = lappend($1, $3); }
{ | boot_index_param { $$ = lcons($1, NIL); }
IndexElem *n = (IndexElem*)$1; ;
n->class = LexIDStr($2);
$$ = n;
}
boot_index_on: boot_index_param:
boot_ident boot_ident boot_ident
{
IndexElem *n = makeNode(IndexElem);
n->name = LexIDStr($1);
$$ = n;
}
| boot_ident LPAREN boot_arg_list RPAREN
{ {
IndexElem *n = makeNode(IndexElem); IndexElem *n = makeNode(IndexElem);
n->name = LexIDStr($1); n->name = LexIDStr($1);
n->args = (List*)$3; n->class = LexIDStr($2);
$$ = n; $$ = n;
} }
boot_arg_list:
boot_ident
{
$$ = lappend(NIL, makeString(LexIDStr($1)));
}
| boot_arg_list COMMA boot_ident
{
$$ = lappend((List*)$1, makeString(LexIDStr($3)));
}
optbootstrap: optbootstrap:
XBOOTSTRAP { $$ = 1; } XBOOTSTRAP { $$ = 1; }
| { $$ = 0; } | { $$ = 0; }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.47 1998/07/27 19:37:43 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.48 1998/08/19 02:01:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -448,8 +448,8 @@ boot_openrel(char *relname) ...@@ -448,8 +448,8 @@ boot_openrel(char *relname)
{ {
int i; int i;
struct typmap **app; struct typmap **app;
Relation rdesc; Relation rel;
HeapScanDesc sdesc; HeapScanDesc scan;
HeapTuple tup; HeapTuple tup;
if (strlen(relname) >= NAMEDATALEN - 1) if (strlen(relname) >= NAMEDATALEN - 1)
...@@ -458,25 +458,27 @@ boot_openrel(char *relname) ...@@ -458,25 +458,27 @@ boot_openrel(char *relname)
if (Typ == (struct typmap **) NULL) if (Typ == (struct typmap **) NULL)
{ {
StartPortalAllocMode(DefaultAllocMode, 0); StartPortalAllocMode(DefaultAllocMode, 0);
rdesc = heap_openr(TypeRelationName); rel = heap_openr(TypeRelationName);
sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL); scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
for (i = 0; PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL)); ++i); i = 0;
heap_endscan(sdesc); while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
++i;
heap_endscan(scan);
app = Typ = ALLOC(struct typmap *, i + 1); app = Typ = ALLOC(struct typmap *, i + 1);
while (i-- > 0) while (i-- > 0)
*app++ = ALLOC(struct typmap, 1); *app++ = ALLOC(struct typmap, 1);
*app = (struct typmap *) NULL; *app = (struct typmap *) NULL;
sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL); scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
app = Typ; app = Typ;
while (PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL))) while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
{ {
(*app)->am_oid = tup->t_oid; (*app)->am_oid = tup->t_oid;
memmove((char *) &(*app++)->am_typ, memmove((char *) &(*app++)->am_typ,
(char *) GETSTRUCT(tup), (char *) GETSTRUCT(tup),
sizeof((*app)->am_typ)); sizeof((*app)->am_typ));
} }
heap_endscan(sdesc); heap_endscan(scan);
heap_close(rdesc); heap_close(rel);
EndPortalAllocMode(); EndPortalAllocMode();
} }
...@@ -505,7 +507,7 @@ boot_openrel(char *relname) ...@@ -505,7 +507,7 @@ boot_openrel(char *relname)
* defined yet. * defined yet.
*/ */
if (namestrcmp(&attrtypes[i]->attname, "attisset") == 0) if (namestrcmp(&attrtypes[i]->attname, "attisset") == 0)
attrtypes[i]->attisset = get_attisset(reldesc->rd_id, attrtypes[i]->attisset = get_attisset(RelationGetRelid(reldesc),
attrtypes[i]->attname.data); attrtypes[i]->attname.data);
else else
attrtypes[i]->attisset = false; attrtypes[i]->attisset = false;
...@@ -786,8 +788,8 @@ static int ...@@ -786,8 +788,8 @@ static int
gettype(char *type) gettype(char *type)
{ {
int i; int i;
Relation rdesc; Relation rel;
HeapScanDesc sdesc; HeapScanDesc scan;
HeapTuple tup; HeapTuple tup;
struct typmap **app; struct typmap **app;
...@@ -811,27 +813,27 @@ gettype(char *type) ...@@ -811,27 +813,27 @@ gettype(char *type)
} }
if (DebugMode) if (DebugMode)
printf("bootstrap.c: External Type: %s\n", type); printf("bootstrap.c: External Type: %s\n", type);
rdesc = heap_openr(TypeRelationName); rel = heap_openr(TypeRelationName);
sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL); scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
i = 0; i = 0;
while (PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL))) while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
++i; ++i;
heap_endscan(sdesc); heap_endscan(scan);
app = Typ = ALLOC(struct typmap *, i + 1); app = Typ = ALLOC(struct typmap *, i + 1);
while (i-- > 0) while (i-- > 0)
*app++ = ALLOC(struct typmap, 1); *app++ = ALLOC(struct typmap, 1);
*app = (struct typmap *) NULL; *app = (struct typmap *) NULL;
sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL); scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
app = Typ; app = Typ;
while (PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL))) while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
{ {
(*app)->am_oid = tup->t_oid; (*app)->am_oid = tup->t_oid;
memmove((char *) &(*app++)->am_typ, memmove((char *) &(*app++)->am_typ,
(char *) GETSTRUCT(tup), (char *) GETSTRUCT(tup),
sizeof((*app)->am_typ)); sizeof((*app)->am_typ));
} }
heap_endscan(sdesc); heap_endscan(scan);
heap_close(rdesc); heap_close(rel);
return (gettype(type)); return (gettype(type));
} }
elog(ERROR, "Error: unknown type '%s'.\n", type); elog(ERROR, "Error: unknown type '%s'.\n", type);
...@@ -1167,7 +1169,7 @@ build_indices() ...@@ -1167,7 +1169,7 @@ build_indices()
*/ */
heap = heap_openr(ILHead->il_heap); heap = heap_openr(ILHead->il_heap);
if (!BootstrapAlreadySeen(heap->rd_id)) if (!BootstrapAlreadySeen(RelationGetRelid(heap)))
UpdateStats(heap->rd_id, 0, true); UpdateStats(RelationGetRelid(heap), 0, true);
} }
} }
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.15 1998/02/26 04:30:31 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.16 1998/08/19 02:01:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -174,7 +174,7 @@ fillatt(TupleDesc tupleDesc) ...@@ -174,7 +174,7 @@ fillatt(TupleDesc tupleDesc)
for (i = 0; i < natts;) for (i = 0; i < natts;)
{ {
tuple = SearchSysCacheTuple(TYPOID, tuple = SearchSysCacheTuple(TYPOID,
Int32GetDatum((*attributeP)->atttypid), ObjectIdGetDatum((*attributeP)->atttypid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.14 1998/04/01 15:35:01 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.15 1998/08/19 02:01:34 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -155,7 +155,8 @@ AggregateCreate(char *aggName, ...@@ -155,7 +155,8 @@ AggregateCreate(char *aggName,
elog(ERROR, "AggregateCreate: bogus function '%s'", aggfinalfnName); elog(ERROR, "AggregateCreate: bogus function '%s'", aggfinalfnName);
} }
tup = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggName), tup = SearchSysCacheTuple(AGGNAME,
PointerGetDatum(aggName),
ObjectIdGetDatum(xbase), ObjectIdGetDatum(xbase),
0, 0); 0, 0);
if (HeapTupleIsValid(tup)) if (HeapTupleIsValid(tup))
...@@ -286,7 +287,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull) ...@@ -286,7 +287,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
tup = SearchSysCacheTuple(AGGNAME, tup = SearchSysCacheTuple(AGGNAME,
PointerGetDatum(aggName), PointerGetDatum(aggName),
PointerGetDatum(basetype), ObjectIdGetDatum(basetype),
0, 0); 0, 0);
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
elog(ERROR, "AggNameGetInitVal: cache lookup failed for aggregate '%s'", elog(ERROR, "AggNameGetInitVal: cache lookup failed for aggregate '%s'",
...@@ -325,7 +326,8 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull) ...@@ -325,7 +326,8 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
strInitVal = textout(textInitVal); strInitVal = textout(textInitVal);
heap_close(aggRel); heap_close(aggRel);
tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(transtype), tup = SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(transtype),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.26 1998/07/27 19:37:49 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.27 1998/08/19 02:01:36 momjian Exp $
* *
* NOTES * NOTES
* these routines moved here from commands/define.c and somewhat cleaned up. * these routines moved here from commands/define.c and somewhat cleaned up.
...@@ -120,7 +120,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, ...@@ -120,7 +120,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
*/ */
pg_operator_scan = heap_beginscan(pg_operator_desc, pg_operator_scan = heap_beginscan(pg_operator_desc,
0, 0,
SnapshotSelf, SnapshotSelf, /* no cache? */
3, 3,
opKey); opKey);
...@@ -129,7 +129,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, ...@@ -129,7 +129,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
* the proper return oid value. * the proper return oid value.
* ---------------- * ----------------
*/ */
tup = heap_getnext(pg_operator_scan, 0, (Buffer *) 0); tup = heap_getnext(pg_operator_scan, 0);
operatorObjectId = HeapTupleIsValid(tup) ? tup->t_oid : InvalidOid; operatorObjectId = HeapTupleIsValid(tup) ? tup->t_oid : InvalidOid;
/* ---------------- /* ----------------
...@@ -138,8 +138,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, ...@@ -138,8 +138,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
*/ */
heap_endscan(pg_operator_scan); heap_endscan(pg_operator_scan);
return return operatorObjectId;
operatorObjectId;
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
...@@ -462,8 +461,6 @@ OperatorDef(char *operatorName, ...@@ -462,8 +461,6 @@ OperatorDef(char *operatorName,
HeapScanDesc pg_operator_scan; HeapScanDesc pg_operator_scan;
HeapTuple tup; HeapTuple tup;
Buffer buffer;
ItemPointerData itemPointerData;
char nulls[Natts_pg_operator]; char nulls[Natts_pg_operator];
char replaces[Natts_pg_operator]; char replaces[Natts_pg_operator];
Datum values[Natts_pg_operator]; Datum values[Natts_pg_operator];
...@@ -549,7 +546,7 @@ OperatorDef(char *operatorName, ...@@ -549,7 +546,7 @@ OperatorDef(char *operatorName,
PointerGetDatum(typeId), PointerGetDatum(typeId),
0); 0);
if (!PointerIsValid(tup)) if (!HeapTupleIsValid(tup))
func_error("OperatorDef", procedureName, nargs, typeId, NULL); func_error("OperatorDef", procedureName, nargs, typeId, NULL);
values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_oid); values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_oid);
...@@ -693,7 +690,7 @@ OperatorDef(char *operatorName, ...@@ -693,7 +690,7 @@ OperatorDef(char *operatorName,
/* last three fields were filled in first */ /* last three fields were filled in first */
/* /*
* If we are adding to an operator shell, get its t_ctid and a buffer. * If we are adding to an operator shell, get its t_ctid
*/ */
pg_operator_desc = heap_openr(OperatorRelationName); pg_operator_desc = heap_openr(OperatorRelationName);
...@@ -705,30 +702,27 @@ OperatorDef(char *operatorName, ...@@ -705,30 +702,27 @@ OperatorDef(char *operatorName,
pg_operator_scan = heap_beginscan(pg_operator_desc, pg_operator_scan = heap_beginscan(pg_operator_desc,
0, 0,
SnapshotSelf, SnapshotSelf, /* no cache? */
3, 3,
opKey); opKey);
tup = heap_getnext(pg_operator_scan, 0, &buffer); tup = heap_getnext(pg_operator_scan, 0);
if (HeapTupleIsValid(tup)) if (HeapTupleIsValid(tup))
{ {
tup = heap_modifytuple(tup, tup = heap_modifytuple(tup,
buffer,
pg_operator_desc, pg_operator_desc,
values, values,
nulls, nulls,
replaces); replaces);
ItemPointerCopy(&tup->t_ctid, &itemPointerData);
setheapoverride(true); setheapoverride(true);
heap_replace(pg_operator_desc, &itemPointerData, tup); heap_replace(pg_operator_desc, &tup->t_ctid, tup);
setheapoverride(false); setheapoverride(false);
} }
else else
elog(ERROR, "OperatorDef: no operator %d", other_oid); elog(ERROR, "OperatorDef: no operator %d", other_oid);
heap_endscan(pg_operator_scan); heap_endscan(pg_operator_scan);
} }
else else
{ {
...@@ -777,8 +771,6 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) ...@@ -777,8 +771,6 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
Relation pg_operator_desc; Relation pg_operator_desc;
HeapScanDesc pg_operator_scan; HeapScanDesc pg_operator_scan;
HeapTuple tup; HeapTuple tup;
Buffer buffer;
ItemPointerData itemPointerData;
char nulls[Natts_pg_operator]; char nulls[Natts_pg_operator];
char replaces[Natts_pg_operator]; char replaces[Natts_pg_operator];
Datum values[Natts_pg_operator]; Datum values[Natts_pg_operator];
...@@ -804,11 +796,11 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) ...@@ -804,11 +796,11 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
pg_operator_scan = heap_beginscan(pg_operator_desc, pg_operator_scan = heap_beginscan(pg_operator_desc,
0, 0,
SnapshotSelf, SnapshotSelf, /* no cache? */
1, 1,
opKey); opKey);
tup = heap_getnext(pg_operator_scan, 0, &buffer); tup = heap_getnext(pg_operator_scan, 0);
/* if the commutator and negator are the same operator, do one update */ /* if the commutator and negator are the same operator, do one update */
if (commId == negId) if (commId == negId)
...@@ -837,16 +829,13 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) ...@@ -837,16 +829,13 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
} }
tup = heap_modifytuple(tup, tup = heap_modifytuple(tup,
buffer,
pg_operator_desc, pg_operator_desc,
values, values,
nulls, nulls,
replaces); replaces);
ItemPointerCopy(&tup->t_ctid, &itemPointerData);
setheapoverride(true); setheapoverride(true);
heap_replace(pg_operator_desc, &itemPointerData, tup); heap_replace(pg_operator_desc, &tup->t_ctid, tup);
setheapoverride(false); setheapoverride(false);
} }
...@@ -855,10 +844,6 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) ...@@ -855,10 +844,6 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
heap_close(pg_operator_desc); heap_close(pg_operator_desc);
/* release the buffer properly */
if (BufferIsValid(buffer))
ReleaseBuffer(buffer);
return; return;
} }
...@@ -869,24 +854,17 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) ...@@ -869,24 +854,17 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
values[Anum_pg_operator_oprcom - 1] = ObjectIdGetDatum(baseId); values[Anum_pg_operator_oprcom - 1] = ObjectIdGetDatum(baseId);
replaces[Anum_pg_operator_oprcom - 1] = 'r'; replaces[Anum_pg_operator_oprcom - 1] = 'r';
tup = heap_modifytuple(tup, tup = heap_modifytuple(tup,
buffer,
pg_operator_desc, pg_operator_desc,
values, values,
nulls, nulls,
replaces); replaces);
ItemPointerCopy(&tup->t_ctid, &itemPointerData);
setheapoverride(true); setheapoverride(true);
heap_replace(pg_operator_desc, &itemPointerData, tup); heap_replace(pg_operator_desc, &tup->t_ctid, tup);
setheapoverride(false); setheapoverride(false);
values[Anum_pg_operator_oprcom - 1] = (Datum) NULL; values[Anum_pg_operator_oprcom - 1] = (Datum) NULL;
replaces[Anum_pg_operator_oprcom - 1] = ' '; replaces[Anum_pg_operator_oprcom - 1] = ' ';
/* release the buffer properly */
if (BufferIsValid(buffer))
ReleaseBuffer(buffer);
} }
/* check and update the negator, if necessary */ /* check and update the negator, if necessary */
...@@ -894,34 +872,27 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) ...@@ -894,34 +872,27 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
pg_operator_scan = heap_beginscan(pg_operator_desc, pg_operator_scan = heap_beginscan(pg_operator_desc,
0, 0,
SnapshotSelf, SnapshotSelf, /* no cache? */
1, 1,
opKey); opKey);
tup = heap_getnext(pg_operator_scan, 0, &buffer); tup = heap_getnext(pg_operator_scan, 0);
if (HeapTupleIsValid(tup) && if (HeapTupleIsValid(tup) &&
!(OidIsValid(((OperatorTupleForm) GETSTRUCT(tup))->oprnegate))) !(OidIsValid(((OperatorTupleForm) GETSTRUCT(tup))->oprnegate)))
{ {
values[Anum_pg_operator_oprnegate - 1] = ObjectIdGetDatum(baseId); values[Anum_pg_operator_oprnegate - 1] = ObjectIdGetDatum(baseId);
replaces[Anum_pg_operator_oprnegate - 1] = 'r'; replaces[Anum_pg_operator_oprnegate - 1] = 'r';
tup = heap_modifytuple(tup, tup = heap_modifytuple(tup,
buffer,
pg_operator_desc, pg_operator_desc,
values, values,
nulls, nulls,
replaces); replaces);
ItemPointerCopy(&tup->t_ctid, &itemPointerData);
setheapoverride(true); setheapoverride(true);
heap_replace(pg_operator_desc, &itemPointerData, tup); heap_replace(pg_operator_desc, &tup->t_ctid, tup);
setheapoverride(false); setheapoverride(false);
} }
/* release the buffer properly */
if (BufferIsValid(buffer))
ReleaseBuffer(buffer);
heap_endscan(pg_operator_scan); heap_endscan(pg_operator_scan);
heap_close(pg_operator_desc); heap_close(pg_operator_desc);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.18 1998/06/15 19:28:10 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.19 1998/08/19 02:01:37 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,7 +57,7 @@ ProcedureCreate(char *procedureName, ...@@ -57,7 +57,7 @@ ProcedureCreate(char *procedureName,
CommandDest dest) CommandDest dest)
{ {
int i; int i;
Relation rdesc; Relation rel;
HeapTuple tup; HeapTuple tup;
bool defined; bool defined;
uint16 parameterCount; uint16 parameterCount;
...@@ -258,23 +258,23 @@ ProcedureCreate(char *procedureName, ...@@ -258,23 +258,23 @@ ProcedureCreate(char *procedureName,
values[i++] = (Datum) fmgr(F_TEXTIN, prosrc); /* prosrc */ values[i++] = (Datum) fmgr(F_TEXTIN, prosrc); /* prosrc */
values[i++] = (Datum) fmgr(F_TEXTIN, probin); /* probin */ values[i++] = (Datum) fmgr(F_TEXTIN, probin); /* probin */
rdesc = heap_openr(ProcedureRelationName); rel = heap_openr(ProcedureRelationName);
tupDesc = rdesc->rd_att; tupDesc = rel->rd_att;
tup = heap_formtuple(tupDesc, tup = heap_formtuple(tupDesc,
values, values,
nulls); nulls);
heap_insert(rdesc, tup); heap_insert(rel, tup);
if (RelationGetRelationTupleForm(rdesc)->relhasindex) if (RelationGetRelationTupleForm(rel)->relhasindex)
{ {
Relation idescs[Num_pg_proc_indices]; Relation idescs[Num_pg_proc_indices];
CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs); CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_proc_indices, rdesc, tup); CatalogIndexInsert(idescs, Num_pg_proc_indices, rel, tup);
CatalogCloseIndices(Num_pg_proc_indices, idescs); CatalogCloseIndices(Num_pg_proc_indices, idescs);
} }
heap_close(rdesc); heap_close(rel);
return tup->t_oid; return tup->t_oid;
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.26 1998/07/27 19:37:49 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.27 1998/08/19 02:01:38 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "fmgr.h" #include "fmgr.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "parser/parse_func.h" #include "parser/parse_func.h"
#include "storage/bufmgr.h"
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/syscache.h" #include "utils/syscache.h"
...@@ -68,7 +69,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc, ...@@ -68,7 +69,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
scan = heap_beginscan(pg_type_desc, scan = heap_beginscan(pg_type_desc,
0, 0,
SnapshotSelf, SnapshotSelf, /* cache? */
1, 1,
typeKey); typeKey);
...@@ -76,7 +77,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc, ...@@ -76,7 +77,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
* get the type tuple, if it exists. * get the type tuple, if it exists.
* ---------------- * ----------------
*/ */
tup = heap_getnext(scan, 0, (Buffer *) 0); tup = heap_getnext(scan, 0);
/* ---------------- /* ----------------
* if no type tuple exists for the given type name, then * if no type tuple exists for the given type name, then
...@@ -99,8 +100,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc, ...@@ -99,8 +100,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
heap_endscan(scan); heap_endscan(scan);
*defined = (bool) ((TypeTupleForm) GETSTRUCT(tup))->typisdefined; *defined = (bool) ((TypeTupleForm) GETSTRUCT(tup))->typisdefined;
return return tup->t_oid;
tup->t_oid;
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
...@@ -143,8 +143,7 @@ TypeGet(char *typeName, /* name of type to be fetched */ ...@@ -143,8 +143,7 @@ TypeGet(char *typeName, /* name of type to be fetched */
*/ */
heap_close(pg_type_desc); heap_close(pg_type_desc);
return return typeoid;
typeoid;
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
...@@ -312,11 +311,9 @@ TypeCreate(char *typeName, ...@@ -312,11 +311,9 @@ TypeCreate(char *typeName,
char replaces[Natts_pg_type]; char replaces[Natts_pg_type];
Datum values[Natts_pg_type]; Datum values[Natts_pg_type];
Buffer buffer;
char *procname; char *procname;
char *procs[4]; char *procs[4];
bool defined; bool defined;
ItemPointerData itemPointerData;
NameData name; NameData name;
TupleDesc tupDesc; TupleDesc tupDesc;
Oid argList[8]; Oid argList[8];
...@@ -353,9 +350,7 @@ TypeCreate(char *typeName, ...@@ -353,9 +350,7 @@ TypeCreate(char *typeName,
* ---------------- * ----------------
*/ */
if (externalSize == 0) if (externalSize == 0)
{
externalSize = -1; /* variable length */ externalSize = -1; /* variable length */
}
/* ---------------- /* ----------------
* initialize arrays needed by FormHeapTuple * initialize arrays needed by FormHeapTuple
...@@ -470,7 +465,7 @@ TypeCreate(char *typeName, ...@@ -470,7 +465,7 @@ TypeCreate(char *typeName,
typeKey[0].sk_argument = PointerGetDatum(typeName); typeKey[0].sk_argument = PointerGetDatum(typeName);
pg_type_scan = heap_beginscan(pg_type_desc, pg_type_scan = heap_beginscan(pg_type_desc,
0, 0,
SnapshotSelf, SnapshotSelf, /* cache? */
1, 1,
typeKey); typeKey);
...@@ -480,21 +475,17 @@ TypeCreate(char *typeName, ...@@ -480,21 +475,17 @@ TypeCreate(char *typeName,
* already there. * already there.
* ---------------- * ----------------
*/ */
tup = heap_getnext(pg_type_scan, 0, &buffer); tup = heap_getnext(pg_type_scan, 0);
if (HeapTupleIsValid(tup)) if (HeapTupleIsValid(tup))
{ {
tup = heap_modifytuple(tup, tup = heap_modifytuple(tup,
buffer,
pg_type_desc, pg_type_desc,
values, values,
nulls, nulls,
replaces); replaces);
/* XXX may not be necessary */
ItemPointerCopy(&tup->t_ctid, &itemPointerData);
setheapoverride(true); setheapoverride(true);
heap_replace(pg_type_desc, &itemPointerData, tup); heap_replace(pg_type_desc, &tup->t_ctid, tup);
setheapoverride(false); setheapoverride(false);
typeObjectId = tup->t_oid; typeObjectId = tup->t_oid;
...@@ -529,9 +520,7 @@ TypeCreate(char *typeName, ...@@ -529,9 +520,7 @@ TypeCreate(char *typeName,
RelationUnsetLockForWrite(pg_type_desc); RelationUnsetLockForWrite(pg_type_desc);
heap_close(pg_type_desc); heap_close(pg_type_desc);
return typeObjectId;
return
typeObjectId;
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
...@@ -545,48 +534,42 @@ TypeRename(char *oldTypeName, char *newTypeName) ...@@ -545,48 +534,42 @@ TypeRename(char *oldTypeName, char *newTypeName)
{ {
Relation pg_type_desc; Relation pg_type_desc;
Relation idescs[Num_pg_type_indices]; Relation idescs[Num_pg_type_indices];
Oid type_oid; HeapTuple oldtup, newtup;
HeapTuple tup;
bool defined;
ItemPointerData itemPointerData;
/* check that that the new type is not already defined */
type_oid = TypeGet(newTypeName, &defined);
if (OidIsValid(type_oid) && defined)
elog(ERROR, "TypeRename: type %s already defined", newTypeName);
/* get the type tuple from the catalog index scan manager */
pg_type_desc = heap_openr(TypeRelationName); pg_type_desc = heap_openr(TypeRelationName);
tup = TypeNameIndexScan(pg_type_desc, oldTypeName);
/* ----------------
* change the name of the type
* ----------------
*/
if (HeapTupleIsValid(tup))
{
namestrcpy(&(((TypeTupleForm) GETSTRUCT(tup))->typname), newTypeName);
ItemPointerCopy(&tup->t_ctid, &itemPointerData);
setheapoverride(true); oldtup = SearchSysCacheTupleCopy(TYPNAME,
heap_replace(pg_type_desc, &itemPointerData, tup); PointerGetDatum(oldTypeName),
setheapoverride(false); 0, 0, 0);
/* update the system catalog indices */ if (!HeapTupleIsValid(oldtup))
CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs); {
CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup); heap_close(pg_type_desc);
CatalogCloseIndices(Num_pg_type_indices, idescs); elog(ERROR, "TypeRename: type %s not defined", oldTypeName);
}
newtup = SearchSysCacheTuple(TYPNAME,
PointerGetDatum(newTypeName),
0, 0, 0);
if (HeapTupleIsValid(newtup))
{
pfree(oldtup);
heap_close(pg_type_desc);
elog(ERROR, "TypeRename: type %s already defined", newTypeName);
}
namestrcpy(&(((TypeTupleForm) GETSTRUCT(oldtup))->typname), newTypeName);
/* all done */ setheapoverride(true);
pfree(tup); heap_replace(pg_type_desc, &oldtup->t_ctid, oldtup);
setheapoverride(false);
} /* update the system catalog indices */
else CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
elog(ERROR, "TypeRename: type %s not defined", oldTypeName); CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, oldtup);
CatalogCloseIndices(Num_pg_type_indices, idescs);
/* finish up */ pfree(oldtup);
heap_close(pg_type_desc); heap_close(pg_type_desc);
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.13 1998/06/15 19:28:17 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.14 1998/08/19 02:01:58 momjian Exp $
* *
* NOTES * NOTES
* At the point the version is defined, 2 physical relations are created * At the point the version is defined, 2 physical relations are created
...@@ -185,26 +185,26 @@ VersionCreate(char *vname, char *bname) ...@@ -185,26 +185,26 @@ VersionCreate(char *vname, char *bname)
static void static void
setAttrList(char *bname) setAttrList(char *bname)
{ {
Relation rdesc; Relation rel;
int i = 0; int i = 0;
int maxattrs = 0; int maxattrs = 0;
char *attrname; char *attrname;
char temp_buf[512]; char temp_buf[512];
int notfirst = 0; int notfirst = 0;
rdesc = heap_openr(bname); rel = heap_openr(bname);
if (rdesc == NULL) if (rel == NULL)
{ {
elog(ERROR, "Unable to expand all -- amopenr failed "); elog(ERROR, "Unable to expand all -- amopenr failed ");
return; return;
} }
maxattrs = RelationGetNumberOfAttributes(rdesc); maxattrs = RelationGetNumberOfAttributes(rel);
attr_list[0] = '\0'; attr_list[0] = '\0';
for (i = maxattrs - 1; i > -1; --i) for (i = maxattrs - 1; i > -1; --i)
{ {
attrname = (rdesc->rd_att->attrs[i]->attname).data; attrname = (rel->rd_att->attrs[i]->attname).data;
if (notfirst == 1) if (notfirst == 1)
sprintf(temp_buf, ", %s = new.%s", attrname, attrname); sprintf(temp_buf, ", %s = new.%s", attrname, attrname);
...@@ -216,7 +216,7 @@ setAttrList(char *bname) ...@@ -216,7 +216,7 @@ setAttrList(char *bname)
strcat(attr_list, temp_buf); strcat(attr_list, temp_buf);
} }
heap_close(rdesc); heap_close(rel);
return; return;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.36 1998/07/27 19:37:50 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.37 1998/08/19 02:01:39 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -172,7 +172,6 @@ Async_Notify(char *relname) ...@@ -172,7 +172,6 @@ Async_Notify(char *relname)
HeapScanDesc sRel; HeapScanDesc sRel;
TupleDesc tdesc; TupleDesc tdesc;
ScanKeyData key; ScanKeyData key;
Buffer b;
Datum d, Datum d,
value[3]; value[3];
bool isnull; bool isnull;
...@@ -211,16 +210,14 @@ Async_Notify(char *relname) ...@@ -211,16 +210,14 @@ Async_Notify(char *relname)
value[0] = value[1] = value[2] = (Datum) 0; value[0] = value[1] = value[2] = (Datum) 0;
value[Anum_pg_listener_notify - 1] = Int32GetDatum(1); value[Anum_pg_listener_notify - 1] = Int32GetDatum(1);
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b))) while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
{ {
d = heap_getattr(lTuple, Anum_pg_listener_notify, d = heap_getattr(lTuple, Anum_pg_listener_notify, tdesc, &isnull);
tdesc, &isnull);
if (!DatumGetInt32(d)) if (!DatumGetInt32(d))
{ {
rTuple = heap_modifytuple(lTuple, b, lRel, value, nulls, repl); rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl);
heap_replace(lRel, &lTuple->t_ctid, rTuple); heap_replace(lRel, &lTuple->t_ctid, rTuple);
} }
ReleaseBuffer(b);
} }
heap_endscan(sRel); heap_endscan(sRel);
RelationUnsetLockForWrite(lRel); RelationUnsetLockForWrite(lRel);
...@@ -260,7 +257,6 @@ Async_NotifyAtCommit() ...@@ -260,7 +257,6 @@ Async_NotifyAtCommit()
ScanKeyData key; ScanKeyData key;
Datum d; Datum d;
bool isnull; bool isnull;
Buffer b;
extern TransactionState CurrentTransactionState; extern TransactionState CurrentTransactionState;
if (!pendingNotifies) if (!pendingNotifies)
...@@ -286,7 +282,7 @@ Async_NotifyAtCommit() ...@@ -286,7 +282,7 @@ Async_NotifyAtCommit()
sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, &key); sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, &key);
tdesc = RelationGetTupleDescriptor(lRel); tdesc = RelationGetTupleDescriptor(lRel);
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b))) while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
{ {
d = heap_getattr(lTuple, Anum_pg_listener_relname, d = heap_getattr(lTuple, Anum_pg_listener_relname,
tdesc, &isnull); tdesc, &isnull);
...@@ -317,7 +313,6 @@ Async_NotifyAtCommit() ...@@ -317,7 +313,6 @@ Async_NotifyAtCommit()
#endif #endif
} }
} }
ReleaseBuffer(b);
} }
heap_endscan(sRel); heap_endscan(sRel);
RelationUnsetLockForWrite(lRel); RelationUnsetLockForWrite(lRel);
...@@ -400,11 +395,10 @@ Async_Listen(char *relname, int pid) ...@@ -400,11 +395,10 @@ Async_Listen(char *relname, int pid)
Datum values[Natts_pg_listener]; Datum values[Natts_pg_listener];
char nulls[Natts_pg_listener]; char nulls[Natts_pg_listener];
TupleDesc tdesc; TupleDesc tdesc;
HeapScanDesc s; HeapScanDesc scan;
HeapTuple htup, HeapTuple tuple,
tup; newtup;
Relation lDesc; Relation lDesc;
Buffer b;
Datum d; Datum d;
int i; int i;
bool isnull; bool isnull;
...@@ -431,22 +425,21 @@ Async_Listen(char *relname, int pid) ...@@ -431,22 +425,21 @@ Async_Listen(char *relname, int pid)
/* is someone already listening. One listener per relation */ /* is someone already listening. One listener per relation */
tdesc = RelationGetTupleDescriptor(lDesc); tdesc = RelationGetTupleDescriptor(lDesc);
s = heap_beginscan(lDesc, 0, SnapshotNow, 0, (ScanKey) NULL); scan = heap_beginscan(lDesc, 0, SnapshotNow, 0, (ScanKey) NULL);
while (HeapTupleIsValid(htup = heap_getnext(s, 0, &b))) while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
{ {
d = heap_getattr(htup, Anum_pg_listener_relname, tdesc, d = heap_getattr(tuple, Anum_pg_listener_relname, tdesc,
&isnull); &isnull);
relnamei = DatumGetPointer(d); relnamei = DatumGetPointer(d);
if (!strncmp(relnamei, relname, NAMEDATALEN)) if (!strncmp(relnamei, relname, NAMEDATALEN))
{ {
d = heap_getattr(htup, Anum_pg_listener_pid, tdesc, &isnull); d = heap_getattr(tuple, Anum_pg_listener_pid, tdesc, &isnull);
pid = DatumGetInt32(d); pid = DatumGetInt32(d);
if (pid == MyProcPid) if (pid == MyProcPid)
alreadyListener = 1; alreadyListener = 1;
} }
ReleaseBuffer(b);
} }
heap_endscan(s); heap_endscan(scan);
if (alreadyListener) if (alreadyListener)
{ {
...@@ -456,12 +449,12 @@ Async_Listen(char *relname, int pid) ...@@ -456,12 +449,12 @@ Async_Listen(char *relname, int pid)
} }
tupDesc = lDesc->rd_att; tupDesc = lDesc->rd_att;
tup = heap_formtuple(tupDesc, newtup = heap_formtuple(tupDesc,
values, values,
nulls); nulls);
heap_insert(lDesc, tup); heap_insert(lDesc, newtup);
pfree(tup); pfree(newtup);
/* /*
* if (alreadyListener) { elog(NOTICE,"Async_Listen: already one * if (alreadyListener) { elog(NOTICE,"Async_Listen: already one
...@@ -504,7 +497,8 @@ Async_Unlisten(char *relname, int pid) ...@@ -504,7 +497,8 @@ Async_Unlisten(char *relname, int pid)
Relation lDesc; Relation lDesc;
HeapTuple lTuple; HeapTuple lTuple;
lTuple = SearchSysCacheTuple(LISTENREL, PointerGetDatum(relname), lTuple = SearchSysCacheTuple(LISTENREL,
PointerGetDatum(relname),
Int32GetDatum(pid), Int32GetDatum(pid),
0, 0); 0, 0);
lDesc = heap_openr(ListenerRelationName); lDesc = heap_openr(ListenerRelationName);
...@@ -556,7 +550,6 @@ Async_NotifyFrontEnd() ...@@ -556,7 +550,6 @@ Async_NotifyFrontEnd()
value[3]; value[3];
char repl[3], char repl[3],
nulls[3]; nulls[3];
Buffer b;
bool isnull; bool isnull;
notifyFrontEndPending = 0; notifyFrontEndPending = 0;
...@@ -585,11 +578,10 @@ Async_NotifyFrontEnd() ...@@ -585,11 +578,10 @@ Async_NotifyFrontEnd()
value[0] = value[1] = value[2] = (Datum) 0; value[0] = value[1] = value[2] = (Datum) 0;
value[Anum_pg_listener_notify - 1] = Int32GetDatum(0); value[Anum_pg_listener_notify - 1] = Int32GetDatum(0);
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b))) while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
{ {
d = heap_getattr(lTuple, Anum_pg_listener_relname, d = heap_getattr(lTuple, Anum_pg_listener_relname, tdesc, &isnull);
tdesc, &isnull); rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl);
rTuple = heap_modifytuple(lTuple, b, lRel, value, nulls, repl);
heap_replace(lRel, &lTuple->t_ctid, rTuple); heap_replace(lRel, &lTuple->t_ctid, rTuple);
/* notifying the front end */ /* notifying the front end */
...@@ -603,8 +595,9 @@ Async_NotifyFrontEnd() ...@@ -603,8 +595,9 @@ Async_NotifyFrontEnd()
} }
else else
elog(NOTICE, "Async_NotifyFrontEnd: no asynchronous notification to frontend on interactive sessions"); elog(NOTICE, "Async_NotifyFrontEnd: no asynchronous notification to frontend on interactive sessions");
ReleaseBuffer(b);
} }
heap_endscan(sRel);
heap_close(lRel);
CommitTransactionCommand(); CommitTransactionCommand();
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.27 1998/08/06 05:12:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.28 1998/08/19 02:01:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -128,7 +128,7 @@ cluster(char oldrelname[], char oldindexname[]) ...@@ -128,7 +128,7 @@ cluster(char oldrelname[], char oldindexname[])
elog(ERROR, "cluster: unknown relation: \"%s\"", elog(ERROR, "cluster: unknown relation: \"%s\"",
oldrelname); oldrelname);
} }
OIDOldHeap = OldHeap->rd_id;/* Get OID for the index scan */ OIDOldHeap = RelationGetRelid(OldHeap);/* Get OID for the index scan */
OldIndex = index_openr(oldindexname); /* Open old index relation */ OldIndex = index_openr(oldindexname); /* Open old index relation */
if (!RelationIsValid(OldIndex)) if (!RelationIsValid(OldIndex))
...@@ -136,7 +136,7 @@ cluster(char oldrelname[], char oldindexname[]) ...@@ -136,7 +136,7 @@ cluster(char oldrelname[], char oldindexname[])
elog(ERROR, "cluster: unknown index: \"%s\"", elog(ERROR, "cluster: unknown index: \"%s\"",
oldindexname); oldindexname);
} }
OIDOldIndex = OldIndex->rd_id; /* OID for the index scan */ OIDOldIndex = RelationGetRelid(OldIndex); /* OID for the index scan */
heap_close(OldHeap); heap_close(OldHeap);
index_close(OldIndex); index_close(OldIndex);
...@@ -150,7 +150,7 @@ cluster(char oldrelname[], char oldindexname[]) ...@@ -150,7 +150,7 @@ cluster(char oldrelname[], char oldindexname[])
* with a pg_vlock. * with a pg_vlock.
*/ */
NewHeap = copy_heap(OIDOldHeap); NewHeap = copy_heap(OIDOldHeap);
OIDNewHeap = NewHeap->rd_id; OIDNewHeap = RelationGetRelid(NewHeap);
strcpy(NewHeapName, NewHeap->rd_rel->relname.data); strcpy(NewHeapName, NewHeap->rd_rel->relname.data);
...@@ -257,7 +257,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) ...@@ -257,7 +257,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
*/ */
Old_pg_index_Tuple = Old_pg_index_Tuple =
SearchSysCacheTuple(INDEXRELID, SearchSysCacheTuple(INDEXRELID,
ObjectIdGetDatum(OldIndex->rd_id), ObjectIdGetDatum(RelationGetRelid(OldIndex)),
0, 0, 0); 0, 0, 0);
Assert(Old_pg_index_Tuple); Assert(Old_pg_index_Tuple);
...@@ -265,7 +265,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) ...@@ -265,7 +265,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
Old_pg_index_relation_Tuple = Old_pg_index_relation_Tuple =
SearchSysCacheTuple(RELOID, SearchSysCacheTuple(RELOID,
ObjectIdGetDatum(OldIndex->rd_id), ObjectIdGetDatum(RelationGetRelid(OldIndex)),
0, 0, 0); 0, 0, 0);
Assert(Old_pg_index_relation_Tuple); Assert(Old_pg_index_relation_Tuple);
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.52 1998/07/27 19:37:51 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.53 1998/08/19 02:01:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -257,9 +257,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -257,9 +257,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
fwrite(&ntuples, sizeof(int32), 1, fp); fwrite(&ntuples, sizeof(int32), 1, fp);
} }
for (tuple = heap_getnext(scandesc, 0, NULL); while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
tuple != NULL;
tuple = heap_getnext(scandesc, 0, NULL))
{ {
if (oids && !binary) if (oids && !binary)
...@@ -417,7 +415,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -417,7 +415,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
if (rel->rd_rel->relhasindex) if (rel->rd_rel->relhasindex)
{ {
GetIndexRelations(rel->rd_id, &n_indices, &index_rels); GetIndexRelations(RelationGetRelid(rel), &n_indices, &index_rels);
if (n_indices > 0) if (n_indices > 0)
{ {
has_index = true; has_index = true;
...@@ -435,7 +433,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -435,7 +433,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
itupdescArr[i] = RelationGetTupleDescriptor(index_rels[i]); itupdescArr[i] = RelationGetTupleDescriptor(index_rels[i]);
pgIndexTup = pgIndexTup =
SearchSysCacheTuple(INDEXRELID, SearchSysCacheTuple(INDEXRELID,
ObjectIdGetDatum(index_rels[i]->rd_id), ObjectIdGetDatum(RelationGetRelid(index_rels[i])),
0, 0, 0); 0, 0, 0);
Assert(pgIndexTup); Assert(pgIndexTup);
pgIndexP[i] = (IndexTupleForm) GETSTRUCT(pgIndexTup); pgIndexP[i] = (IndexTupleForm) GETSTRUCT(pgIndexTup);
...@@ -758,7 +756,6 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -758,7 +756,6 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
(AttrNumber *) &(pgIndexP[i]->indkey[0]), (AttrNumber *) &(pgIndexP[i]->indkey[0]),
tuple, tuple,
tupDesc, tupDesc,
InvalidBuffer,
idatum, idatum,
index_nulls, index_nulls,
finfoP[i]); finfoP[i]);
...@@ -833,7 +830,6 @@ GetTypeElement(Oid type) ...@@ -833,7 +830,6 @@ GetTypeElement(Oid type)
ObjectIdGetDatum(type), ObjectIdGetDatum(type),
0, 0, 0); 0, 0, 0);
if (HeapTupleIsValid(typeTuple)) if (HeapTupleIsValid(typeTuple))
return ((int) ((TypeTupleForm) GETSTRUCT(typeTuple))->typelem); return ((int) ((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
...@@ -913,9 +909,7 @@ GetIndexRelations(Oid main_relation_oid, ...@@ -913,9 +909,7 @@ GetIndexRelations(Oid main_relation_oid,
scan = head; scan = head;
head->next = NULL; head->next = NULL;
for (tuple = heap_getnext(scandesc, 0, NULL); while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
tuple != NULL;
tuple = heap_getnext(scandesc, 0, NULL))
{ {
index_relation_oid = index_relation_oid =
...@@ -1168,10 +1162,9 @@ CountTuples(Relation relation) ...@@ -1168,10 +1162,9 @@ CountTuples(Relation relation)
scandesc = heap_beginscan(relation, 0, SnapshotNow, 0, NULL); scandesc = heap_beginscan(relation, 0, SnapshotNow, 0, NULL);
for (tuple = heap_getnext(scandesc, 0, NULL), i = 0; i = 0;
tuple != NULL; while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
tuple = heap_getnext(scandesc, 0, NULL), i++) i++;
;
heap_endscan(scandesc); heap_endscan(scandesc);
return (i); return (i);
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -466,7 +466,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber) ...@@ -466,7 +466,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
} }
typeTuple = SearchSysCacheTuple(TYPOID, typeTuple = SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid), ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typeTuple)) if (!HeapTupleIsValid(typeTuple))
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment