Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
pg_resetwal: Corrections around -c option
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 10 Oct 2023 06:58:50 +0000 (08:58 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 10 Oct 2023 06:58:50 +0000 (08:58 +0200)
The present pg_resetwal code hardcodes the minimum value for -c as 2,
which is FrozenTransactionId, but it's not clear why that is allowed.
After some research, it was probably a mistake in the original patch.
Change it to FirstNormalTransactionId, which matches other xid-related
options in pg_resetwal.

Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/d09f0e91-8757-642b-1a92-da9a52f5589a%40eisentraut.org

src/bin/pg_resetwal/pg_resetwal.c

index 04567f349d67446a4bb1892b058429a7580ad10b..3ae3fc06df20dd4758c755d31eeec468aee33ea4 100644 (file)
@@ -211,13 +211,13 @@ main(int argc, char *argv[])
                    exit(1);
                }
 
-               if (set_oldest_commit_ts_xid < 2 &&
-                   set_oldest_commit_ts_xid != 0)
-                   pg_fatal("transaction ID (-c) must be either 0 or greater than or equal to 2");
+               if (set_oldest_commit_ts_xid < FirstNormalTransactionId &&
+                   set_oldest_commit_ts_xid != InvalidTransactionId)
+                   pg_fatal("transaction ID (-c) must be either %u or greater than or equal to %u", InvalidTransactionId, FirstNormalTransactionId);
 
-               if (set_newest_commit_ts_xid < 2 &&
-                   set_newest_commit_ts_xid != 0)
-                   pg_fatal("transaction ID (-c) must be either 0 or greater than or equal to 2");
+               if (set_newest_commit_ts_xid < FirstNormalTransactionId &&
+                   set_newest_commit_ts_xid != InvalidTransactionId)
+                   pg_fatal("transaction ID (-c) must be either %u or greater than or equal to %u", InvalidTransactionId, FirstNormalTransactionId);
                break;
 
            case 'o':