Skip to content

Commit 08eac1d

Browse files
author
Alexander Korotkov
committed
Make ages 64-bit
1 parent 6aadd41 commit 08eac1d

File tree

14 files changed

+687
-180
lines changed

14 files changed

+687
-180
lines changed

src/backend/access/common/reloptions.c

Lines changed: 121 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -191,58 +191,6 @@ static relopt_int intRelOpts[] =
191191
},
192192
-1, 1, 10000
193193
},
194-
{
195-
{
196-
"autovacuum_freeze_min_age",
197-
"Minimum age at which VACUUM should freeze a table row, for autovacuum",
198-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
199-
ShareUpdateExclusiveLock
200-
},
201-
-1, 0, 1000000000
202-
},
203-
{
204-
{
205-
"autovacuum_multixact_freeze_min_age",
206-
"Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
207-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
208-
ShareUpdateExclusiveLock
209-
},
210-
-1, 0, 1000000000
211-
},
212-
{
213-
{
214-
"autovacuum_freeze_max_age",
215-
"Age at which to autovacuum a table to prevent transaction ID wraparound",
216-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
217-
ShareUpdateExclusiveLock
218-
},
219-
-1, 100000, 2000000000
220-
},
221-
{
222-
{
223-
"autovacuum_multixact_freeze_max_age",
224-
"Multixact age at which to autovacuum a table to prevent multixact wraparound",
225-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
226-
ShareUpdateExclusiveLock
227-
},
228-
-1, 10000, 2000000000
229-
},
230-
{
231-
{
232-
"autovacuum_freeze_table_age",
233-
"Age at which VACUUM should perform a full table sweep to freeze row versions",
234-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
235-
ShareUpdateExclusiveLock
236-
}, -1, 0, 2000000000
237-
},
238-
{
239-
{
240-
"autovacuum_multixact_freeze_table_age",
241-
"Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
242-
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
243-
ShareUpdateExclusiveLock
244-
}, -1, 0, 2000000000
245-
},
246194
{
247195
{
248196
"log_autovacuum_min_duration",
@@ -291,7 +239,66 @@ static relopt_int intRelOpts[] =
291239
},
292240
-1, 0, 1024
293241
},
242+
/* list terminator */
243+
{{NULL}}
244+
};
294245

246+
static relopt_int64 int64RelOpts[] =
247+
{
248+
{
249+
{
250+
"autovacuum_freeze_min_age",
251+
"Minimum age at which VACUUM should freeze a table row, for autovacuum",
252+
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
253+
ShareUpdateExclusiveLock
254+
},
255+
INT64CONST(-1), INT64CONST(0), INT64CONST(1000000000)
256+
},
257+
{
258+
{
259+
"autovacuum_multixact_freeze_min_age",
260+
"Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
261+
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
262+
ShareUpdateExclusiveLock
263+
},
264+
INT64CONST(-1), INT64CONST(0), INT64CONST(1000000000)
265+
},
266+
{
267+
{
268+
"autovacuum_freeze_max_age",
269+
"Age at which to autovacuum a table to prevent transaction ID wraparound",
270+
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
271+
ShareUpdateExclusiveLock
272+
},
273+
INT64CONST(-1), INT64CONST(100000), INT64CONST(2000000000)
274+
},
275+
{
276+
{
277+
"autovacuum_multixact_freeze_max_age",
278+
"Multixact age at which to autovacuum a table to prevent multixact wraparound",
279+
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
280+
ShareUpdateExclusiveLock
281+
},
282+
INT64CONST(-1), INT64CONST(10000), INT64CONST(2000000000)
283+
},
284+
{
285+
{
286+
"autovacuum_freeze_table_age",
287+
"Age at which VACUUM should perform a full table sweep to freeze row versions",
288+
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
289+
ShareUpdateExclusiveLock
290+
},
291+
INT64CONST(-1), INT64CONST(0), INT64CONST(2000000000)
292+
},
293+
{
294+
{
295+
"autovacuum_multixact_freeze_table_age",
296+
"Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
297+
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
298+
ShareUpdateExclusiveLock
299+
},
300+
INT64CONST(-1), INT64CONST(0), INT64CONST(2000000000)
301+
},
295302
/* list terminator */
296303
{{NULL}}
297304
};
@@ -458,6 +465,14 @@ initialize_reloptions(void)
458465
j++;
459466
}
460467

