Skip to content

Commit d324c03

Browse files
midenokvuvova
authored andcommitted
Vanilla cleanups and refactorings
Dead code cleanup: part_info->num_parts usage was wrong and working incorrectly in mysql_drop_partitions() because num_parts is already updated in prep_alter_part_table(). We don't have to update part_info->partitions because part_info is destroyed at alter_partition_lock_handling(). Cleanups: - DBUG_EVALUATE_IF() macro replaced by shorter form DBUG_IF(); - Typo in ER_KEY_COLUMN_DOES_NOT_EXITS. Refactorings: - Splitted write_log_replace_delete_frm() into write_log_delete_frm() and write_log_replace_frm(); - partition_info via DDL_LOG_STATE; - set_part_info_exec_log_entry() removed. DBUG_EVALUATE removed DBUG_EVALUTATE was only added for consistency together with DBUG_EVALUATE_IF. It is not used anywhere in the code. DBUG_SUICIDE() fix on release build On release DBUG_SUICIDE() was statement. It was wrong as DBUG_SUICIDE() is used in expression context.
1 parent 2dc3c32 commit d324c03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+686
-836
lines changed

dbug/tests-t.pl

-41
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,17 @@
4444
% ./tests -#d
4545
func2: info: s=ok
4646
=> execute
47-
=> evaluate: ON
4847
=> evaluate_if: OFF
4948
main: explain: dbug explained: d
5049
func2: info: s=ok
5150
% ./tests d,ret3
52-
=> evaluate: OFF
5351
=> evaluate_if: OFF
5452
#
5553
## Testing negative lists
5654
#
5755
% ./tests d:-d,ret3
5856
func2: info: s=ko
5957
=> execute
60-
=> evaluate: ON
6158
=> evaluate_if: OFF
6259
main: explain: dbug explained: d:-d,ret3
6360
func2: info: s=ko
@@ -69,7 +66,6 @@
6966
| | | <func3
7067
| | <func2
7168
| <func1
72-
=> evaluate: OFF
7369
=> evaluate_if: OFF
7470
| >func2
7571
| | >func3
@@ -85,7 +81,6 @@
8581
| | | info: s=ko
8682
| | <func2
8783
| <func1
88-
=> evaluate: OFF
8984
=> evaluate_if: OFF
9085
| >func2
9186
| | >func3
@@ -99,19 +94,15 @@
9994
| | | >func3
10095
| | | <func3
10196
| <func1
102-
=> evaluate: OFF
10397
=> evaluate_if: OFF
10498
| | >func3
10599
| | <func3
106100
<main
107101
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate
108-
=> evaluate: ON
109102
=> evaluate_if: OFF
110103
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate_if
111-
=> evaluate: OFF
112104
=> evaluate_if: ON
113105
% ./tests t:d:-d,ret3:-f,func2 d,evaluate_if
114-
=> evaluate: OFF
115106
=> evaluate_if: ON
116107
% ./tests t:d:-d,ret3:-f,func2
117108
>main
@@ -120,7 +111,6 @@
120111
| | | <func3
121112
| <func1
122113
=> execute
123-
=> evaluate: ON
124114
=> evaluate_if: OFF
125115
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
126116
| | >func3
@@ -135,7 +125,6 @@
135125
| | | >func3
136126
| | | <func3
137127
| <func1
138-
=> evaluate: OFF
139128
=> evaluate_if: ON
140129
| | >func3
141130
| | <func3
@@ -152,7 +141,6 @@
152141
| dump: Memory: 0x#### Bytes: (27)
153142
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
154143
74
155-
=> evaluate: OFF
156144
=> evaluate_if: OFF
157145
| | >func3
158146
| | <func3
@@ -166,7 +154,6 @@
166154
| dump: Memory: 0x#### Bytes: (27)
167155
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
168156
74
169-
=> evaluate: OFF
170157
=> evaluate_if: OFF
171158
| | >func3
172159
| | <func3
@@ -180,7 +167,6 @@
180167
| dump: Memory: 0x#### Bytes: (27)
181168
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
182169
74
183-
=> evaluate: OFF
184170
=> evaluate_if: OFF
185171
| | >func3
186172
| | <func3
@@ -194,7 +180,6 @@
194180
| dump: Memory: 0x#### Bytes: (35)
195181
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
196182
66 2C 66 75 6E 63 32 3A 74
197-
=> evaluate: OFF
198183
=> evaluate_if: OFF
199184
| explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:t
200185
| | >func3
@@ -209,7 +194,6 @@
209194
dbug-tests: | dump: Memory: 0x#### Bytes: (37)
210195
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
211196
66 2C 66 75 6E 63 32 3A 50 3A 74
212-
=> evaluate: OFF
213197
=> evaluate_if: OFF
214198
dbug-tests: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:P:t
215199
dbug-tests: | | >func3
@@ -224,7 +208,6 @@
224208
dbug-tests: tests.c: | dump: Memory: 0x#### Bytes: (39)
225209
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
226210
66 2C 66 75 6E 63 32 3A 46 3A 50 3A 74
227-
=> evaluate: OFF
228211
=> evaluate_if: OFF
229212
dbug-tests: tests.c: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:F:P:t
230213
dbug-tests: tests.c: | | >func3
@@ -240,7 +223,6 @@
240223
| | | <func3
241224
| <func1
242225
=> execute
243-
=> evaluate: ON
244226
=> evaluate_if: OFF
245227
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
246228
| | >func3
@@ -256,7 +238,6 @@
256238
| | <func2
257239
| <func1
258240
=> execute
259-
=> evaluate: ON
260241
=> evaluate_if: OFF
261242
| explain: dbug explained: d:-d,ret3:t
262243
| >func2
@@ -267,7 +248,6 @@
267248
<main
268249
% ./tests d,info:-d,ret3:d,push
269250
func2: info: s=ko
270-
=> evaluate: OFF
271251
=> evaluate_if: OFF
272252
| >func2
273253
| | >func3
@@ -277,7 +257,6 @@
277257
<main
278258
% ./tests d,info:-d,ret3:d,push,explain
279259
func2: info: s=ko
280-
=> evaluate: OFF
281260
=> evaluate_if: OFF
282261
| explain: dbug explained: d,info,push,explain:-d,ret3:t
283262
| >func2
@@ -288,13 +267,11 @@
288267
<main
289268
% ./tests d,info:-d,ret3:d,explain
290269
func2: info: s=ko
291-
=> evaluate: OFF
292270
=> evaluate_if: OFF
293271
main: explain: dbug explained: d,info,explain:-d,ret3
294272
func2: info: s=ko
295273
% ./tests d,info:-d,ret3:d,explain,pop
296274
func2: info: s=ko
297-
=> evaluate: OFF
298275
=> evaluate_if: OFF
299276
% ./tests d,info:-d,ret3:d,explain t:d,pop
300277
>main
@@ -304,7 +281,6 @@
304281
| | | <func3
305282
| | <func2
306283
| <func1
307-
=> evaluate: OFF
308284
=> evaluate_if: OFF
309285
main: explain: dbug explained: d,info,explain:-d,ret3
310286
func2: info: s=ko
@@ -317,13 +293,11 @@
317293
| | | info: s=ko
318294
| | <func2
319295
| <func1
320-
=> evaluate: OFF
321296
=> evaluate_if: OFF
322297
main: explain: dbug explained: d,info,explain,pop:-d,ret3
323298
func2: info: s=ko
324299
% ./tests d,info:-d,ret3:d,explain,set
325300
func2: info: s=ko
326-
=> evaluate: OFF
327301
=> evaluate_if: OFF
328302
tests.c: main: explain: dbug explained: d,info,explain,set:-d,ret3:F
329303
tests.c: func2: info: s=ko
@@ -336,7 +310,6 @@
336310
| | | info: s=ko
337311
| | <func2
338312
| <func1
339-
=> evaluate: OFF
340313
=> evaluate_if: OFF
341314
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
342315
tests.c: | >func2
@@ -354,7 +327,6 @@
354327
| | | info: s=ko
355328
| | <func2
356329
| <func1
357-
=> evaluate: OFF
358330
=> evaluate_if: OFF
359331
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
360332
tests.c: | >func2
@@ -365,7 +337,6 @@
365337
tests.c: <main
366338
% ./tests t d,info:-d,ret3:d,explain,set,pop
367339
func2: info: s=ko
368-
=> evaluate: OFF
369340
=> evaluate_if: OFF
370341
| >func2
371342
| | >func3
@@ -375,7 +346,6 @@
375346
% ./tests t:f,func2
376347
| | >func2
377348
| | <func2
378-
=> evaluate: OFF
379349
=> evaluate_if: OFF
380350
| >func2
381351
| <func2
@@ -387,7 +357,6 @@
387357
| >func1
388358
| <func1
389359
=> execute
390-
=> evaluate: ON
391360
=> evaluate_if: OFF
392361
| explain: dbug explained: d:f:-f,func2/:t
393362
<main
@@ -399,7 +368,6 @@
399368
| | | info: s=ok
400369
| | <func2
401370
| <func1
402-
=> evaluate: OFF
403371
=> evaluate_if: OFF
404372
% ./tests t:f,main/:d,pop
405373
>main
@@ -409,10 +377,8 @@
409377
| | | <func3
410378
| | <func2
411379
| <func1
412-
=> evaluate: OFF
413380
=> evaluate_if: OFF
414381
% ./tests f,main/:d,push
415-
=> evaluate: OFF
416382
=> evaluate_if: OFF
417383
| >func2
418384
| | >func3
@@ -431,7 +397,6 @@
431397
| | | <func3
432398
| | <func2
433399
=> push1
434-
=> evaluate: OFF
435400
=> evaluate_if: OFF
436401
| | >func3
437402
| | <func3
@@ -440,7 +405,6 @@
440405
>main
441406
=> push1
442407
| <func1
443-
=> evaluate: OFF
444408
=> evaluate_if: OFF
445409
| >func2
446410
| | >func3
@@ -453,7 +417,6 @@
453417
| | | <func3
454418
=> push1
455419
| <func1
456-
=> evaluate: OFF
457420
=> evaluate_if: OFF
458421
| >func2
459422
| | >func3
@@ -469,15 +432,13 @@
469432
| | | <func3
470433
| | <func2
471434
=> push1
472-
=> evaluate: OFF
473435
=> evaluate_if: OFF
474436
# change the defaults
475437
% ./tests t:f,func3 --push1=t
476438
| | | >func3
477439
| | | <func3
478440
=> push1
479441
| <func1
480-
=> evaluate: OFF
481442
=> evaluate_if: OFF
482443
| >func2
483444
| | >func3
@@ -487,11 +448,9 @@
487448
# repeated keyword
488449
% ./tests d:-d,info,info
489450
=> execute
490-
=> evaluate: ON
491451
=> evaluate_if: OFF
492452
main: explain: dbug explained: d:-d,info
493453
% ./tests d:-d,info/,info
494454
=> execute
495-
=> evaluate: ON
496455
=> evaluate_if: OFF
497456
main: explain: dbug explained: d:-d,info/

