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

Commit10b7218

Browse files
committed
Use macro to define the number of enum values
Refactoring in the interest of code consistency, a follow-up to2e068db.The argument against inserting a special enum value at the end of the enumdefinition is that a switch statement might generate a compiler warning unlessit has a default clause.Aleksander Alekseev, reviewed by Michael Paquier, Dean Rasheed, Peter EisentrautDiscussion:https://postgr.es/m/CAJ7c6TMsiaV5urU_Pq6zJ2tXPDwk69-NKVh4AMN5XrRiM7N%2BGA%40mail.gmail.com
1 parentfc1b2ce commit10b7218

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ typedef enum pgssStoreKind
126126
*/
127127
PGSS_PLAN=0,
128128
PGSS_EXEC,
129-
130-
PGSS_NUMKIND/* Must be last value of this enum */
131129
}pgssStoreKind;
132130

131+
#definePGSS_NUMKIND (PGSS_EXEC + 1)
132+
133133
/*
134134
* Hashtable key that defines the identity of a hashtable entry. We separate
135135
* queries by user and by database even if they are otherwise identical.

‎src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ typedef enum
247247
{
248248
AutoVacForkFailed,/* failed trying to start a worker */
249249
AutoVacRebalance,/* rebalance the cost limits */
250-
AutoVacNumSignals,/* must be last */
251250
}AutoVacuumSignal;
252251

252+
#defineAutoVacNumSignals (AutoVacRebalance + 1)
253+
253254
/*
254255
* Autovacuum workitem array, stored in AutoVacuumShmem->av_workItems. This
255256
* list is mostly protected by AutovacuumLock, except that if an item is

‎src/bin/pg_dump/pg_backup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ enum _dumpPreparedQueries
7474
PREPQUERY_DUMPTABLEATTACH,
7575
PREPQUERY_GETCOLUMNACLS,
7676
PREPQUERY_GETDOMAINCONSTRAINTS,
77-
NUM_PREP_QUERIES/* must be last */
7877
};
7978

79+
#defineNUM_PREP_QUERIES (PREPQUERY_GETDOMAINCONSTRAINTS + 1)
80+
8081
/* Parameters needed by ConnectDatabase; same for dump and restore */
8182
typedefstruct_connParams
8283
{

‎src/include/storage/pmsignal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ typedef enum
4040
PMSIGNAL_BACKGROUND_WORKER_CHANGE,/* background worker state change */
4141
PMSIGNAL_START_WALRECEIVER,/* start a walreceiver */
4242
PMSIGNAL_ADVANCE_STATE_MACHINE,/* advance postmaster's state machine */
43-
44-
NUM_PMSIGNALS/* Must be last value of enum! */
4543
}PMSignalReason;
4644

45+
#defineNUM_PMSIGNALS (PMSIGNAL_ADVANCE_STATE_MACHINE+1)
46+
4747
/*
4848
* Reasons why the postmaster would send SIGQUIT to its children.
4949
*/

‎src/include/storage/procsignal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ typedef enum
4747
PROCSIG_RECOVERY_CONFLICT_BUFFERPIN,
4848
PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK,
4949
PROCSIG_RECOVERY_CONFLICT_LAST=PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK,
50-
51-
NUM_PROCSIGNALS/* Must be last! */
5250
}ProcSignalReason;
5351

52+
#defineNUM_PROCSIGNALS (PROCSIG_RECOVERY_CONFLICT_LAST + 1)
53+
5454
typedefenum
5555
{
5656
PROCSIGNAL_BARRIER_SMGRRELEASE,/* ask smgr to close files */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp