148
148
"Age at which to autovacuum a table to prevent transaction ID wraparound",
149
149
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
151
200000000, 100000000, 2000000000
151
-1, 100000000, 2000000000
155
155
"autovacuum_freeze_table_age",
156
156
"Age at which VACUUM should perform a full table sweep to replace old Xid values with FrozenXID",
157
157
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
158
}, 150000000, 0, 2000000000
160
160
/* list terminator */
164
164
static relopt_real realRelOpts[] =
177
177
"Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples",
178
178
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
182
182
/* list terminator */
186
186
static relopt_string stringRelOpts[] =
188
188
/* list terminator */
192
192
static relopt_gen **relOpts = NULL;
193
static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT << 1;
193
static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT;
195
static int num_custom_options = 0;
195
static int num_custom_options = 0;
196
196
static relopt_gen **custom_options = NULL;
197
static bool need_initialization = true;
197
static bool need_initialization = true;
199
199
static void initialize_reloptions(void);
200
200
static void parse_one_reloption(relopt_value *option, char *text_str,
274
274
* add_reloption_kind
275
* Create a new relopt_kind value, to be used in custom reloptions by
275
* Create a new relopt_kind value, to be used in custom reloptions by
279
279
add_reloption_kind(void)
283
/* don't hand out the last bit so that the wraparound check is portable */
281
/* don't hand out the last bit so that the enum's behavior is portable */
284
282
if (last_assigned_kind >= RELOPT_KIND_MAX)
286
284
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
287
errmsg("user-defined relation parameter types limit exceeded")));
289
kind = (relopt_kind) last_assigned_kind;
285
errmsg("user-defined relation parameter types limit exceeded")));
290
286
last_assigned_kind <<= 1;
287
return (relopt_kind) last_assigned_kind;
296
* Add an already-created custom reloption to the list, and recompute the
292
* Add an already-created custom reloption to the list, and recompute the
300
296
add_reloption(relopt_gen *newoption)
302
static int max_custom_options = 0;
298
static int max_custom_options = 0;
304
300
if (num_custom_options >= max_custom_options)
306
MemoryContext oldcxt;
302
MemoryContext oldcxt;
308
304
oldcxt = MemoryContextSwitchTo(TopMemoryContext);
898
894
parsed = parse_bool(value, &option->values.bool_val);
899
895
if (validate && !parsed)
901
(errmsg("invalid value for boolean option \"%s\": %s",
902
option->gen->name, value)));
897
(errmsg("invalid value for boolean option \"%s\": %s",
898
option->gen->name, value)));
905
901
case RELOPT_TYPE_INT:
907
relopt_int *optint = (relopt_int *) option->gen;
903
relopt_int *optint = (relopt_int *) option->gen;
909
905
parsed = parse_int(value, &option->values.int_val, 0, NULL);
910
906
if (validate && !parsed)
912
(errmsg("invalid value for integer option \"%s\": %s",
913
option->gen->name, value)));
908
(errmsg("invalid value for integer option \"%s\": %s",
909
option->gen->name, value)));
914
910
if (validate && (option->values.int_val < optint->min ||
915
911
option->values.int_val > optint->max))
917
(errmsg("value %s out of bounds for option \"%s\"",
918
value, option->gen->name),
919
errdetail("Valid values are between \"%d\" and \"%d\".",
920
optint->min, optint->max)));
913
(errmsg("value %s out of bounds for option \"%s\"",
914
value, option->gen->name),
915
errdetail("Valid values are between \"%d\" and \"%d\".",
916
optint->min, optint->max)));
923
919
case RELOPT_TYPE_REAL:
925
relopt_real *optreal = (relopt_real *) option->gen;
921
relopt_real *optreal = (relopt_real *) option->gen;
927
923
parsed = parse_real(value, &option->values.real_val);
928
924
if (validate && !parsed)
932
928
if (validate && (option->values.real_val < optreal->min ||
933
929
option->values.real_val > optreal->max))
935
(errmsg("value %s out of bounds for option \"%s\"",
936
value, option->gen->name),
937
errdetail("Valid values are between \"%f\" and \"%f\".",
938
optreal->min, optreal->max)));
931
(errmsg("value %s out of bounds for option \"%s\"",
932
value, option->gen->name),
933
errdetail("Valid values are between \"%f\" and \"%f\".",
934
optreal->min, optreal->max)));
941
937
case RELOPT_TYPE_STRING:
943
relopt_string *optstring = (relopt_string *) option->gen;
939
relopt_string *optstring = (relopt_string *) option->gen;
945
941
option->values.string_val = value;
1074
1070
default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
1076
relopt_value *options;
1077
StdRdOptions *rdopts;
1072
relopt_value *options;
1073
StdRdOptions *rdopts;
1079
1075
static const relopt_parse_elt tab[] = {
1080
1076
{"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
1081
1077
{"autovacuum_enabled", RELOPT_TYPE_BOOL,
1082
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
1078
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, enabled)},
1083
1079
{"autovacuum_vacuum_threshold", RELOPT_TYPE_INT,
1084
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_threshold)},
1080
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_threshold)},
1085
1081
{"autovacuum_analyze_threshold", RELOPT_TYPE_INT,
1086
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)},
1082
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, analyze_threshold)},
1087
1083
{"autovacuum_vacuum_cost_delay", RELOPT_TYPE_INT,
1088
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_delay)},
1084
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_delay)},
1089
1085
{"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
1090
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_limit)},
1086
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_limit)},
1091
1087
{"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
1092
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)},
1088
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_min_age)},
1093
1089
{"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
1094
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)},
1090
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_max_age)},
1095
1091
{"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
1096
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)},
1092
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_table_age)},
1097
1093
{"autovacuum_vacuum_scale_factor", RELOPT_TYPE_REAL,
1098
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_scale_factor)},
1094
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_scale_factor)},
1099
1095
{"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL,
1100
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_scale_factor)}
1096
offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, analyze_scale_factor)}
1103
1099
options = parseRelOptions(reloptions, validate, kind, &numoptions);