468+
for (i = 0; int64RelOpts[i].gen.name; i++)
469+
{
470+
relOpts[j] = &int64RelOpts[i].gen;
471+
relOpts[j]->type = RELOPT_TYPE_INT64;
472+
relOpts[j]->namelen = strlen(relOpts[j]->name);
473+
j++;
474+
}
475+
461476
for (i = 0; realRelOpts[i].gen.name; i++)
462477
{
463478
relOpts[j] = &realRelOpts[i].gen;
@@ -560,6 +575,9 @@ allocate_reloption(bits32 kinds, int type, char *name, char *desc)
560575
case RELOPT_TYPE_INT:
561576
size = sizeof(relopt_int);
562577
break;
578+
case RELOPT_TYPE_INT64:
579+
size = sizeof(relopt_int64);
580+
break;
563581
case RELOPT_TYPE_REAL:
564582
size = sizeof(relopt_real);
565583
break;
@@ -622,6 +640,25 @@ add_int_reloption(bits32 kinds, char *name, char *desc, int default_val,
622640
add_reloption((relopt_gen *) newoption);
623641
}
624642

643+
/*
644+
* add_int64_reloption
645+
* Add a new integer reloption
646+
*/
647+
void
648+
add_int64_reloption(bits32 kinds, char *name, char *desc, int64 default_val,
649+
int64 min_val, int64 max_val)
650+
{
651+
relopt_int64 *newoption;
652+
653+
newoption = (relopt_int64 *) allocate_reloption(kinds, RELOPT_TYPE_INT64,
654+
name, desc);
655+
newoption->default_val = default_val;
656+
newoption->min = min_val;
657+
newoption->max = max_val;
658+
659+
add_reloption((relopt_gen *) newoption);
660+
}
661+
625662
/*
626663
* add_real_reloption
627664
* Add a new float reloption
@@ -1126,6 +1163,27 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len,
11261163
optint->min, optint->max)));
11271164
}
11281165
break;
1166+
case RELOPT_TYPE_INT64:
1167+
{
1168+
relopt_int64 *optint = (relopt_int64 *) option->gen;
1169+
1170+
parsed = parse_int64(value, &option->values.int64_val, 0, NULL);
1171+
if (validate && !parsed)
1172+
ereport(ERROR,
1173+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1174+
errmsg("invalid value for integer option \"%s\": %s",
1175+
option->gen->name, value)));
1176+
if (validate && (option->values.int64_val < optint->min ||
1177+
option->values.int64_val > optint->max))
1178+
ereport(ERROR,
1179+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1180+
errmsg("value %s out of bounds for option \"%s\"",
1181+
value, option->gen->name),
1182+
errdetail("Valid values are between \"" INT64_FORMAT
1183+
"\" and \"" INT64_FORMAT "\".",
1184+
optint->min, optint->max)));
1185+
}
1186+
break;
11291187
case RELOPT_TYPE_REAL:
11301188
{
11311189
relopt_real *optreal = (relopt_real *) option->gen;
@@ -1234,6 +1292,11 @@ fillRelOptions(void *rdopts, Size basesize,
12341292
options[i].values.int_val :
12351293
((relopt_int *) options[i].gen)->default_val;
12361294
break;
1295+
case RELOPT_TYPE_INT64:
1296+
*(int64 *) itempos = options[i].isset ?
1297+
options[i].values.int64_val :
1298+
((relopt_int64 *) options[i].gen)->default_val;
1299+
break;
12371300
case RELOPT_TYPE_REAL:
12381301
*(double *) itempos = options[i].isset ?
12391302
options[i].values.real_val :
@@ -1295,17 +1358,17 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
12951358
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_delay)},
12961359
{"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
12971360
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_limit)},
1298-
{"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
1361+
{"autovacuum_freeze_min_age", RELOPT_TYPE_INT64,
12991362
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_min_age)},
1300-
{"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
1363+
{"autovacuum_freeze_max_age", RELOPT_TYPE_INT64,
13011364
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_max_age)},
1302-
{"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
1365+
{"autovacuum_freeze_table_age", RELOPT_TYPE_INT64,
13031366
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_table_age)},
1304-
{"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT,
1367+
{"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT64,
13051368
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, multixact_freeze_min_age)},
1306-
{"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT,
1369+
{"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT64,
13071370
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, multixact_freeze_max_age)},
1308-
{"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT,
1371+
{"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT64,
13091372
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, multixact_freeze_table_age)},
13101373
{"log_autovacuum_min_duration", RELOPT_TYPE_INT,
13111374
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, log_min_duration)},

src/backend/commands/vacuum.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
/*
5555
* GUC parameters
5656
*/
57-
int vacuum_freeze_min_age;
58-
int vacuum_freeze_table_age;
59-
int vacuum_multixact_freeze_min_age;
60-
int vacuum_multixact_freeze_table_age;
57+
int64 vacuum_freeze_min_age;
58+
int64 vacuum_freeze_table_age;
59+
int64 vacuum_multixact_freeze_min_age;
60+
int64 vacuum_multixact_freeze_table_age;
6161

6262

6363
/* A few variables that don't seem worth passing around as parameters */
@@ -469,19 +469,19 @@ get_rel_oids(Oid relid, const RangeVar *vacrel)
469469
*/
470470
void
471471
vacuum_set_xid_limits(Relation rel,
472-
int freeze_min_age,
473-
int freeze_table_age,
474-
int multixact_freeze_min_age,
475-
int multixact_freeze_table_age,
472+
int64 freeze_min_age,
473+
int64 freeze_table_age,
474+
int64 multixact_freeze_min_age,
475+
int64 multixact_freeze_table_age,
476476
TransactionId *oldestXmin,
477477
TransactionId *freezeLimit,
478478
TransactionId *xidFullScanLimit,
479479
MultiXactId *multiXactCutoff,
480480
MultiXactId *mxactFullScanLimit)
481481
{
482-
int freezemin;
483-
int mxid_freezemin;
484-
int effective_multixact_freeze_max_age;
482+
int64 freezemin;
483+
int64 mxid_freezemin;
484+
int64 effective_multixact_freeze_max_age;
485485
TransactionId limit;
486486
TransactionId safeLimit;
487487
TransactionId nextXid;

src/backend/postmaster/autovacuum.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ int autovacuum_vac_thresh;
115115
double autovacuum_vac_scale;
116116
int autovacuum_anl_thresh;
117117
double autovacuum_anl_scale;
118-
int autovacuum_freeze_max_age;
119-
int autovacuum_multixact_freeze_max_age;
118+
int64 autovacuum_freeze_max_age;
119+
int64 autovacuum_multixact_freeze_max_age;
120120

121121
int autovacuum_vac_cost_delay;
122122
int autovacuum_vac_cost_limit;
@@ -144,10 +144,10 @@ static TransactionId recentXid;
144144
static MultiXactId recentMulti;
145145

146146
/* Default freeze ages to use for autovacuum (varies by database) */
147-
static int default_freeze_min_age;
148-
static int default_freeze_table_age;
149-
static int default_multixact_freeze_min_age;
150-
static int default_multixact_freeze_table_age;
147+
static int64 default_freeze_min_age;
148+
static int64 default_freeze_table_age;
149+
static int64 default_multixact_freeze_min_age;
150+
static int64 default_multixact_freeze_table_age;
151151

152152
/* Memory context for long-lived data */
153153
static MemoryContext AutovacMemCxt;
@@ -302,11 +302,11 @@ static void FreeWorkerInfo(int code, Datum arg);
302302

303303
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
304304
TupleDesc pg_class_desc,
305-
int effective_multixact_freeze_max_age);
305+
int64 effective_multixact_freeze_max_age);
306306
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
307307
Form_pg_class classForm,
308308
PgStat_StatTabEntry *tabentry,
309-
int effective_multixact_freeze_max_age,
309+
int64 effective_multixact_freeze_max_age,
310310
bool *dovacuum, bool *doanalyze, bool *wraparound);
311311

312312
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1900,7 +1900,7 @@ do_autovacuum(void)
19001900
BufferAccessStrategy bstrategy;
19011901
ScanKeyData key;
19021902
TupleDesc pg_class_desc;
1903-
int effective_multixact_freeze_max_age;
1903+
int64 effective_multixact_freeze_max_age;
19041904

19051905
/*
19061906
* StartTransactionCommand and CommitTransactionCommand will automatically
@@ -2471,7 +2471,7 @@ get_pgstat_tabentry_relid(Oid relid, bool isshared, PgStat_StatDBEntry *shared,
24712471
static autovac_table *
24722472
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
24732473
TupleDesc pg_class_desc,
2474-
int effective_multixact_freeze_max_age)
2474+
int64 effective_multixact_freeze_max_age)
24752475
{
24762476
Form_pg_class classForm;
24772477
HeapTuple classTup;
@@ -2527,10 +2527,10 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
25272527
/* OK, it needs something done */
25282528
if (doanalyze || dovacuum)
25292529
{
2530-
int freeze_min_age;
2531-
int freeze_table_age;
2532-
int multixact_freeze_min_age;
2533-
int multixact_freeze_table_age;
2530+
int64 freeze_min_age;
2531+
int64 freeze_table_age;
2532+
int64 multixact_freeze_min_age;
2533+
int64 multixact_freeze_table_age;
25342534
int vac_cost_limit;
25352535
int vac_cost_delay;
25362536
int log_min_duration;
@@ -2655,7 +2655,7 @@ relation_needs_vacanalyze(Oid relid,
26552655
AutoVacOpts *relopts,
26562656
Form_pg_class classForm,
26572657
PgStat_StatTabEntry *tabentry,
2658-
int effective_multixact_freeze_max_age,
2658+
int64 effective_multixact_freeze_max_age,
26592659
/* output params below */
26602660
bool *dovacuum,
26612661
bool *doanalyze,
@@ -2679,8 +2679,8 @@ relation_needs_vacanalyze(Oid relid,
26792679
anltuples;
26802680

26812681
/* freeze parameters */
2682-
int freeze_max_age;
2683-
int multixact_freeze_max_age;
2682+
int64 freeze_max_age;
2683+
int64 multixact_freeze_max_age;
26842684

26852685
AssertArg(classForm != NULL);
26862686
AssertArg(OidIsValid(relid));

src/backend/storage/ipc/standby.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "utils/timestamp.h"
3434

3535
/* User-settable GUC parameters */
36-
int vacuum_defer_cleanup_age;
36+
int64 vacuum_defer_cleanup_age;
3737
int max_standby_archive_delay = 30 * 1000;
3838
int max_standby_streaming_delay = 30 * 1000;
3939

src/backend/utils/adt/numutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ pg_ltostr(char *str, int32 value)
393393
* pg_strtouint64
394394
* Converts 'str' into an unsigned 64-bit integer.
395395
*
396-
* This has the identical API to strtoul(3), except that it will handle
396+
* This has the identical API to strtoull(3), except that it will handle
397397
* 64-bit ints even where "long" is narrower than that.
398398
*
399399
* For the moment it seems sufficient to assume that the platform has

src/backend/utils/adt/version.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ Datum
3333
pgpro_edition(PG_FUNCTION_ARGS)
3434
{
3535
PG_RETURN_TEXT_P(cstring_to_text(PGPRO_EDITION));
36-
}
36+
}

0 commit comments

Comments
 (0)