Commit a753e5d1 authored by Bruce Momjian's avatar Bruce Momjian

Fix for possible releasebuffer bug.

parent 6c498285
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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, ...@@ -227,31 +227,26 @@ CatalogIndexFetchTuple(Relation heapRelation,
{ {
IndexScanDesc sd; IndexScanDesc sd;
RetrieveIndexResult indexRes; RetrieveIndexResult indexRes;
HeapTuple tuple; HeapTuple tuple = NULL;
Buffer buffer; Buffer buffer;
sd = index_beginscan(idesc, false, num_keys, skey); sd = index_beginscan(idesc, false, num_keys, skey);
tuple = (HeapTuple) NULL; while ((indexRes = index_getnext(sd, ForwardScanDirection)))
do
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (indexRes)
{ {
ItemPointer iptr; ItemPointer iptr;
iptr = &indexRes->heap_iptr; iptr = &indexRes->heap_iptr;
tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer); tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
pfree(indexRes); pfree(indexRes);
} if (HeapTupleIsValid(tuple))
else
break; break;
} while (!HeapTupleIsValid(tuple)); }
if (HeapTupleIsValid(tuple)) if (HeapTupleIsValid(tuple))
{
tuple = heap_copytuple(tuple); tuple = heap_copytuple(tuple);
if (BufferIsValid(buffer))
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
}
index_endscan(sd); index_endscan(sd);
pfree(sd); pfree(sd);
...@@ -333,7 +328,7 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId) ...@@ -333,7 +328,7 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
(RegProcedure) F_OIDEQ, (RegProcedure) F_OIDEQ,
(Datum) procId); ObjectIdGetDatum(procId));
idesc = index_openr(ProcedureOidIndex); idesc = index_openr(ProcedureOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
...@@ -359,7 +354,7 @@ ProcedureNameIndexScan(Relation heapRelation, ...@@ -359,7 +354,7 @@ ProcedureNameIndexScan(Relation heapRelation,
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
(RegProcedure) F_NAMEEQ, (RegProcedure) F_NAMEEQ,
(Datum) procName); PointerGetDatum(procName));
ScanKeyEntryInitialize(&skey[1], ScanKeyEntryInitialize(&skey[1],
(bits16) 0x0, (bits16) 0x0,
...@@ -371,7 +366,7 @@ ProcedureNameIndexScan(Relation heapRelation, ...@@ -371,7 +366,7 @@ ProcedureNameIndexScan(Relation heapRelation,
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 3, (AttrNumber) 3,
(RegProcedure) F_OID8EQ, (RegProcedure) F_OID8EQ,
(Datum) argTypes); PointerGetDatum(argTypes));
idesc = index_openr(ProcedureNameIndex); idesc = index_openr(ProcedureNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
...@@ -394,7 +389,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text *procSrc) ...@@ -394,7 +389,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text *procSrc)
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
(RegProcedure) F_TEXTEQ, (RegProcedure) F_TEXTEQ,
(Datum) procSrc); PointerGetDatum(procSrc));
idesc = index_openr(ProcedureSrcIndex); idesc = index_openr(ProcedureSrcIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
...@@ -415,7 +410,7 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId) ...@@ -415,7 +410,7 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
(RegProcedure) F_OIDEQ, (RegProcedure) F_OIDEQ,
(Datum) typeId); ObjectIdGetDatum(typeId));
idesc = index_openr(TypeOidIndex); idesc = index_openr(TypeOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
...@@ -436,7 +431,7 @@ TypeNameIndexScan(Relation heapRelation, char *typeName) ...@@ -436,7 +431,7 @@ TypeNameIndexScan(Relation heapRelation, char *typeName)
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
(RegProcedure) F_NAMEEQ, (RegProcedure) F_NAMEEQ,
(Datum) typeName); PointerGetDatum(typeName));
idesc = index_openr(TypeNameIndex); idesc = index_openr(TypeNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
...@@ -477,7 +472,7 @@ ClassOidIndexScan(Relation heapRelation, Oid relId) ...@@ -477,7 +472,7 @@ ClassOidIndexScan(Relation heapRelation, Oid relId)
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
(RegProcedure) F_OIDEQ, (RegProcedure) F_OIDEQ,
(Datum) relId); ObjectIdGetDatum(relId));
idesc = index_openr(ClassOidIndex); idesc = index_openr(ClassOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
......
/* A lexical scanner generated by flex */ /* A lexical scanner generated by flex */
/* Scanner skeleton version: /* 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 #define FLEX_SCANNER
...@@ -555,7 +555,7 @@ char *yytext; ...@@ -555,7 +555,7 @@ char *yytext;
* *
* *
* IDENTIFICATION * 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 ...@@ -1181,6 +1181,8 @@ YY_RULE_SETUP
if (isascii((unsigned char)yytext[i]) && if (isascii((unsigned char)yytext[i]) &&
isupper(yytext[i])) isupper(yytext[i]))
yytext[i] = tolower(yytext[i]); yytext[i] = tolower(yytext[i]);
if (i >= NAMEDATALEN)
yytext[NAMEDATALEN-1] = '\0';
keyword = ScanKeywordLookup((char*)yytext); keyword = ScanKeywordLookup((char*)yytext);
if (keyword != NULL) { if (keyword != NULL) {
...@@ -1195,7 +1197,7 @@ YY_RULE_SETUP ...@@ -1195,7 +1197,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 337 "scan.l" #line 339 "scan.l"
{ {
char* endptr; char* endptr;
...@@ -1217,7 +1219,7 @@ YY_RULE_SETUP ...@@ -1217,7 +1219,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 355 "scan.l" #line 357 "scan.l"
{ {
char* endptr; char* endptr;
...@@ -1232,7 +1234,7 @@ YY_RULE_SETUP ...@@ -1232,7 +1234,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 366 "scan.l" #line 368 "scan.l"
{ {
char* endptr; char* endptr;
...@@ -1253,7 +1255,7 @@ YY_RULE_SETUP ...@@ -1253,7 +1255,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 383 "scan.l" #line 385 "scan.l"
{ {
char* endptr; char* endptr;
...@@ -1267,7 +1269,7 @@ YY_RULE_SETUP ...@@ -1267,7 +1269,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 395 "scan.l" #line 397 "scan.l"
{ {
int i; int i;
ScanKeyword *keyword; ScanKeyword *keyword;
...@@ -1276,6 +1278,8 @@ YY_RULE_SETUP ...@@ -1276,6 +1278,8 @@ YY_RULE_SETUP
if (isascii((unsigned char)yytext[i]) && if (isascii((unsigned char)yytext[i]) &&
isupper(yytext[i])) isupper(yytext[i]))
yytext[i] = tolower(yytext[i]); yytext[i] = tolower(yytext[i]);
if (i >= NAMEDATALEN)
yytext[NAMEDATALEN-1] = '\0';
keyword = ScanKeywordLookup((char*)yytext); keyword = ScanKeywordLookup((char*)yytext);
if (keyword != NULL) { if (keyword != NULL) {
...@@ -1290,20 +1294,20 @@ YY_RULE_SETUP ...@@ -1290,20 +1294,20 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 414 "scan.l" #line 418 "scan.l"
{ /* ignore */ } { /* ignore */ }
YY_BREAK YY_BREAK
case 40: case 40:
YY_RULE_SETUP YY_RULE_SETUP
#line 416 "scan.l" #line 420 "scan.l"
{ return (yytext[0]); } { return (yytext[0]); }
YY_BREAK YY_BREAK
case 41: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 418 "scan.l" #line 422 "scan.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1307 "lex.yy.c" #line 1311 "lex.yy.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(xb): case YY_STATE_EOF(xb):
case YY_STATE_EOF(xc): case YY_STATE_EOF(xc):
...@@ -2189,7 +2193,7 @@ int main() ...@@ -2189,7 +2193,7 @@ int main()
return 0; return 0;
} }
#endif #endif
#line 418 "scan.l" #line 422 "scan.l"
void yyerror(char message[]) void yyerror(char message[])
......
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