dbug/tests.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ char *push1=0;
1616
const char *func3()
1717
{
1818
DBUG_ENTER("func3");
19-
DBUG_RETURN(DBUG_EVALUATE("ret3", "ok", "ko"));
19+
DBUG_EXECUTE("ret3", DBUG_RETURN("ok"););
20+
DBUG_RETURN("ko");
2021
}
2122

2223
void func2()
@@ -72,10 +73,8 @@ int main (int argc __attribute__((unused)),
7273
DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); );
7374
DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
7475
DBUG_EXECUTE_IF("set", DBUG_SET("+F"); );
75-
fprintf(DBUG_FILE, "=> evaluate: %s\n",
76-
DBUG_EVALUATE("evaluate", "ON", "OFF"));
7776
fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
78-
DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
77+
(DBUG_IF("evaluate_if") ? "ON": "OFF"));
7978
DBUG_EXECUTE_IF("pop", DBUG_POP(); );
8079
{
8180
char s[1000] __attribute__((unused));

dbug/user.r

+8-20
Original file line numberDiff line numberDiff line change
@@ -771,32 +771,20 @@ artificial delay checking for race conditions.
771771
.SP 1
772772
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ DBUG_ABORT()\ ());\fR
773773
.SP 1
774-
.LI DBUG_EVALUATE\
775-
The DBUG_EVALUATE macro is similar to DBUG_EXECUTE, but it can be used in
776-
the expression context. The first argument is the debug keyword that is used to
777-
choose whether the second (keyword is enabled) or the third (keyword is not
778-
enabled) argument is evaluated. When
779-
.I dbug
780-
is compiled off, the third argument is evaluated.
781-
.SP 1
782-
EX:\fC
783-
.br
784-
printf("Info-debug is %s",
785-
.br
786-
DBUG_EVALUATE\ ("info", "ON", "OFF"));\fR
787-
.SP 1
788-
.LI DBUG_EVALUATE_IF\
789-
Works like DBUG_EVALUATE macro, but the second argument is
790-
.B not
791-
evaluated, if the keyword is not explicitly listed in
792-
the 'd' flag. Like DBUG_EXECUTE_IF this could be used to conditionally execute
774+
.LI DBUG_IF\
775+
Returns
776+
.B 1
777+
if the keyword is explicitly listed in
778+
the 'd' flag. Otherwise returns
779+
.B 0
780+
Like DBUG_EXECUTE_IF this could be used to conditionally execute
793781
"dangerous" actions.
794782
.SP 1
795783
EX:\fC
796784
.br
797785
if (prepare_transaction () ||
798786
.br
799-
DBUG_EVALUATE ("crashme", (DBUG_ABORT(), 0), 0) ||
787+
(DBUG_IF("crashme") && (DBUG_ABORT(), 0)) ||
800788
.br
801789
commit_transaction () )\fR
802790
.SP 1

include/my_dbug.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ extern int (*dbug_sanity)(void);
100100
do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
101101
#define DBUG_EXECUTE_IF(keyword,a1) \
102102
do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
103-
#define DBUG_EVALUATE(keyword,a1,a2) \
104-
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
105-
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
106-
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
103+
#define DBUG_IF(keyword) _db_keyword_(0, (keyword), 1)
107104
#define DBUG_PRINT(keyword,arglist) \
108105
do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)
109106

@@ -172,8 +169,7 @@ extern void _db_suicide_(void);
172169
#define DBUG_VOID_RETURN do { return; } while(0)
173170
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
174171
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
175-
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
176-
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
172+
#define DBUG_IF(keyword) 0
177173
#define DBUG_PRINT(keyword,arglist) do { } while(0)
178174
#define DBUG_PUSH_EMPTY do { } while(0)
179175
#define DBUG_POP_EMPTY do { } while(0)
@@ -199,7 +195,7 @@ extern void _db_suicide_(void);
199195
#define DBUG_CRASH_ENTER(func)
200196
#define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
201197
#define DBUG_CRASH_VOID_RETURN do { return; } while(0)
202-
#define DBUG_SUICIDE() do { } while(0)
198+
#define DBUG_SUICIDE() ((void) 0)
203199

204200
#ifdef DBUG_ASSERT_AS_PRINTF
205201
extern void (*my_dbug_assert_failed)(const char *assert_expr, const char* file, unsigned long line);

0 commit comments

Comments
 (0)