Debian Codegraph @

mysql-test/suite/sys_vars/inc/json_sysvar_spec.inc

raw
1 # ==== Purpose ====
2 #
3 # Define properties of system variables, in a JSON object.
4 #
5 # ==== Usage ====
6 #
7 # [--let $json_verbose = {0 | 1 | LIST}]
8 # --source json_sysvar_spec.inc
9 # --let $json_object = $sysvar_specs
10 # --source $json_sysvar_start
11 # while (!$json_sysvar_done) {
12 # # Each iteration, process one sysvar.
13 # # The sysvar is described with mtr variables, listed below.
14 # --source $json_sysvar_next
15 # }
16 #
17 # # See e.g. all_global_sysvars_with_aliases.inc for a complete example.
18 #
19 # Parameters:
20 #
21 # $json_verbose
22 # Controls what output will be printed by $json_sysvar_next and
23 # $json_sysvar_start. See
24 # include/create_unpacking_json_iterator.inc for a complete
25 # description.
26 #
27 # When used as above, the loop will iterate over sysvars. In each iteration
28 # the following variables are set:
29 #
30 # $name
31 # The name of the variable.
32 #
33 # $alias
34 # If the variable has an alias, this should be set to the alias.
35 # Otherwise an empty string.
36 #
37 # $default
38 # The default value.
39 #
40 # $values
41 # A JSON array containing at least three valid values. The values
42 # are chosen to be as "interesting" as possible to test, testing as
43 # many syntax variations as possible. In addition:
44 # - The first element is always different from the default.
45 # - The Nth element is always different from the (N-1)th element.
46 # - All elements are different, unless the range of the data type is
47 # smaller than the length of the array.
48 #
49 # $invalid_values
50 # A JSON array containing a set of invalid values.
51 #
52 # $min
53 # The minimum value, if the variable is numeric. Otherwise an empty string.
54 #
55 # $max
56 # The maximum value, if the variable is numeric. Otherwise an empty string.
57 #
58 # $block_size
59 # The block size, if the variable is numeric. Otherwise 1.
60 #
61 # $global
62 # Set to 1 for variables that exist in global scope, 0 for variables
63 # that don't.
64 #
65 # $session
66 # Set to 1 for variables that exist in session scope, 0 for
67 # variables that don't.
68 #
69 # $cmdline
70 # Set to 1 for variables that have a command-line counterpart, and 0
71 # for variables that are not settable on the command-line.
72 #
73 # $persist
74 # Set to 1 for persistable variables and 0 for non-persistable variables.
75 #
76 # $persist_as_readonly
77 # Set to 1 for variables defined with the PERSIST_AS_READONLY flag,
78 # and 0 for variables without it. The PERSIST_AS_READONLY flag
79 # controls how the variable is initialized during server start, if
80 # it was found in the persisted variables file: without the flag,
81 # the server exeuctes the equivalent of a SET statement. With the
82 # flag, the server executes the equivalent of a command-line option.
83 #
84 # $dynamic
85 # Set to 1 for dynamic variables and 0 for read-only variables.
86 #
87 # $value_map
88 # Sometimes, the value you get when you use SELECT is not literally
89 # identical to what you used in SET. Examples are:
90 # - For a string variable, you quote the value in SET, whereas
91 # SELECT returns the value without quotes.
92 # - For Boolean values, SET accepts 1, TRUE, ON, 'TRUE', etc,
93 # whereas SELECT returns 0 or 1.
94 # If any such values occur among $values or $default, your test
95 # script may need to know what to expect from a SELECT statement.
96 # It can find that value using this variable. The format is a JSON
97 # object, where the keys are values used in SET and the values are
98 # the corresponding results observed in SELECT @@$name.
99 #
100 # $ps_value_map
101 # Sometimes, the value shown in performance_schema is different from
102 # the value returned by SELECT @@$name. For example, Boolean
103 # variables show the value 0 or 1 in SELECT @@$name, but OFF or ON
104 # in performance_schema. If any such values occur among $values,
105 # your test may need to know what to expect when reading values from
106 # performance_schema. The format is a JSON object, where the keys
107 # are values of SELECT @@$name, and the values are the corresponding
108 # expected values in performance_schema.
109 #
110 # $skip_set_persist_only_default
111 # Due to BUG#32761053, SET PERSIST_ONLY ... = DEFAULT is broken for
112 # some variables, which makes it hard to test them. For those
113 # varibles, $skip_set_persist_only_default should be set to 1.
114 #
115 # $mask_value
116 # If $values or $default contains nondeterministic values, for
117 # example paths, $mask_value is set to 1.
118
119 # ==== Define "constants" that depend on environment ====
120
121 # Define numeric maxima.
122 --let $maxint32 = 4294967295
123 --let $maxint64 = 18446744073709551615
124 --source include/check_64bit_ulong.inc
125 if ($have_64bit_ulong) {
126 --let $maxint = $maxint64
127 }
128 if (!$have_64bit_ulong) {
129 --let $maxint = $maxint32
130 }
131
132 # Define numbers that depend on debug mode
133 --let $debug = `SELECT VERSION() LIKE '%debug%'`
134 if ($debug) {
135 --let $if_debug_0_else_1 = 0
136 --let $if_debug_1_else_8 = 1
137 --let $if_debug_1_else_32 = 1
138 }
139 if (!$debug) {
140 --let $if_debug_0_else_1 = 1
141 --let $if_debug_1_else_8 = 8
142 --let $if_debug_1_else_32 = 32
143 }
144
145 # Define paths
146 --let $tmpdir = `SELECT @@global.tmpdir`
147
148 # ==== Define abbreviations for common cases ====
149
150 # Define properties of booleans.
151 if(0){
152 # Do not check values that begin with backtick, due to
153 # BUG#32495164: MYSQLTEST DOUBLE-INTERPOLATES STRING VARIABLES
154 # STARTING WITH BACKTICK
155 let $bool =
156 "default": 0,
157 "value_map": { "0": 0, "FALSE": 0, "OFF": 0, "'OFF'": 0, "`OFF`": 0, "1": 1, "TRUE": 1, "ON": 1, "'ON'": 1, "`ON`": 1 },
158 "ps_value_map": {"0": "OFF", "1": "ON"},
159 "values": ["ON", "OFF", 1, 0, "TRUE", "FALSE", "'ON'", "'OFF'", "`ON`", "`OFF`"],
160 "invalid": [ 0.1, 2, -1, "''", "'x'", "'TRUE'", "'1'", "NULL"];
161 }
162 let $bool =
163 "values": ["ON", "OFF", 1, 0, "TRUE", "FALSE", "'ON'", "'OFF'"],
164 "invalid": [ 0.1, 2, -1, "''", "'x'", "'TRUE'", "'1'", "NULL"],
165 "value_map": { "0": 0, "FALSE": 0, "OFF": 0, "'OFF'": 0, "1": 1, "TRUE": 1, "ON": 1, "'ON'": 1 },
166 "ps_value_map": {"0": "OFF", "1": "ON"};
167
168 # Define invalid values for common data types.
169 --let $int_invalid = "invalid": [1.5, "ON", "'x'", "NULL"]
170 # Surprisingly, ON and NULL are allowed for strings, not listing them here.
171 --let $str_invalid = "invalid": [7, 1.9, "FALSE"]
172 --let $enum_invalid = 1.5, "ON", "'x'", "NULL", "'FOO_BAR'"
173
174 # Use this for variables that are read-only.
175 --let $readonly = "dynamic": 0
176
177 # Use this for variables that are non-persist.
178 --let $nopersist = "persist": 0
179
180 # Use this for variables that are persisted in "persist_as_readonly"
181 # mode. (This has nothing to do with readonliness; it only means that
182 # the variable is loaded using the framework for command-line options
183 # rather than using the framework for SET statements.)
184 --let $persist_as_readonly = "persist_as_readonly": 1
185
186 # Use this for variables that are not settable on the command line.
187 --let $nocmdline = "cmdline": 0
188
189
190 # ==== Declare the array of sysvar descriptions ====
191 #
192 # This is a JSON document contains a JSON array where each element is
193 # a JSON object that describes one sysvar. The JSON object has the
194 # following keys:
195 #
196 # - name: The name of the variable.
197 # - alias: The alias for the variable, if it has one.
198 # - default: The default value.
199 # - values: Array with at least three elements, containing some valid
200 # values for the variable.
201 # - min: The minimum value, if it is a numeric variable.
202 # - max: The maximum value, if it is a numeric variable.
203 # - block_size: The "block size", if this is a numeric variable. It
204 # defaults to 1 if not given.
205 # - invalid: Array of values that are not allowed to assign the
206 # variable.
207 # - readonly: If given, and set to 1, the variable is expected to be
208 # read-only.
209 # - nopersist: If given, and set to 1, the variable is expected to be
210 # non-persistent.
211 # - value_map: Used when the value of a variable as seen by SELECT
212 # @@variable differs from that in the preceding SET statement. In
213 # that case, this should be JSON object where the keys are values
214 # that this script may use in a SET statement, and the values should
215 # be the result of a subsequent SELECT. Values that are not listed
216 # in the object are assumed to be the same in SELECT as in the
217 # preceding SET. If value_map is omitted, it defults to the empty
218 # set.
219 # - ps_value_map: Used when the value of a variable displayed in
220 # performance_schema differs from the value displayed in a SELECT
221 # @@variable statement. When this is the case, this should be a JSON
222 # object where each key is a value shown by SELECT @@variable and
223 # each value is the corresponding value shown in performance_schema.
224 # Values that are not listed in the object are assumed to be the
225 # same in SELECT @@variable and in performance_schema. If
226 # ps_value_map is omitted, it defaults to the empty set.
227
228 --delimiter |||
229 let $sysvar_specs =
230 [
231 {
232 "name": "init_replica",
233 "alias": "init_slave",
234 "default": "",
235 "values": ["'SELECT 1'", "'SELECT 9'", "'SELECT(3)'"],
236 "value_map": {"'SELECT 1'": "SELECT 1", "'SELECT 9'": "SELECT 9", "'SELECT(3)'": "SELECT(3)"},
237 $str_invalid
238 },
239 {
240 "name": "log_replica_updates",
241 "alias": "log_slave_updates",
242 $readonly,
243 $persist_as_readonly,
244 "default": 1,
245 $bool
246 },
247 {
248 "name": "log_slow_replica_statements",
249 "alias": "log_slow_slave_statements",
250 "default": 0,
251 $bool
252 },
253 {
254 "name": "replica_allow_batching",
255 "alias": "slave_allow_batching",
256 "default": 1,
257 $bool
258 },
259 {
260 "name": "replica_checkpoint_group",
261 "alias": "slave_checkpoint_group",
262 "default": 512,
263 "values": [520, 1000, 2000],
264 "min": $if_debug_1_else_32,
265 "max": 524280,
266 "block_size": $if_debug_1_else_8,
267 $int_invalid
268 },
269 {
270 "name": "replica_checkpoint_period",
271 "alias": "slave_checkpoint_period",
272 "default": 300,
273 "values": [1, 2, 12323],
274 "min": $if_debug_0_else_1,
275 "max": $maxint32,
276 $int_invalid
277 },
278 {
279 "name": "replica_compressed_protocol",
280 "alias": "slave_compressed_protocol",
281 "default": 0,
282 $bool
283 },
284 {
285 "name": "replica_exec_mode",
286 "alias": "slave_exec_mode",
287 "default": "STRICT",
288 "values": ["IDEMPOTENT", "STRICT", "'IDEMPOTENT'", 0, 1],
289 "invalid": [$enum_invalid, -1, 2],
290 "value_map": {"'IDEMPOTENT'": "IDEMPOTENT", "0": "STRICT", "1": "IDEMPOTENT"},
291 "skip_set_persist_only_default": 1
292 },
293 {
294 "name": "replica_load_tmpdir",
295 "alias": "slave_load_tmpdir",
296 $readonly,
297 $nopersist,
298 "default": "'$tmpdir'",
299 "values": ["'$tmpdir/x'", "'$tmpdir'", "'$tmpdir/y'"],
300 "invalid": ["NULL", "ON"],
301 "value_map": {"'$tmpdir/x'": "$tmpdir/x", "'$tmpdir'": "$tmpdir", "'$tmpdir/y'": "$tmpdir/y"},
302 "mask_value": 1
303 },
304 {
305 "name": "replica_max_allowed_packet",
306 "alias": "slave_max_allowed_packet",
307 "default": 1073741824,
308 "values": [1024, 2048, 65536],
309 "min": 1024,
310 "max": 1073741824,
311 "block_size": 1024,
312 $int_invalid
313 },
314 {
315 "name": "replica_net_timeout",
316 "alias": "slave_net_timeout",
317 "default": 60,
318 "values": [1, 2, 65536],
319 "min": 1,
320 "max": 31536000,
321 $int_invalid
322 },
323 {
324 "name": "replica_parallel_workers",
325 "alias": "slave_parallel_workers",
326 $persist_as_readonly,
327 "default": 4,
328 "values": [1, 2, 100],
329 "max": 1024,
330 $int_invalid
331 },
332 {
333 "name": "replica_pending_jobs_size_max",
334 "alias": "slave_pending_jobs_size_max",
335 "default": 134217728,
336 "values": [65536, 32768, 4096],
337 "min": 1024,
338 "max": 18446744073709550592,
339 "block_size": 1024,
340 $int_invalid
341 },
342 {
343 "name": "replica_preserve_commit_order",
344 "alias": "slave_preserve_commit_order",
345 $persist_as_readonly,
346 "default": 1,
347 $bool
348 },
349 {
350 "name": "replica_skip_errors",
351 "alias": "slave_skip_errors",
352 $readonly,
353 $persist_as_readonly,
354 "default": "OFF",
355 "values": ["all", "ddl_exist_errors", "'1,2'", "'ddl_exist_errors,3,9,3,ddl_exist_errors,all'"],
356 "invalid": [0, 1, 1.5, -1, "ON", null, "'x'"],
357 "value_map": {"'1,2'": "1,2"},
358 "skip_set_persist_only_default": 1
359 },
360 {
361 "name": "replica_sql_verify_checksum",
362 "alias": "slave_sql_verify_checksum",
363 "default": 1,
364 $bool
365 },
366 {
367 "name": "replica_transaction_retries",
368 "alias": "slave_transaction_retries",
369 "default": 10,
370 "values": [1, 2, 99],
371 "min": 0,
372 "max": $maxint,
373 $int_invalid
374 },
375 {
376 "name": "replica_type_conversions",
377 "alias": "slave_type_conversions",
378 "default": "",
379 "values": ["ALL_LOSSY", "'ALL_NON_LOSSY'", "''", "'ALL_LOSSY,ALL_NON_LOSSY,ALL_UNSIGNED,ALL_SIGNED'", 0, 8, 15],
380 "invalid": [$enum_invalid, -1, 16],
381 "value_map": {
382 "'ALL_NON_LOSSY'": "ALL_NON_LOSSY",
383 "'ALL_LOSSY,ALL_NON_LOSSY,ALL_UNSIGNED,ALL_SIGNED'": "ALL_LOSSY,ALL_NON_LOSSY,ALL_UNSIGNED,ALL_SIGNED",
384 "''": "",
385 "0": "",
386 "8": "ALL_SIGNED",
387 "15": "ALL_LOSSY,ALL_NON_LOSSY,ALL_UNSIGNED,ALL_SIGNED"
388 },
389 "skip_set_persist_only_default": 1
390 },
391 {
392 "name": "rpl_stop_replica_timeout",
393 "alias": "rpl_stop_slave_timeout",
394 "default": 31536000,
395 "values": [100, 200, 3],
396 "min": 2,
397 "max": 31536000,
398 $int_invalid
399 },
400 {
401 "name": "source_verify_checksum",
402 "alias": "master_verify_checksum",
403 "default": 0,
404 $bool
405 },
406 {
407 "name": "sql_replica_skip_counter",
408 "alias": "sql_slave_skip_counter",
409 $nocmdline,
410 "default": 0,
411 "values": [1, 2, 12323],
412 "min": 0,
413 "max": $maxint32,
414 $int_invalid
415 },
416 {
417 "name": "sync_source_info",
418 "alias": "sync_master_info",
419 "default": 10000,
420 "values": [1, 999, 123456],
421 "min": 0,
422 "max": $maxint32,
423 $int_invalid
424 }
425 ]|||
426 --delimiter ;
427
428 # Removed the following due to
429 # BUG#32640588: SOURCE FOR SKIP_SLAVE_START DISPLAYED AS COMPILED WHEN IT IS PERSISTED
430 # {
431 # "name": "skip_replica_start",
432 # "alias": "skip_slave_start",
433 # $readonly,
434 # $persist_as_readonly,
435 # "default": 0,
436 # $bool
437 # },
438
439
440 # ==== Create iterator ====
441 #
442 # The JSON document declared above may be processed using the iterator
443 # declared below. See include/create_json_unpacking_iterator.inc for
444 # details.
445
446 --let $json_label = sysvar
447 --let $json_keys = name, alias, default, values, invalid, global, session, cmdline, persist, persist_as_readonly, dynamic, min, max, block_size, value_map, ps_value_map, skip_set_persist_only_default, mask_value
448 #--let $json_output_single_quoted = value_map, ps_value_map
449 --let $json_defaults = { "block_size": 1, "global": 1, "session": 0, "cmdline": 1, "persist": 1, "persist_as_readonly": 0, "dynamic": 1, "value_map": {}, "ps_value_map": {}, "skip_set_persist_only_default": 0, "mask_value": 0 }
450 --let $json_required = name, default, values, invalid
451
452 # Default and values are not included in $json_verbose, since they
453 # contain paths for some variables. Instead we just print them using
454 # an explicit 'echo' command in the loop, and an exception for
455 # variables containing a path.
456 # min, max, and block_size are not included in $json_verbose, since
457 # they differ between platforms or between debug and optimized build
458 # for some variables.
459 if (!$json_verbose) {
460 --let $json_verbose = name, alias, invalid, min, max, block_size, global, session, cmdline, persist, persist_as_readonly, dynamic
461 }
462
463 --source include/create_json_unpacking_iterator.inc
464
465 # Sanity-check the JSON
466 --let $json = $sysvar_specs
467 --source include/json_check.inc