1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Restructure indexscan API (index_beginscan, index_getnext) per

yesterday's proposal to pghackers.  Also remove unnecessary parameters
to heap_beginscan, heap_rescan.  I modified pg_proc.h to reflect the
new numbers of parameters for the AM interface routines, but did not
force an initdb because nothing actually looks at those fields.
This commit is contained in:
Tom Lane
2002-05-20 23:51:44 +00:00
parent c961474c96
commit 44fbe20d62
59 changed files with 834 additions and 1283 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.32 2002/04/16 23:08:10 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.33 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -524,8 +524,8 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
/*
* Do a simple linear scan until we reach the target number of rows.
*/
scan = heap_beginscan(onerel, false, SnapshotNow, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
scan = heap_beginscan(onerel, SnapshotNow, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
rows[numrows++] = heap_copytuple(tuple);
if (numrows >= targrows)

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.84 2002/05/05 00:03:28 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.85 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -204,8 +204,8 @@ Async_Listen(char *relname, int pid)
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
/* Detect whether we are already listening on this relname */
scan = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey) NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
scan = heap_beginscan(lRel, SnapshotNow, 0, (ScanKey) NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple);
@ -305,8 +305,8 @@ Async_Unlisten(char *relname, int pid)
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
scan = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey) NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
scan = heap_beginscan(lRel, SnapshotNow, 0, (ScanKey) NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple);
@ -369,9 +369,9 @@ Async_UnlistenAll(void)
Anum_pg_listener_pid,
F_INT4EQ,
Int32GetDatum(MyProcPid));
scan = heap_beginscan(lRel, 0, SnapshotNow, 1, key);
scan = heap_beginscan(lRel, SnapshotNow, 1, key);
while (HeapTupleIsValid(lTuple = heap_getnext(scan, 0)))
while ((lTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
simple_heap_delete(lRel, &lTuple->t_self);
heap_endscan(scan);
@ -472,9 +472,9 @@ AtCommit_Notify(void)
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
tdesc = RelationGetDescr(lRel);
scan = heap_beginscan(lRel, 0, SnapshotNow, 0, (ScanKey) NULL);
scan = heap_beginscan(lRel, SnapshotNow, 0, (ScanKey) NULL);
while (HeapTupleIsValid(lTuple = heap_getnext(scan, 0)))
while ((lTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(lTuple);
char *relname = NameStr(listener->relname);
@ -773,7 +773,7 @@ ProcessIncomingNotify(void)
Anum_pg_listener_pid,
F_INT4EQ,
Int32GetDatum(MyProcPid));
scan = heap_beginscan(lRel, 0, SnapshotNow, 1, key);
scan = heap_beginscan(lRel, SnapshotNow, 1, key);
/* Prepare data for rewriting 0 into notification field */
nulls[0] = nulls[1] = nulls[2] = ' ';
@ -782,7 +782,7 @@ ProcessIncomingNotify(void)
value[0] = value[1] = value[2] = (Datum) 0;
value[Anum_pg_listener_notify - 1] = Int32GetDatum(0);
while (HeapTupleIsValid(lTuple = heap_getnext(scan, 0)))
while ((lTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(lTuple);
char *relname = NameStr(listener->relname);

View File

@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.79 2002/04/27 21:24:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.80 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -217,7 +217,7 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
LocalOldHeap,
LocalOldIndex;
IndexScanDesc ScanDesc;
RetrieveIndexResult ScanResult;
HeapTuple LocalHeapTuple;
/*
* Open the relations I need. Scan through the OldHeap on the OldIndex
@ -227,36 +227,24 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
LocalOldHeap = heap_open(OIDOldHeap, AccessExclusiveLock);
LocalOldIndex = index_open(OIDOldIndex);
ScanDesc = index_beginscan(LocalOldIndex, false, 0, (ScanKey) NULL);
ScanDesc = index_beginscan(LocalOldHeap, LocalOldIndex,
SnapshotNow, 0, (ScanKey) NULL);
while ((ScanResult = index_getnext(ScanDesc, ForwardScanDirection)) != NULL)
while ((LocalHeapTuple = index_getnext(ScanDesc, ForwardScanDirection)) != NULL)
{
HeapTupleData LocalHeapTuple;
Buffer LocalBuffer;
/*
* We must copy the tuple because heap_insert() will overwrite
* the commit-status fields of the tuple it's handed, and the
* retrieved tuple will actually be in a disk buffer! Thus,
* the source relation would get trashed, which is bad news if
* we abort later on. (This was a bug in releases thru 7.0)
*/
HeapTuple copiedTuple = heap_copytuple(LocalHeapTuple);
heap_insert(LocalNewHeap, copiedTuple);
heap_freetuple(copiedTuple);
CHECK_FOR_INTERRUPTS();
LocalHeapTuple.t_self = ScanResult->heap_iptr;
LocalHeapTuple.t_datamcxt = NULL;
LocalHeapTuple.t_data = NULL;
heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer,
ScanDesc);
if (LocalHeapTuple.t_data != NULL)
{
/*
* We must copy the tuple because heap_insert() will overwrite
* the commit-status fields of the tuple it's handed, and the
* retrieved tuple will actually be in a disk buffer! Thus,
* the source relation would get trashed, which is bad news if
* we abort later on. (This was a bug in releases thru 7.0)
*/
HeapTuple copiedTuple = heap_copytuple(&LocalHeapTuple);
ReleaseBuffer(LocalBuffer);
heap_insert(LocalNewHeap, copiedTuple);
heap_freetuple(copiedTuple);
}
pfree(ScanResult);
}
index_endscan(ScanDesc);

View File

@ -7,7 +7,7 @@
* Copyright (c) 1999-2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.46 2002/05/13 17:45:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.47 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -122,12 +122,9 @@ void
CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
{
Relation description;
Relation descriptionindex;
ScanKeyData skey[3];
IndexScanDesc sd;
RetrieveIndexResult indexRes;
HeapTupleData oldtuple;
Buffer buffer;
SysScanDesc sd;
HeapTuple oldtuple;
HeapTuple newtuple = NULL;
Datum values[Natts_pg_description];
char nulls[Natts_pg_description];
@ -153,11 +150,6 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
values[i++] = DirectFunctionCall1(textin, CStringGetDatum(comment));
}
/* Open pg_description and its index */
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
descriptionindex = index_openr(DescriptionObjIndex);
/* Use the index to search for a matching old tuple */
ScanKeyEntryInitialize(&skey[0],
@ -178,40 +170,32 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
(RegProcedure) F_INT4EQ,
Int32GetDatum(subid));
sd = index_beginscan(descriptionindex, false, 3, skey);
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
oldtuple.t_datamcxt = CurrentMemoryContext;
oldtuple.t_data = NULL;
sd = systable_beginscan(description, DescriptionObjIndex, true,
SnapshotNow, 3, skey);
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
while ((oldtuple = systable_getnext(sd)) != NULL)
{
oldtuple.t_self = indexRes->heap_iptr;
heap_fetch(description, SnapshotNow, &oldtuple, &buffer, sd);
pfree(indexRes);
if (oldtuple.t_data == NULL)
continue; /* time qual failed */
/* Found the old tuple, so delete or update it */
if (comment == NULL)
simple_heap_delete(description, &oldtuple.t_self);
simple_heap_delete(description, &oldtuple->t_self);
else
{
newtuple = heap_modifytuple(&oldtuple, description, values,
newtuple = heap_modifytuple(oldtuple, description, values,
nulls, replaces);
simple_heap_update(description, &oldtuple.t_self, newtuple);
simple_heap_update(description, &oldtuple->t_self, newtuple);
}
ReleaseBuffer(buffer);
break; /* Assume there can be only one match */
}
index_endscan(sd);
systable_endscan(sd);
/* If we didn't find an old tuple, insert a new one */
if (oldtuple.t_data == NULL && comment != NULL)
if (newtuple == NULL && comment != NULL)
{
newtuple = heap_formtuple(RelationGetDescr(description),
values, nulls);
@ -237,7 +221,6 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
/* Done */
index_close(descriptionindex);
heap_close(description, NoLock);
}
@ -252,17 +235,9 @@ void
DeleteComments(Oid oid, Oid classoid)
{
Relation description;
Relation descriptionindex;
ScanKeyData skey[2];
IndexScanDesc sd;
RetrieveIndexResult indexRes;
HeapTupleData oldtuple;
Buffer buffer;
/* Open pg_description and its index */
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
descriptionindex = index_openr(DescriptionObjIndex);
SysScanDesc sd;
HeapTuple oldtuple;
/* Use the index to search for all matching old tuples */
@ -278,26 +253,19 @@ DeleteComments(Oid oid, Oid classoid)
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(classoid));
sd = index_beginscan(descriptionindex, false, 2, skey);
description = heap_openr(DescriptionRelationName, RowExclusiveLock);
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
sd = systable_beginscan(description, DescriptionObjIndex, true,
SnapshotNow, 2, skey);
while ((oldtuple = systable_getnext(sd)) != NULL)
{
oldtuple.t_self = indexRes->heap_iptr;
heap_fetch(description, SnapshotNow, &oldtuple, &buffer, sd);
pfree(indexRes);
if (oldtuple.t_data == NULL)
continue; /* time qual failed */
simple_heap_delete(description, &oldtuple.t_self);
ReleaseBuffer(buffer);
simple_heap_delete(description, &oldtuple->t_self);
}
/* Done */
index_endscan(sd);
index_close(descriptionindex);
systable_endscan(sd);
heap_close(description, NoLock);
}
@ -449,8 +417,8 @@ CommentDatabase(List *qualname, char *comment)
pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry, 0, Anum_pg_database_datname,
F_NAMEEQ, CStringGetDatum(database));
scan = heap_beginscan(pg_database, 0, SnapshotNow, 1, &entry);
dbtuple = heap_getnext(scan, 0);
scan = heap_beginscan(pg_database, SnapshotNow, 1, &entry);
dbtuple = heap_getnext(scan, ForwardScanDirection);
/* Validate database exists, and fetch the db oid */
@ -566,10 +534,10 @@ CommentRule(List *qualname, char *comment)
PointerGetDatum(rulename));
RewriteRelation = heap_openr(RewriteRelationName, AccessShareLock);
scanDesc = heap_beginscan(RewriteRelation,
0, SnapshotNow, 1, &scanKeyData);
scanDesc = heap_beginscan(RewriteRelation, SnapshotNow,
1, &scanKeyData);
tuple = heap_getnext(scanDesc, 0);
tuple = heap_getnext(scanDesc, ForwardScanDirection);
if (HeapTupleIsValid(tuple))
{
reloid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
@ -581,7 +549,8 @@ CommentRule(List *qualname, char *comment)
reloid = ruleoid = 0; /* keep compiler quiet */
}
if (HeapTupleIsValid(tuple = heap_getnext(scanDesc, 0)))
if (HeapTupleIsValid(tuple = heap_getnext(scanDesc,
ForwardScanDirection)))
elog(ERROR, "There are multiple rules \"%s\""
"\n\tPlease specify a relation name as well as a rule name",
rulename);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.153 2002/04/27 03:45:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.154 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -494,9 +494,9 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp,
CopySendData(&tmp, sizeof(int32), fp);
}
scandesc = heap_beginscan(rel, 0, QuerySnapshot, 0, NULL);
scandesc = heap_beginscan(rel, QuerySnapshot, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
while ((tuple = heap_getnext(scandesc, ForwardScanDirection)) != NULL)
{
bool need_delim = false;

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.89 2002/05/17 01:19:17 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.90 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -387,9 +387,9 @@ dropdb(const char *dbname)
ScanKeyEntryInitialize(&key, 0, ObjectIdAttributeNumber,
F_OIDEQ, ObjectIdGetDatum(db_id));
pgdbscan = heap_beginscan(pgdbrel, 0, SnapshotNow, 1, &key);
pgdbscan = heap_beginscan(pgdbrel, SnapshotNow, 1, &key);
tup = heap_getnext(pgdbscan, 0);
tup = heap_getnext(pgdbscan, ForwardScanDirection);
if (!HeapTupleIsValid(tup))
{
/*
@ -463,8 +463,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
rel = heap_openr(DatabaseRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&scankey, 0, Anum_pg_database_datname,
F_NAMEEQ, NameGetDatum(stmt->dbname));
scan = heap_beginscan(rel, 0, SnapshotNow, 1, &scankey);
tuple = heap_getnext(scan, 0);
scan = heap_beginscan(rel, SnapshotNow, 1, &scankey);
tuple = heap_getnext(scan, ForwardScanDirection);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "database \"%s\" does not exist", stmt->dbname);
@ -535,9 +535,9 @@ get_db_info(const char *name, Oid *dbIdP, int4 *ownerIdP,
ScanKeyEntryInitialize(&scanKey, 0, Anum_pg_database_datname,
F_NAMEEQ, NameGetDatum(name));
scan = heap_beginscan(relation, 0, SnapshotNow, 1, &scanKey);
scan = heap_beginscan(relation, SnapshotNow, 1, &scanKey);
tuple = heap_getnext(scan, 0);
tuple = heap_getnext(scan, ForwardScanDirection);
gottuple = HeapTupleIsValid(tuple);
if (gottuple)

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.73 2002/05/12 20:10:02 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.74 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -736,9 +736,9 @@ ReindexDatabase(const char *dbname, bool force, bool all)
* Scan pg_class to build a list of the relations we need to reindex.
*/
relationRelation = heap_openr(RelationRelationName, AccessShareLock);
scan = heap_beginscan(relationRelation, false, SnapshotNow, 0, NULL);
scan = heap_beginscan(relationRelation, SnapshotNow, 0, NULL);
relcnt = relalc = 0;
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
if (!all)
{

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.14 2002/05/17 22:35:12 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.15 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1314,32 +1314,38 @@ update_ri_trigger_args(Oid relid,
bool update_relname)
{
Relation tgrel;
Relation irel;
ScanKeyData skey[1];
IndexScanDesc idxtgscan;
RetrieveIndexResult idxres;
SysScanDesc trigscan;
HeapTuple tuple;
Datum values[Natts_pg_trigger];
char nulls[Natts_pg_trigger];
char replaces[Natts_pg_trigger];
tgrel = heap_openr(TriggerRelationName, RowExclusiveLock);
if (fk_scan)
irel = index_openr(TriggerConstrRelidIndex);
else
irel = index_openr(TriggerRelidNameIndex);
ScanKeyEntryInitialize(&skey[0], 0x0,
1, /* column 1 of index in either case */
F_OIDEQ,
ObjectIdGetDatum(relid));
idxtgscan = index_beginscan(irel, false, 1, skey);
while ((idxres = index_getnext(idxtgscan, ForwardScanDirection)) != NULL)
{
HeapTupleData tupledata;
Buffer buffer;
HeapTuple tuple;
Form_pg_trigger pg_trigger;
ScanKeyEntryInitialize(&skey[0], 0x0,
Anum_pg_trigger_tgconstrrelid,
F_OIDEQ,
ObjectIdGetDatum(relid));
trigscan = systable_beginscan(tgrel, TriggerConstrRelidIndex,
true, SnapshotNow,
1, skey);
}
else
{
ScanKeyEntryInitialize(&skey[0], 0x0,
Anum_pg_trigger_tgrelid,
F_OIDEQ,
ObjectIdGetDatum(relid));
trigscan = systable_beginscan(tgrel, TriggerRelidNameIndex,
true, SnapshotNow,
1, skey);
}
while ((tuple = systable_getnext(trigscan)) != NULL)
{
Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
bytea *val;
bytea *newtgargs;
bool isnull;
@ -1352,18 +1358,10 @@ update_ri_trigger_args(Oid relid,
const char *arga[RI_MAX_ARGUMENTS];
const char *argp;
tupledata.t_self = idxres->heap_iptr;
heap_fetch(tgrel, SnapshotNow, &tupledata, &buffer, idxtgscan);
pfree(idxres);
if (!tupledata.t_data)
continue;
tuple = &tupledata;
pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
tg_type = ri_trigger_type(pg_trigger->tgfoid);
if (tg_type == RI_TRIGGER_NONE)
{
/* Not an RI trigger, forget it */
ReleaseBuffer(buffer);
continue;
}
@ -1381,7 +1379,6 @@ update_ri_trigger_args(Oid relid,
tgnargs > RI_MAX_ARGUMENTS)
{
/* This probably shouldn't happen, but ignore busted triggers */
ReleaseBuffer(buffer);
continue;
}
argp = (const char *) VARDATA(val);
@ -1429,7 +1426,6 @@ update_ri_trigger_args(Oid relid,
if (!changed)
{
/* Don't need to update this tuple */
ReleaseBuffer(buffer);
continue;
}
@ -1462,11 +1458,6 @@ update_ri_trigger_args(Oid relid,
tuple = heap_modifytuple(tuple, tgrel, values, nulls, replaces);
/*
* Now we can release hold on original tuple.
*/
ReleaseBuffer(buffer);
/*
* Update pg_trigger and its indexes
*/
@ -1485,8 +1476,7 @@ update_ri_trigger_args(Oid relid,
heap_freetuple(tuple);
}
index_endscan(idxtgscan);
index_close(irel);
systable_endscan(trigscan);
heap_close(tgrel, RowExclusiveLock);
@ -1979,9 +1969,9 @@ AlterTableAlterColumnSetNotNull(Oid myrelid,
*/
tupdesc = RelationGetDescr(rel);
scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Datum d;
bool isnull;
@ -2177,9 +2167,9 @@ drop_default(Oid relid, int16 attnum)
Anum_pg_attrdef_adnum, F_INT2EQ,
Int16GetDatum(attnum));
scan = heap_beginscan(attrdef_rel, false, SnapshotNow, 2, scankeys);
scan = heap_beginscan(attrdef_rel, SnapshotNow, 2, scankeys);
if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
if ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
simple_heap_delete(attrdef_rel, &tuple->t_self);
heap_endscan(scan);
@ -2501,9 +2491,9 @@ AlterTableAddConstraint(Oid myrelid,
* Scan through the rows now, checking the
* expression at each row.
*/
scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
ExecStoreTuple(tuple, slot, InvalidBuffer, false);
if (!ExecQual(qual, econtext, true))
@ -2621,9 +2611,9 @@ AlterTableAddConstraint(Oid myrelid,
}
trig.tgnargs = count - 1;
scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
/* Make a call to the check function */

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.101 2002/05/17 01:19:17 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.102 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -140,8 +140,8 @@ write_group_file(Relation urel, Relation grel)
elog(ERROR, "write_group_file: unable to write %s: %m", tempname);
/* read table */
scan = heap_beginscan(grel, false, SnapshotSelf, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
scan = heap_beginscan(grel, SnapshotSelf, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Datum datum, grolist_datum;
bool isnull;
@ -284,8 +284,8 @@ write_user_file(Relation urel)
elog(ERROR, "write_password_file: unable to write %s: %m", tempname);
/* read table */
scan = heap_beginscan(urel, false, SnapshotSelf, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
scan = heap_beginscan(urel, SnapshotSelf, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Datum datum;
bool isnull;
@ -517,10 +517,10 @@ CreateUser(CreateUserStmt *stmt)
pg_shadow_rel = heap_openr(ShadowRelationName, ExclusiveLock);
pg_shadow_dsc = RelationGetDescr(pg_shadow_rel);
scan = heap_beginscan(pg_shadow_rel, false, SnapshotNow, 0, NULL);
scan = heap_beginscan(pg_shadow_rel, SnapshotNow, 0, NULL);
max_id = 99; /* start auto-assigned ids at 100 */
while (!user_exists && !sysid_exists &&
HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
(tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_shadow shadow_form = (Form_pg_shadow) GETSTRUCT(tuple);
int32 this_sysid;
@ -977,9 +977,9 @@ DropUser(DropUserStmt *stmt)
Anum_pg_database_datdba, F_INT4EQ,
Int32GetDatum(usesysid));
scan = heap_beginscan(pg_rel, false, SnapshotNow, 1, &scankey);
scan = heap_beginscan(pg_rel, SnapshotNow, 1, &scankey);
if (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0)))
if ((tmp_tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
char *dbname;
@ -1012,8 +1012,8 @@ DropUser(DropUserStmt *stmt)
*/
pg_rel = heap_openr(GroupRelationName, ExclusiveLock);
pg_dsc = RelationGetDescr(pg_rel);
scan = heap_beginscan(pg_rel, false, SnapshotNow, 0, NULL);
while (HeapTupleIsValid(tmp_tuple = heap_getnext(scan, 0)))
scan = heap_beginscan(pg_rel, SnapshotNow, 0, NULL);
while ((tmp_tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
AlterGroupStmt ags;
@ -1148,10 +1148,10 @@ CreateGroup(CreateGroupStmt *stmt)
pg_group_rel = heap_openr(GroupRelationName, ExclusiveLock);
pg_group_dsc = RelationGetDescr(pg_group_rel);
scan = heap_beginscan(pg_group_rel, false, SnapshotNow, 0, NULL);
scan = heap_beginscan(pg_group_rel, SnapshotNow, 0, NULL);
max_id = 99; /* start auto-assigned ids at 100 */
while (!group_exists && !sysid_exists &&
HeapTupleIsValid(tuple = heap_getnext(scan, false)))
(tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_group group_form = (Form_pg_group) GETSTRUCT(tuple);
int32 this_sysid;

View File

@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.224 2002/04/15 23:39:42 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.225 2002/05/20 23:51:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -350,9 +350,9 @@ getrels(const RangeVar *vacrel, const char *stmttype)
pgclass = heap_openr(RelationRelationName, AccessShareLock);
scan = heap_beginscan(pgclass, false, SnapshotNow, 1, &key);
scan = heap_beginscan(pgclass, SnapshotNow, 1, &key);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
/* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context);
@ -521,9 +521,9 @@ vac_update_dbstats(Oid dbid,
ObjectIdAttributeNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
scan = heap_beginscan(relation, 0, SnapshotNow, 1, entry);
scan = heap_beginscan(relation, SnapshotNow, 1, entry);
tuple = heap_getnext(scan, 0);
tuple = heap_getnext(scan, ForwardScanDirection);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "database %u does not exist", dbid);
@ -573,9 +573,9 @@ vac_truncate_clog(TransactionId vacuumXID, TransactionId frozenXID)
relation = heap_openr(DatabaseRelationName, AccessShareLock);
scan = heap_beginscan(relation, 0, SnapshotNow, 0, NULL);
scan = heap_beginscan(relation, SnapshotNow, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple);