1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-22 23:02:54 +03:00

Introduce InvalidCommandId.

This allows a 32-bit field to represent an *optional* command ID
without a separate flag bit.

Andres Freund
This commit is contained in:
Robert Haas 2013-09-09 16:25:29 -04:00
parent 9c68834bfc
commit 71901ab6da
2 changed files with 3 additions and 2 deletions

View File

@ -766,12 +766,12 @@ CommandCounterIncrement(void)
if (currentCommandIdUsed) if (currentCommandIdUsed)
{ {
currentCommandId += 1; currentCommandId += 1;
if (currentCommandId == FirstCommandId) /* check for overflow */ if (currentCommandId == InvalidCommandId)
{ {
currentCommandId -= 1; currentCommandId -= 1;
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("cannot have more than 2^32-1 commands in a transaction"))); errmsg("cannot have more than 2^32-2 commands in a transaction")));
} }
currentCommandIdUsed = false; currentCommandIdUsed = false;

View File

@ -368,6 +368,7 @@ typedef uint32 MultiXactOffset;
typedef uint32 CommandId; typedef uint32 CommandId;
#define FirstCommandId ((CommandId) 0) #define FirstCommandId ((CommandId) 0)
#define InvalidCommandId (~(CommandId)0)
/* /*
* Array indexing support * Array indexing support