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

Commitfe54862

Browse files
committed
Invent ResourceOwner mechanism as per my recent proposal, and use it to
keep track of portal-related resources separately from transaction-relatedresources. This allows cursors to work in a somewhat sane fashion withnested transactions. For now, cursor behavior is non-subtransactional,that is a cursor's state does not roll back if you abort a subtransactionthat fetched from the cursor. We might want to change that later.
1 parentf4c069c commitfe54862

File tree

41 files changed

+2085
-1191
lines changed

Some content is hidden

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

41 files changed

+2085
-1191
lines changed

‎contrib/userlock/user_locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ user_write_unlock_oid(Oid oid)
7575
int
7676
user_unlock_all(void)
7777
{
78-
returnLockReleaseAll(USER_LOCKMETHOD,MyProc,ReleaseAll,0,NULL);
78+
returnLockReleaseAll(USER_LOCKMETHOD,MyProc,true);
7979
}
8080

8181
/* end of file */

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

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.52 2004/07/01 00:49:27 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.53 2004/07/17 03:27:20 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -17,6 +17,7 @@
1717
#include"access/genam.h"
1818
#include"access/gist.h"
1919
#include"access/gistscan.h"
20+
#include"utils/resowner.h"
2021

2122

2223
/* routines defined and used here */
@@ -41,7 +42,7 @@ static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
4142
typedefstructGISTScanListData
4243
{
4344
IndexScanDescgsl_scan;
44-
TransactionIdgsl_creatingXid;
45+
ResourceOwnergsl_owner;
4546
structGISTScanListData*gsl_next;
4647
}GISTScanListData;
4748

@@ -224,7 +225,7 @@ gistregscan(IndexScanDesc s)
224225

225226
l= (GISTScanList)palloc(sizeof(GISTScanListData));
226227
l->gsl_scan=s;
227-
l->gsl_creatingXid=GetCurrentTransactionId();
228+
l->gsl_owner=CurrentResourceOwner;
228229
l->gsl_next=GISTScans;
229230
GISTScans=l;
230231
}
@@ -253,52 +254,28 @@ gistdropscan(IndexScanDesc s)
253254
}
254255

