]> granicus.if.org Git - postgresql/commitdiff
Introduce InvalidCommandId.
authorRobert Haas <rhaas@postgresql.org>
Mon, 9 Sep 2013 20:25:29 +0000 (16:25 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 9 Sep 2013 20:25:29 +0000 (16:25 -0400)
This allows a 32-bit field to represent an *optional* command ID
without a separate flag bit.

Andres Freund

src/backend/access/transam/xact.c
src/include/c.h

index 31e868d4bc7a0ad23d7ade8230cabe116d6ee437..0591f3fd56210d3f4902fce03392f5fc12ec931b 100644 (file)
@@ -766,12 +766,12 @@ CommandCounterIncrement(void)
        if (currentCommandIdUsed)
        {
                currentCommandId += 1;
-               if (currentCommandId == FirstCommandId) /* check for overflow */
+               if (currentCommandId == InvalidCommandId)
                {
                        currentCommandId -= 1;
                        ereport(ERROR,
                                        (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;
 
index 596118342dfc4e4ba32741a9a9f3296747047ce8..14bfdcd4dab5afd18dde7303517388b1a1ee5a24 100644 (file)
@@ -368,6 +368,7 @@ typedef uint32 MultiXactOffset;
 typedef uint32 CommandId;
 
 #define FirstCommandId ((CommandId) 0)
+#define InvalidCommandId       (~(CommandId)0)
 
 /*
  * Array indexing support