mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Properly structure ProcedureNameIndexScan so it doesn't generate
"may be used before being set" warnings.
This commit is contained in:
parent
bf14017220
commit
02c0eb6549
@ -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,26 +352,36 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
|
|||||||
return tuple;
|
return tuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HeapTuple
|
HeapTuple
|
||||||
ProcedureNameIndexScan(Relation heapRelation,
|
ProcedureNameIndexScan(Relation heapRelation,
|
||||||
char *procName,
|
char *procName,
|
||||||
int nargs,
|
int nargs,
|
||||||
Oid *argTypes)
|
Oid *argTypes)
|
||||||
{
|
{
|
||||||
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,
|
||||||
(AttrNumber)1,
|
(AttrNumber)1,
|
||||||
(RegProcedure)NameEqualRegProcedure,
|
(RegProcedure)NameEqualRegProcedure,
|
||||||
(Datum)procName);
|
(Datum)procName);
|
||||||
|
|
||||||
idesc = index_openr(ProcedureNameIndex);
|
idesc = index_openr(ProcedureNameIndex);
|
||||||
|
|
||||||
@ -382,41 +392,46 @@ 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);
|
||||||
}
|
if (indexRes) {
|
||||||
|
ItemPointer iptr;
|
||||||
indexRes = index_getnext(sd, ForwardScanDirection);
|
|
||||||
if (indexRes) {
|
iptr = &indexRes->heap_iptr;
|
||||||
ItemPointer iptr;
|
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
||||||
|
pfree(indexRes);
|
||||||
iptr = &indexRes->heap_iptr;
|
if (HeapTupleIsValid(tuple)) {
|
||||||
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
/* Here's a row for a procedure that has the sought procedure
|
||||||
pfree(indexRes);
|
name. To be a match, though, we need it to have the
|
||||||
if (HeapTupleIsValid(tuple)) {
|
right number and type of arguments too, so we check that
|
||||||
pgProcP = (Form_pg_proc)GETSTRUCT(tuple);
|
now.
|
||||||
bufferUsed = TRUE;
|
*/
|
||||||
}
|
pgProcP = (Form_pg_proc)GETSTRUCT(tuple);
|
||||||
} else
|
if (pgProcP->pronargs == nargs &&
|
||||||
break;
|
oid8eq(&(pgProcP->proargtypes[0]), argTypes))
|
||||||
} while (!HeapTupleIsValid(tuple) ||
|
FoundMatch = true;
|
||||||
pgProcP->pronargs != nargs ||
|
else ReleaseBuffer(buffer);
|
||||||
!oid8eq(&(pgProcP->proargtypes[0]), argTypes));
|
}
|
||||||
|
} else ScanComplete = true;
|
||||||
if (HeapTupleIsValid(tuple)) {
|
|
||||||
tuple = heap_copytuple(tuple);
|
|
||||||
ReleaseBuffer(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FoundMatch) {
|
||||||
|
Assert(HeapTupleIsValid(tuple));
|
||||||
|
return_tuple = heap_copytuple(tuple);
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user