255256
/*
256-
*AtEOXact_gist() --- clean up gist subsystemat xact abort or commit.
257+
*ReleaseResources_gist() --- clean up gist subsystemresources.
257258
*
258259
* This is here because it needs to touch this module's static var GISTScans.
259260
*/
260261
void
261-
AtEOXact_gist(void)
262-
{
263-
/*
264-
* Note: these actions should only be necessary during xact abort; but
265-
* they can't hurt during a commit.
266-
*/
267-
268-
/*
269-
* Reset the active-scans list to empty. We do not need to free the
270-
* list elements, because they're all palloc()'d, so they'll go away
271-
* at end of transaction anyway.
272-
*/
273-
GISTScans=NULL;
274-
}
275-
276-
/*
277-
* AtEOSubXact_gist() --- clean up gist subsystem at subxact abort or commit.
278-
*
279-
* This is here because it needs to touch this module's static var GISTScans.
280-
*/
281-
void
282-
AtEOSubXact_gist(TransactionIdchildXid)
262+
ReleaseResources_gist(void)
283263
{
284264
GISTScanListl;
285265
GISTScanListprev;
286266
GISTScanListnext;
287267

288268
/*
289-
* Note: these actions should only be necessary during xact abort; but
290-
* they can't hurt during a commit.
291-
*/
292-
293-
/*
294-
* Forget active scans that were started in this subtransaction.
269+
* Note: this should be a no-op during normal query shutdown.
270+
* However, in an abort situation ExecutorEnd is not called and so
271+
* there may be open index scans to clean up.
295272
*/
296273
prev=NULL;
297274

298275
for (l=GISTScans;l!=NULL;l=next)
299276
{
300277
next=l->gsl_next;
301-
if (l->gsl_creatingXid==childXid)
278+
if (l->gsl_owner==CurrentResourceOwner)
302279
{
303280
if (prev==NULL)
304281
GISTScans=next;

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

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.34 2004/07/01 00:49:29 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.35 2004/07/17 03:27:40 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515

1616
#include"postgres.h"
1717

1818
#include"access/hash.h"
19+
#include"utils/resowner.h"
1920

2021

2122
typedefstructHashScanListData
2223
{
2324
IndexScanDeschashsl_scan;
24-
TransactionIdhashsl_creatingXid;
25+
ResourceOwnerhashsl_owner;
2526
structHashScanListData*hashsl_next;
2627
}HashScanListData;
2728

@@ -31,52 +32,28 @@ static HashScanList HashScans = NULL;
3132

3233

3334
/*
34-
*AtEOXact_hash() --- clean up hash subsystemat xact abort or commit.
35+
*ReleaseResources_hash() --- clean up hash subsystemresources.
3536
*
3637
* This is here because it needs to touch this module's static var HashScans.
3738
*/
3839
void
39-
AtEOXact_hash(void)
40-
{
41-
/*
42-
* Note: these actions should only be necessary during xact abort; but
43-
* they can't hurt during a commit.
44-
*/
45-
46-
/*
47-
* Reset the active-scans list to empty. We do not need to free the
48-
* list elements, because they're all palloc()'d, so they'll go away
49-
* at end of transaction anyway.
50-
*/
51-
HashScans=NULL;
52-
}
53-
54-
/*
55-
* AtEOSubXact_hash() --- clean up hash subsystem at subxact abort or commit.
56-
*
57-
* This is here because it needs to touch this module's static var HashScans.
58-
*/
59-
void
60-
AtEOSubXact_hash(TransactionIdchildXid)
40+
ReleaseResources_hash(void)
6141
{
6242
HashScanListl;
6343
HashScanListprev;
6444
HashScanListnext;
6545

6646
/*
67-
* Note: these actions should only be necessary during xact abort; but
68-
* they can't hurt during a commit.
69-
*/
70-
71-
/*
72-
* Forget active scans that were started in this subtransaction.
47+
* Note: this should be a no-op during normal query shutdown.
48+
* However, in an abort situation ExecutorEnd is not called and so
49+
* there may be open index scans to clean up.
7350
*/
7451
prev=NULL;
7552

7653
for (l=HashScans;l!=NULL;l=next)
7754
{
7855
next=l->hashsl_next;
79-
if (l->hashsl_creatingXid==childXid)
56+
if (l->hashsl_owner==CurrentResourceOwner)
8057
{
8158
if (prev==NULL)
8259
HashScans=next;
@@ -101,7 +78,7 @@ _hash_regscan(IndexScanDesc scan)
10178

10279
new_el= (HashScanList)palloc(sizeof(HashScanListData));
10380
new_el->hashsl_scan=scan;
104-
new_el->hashsl_creatingXid=GetCurrentTransactionId();
81+
new_el->hashsl_owner=CurrentResourceOwner;
10582
new_el->hashsl_next=HashScans;
10683
HashScans=new_el;
10784
}

‎src/backend/access/nbtree/nbtree.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.118 2004/06/05 19:48:07 tgl Exp $
15+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.119 2004/07/17 03:27:59 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -58,16 +58,6 @@ static void btbuildCallback(Relation index,
5858
void*state);
5959

6060

61-
/*
62-
* AtEOXact_nbtree() --- clean up nbtree subsystem at xact abort or commit.
63-
*/
64-
void
65-
AtEOXact_nbtree(void)
66-
{
67-
/* nothing to do at the moment */
68-
}
69-
70-
7161
/*
7262
*btbuild() -- build a new btree index.
7363
*

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

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.52 2004/07/01 00:49:31 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.53 2004/07/17 03:28:17 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -18,6 +18,7 @@
1818
#include"access/genam.h"
1919
#include"access/rtree.h"
2020
#include"utils/lsyscache.h"
21+
#include"utils/resowner.h"
2122

2223

2324
/* routines defined and used here */
@@ -42,7 +43,7 @@ static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
4243
typedefstructRTScanListData
4344
{
4445
IndexScanDescrtsl_scan;
45-
TransactionIdrtsl_creatingXid;
46+
ResourceOwnerrtsl_owner;
4647
structRTScanListData*rtsl_next;
4748
}RTScanListData;
4849

@@ -241,7 +242,7 @@ rtregscan(IndexScanDesc s)
241242

242243
l= (RTScanList)palloc(sizeof(RTScanListData));
243244
l->rtsl_scan=s;
244-
l->rtsl_creatingXid=GetCurrentTransactionId();
245+
l->rtsl_owner=CurrentResourceOwner;
245246
l->rtsl_next=RTScans;
246247
RTScans=l;
247248
}
@@ -272,52 +273,28 @@ rtdropscan(IndexScanDesc s)
272273
}
273274

274275
/*
275-
*AtEOXact_rtree() --- clean up rtree subsystemat xact abort or commit.
276+
*ReleaseResources_rtree() --- clean up rtree subsystemresources.
276277
*
277278
* This is here because it needs to touch this module's static var RTScans.
278279
*/
279280
void
280-
AtEOXact_rtree(void)
281-
{
282-
/*
283-
* Note: these actions should only be necessary during xact abort; but
284-
* they can't hurt during a commit.
285-
*/
286-
287-
/*
288-
* Reset the active-scans list to empty. We do not need to free the
289-
* list elements, because they're all palloc()'d, so they'll go away
290-
* at end of transaction anyway.
291-
*/
292-
RTScans=NULL;
293-
}
294-
295-
/*
296-
* AtEOSubXact_rtree() --- clean up rtree subsystem at subxact abort or commit.
297-
*
298-
* This is here because it needs to touch this module's static var RTScans.
299-
*/
300-
void
301-
AtEOSubXact_rtree(TransactionIdchildXid)
281+
ReleaseResources_rtree(void)
302282
{
303283
RTScanListl;
304284
RTScanListprev;
305285
RTScanListnext;
306286

307287
/*
308-
* Note: these actions should only be necessary during xact abort; but
309-
* they can't hurt during a commit.
310-
*/
311-
312-
/*
313-
* Forget active scans that were started in this subtransaction.
288+
* Note: this should be a no-op during normal query shutdown.
289+
* However, in an abort situation ExecutorEnd is not called and so
290+
* there may be open index scans to clean up.
314291
*/
315292
prev=NULL;
316293

317294
for (l=RTScans;l!=NULL;l=next)
318295
{
319296
next=l->rtsl_next;
320-
if (l->rtsl_creatingXid==childXid)
297+
if (l->rtsl_owner==CurrentResourceOwner)
321298
{
322299
if (prev==NULL)
323300
RTScans=next;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp