Fix for possible releasebuffer bug.

This commit is contained in:
Bruce Momjian 1998-08-30 23:25:56 +00:00
parent 6c4982851a
commit a753e5d192
2 changed files with 34 additions and 35 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.22 1998/08/20 22:07:36 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.23 1998/08/30 23:25:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -227,31 +227,26 @@ CatalogIndexFetchTuple(Relation heapRelation,
{
IndexScanDesc sd;
RetrieveIndexResult indexRes;
HeapTuple tuple;
HeapTuple tuple = NULL;
Buffer buffer;
sd = index_beginscan(idesc, false, num_keys, skey);
tuple = (HeapTuple) NULL;
do
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (indexRes)
{
ItemPointer iptr;
ItemPointer iptr;
iptr = &indexRes->heap_iptr;
tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
pfree(indexRes);
}
else
iptr = &indexRes->heap_iptr;
tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
pfree(indexRes);
if (HeapTupleIsValid(tuple))
break;
} while (!HeapTupleIsValid(tuple));
}
if (HeapTupleIsValid(tuple))
{
tuple = heap_copytuple(tuple);
if (BufferIsValid(buffer))
ReleaseBuffer(buffer);
}
index_endscan(sd);
pfree(sd);
@ -333,7 +328,7 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
(Datum) procId);
ObjectIdGetDatum(procId));
idesc = index_openr(ProcedureOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -359,7 +354,7 @@ ProcedureNameIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
(Datum) procName);
PointerGetDatum(procName));
ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0,
@ -371,7 +366,7 @@ ProcedureNameIndexScan(Relation heapRelation,
(bits16) 0x0,
(AttrNumber) 3,
(RegProcedure) F_OID8EQ,
(Datum) argTypes);
PointerGetDatum(argTypes));
idesc = index_openr(ProcedureNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
@ -394,7 +389,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text *procSrc)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_TEXTEQ,
(Datum) procSrc);
PointerGetDatum(procSrc));
idesc = index_openr(ProcedureSrcIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -415,7 +410,7 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
(Datum) typeId);
ObjectIdGetDatum(typeId));
idesc = index_openr(TypeOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -436,7 +431,7 @@ TypeNameIndexScan(Relation heapRelation, char *typeName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
(Datum) typeName);
PointerGetDatum(typeName));
idesc = index_openr(TypeNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
@ -477,7 +472,7 @@ ClassOidIndexScan(Relation heapRelation, Oid relId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
(Datum) relId);
ObjectIdGetDatum(relId));
idesc = index_openr(ClassOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);

View File

@ -1,7 +1,7 @@
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.24 1998/08/23 22:25:51 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.25 1998/08/30 23:25:56 momjian Exp $
*/
#define FLEX_SCANNER
@ -555,7 +555,7 @@ char *yytext;
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.24 1998/08/23 22:25:51 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.25 1998/08/30 23:25:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -1181,6 +1181,8 @@ YY_RULE_SETUP
if (isascii((unsigned char)yytext[i]) &&
isupper(yytext[i]))
yytext[i] = tolower(yytext[i]);
if (i >= NAMEDATALEN)
yytext[NAMEDATALEN-1] = '\0';
keyword = ScanKeywordLookup((char*)yytext);
if (keyword != NULL) {
@ -1195,7 +1197,7 @@ YY_RULE_SETUP
YY_BREAK
case 34:
YY_RULE_SETUP
#line 337 "scan.l"
#line 339 "scan.l"
{
char* endptr;
@ -1217,7 +1219,7 @@ YY_RULE_SETUP
YY_BREAK
case 35:
YY_RULE_SETUP
#line 355 "scan.l"
#line 357 "scan.l"
{
char* endptr;
@ -1232,7 +1234,7 @@ YY_RULE_SETUP
YY_BREAK
case 36:
YY_RULE_SETUP
#line 366 "scan.l"
#line 368 "scan.l"
{
char* endptr;
@ -1253,7 +1255,7 @@ YY_RULE_SETUP
YY_BREAK
case 37:
YY_RULE_SETUP
#line 383 "scan.l"
#line 385 "scan.l"
{
char* endptr;
@ -1267,7 +1269,7 @@ YY_RULE_SETUP
YY_BREAK
case 38:
YY_RULE_SETUP
#line 395 "scan.l"
#line 397 "scan.l"
{
int i;
ScanKeyword *keyword;
@ -1276,6 +1278,8 @@ YY_RULE_SETUP
if (isascii((unsigned char)yytext[i]) &&
isupper(yytext[i]))
yytext[i] = tolower(yytext[i]);
if (i >= NAMEDATALEN)
yytext[NAMEDATALEN-1] = '\0';
keyword = ScanKeywordLookup((char*)yytext);
if (keyword != NULL) {
@ -1290,20 +1294,20 @@ YY_RULE_SETUP
YY_BREAK
case 39:
YY_RULE_SETUP
#line 414 "scan.l"
#line 418 "scan.l"
{ /* ignore */ }
YY_BREAK
case 40:
YY_RULE_SETUP
#line 416 "scan.l"
#line 420 "scan.l"
{ return (yytext[0]); }
YY_BREAK
case 41:
YY_RULE_SETUP
#line 418 "scan.l"
#line 422 "scan.l"
ECHO;
YY_BREAK
#line 1307 "lex.yy.c"
#line 1311 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(xb):
case YY_STATE_EOF(xc):
@ -2189,7 +2193,7 @@ int main()
return 0;
}
#endif
#line 418 "scan.l"
#line 422 "scan.l"
void yyerror(char message[])