1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +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

@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.52 1998/08/06 05:12:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.53 1998/08/19 02:01:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -283,7 +283,7 @@ ExecCheckPerms(CmdType operation,
{
int i = 1;
Oid relid;
HeapTuple htp;
HeapTuple htup;
List *lp;
List *qvars,
*tvars;
@ -314,14 +314,14 @@ ExecCheckPerms(CmdType operation,
}
relid = rte->relid;
htp = SearchSysCacheTuple(RELOID,
htup = SearchSysCacheTuple(RELOID,
ObjectIdGetDatum(relid),
0, 0, 0);
if (!HeapTupleIsValid(htp))
if (!HeapTupleIsValid(htup))
elog(ERROR, "ExecCheckPerms: bogus RT relid: %d",
relid);
StrNCpy(rname.data,
((Form_pg_class) GETSTRUCT(htp))->relname.data,
((Form_pg_class) GETSTRUCT(htup))->relname.data,
NAMEDATALEN);
if (i == resultRelation)
{ /* this is the result relation */
@ -1290,9 +1290,10 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
if (repl == NULL)
return (tuple);
newtuple = heap_modifytuple(tuple, InvalidBuffer, rel, replValue, replNull, repl);
newtuple = heap_modifytuple(tuple, rel, replValue, replNull, repl);
pfree(repl);
pfree(tuple);
pfree(replNull);
pfree(replValue);
@ -1323,7 +1324,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
slot->ttc_whichplan = -1;
rte->relname = nameout(&(rel->rd_rel->relname));
rte->refname = rte->relname;
rte->relid = rel->rd_id;
rte->relid = RelationGetRelid(rel);
rte->inh = false;
rte->inFromCl = true;
rtlist = lcons(rte, NIL);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.34 1998/07/27 19:37:56 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.35 1998/08/19 02:02:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -760,10 +760,7 @@ ExecOpenIndices(Oid resultRelationOid,
fiList = NIL;
predList = NIL;
while (tuple = heap_getnext(indexSd, /* scan desc */
false, /* scan backward flag */
NULL), /* return: buffer */
HeapTupleIsValid(tuple))
while (HeapTupleIsValid(tuple = heap_getnext(indexSd, 0)))
{
/* ----------------
@ -1020,8 +1017,6 @@ ExecFormIndexTuple(HeapTuple heapTuple,
keyAttributeNumbers, /* array of att nums to extract */
heapTuple, /* tuple from base relation */
heapDescriptor, /* heap tuple's descriptor */
InvalidBuffer, /* buffer associated with heap
* tuple */
datum, /* return: array of attributes */
nulls, /* return: array of char's */
fInfoP); /* functional index information */
@ -1136,8 +1131,6 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
* extract */
heapTuple, /* tuple from base relation */
heapDescriptor, /* heap tuple's descriptor */
InvalidBuffer, /* buffer associated with heap
* tuple */
datum, /* return: array of attributes */
nulls, /* return: array of char's */
fInfoP); /* functional index information */

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.23 1998/08/04 18:42:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.24 1998/08/19 02:02:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -123,7 +123,6 @@ IndexNext(IndexScan *node)
{
tuple = heap_fetch(heapRelation, snapshot,
&result->heap_iptr, &buffer);
/* be tidy */
pfree(result);
if (tuple != NULL)
@ -224,7 +223,7 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
ScanDirection direction;
IndexScanDescPtr scanDescs;
ScanKey *scanKeys;
IndexScanDesc sdesc;
IndexScanDesc scan;
ScanKey skey;
int numIndices;
int i;
@ -301,9 +300,9 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
}
}
}
sdesc = scanDescs[i];
scan = scanDescs[i];
skey = scanKeys[i];
index_rescan(sdesc, direction, skey);
index_rescan(scan, direction, skey);
}
/* ----------------
* perhaps return something meaningful

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.14 1998/07/27 19:37:57 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.15 1998/08/19 02:02:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -59,7 +59,6 @@ ExecMaterial(Material *node)
HeapScanDesc currentScanDesc;
HeapTuple heapTuple;
TupleTableSlot *slot;
Buffer buffer;
/* ----------------
* get state info from node
@ -162,10 +161,7 @@ ExecMaterial(Material *node)
*/
currentScanDesc = matstate->csstate.css_currentScanDesc;
heapTuple = heap_getnext(currentScanDesc, /* scan desc */
ScanDirectionIsBackward(dir),
/* bkwd flag */
&buffer); /* return: buffer */
heapTuple = heap_getnext(currentScanDesc, ScanDirectionIsBackward(dir));
/* ----------------
* put the tuple into the scan tuple slot and return the slot.
@ -177,7 +173,7 @@ ExecMaterial(Material *node)
return ExecStoreTuple(heapTuple, /* tuple to store */
slot, /* slot to store in */
buffer, /* buffer for this tuple */
currentScanDesc->rs_cbuf, /* buffer for this tuple */
false); /* don't pfree this pointer */
}
@ -370,7 +366,7 @@ List /* nothing of interest */
ExecMaterialMarkPos(Material node)
{
MaterialState matstate;
HeapScanDesc sdesc;
HeapScanDesc scan;
/* ----------------
* if we haven't materialized yet, just return NIL.
@ -386,8 +382,8 @@ ExecMaterialMarkPos(Material node)
* they will never return positions for all I know -cim 10/16/89
* ----------------
*/
sdesc = get_css_currentScanDesc((CommonScanState) matstate);
heap_markpos(sdesc);
scan = get_css_currentScanDesc((CommonScanState) matstate);
heap_markpos(scan);
return NIL;
}
@ -400,7 +396,7 @@ void
ExecMaterialRestrPos(Material node)
{
MaterialState matstate;
HeapScanDesc sdesc;
HeapScanDesc scan;
/* ----------------
* if we haven't materialized yet, just return.
@ -414,8 +410,8 @@ ExecMaterialRestrPos(Material node)
* restore the scan to the previously marked position
* ----------------
*/
sdesc = get_css_currentScanDesc((CommonScanState) matstate);
heap_restrpos(sdesc);
scan = get_css_currentScanDesc((CommonScanState) matstate);
heap_restrpos(scan);
}
#endif

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.11 1998/07/27 19:37:57 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.12 1998/08/19 02:02:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -55,7 +55,6 @@ SeqNext(SeqScan *node)
EState *estate;
ScanDirection direction;
TupleTableSlot *slot;
Buffer buffer;
/* ----------------
* get information from the estate and scan state
@ -70,9 +69,7 @@ SeqNext(SeqScan *node)
* get the next tuple from the access methods
* ----------------
*/
tuple = heap_getnext(scandesc, /* scan desc */
ScanDirectionIsBackward(direction), /* backward flag */
&buffer); /* return: buffer */
tuple = heap_getnext(scandesc, ScanDirectionIsBackward(direction));
/* ----------------
* save the tuple and the buffer returned to us by the access methods
@ -86,8 +83,7 @@ SeqNext(SeqScan *node)
slot = ExecStoreTuple(tuple,/* tuple to store */
slot, /* slot to store in */
buffer, /* buffer associated with this
* tuple */
scandesc->rs_cbuf,/* buffer associated with this tuple */
false); /* don't pfree this pointer */
/* ----------------
@ -364,8 +360,8 @@ ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent)
CommonScanState *scanstate;
EState *estate;
Plan *outerPlan;
Relation rdesc;
HeapScanDesc sdesc;
Relation rel;
HeapScanDesc scan;
ScanDirection direction;
scanstate = node->scanstate;
@ -380,11 +376,11 @@ ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent)
else
{
/* otherwise, we are scanning a relation */
rdesc = scanstate->css_currentRelation;
sdesc = scanstate->css_currentScanDesc;
rel = scanstate->css_currentRelation;
scan = scanstate->css_currentScanDesc;
direction = estate->es_direction;
sdesc = ExecReScanR(rdesc, sdesc, direction, 0, NULL);
scanstate->css_currentScanDesc = sdesc;
scan = ExecReScanR(rel, scan, direction, 0, NULL);
scanstate->css_currentScanDesc = scan;
}
}
@ -399,7 +395,7 @@ ExecSeqMarkPos(SeqScan *node)
{
CommonScanState *scanstate;
Plan *outerPlan;
HeapScanDesc sdesc;
HeapScanDesc scan;
scanstate = node->scanstate;
@ -421,8 +417,8 @@ ExecSeqMarkPos(SeqScan *node)
*
* ----------------
*/
sdesc = scanstate->css_currentScanDesc;
heap_markpos(sdesc);
scan = scanstate->css_currentScanDesc;
heap_markpos(scan);
return;
}
@ -438,7 +434,7 @@ ExecSeqRestrPos(SeqScan *node)
{
CommonScanState *scanstate;
Plan *outerPlan;
HeapScanDesc sdesc;
HeapScanDesc scan;
scanstate = node->scanstate;
@ -459,6 +455,6 @@ ExecSeqRestrPos(SeqScan *node)
* position using the access methods..
* ----------------
*/
sdesc = scanstate->css_currentScanDesc;
heap_restrpos(sdesc);
scan = scanstate->css_currentScanDesc;
heap_restrpos(scan);
}

View File

@ -15,7 +15,7 @@
* ExecEndTee
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.20 1998/08/06 05:12:36 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.21 1998/08/19 02:02:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -303,7 +303,6 @@ ExecTee(Tee *node, Plan *parent)
HeapTuple heapTuple;
Relation bufferRel;
HeapScanDesc scanDesc;
Buffer buffer;
estate = ((Plan *) node)->state;
teeState = node->teestate;
@ -366,10 +365,7 @@ ExecTee(Tee *node, Plan *parent)
HeapTuple throwAway;
/* Buffer buffer; */
throwAway = heap_getnext(scanDesc,
ScanDirectionIsBackward(dir),
/* &buffer */
(Buffer *) NULL);
throwAway = heap_getnext(scanDesc,ScanDirectionIsBackward(dir));
}
/*
@ -393,9 +389,7 @@ ExecTee(Tee *node, Plan *parent)
scanDesc = (parent == node->leftParent) ?
teeState->tee_leftScanDesc : teeState->tee_rightScanDesc;
heapTuple = heap_getnext(scanDesc,
ScanDirectionIsBackward(dir),
&buffer);
heapTuple = heap_getnext(scanDesc, ScanDirectionIsBackward(dir));
/*
* Increase the pin count on the buffer page, because the tuple
@ -404,15 +398,15 @@ ExecTee(Tee *node, Plan *parent)
* count on the next iteration.
*/
if (buffer != InvalidBuffer)
IncrBufferRefCount(buffer);
if (scanDesc->rs_cbuf != InvalidBuffer)
IncrBufferRefCount(scanDesc->rs_cbuf);
slot = teeState->cstate.cs_ResultTupleSlot;
slot->ttc_tupleDescriptor = RelationGetTupleDescriptor(bufferRel);
result = ExecStoreTuple(heapTuple, /* tuple to store */
slot, /* slot to store in */
buffer, /* this tuple's buffer */
scanDesc->rs_cbuf, /* this tuple's buffer */
false); /* don't free stuff from
* heap_getnext */

View File

@ -466,7 +466,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
}
typeTuple = SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid),
ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))