diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-24 00:25:33 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-24 00:25:33 +0000 |
commit | e812458b273be00bde34fb74991ab4a99c24ab30 (patch) | |
tree | e7460ae5c0344782f6f6068399f6f7eab5be96f6 /src/backend/executor/nodeIndexscan.c | |
parent | ad791c1d140af97d93ee98883e2c45413d6f9836 (diff) | |
download | postgresql-e812458b273be00bde34fb74991ab4a99c24ab30.tar.gz postgresql-e812458b273be00bde34fb74991ab4a99c24ab30.zip |
Several changes here, not very related but touching some of the same files.
* Buffer refcount cleanup (per my "progress report" to pghackers, 9/22).
* Add links to backend PROC structs to sinval's array of per-backend info,
and use these links for routines that need to check the state of all
backends (rather than the slow, complicated search of the ShmemIndex
hashtable that was used before). Add databaseOID to PROC structs.
* Use this to implement an interlock that prevents DESTROY DATABASE of
a database containing running backends. (It's a little tricky to prevent
a concurrently-starting backend from getting in there, since the new
backend is not able to lock anything at the time it tries to look up
its database in pg_database. My solution is to recheck that the DB is
OK at the end of InitPostgres. It may not be a 100% solution, but it's
a lot better than no interlock at all...)
* In ALTER TABLE RENAME, flush buffers for the relation before doing the
rename of the physical files, to ensure we don't get failures later from
mdblindwrt().
* Update TRUNCATE patch so that it actually compiles against current
sources :-(.
You should do "make clean all" after pulling these changes.
Diffstat (limited to 'src/backend/executor/nodeIndexscan.c')
-rw-r--r-- | src/backend/executor/nodeIndexscan.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index 362851a425a..b9e3cf58636 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.42 1999/08/12 00:42:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.43 1999/09/24 00:24:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -125,14 +125,14 @@ IndexNext(IndexScan *node) { int iptr; - slot->ttc_buffer = InvalidBuffer; - slot->ttc_shouldFree = false; + ExecClearTuple(slot); if (estate->es_evTupleNull[node->scan.scanrelid - 1]) - { - slot->val = NULL; /* must not free tuple! */ - return (slot); - } + return slot; /* return empty slot */ + + /* probably ought to use ExecStoreTuple here... */ slot->val = estate->es_evTuple[node->scan.scanrelid - 1]; + slot->ttc_shouldFree = false; + for (iptr = 0; iptr < numIndices; iptr++) { scanstate->cstate.cs_ExprContext->ecxt_scantuple = slot; @@ -142,6 +142,7 @@ IndexNext(IndexScan *node) } if (iptr == numIndices) /* would not be returned by indices */ slot->val = NULL; + /* Flag for the next call that no more tuples */ estate->es_evTupleNull[node->scan.scanrelid - 1] = true; return (slot); @@ -192,7 +193,7 @@ IndexNext(IndexScan *node) * the scan state. Eventually we will only do this and not * return a tuple. Note: we pass 'false' because tuples * returned by amgetnext are pointers onto disk pages and - * were not created with palloc() and so should not be pfree()'d. + * must not be pfree()'d. * ---------------- */ ExecStoreTuple(tuple, /* tuple to store */ @@ -201,6 +202,13 @@ IndexNext(IndexScan *node) false); /* don't pfree */ /* + * At this point we have an extra pin on the buffer, + * because ExecStoreTuple incremented the pin count. + * Drop our local pin. + */ + ReleaseBuffer(buffer); + + /* * We must check to see if the current tuple would have * been matched by an earlier index, so we don't double * report it. We do this by passing the tuple through @@ -223,8 +231,6 @@ IndexNext(IndexScan *node) else ExecClearTuple(slot); } - if (BufferIsValid(buffer)) - ReleaseBuffer(buffer); } if (indexNumber < numIndices) { |