Commit 71901ab6 authored by Robert Haas's avatar Robert Haas

Introduce InvalidCommandId.

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

Andres Freund
parent 9c68834b
...@@ -766,12 +766,12 @@ CommandCounterIncrement(void) ...@@ -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;
......
...@@ -368,6 +368,7 @@ typedef uint32 MultiXactOffset; ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment