Commit 02c0eb65 authored by Bryan Henderson's avatar Bryan Henderson

Properly structure ProcedureNameIndexScan so it doesn't generate

"may be used before being set" warnings.
parent bf140172
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.6 1996/11/13 20:47:57 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.7 1996/11/26 02:45:05 bryanh Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -352,6 +352,8 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId) ...@@ -352,6 +352,8 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
return tuple; return tuple;
} }
HeapTuple HeapTuple
ProcedureNameIndexScan(Relation heapRelation, ProcedureNameIndexScan(Relation heapRelation,
char *procName, char *procName,
...@@ -360,12 +362,20 @@ ProcedureNameIndexScan(Relation heapRelation, ...@@ -360,12 +362,20 @@ ProcedureNameIndexScan(Relation heapRelation,
{ {
Relation idesc; Relation idesc;
ScanKeyData skey; ScanKeyData skey;
HeapTuple tuple; HeapTuple tuple; /* tuple being tested */
HeapTuple return_tuple; /* The tuple pointer we eventually return */
IndexScanDesc sd; IndexScanDesc sd;
RetrieveIndexResult indexRes; RetrieveIndexResult indexRes;
Buffer buffer; Buffer buffer;
Form_pg_proc pgProcP; Form_pg_proc pgProcP;
bool bufferUsed = FALSE; bool ScanComplete;
/* The index scan is complete, i.e. we've scanned everything there
is to scan.
*/
bool FoundMatch;
/* In scanning pg_proc, we have found a row that meets our search
criteria.
*/
ScanKeyEntryInitialize(&skey, ScanKeyEntryInitialize(&skey,
(bits16)0x0, (bits16)0x0,
...@@ -382,13 +392,10 @@ ProcedureNameIndexScan(Relation heapRelation, ...@@ -382,13 +392,10 @@ ProcedureNameIndexScan(Relation heapRelation,
* by hand, so that we can check that the other keys match. when * by hand, so that we can check that the other keys match. when
* multi-key indices are added, they will be used here. * multi-key indices are added, they will be used here.
*/ */
do { tuple = (HeapTuple) NULL; /* initial value */
tuple = (HeapTuple)NULL; ScanComplete = false; /* Scan hasn't begun yet */
if (bufferUsed) { FoundMatch = false; /* No match yet; haven't even looked. */
ReleaseBuffer(buffer); while (!FoundMatch && !ScanComplete) {
bufferUsed = FALSE;
}
indexRes = index_getnext(sd, ForwardScanDirection); indexRes = index_getnext(sd, ForwardScanDirection);
if (indexRes) { if (indexRes) {
ItemPointer iptr; ItemPointer iptr;
...@@ -397,26 +404,34 @@ ProcedureNameIndexScan(Relation heapRelation, ...@@ -397,26 +404,34 @@ ProcedureNameIndexScan(Relation heapRelation,
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
pfree(indexRes); pfree(indexRes);
if (HeapTupleIsValid(tuple)) { if (HeapTupleIsValid(tuple)) {
/* Here's a row for a procedure that has the sought procedure
name. To be a match, though, we need it to have the
right number and type of arguments too, so we check that
now.
*/
pgProcP = (Form_pg_proc)GETSTRUCT(tuple); pgProcP = (Form_pg_proc)GETSTRUCT(tuple);
bufferUsed = TRUE; if (pgProcP->pronargs == nargs &&
oid8eq(&(pgProcP->proargtypes[0]), argTypes))
FoundMatch = true;
else ReleaseBuffer(buffer);
}
} else ScanComplete = true;
} }
} else
break;
} while (!HeapTupleIsValid(tuple) ||
pgProcP->pronargs != nargs ||
!oid8eq(&(pgProcP->proargtypes[0]), argTypes));
if (HeapTupleIsValid(tuple)) { if (FoundMatch) {
tuple = heap_copytuple(tuple); Assert(HeapTupleIsValid(tuple));
return_tuple = heap_copytuple(tuple);
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
} } else return_tuple = (HeapTuple)NULL;
index_endscan(sd); index_endscan(sd);
index_close(idesc); index_close(idesc);
return tuple; return return_tuple;
} }
HeapTuple HeapTuple
ProcedureSrcIndexScan(Relation heapRelation, text *procSrc) ProcedureSrcIndexScan(Relation heapRelation, text *procSrc)
{ {
......
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