Skip to content

Commit 9fac5fd

Browse files
committed
Move LockClauseStrength, LockWaitPolicy into new file nodes/lockoptions.h.
Commit df630b0 moved enum LockWaitPolicy into its very own header file utils/lockwaitpolicy.h, which does not seem like a great idea from here. First, it's still a node-related declaration, and second, a file named like that can never sensibly be used for anything else. I do not think we want to encourage a one-typedef-per-header-file approach. The upcoming foreign table inheritance patch was doubling down on this bad idea by moving enum LockClauseStrength into its *own* can-never-be-used-for-anything-else file. Instead, let's put them both in a file named nodes/lockoptions.h. (They do seem to need a separate header file because we need them in both parsenodes.h and plannodes.h, and we don't want either of those including the other. Past practice might suggest adding them to nodes/nodes.h, but they don't seem sufficiently globally useful to justify that.) Committed separately since there's no functional change here, just some header-file refactoring.
1 parent 8008959 commit 9fac5fd

File tree

6 files changed

+48
-44
lines changed

6 files changed

+48
-44
lines changed

src/include/access/heapam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
#include "access/sdir.h"
1818
#include "access/skey.h"
19+
#include "nodes/lockoptions.h"
1920
#include "nodes/primnodes.h"
2021
#include "storage/bufpage.h"
2122
#include "storage/lock.h"
22-
#include "utils/lockwaitpolicy.h"
2323
#include "utils/relcache.h"
2424
#include "utils/snapshot.h"
2525

src/include/executor/executor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "executor/execdesc.h"
1818
#include "nodes/parsenodes.h"
19-
#include "utils/lockwaitpolicy.h"
2019

2120

2221
/*

src/include/nodes/lockoptions.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* lockoptions.h
4+
* Common header for some locking-related declarations.
5+
*
6+
*
7+
* Copyright (c) 2014-2015, PostgreSQL Global Development Group
8+
*
9+
* src/include/nodes/lockoptions.h
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef LOCKOPTIONS_H
14+
#define LOCKOPTIONS_H
15+
16+
/*
17+
* This enum represents the different strengths of FOR UPDATE/SHARE clauses.
18+
* The ordering here is important, because the highest numerical value takes
19+
* precedence when a RTE is specified multiple ways. See applyLockingClause.
20+
*/
21+
typedef enum LockClauseStrength
22+
{
23+
LCS_FORKEYSHARE, /* FOR KEY SHARE */
24+
LCS_FORSHARE, /* FOR SHARE */
25+
LCS_FORNOKEYUPDATE, /* FOR NO KEY UPDATE */
26+
LCS_FORUPDATE /* FOR UPDATE */
27+
} LockClauseStrength;
28+
29+
/*
30+
* This enum controls how to deal with rows being locked by FOR UPDATE/SHARE
31+
* clauses (i.e., it represents the NOWAIT and SKIP LOCKED options).
32+
* The ordering here is important, because the highest numerical value takes
33+
* precedence when a RTE is specified multiple ways. See applyLockingClause.
34+
*/
35+
typedef enum LockWaitPolicy
36+
{
37+
/* Wait for the lock to become available (default behavior) */
38+
LockWaitBlock,
39+
/* Skip rows that can't be locked (SKIP LOCKED) */
40+
LockWaitSkip,
41+
/* Raise an error if a row cannot be locked (NOWAIT) */
42+
LockWaitError
43+
} LockWaitPolicy;
44+
45+
#endif /* LOCKOPTIONS_H */

src/include/nodes/parsenodes.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#define PARSENODES_H
2222

2323
#include "nodes/bitmapset.h"
24+
#include "nodes/lockoptions.h"
2425
#include "nodes/primnodes.h"
2526
#include "nodes/value.h"
26-
#include "utils/lockwaitpolicy.h"
2727

2828
/* Possible sources of a Query */
2929
typedef enum QuerySource
@@ -645,15 +645,6 @@ typedef struct DefElem
645645
* a location field --- currently, parse analysis insists on unqualified
646646
* names in LockingClause.)
647647
*/
648-
typedef enum LockClauseStrength
649-
{
650-
/* order is important -- see applyLockingClause */
651-
LCS_FORKEYSHARE,
652-
LCS_FORSHARE,
653-
LCS_FORNOKEYUPDATE,
654-
LCS_FORUPDATE
655-
} LockClauseStrength;
656-
657648
typedef struct LockingClause
658649
{
659650
NodeTag type;

src/include/nodes/plannodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "access/sdir.h"
1818
#include "lib/stringinfo.h"
1919
#include "nodes/bitmapset.h"
20+
#include "nodes/lockoptions.h"
2021
#include "nodes/primnodes.h"
21-
#include "utils/lockwaitpolicy.h"
2222

2323

2424
/* ----------------------------------------------------------------

src/include/utils/lockwaitpolicy.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy