Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite812458

Browse files
committed
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 allbackends (rather than the slow, complicated search of the ShmemIndexhashtable that was used before). Add databaseOID to PROC structs.* Use this to implement an interlock that prevents DESTROY DATABASE ofa database containing running backends. (It's a little tricky to preventa concurrently-starting backend from getting in there, since the newbackend is not able to lock anything at the time it tries to look upits database in pg_database. My solution is to recheck that the DB isOK at the end of InitPostgres. It may not be a 100% solution, but it'sa lot better than no interlock at all...)* In ALTER TABLE RENAME, flush buffers for the relation before doing therename of the physical files, to ensure we don't get failures later frommdblindwrt().* Update TRUNCATE patch so that it actually compiles against currentsources :-(.You should do "make clean all" after pulling these changes.
1 parentad791c1 commite812458

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1209
-946
lines changed

‎src/backend/access/gist/gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.45 1999/09/18 19:05:46 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.46 1999/09/24 00:23:42 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -141,7 +141,7 @@ gistbuild(Relation heap,
141141
tupleTable=ExecCreateTupleTable(1);
142142
slot=ExecAllocTableSlot(tupleTable);
143143
econtext=makeNode(ExprContext);
144-
FillDummyExprContext(econtext,slot,hd,buffer);
144+
FillDummyExprContext(econtext,slot,hd,InvalidBuffer);
145145
}
146146
else
147147
/* shut the compiler up */

‎src/backend/access/hash/hash.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.31 1999/09/18 19:05:52 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.32 1999/09/24 00:23:48 tgl Exp $
1111
*
1212
* NOTES
1313
* This file contains only the public interface routines.
@@ -58,7 +58,6 @@ hashbuild(Relation heap,
5858
nitups;
5959
inti;
6060
HashItemhitem;
61-
Bufferbuffer=InvalidBuffer;
6261

6362
#ifndefOMIT_PARTIAL_INDEX
6463
ExprContext*econtext;
@@ -101,7 +100,7 @@ hashbuild(Relation heap,
101100
tupleTable=ExecCreateTupleTable(1);
102101
slot=ExecAllocTableSlot(tupleTable);
103102
econtext=makeNode(ExprContext);
104-
FillDummyExprContext(econtext,slot,htupdesc,buffer);
103+
FillDummyExprContext(econtext,slot,htupdesc,InvalidBuffer);
105104
}
106105
else
107106
/* quiet the compiler */

‎src/backend/access/heap/heapam.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.54 1999/09/18 19:05:58 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.55 1999/09/24 00:23:54 tgl Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -160,7 +160,7 @@ unpinscan(HeapScanDesc scan)
160160
ReleaseBuffer(scan->rs_pbuf);
161161

162162
/* ------------------------------------
163-
*Scan will pin bufferone for each non-NULL tuple pointer
163+
*Scan will pin bufferonce for each non-NULL tuple pointer
164164
*(ptup, ctup, ntup), so they have to be unpinned multiple
165165
*times.
166166
* ------------------------------------
@@ -170,6 +170,10 @@ unpinscan(HeapScanDesc scan)
170170

171171
if (BufferIsValid(scan->rs_nbuf))
172172
ReleaseBuffer(scan->rs_nbuf);
173+
174+
/* we don't bother to clear rs_pbuf etc --- caller must
175+
* reinitialize them if scan descriptor is not being deleted.
176+
*/
173177
}
174178

175179
/* ------------------------------------------
@@ -826,6 +830,8 @@ heap_getnext(HeapScanDesc scandesc, int backw)
826830
{
827831
if (BufferIsValid(scan->rs_nbuf))
828832
ReleaseBuffer(scan->rs_nbuf);
833+
scan->rs_ntup.t_data=NULL;
834+
scan->rs_nbuf=UnknownBuffer;
829835
returnNULL;
830836
}
831837

@@ -906,6 +912,8 @@ heap_getnext(HeapScanDesc scandesc, int backw)
906912
{
907913
if (BufferIsValid(scan->rs_pbuf))
908914
ReleaseBuffer(scan->rs_pbuf);
915+
scan->rs_ptup.t_data=NULL;
916+
scan->rs_pbuf=UnknownBuffer;
909917
HEAPDEBUG_3;/* heap_getnext returns NULL at end */
910918
returnNULL;
911919
}
@@ -1014,8 +1022,6 @@ heap_fetch(Relation relation,
10141022
ItemPointertid=&(tuple->t_self);
10151023
OffsetNumberoffnum;
10161024

1017-
AssertMacro(PointerIsValid(userbuf));/* see comments above */
1018-
10191025
/* ----------------
10201026
*increment access statistics
10211027
* ----------------
@@ -1067,21 +1073,17 @@ heap_fetch(Relation relation,
10671073

10681074
if (tuple->t_data==NULL)
10691075
{
1076+
/* Tuple failed time check, so we can release now. */
10701077
ReleaseBuffer(buffer);
1071-
return;
1078+
*userbuf=InvalidBuffer;
1079+
}
1080+
else
1081+
{
1082+
/* All checks passed, so return the tuple as valid.
1083+
* Caller is now responsible for releasing the buffer.
1084+
*/
1085+
*userbuf=buffer;
10721086
}
1073-
1074-
/* ----------------
1075-
*all checks passed, now either return a copy of the tuple
1076-
*or pin the buffer page and return a pointer, depending on
1077-
*whether caller gave us a valid buf.
1078-
* ----------------
1079-
*/
1080-
1081-
*userbuf=buffer;/* user is required to ReleaseBuffer()
1082-
* this */
1083-
1084-
return;
10851087
}
10861088

10871089
/* ----------------

‎src/backend/access/rtree/rtree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.37 1999/09/18 19:06:16 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.38 1999/09/24 00:23:59 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -135,7 +135,7 @@ rtbuild(Relation heap,
135135
tupleTable=ExecCreateTupleTable(1);
136136
slot=ExecAllocTableSlot(tupleTable);
137137
econtext=makeNode(ExprContext);
138-
FillDummyExprContext(econtext,slot,hd,buffer);
138+
FillDummyExprContext(econtext,slot,hd,InvalidBuffer);
139139
}
140140
else
141141
{

‎src/backend/access/transam/xact.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.52 1999/09/16 09:08:56 ishii Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.53 1999/09/24 00:24:05 tgl Exp $
1111
*
1212
* NOTES
1313
*Transaction aborts can now occur two ways:
@@ -151,6 +151,7 @@
151151
#include"commands/vacuum.h"
152152
#include"libpq/be-fsstubs.h"
153153
#include"storage/proc.h"
154+
#include"storage/sinval.h"
154155
#include"utils/temprel.h"
155156
#include"utils/inval.h"
156157
#include"utils/portal.h"
@@ -749,8 +750,8 @@ RecordTransactionAbort()
749750
staticvoid
750751
AtAbort_Cache()
751752
{
752-
RegisterInvalid(false);
753753
RelationCacheAbort();
754+
RegisterInvalid(false);
754755
}
755756

756757
/* --------------------------------
@@ -929,18 +930,19 @@ CommitTransaction()
929930
/*
930931
* Let others know about no transaction in progress by me.
931932
* Note that this must be done _before_ releasing locks we hold
932-
* and SpinAcquire(ShmemIndexLock) is required: UPDATE with xid 0 is
933+
* and SpinAcquire(SInvalLock) is required: UPDATE with xid 0 is
933934
* blocked by xid 1' UPDATE, xid 1 is doing commit while xid 2
934935
* gets snapshot - if xid 2' GetSnapshotData sees xid 1 as running
935936
* then it must see xid 0 as running as well or it will see two
936937
* tuple versions - one deleted by xid 1 and one inserted by xid 0.
937938
*/
938939
if (MyProc!= (PROC*)NULL)
939940
{
940-
SpinAcquire(ShmemIndexLock);
941+
/* Lock SInvalLock because that's what GetSnapshotData uses. */
942+
SpinAcquire(SInvalLock);
941943
MyProc->xid=InvalidTransactionId;
942944
MyProc->xmin=InvalidTransactionId;
943-
SpinRelease(ShmemIndexLock);
945+
SpinRelease(SInvalLock);
944946
}
945947

946948
RelationPurgeLocalRelation(true);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp