Skip to content

Commit 78cb73e

Browse files
author
Tor Didriksen
committed
Bug#35648987 Item::fixed is a bool, treat it as such in all asserts
Replace assert(fixed == 1) or assert(fixed == 0) or assert(fixed == true) with assert(fixed), assert(!fixed) and assert(fixed) respectively. Change-Id: I28310f8c05cc0dfa2676415150393d37c315b5e5
1 parent 07da2e1 commit 78cb73e

15 files changed

+321
-321
lines changed

sql/item.cc

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ String *Item::val_string_from_decimal(String *str) {
315315
}
316316

317317
String *Item::val_string_from_datetime(String *str) {
318-
assert(fixed == 1);
318+
assert(fixed);
319319
MYSQL_TIME ltime;
320320
if (get_date(&ltime, TIME_FUZZY_DATE) ||
321321
(null_value = str->alloc(MAX_DATE_STRING_REP_LENGTH)))
@@ -325,7 +325,7 @@ String *Item::val_string_from_datetime(String *str) {
325325
}
326326

327327
String *Item::val_string_from_date(String *str) {
328-
assert(fixed == 1);
328+
assert(fixed);
329329
MYSQL_TIME ltime;
330330
if (get_date(&ltime, TIME_FUZZY_DATE) ||
331331
(null_value = str->alloc(MAX_DATE_STRING_REP_LENGTH)))
@@ -335,7 +335,7 @@ String *Item::val_string_from_date(String *str) {
335335
}
336336

337337
String *Item::val_string_from_time(String *str) {
338-
assert(fixed == 1);
338+
assert(fixed);
339339
MYSQL_TIME ltime;
340340
if (get_time(&ltime) || (null_value = str->alloc(MAX_DATE_STRING_REP_LENGTH)))
341341
return error_str();
@@ -378,7 +378,7 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value) {
378378
}
379379

380380
my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) {
381-
assert(fixed == 1);
381+
assert(fixed);
382382
MYSQL_TIME ltime;
383383
if (get_date(&ltime, TIME_FUZZY_DATE)) {
384384
return error_decimal(decimal_value);
@@ -387,7 +387,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) {
387387
}
388388

389389
my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value) {
390-
assert(fixed == 1);
390+
assert(fixed);
391391
MYSQL_TIME ltime;
392392
if (get_time(&ltime)) {
393393
return error_decimal(decimal_value);
@@ -480,7 +480,7 @@ longlong Item::val_int_from_decimal() {
480480
}
481481

482482
longlong Item::val_int_from_time() {
483-
assert(fixed == 1);
483+
assert(fixed);
484484
MYSQL_TIME ltime;
485485
ulonglong value = 0;
486486
if (get_time(&ltime)) return 0LL;
@@ -494,15 +494,15 @@ longlong Item::val_int_from_time() {
494494
}
495495

496496
longlong Item::val_int_from_date() {
497-
assert(fixed == 1);
497+
assert(fixed);
498498
MYSQL_TIME ltime;
499499
return get_date(&ltime, TIME_FUZZY_DATE)
500500
? 0LL
501501
: (longlong)TIME_to_ulonglong_date(ltime);
502502
}
503503

504504
longlong Item::val_int_from_datetime() {
505-
assert(fixed == 1);
505+
assert(fixed);
506506
MYSQL_TIME ltime;
507507
if (get_date(&ltime, TIME_FUZZY_DATE)) return 0LL;
508508

@@ -1704,15 +1704,15 @@ bool Item::get_time_from_int(MYSQL_TIME *ltime) {
17041704
}
17051705

17061706
bool Item::get_time_from_date(MYSQL_TIME *ltime) {
1707-
assert(fixed == 1);
1707+
assert(fixed);
17081708
if (get_date(ltime, TIME_FUZZY_DATE)) // Need this check if NULL value
17091709
return true;
17101710
set_zero_time(ltime, MYSQL_TIMESTAMP_TIME);
17111711
return false;
17121712
}
17131713

17141714
bool Item::get_time_from_datetime(MYSQL_TIME *ltime) {
1715-
assert(fixed == 1);
1715+
assert(fixed);
17161716
if (get_date(ltime, TIME_FUZZY_DATE)) return true;
17171717
datetime_to_time(ltime);
17181718
return false;
@@ -3139,7 +3139,7 @@ TYPELIB *Item_field::get_typelib() const {
31393139
}
31403140

31413141
String *Item_field::val_str(String *str) {
3142-
assert(fixed == 1);
3142+
assert(fixed);
31433143
if ((null_value = field->is_null())) return nullptr;
31443144
str->set_charset(str_value.charset());
31453145
return field->val_str(str, &str_value);
@@ -3154,37 +3154,37 @@ bool Item_field::val_json(Json_wrapper *result) {
31543154
}
31553155

31563156
double Item_field::val_real() {
3157-
assert(fixed == 1);
3157+
assert(fixed);
31583158
if ((null_value = field->is_null())) return 0.0;
31593159
return field->val_real();
31603160
}
31613161

31623162
longlong Item_field::val_int() {
3163-
assert(fixed == 1);
3163+
assert(fixed);
31643164
if ((null_value = field->is_null())) return 0;
31653165
return field->val_int();
31663166
}
31673167

31683168
longlong Item_field::val_time_temporal() {
3169-
assert(fixed == 1);
3169+
assert(fixed);
31703170
if ((null_value = field->is_null())) return 0;
31713171
return field->val_time_temporal();
31723172
}
31733173

31743174
longlong Item_field::val_date_temporal() {
3175-
assert(fixed == 1);
3175+
assert(fixed);
31763176
if ((null_value = field->is_null())) return 0;
31773177
return field->val_date_temporal();
31783178
}
31793179

31803180
longlong Item_field::val_time_temporal_at_utc() {
3181-
assert(fixed == 1);
3181+
assert(fixed);
31823182
if ((null_value = field->is_null())) return 0;
31833183
return field->val_time_temporal_at_utc();
31843184
}
31853185

31863186
longlong Item_field::val_date_temporal_at_utc() {
3187-
assert(fixed == 1);
3187+
assert(fixed);
31883188
if ((null_value = field->is_null())) return 0;
31893189
return field->val_date_temporal_at_utc();
31903190
}
@@ -3381,7 +3381,7 @@ my_decimal *Item_int::val_decimal(my_decimal *decimal_value) {
33813381

33823382
String *Item_int::val_str(String *str) {
33833383
// following assert is redundant, because fixed=1 assigned in constructor
3384-
assert(fixed == 1);
3384+
assert(fixed);
33853385
str->set_int(value, unsigned_flag, collation.collation);
33863386
return str;
33873387
}
@@ -3410,7 +3410,7 @@ void Item_int::print(const THD *, String *str,
34103410

34113411
String *Item_uint::val_str(String *str) {
34123412
// following assert is redundant, because fixed=1 assigned in constructor
3413-
assert(fixed == 1);
3413+
assert(fixed);
34143414
str->set((ulonglong)value, collation.collation);
34153415
return str;
34163416
}
@@ -3537,14 +3537,14 @@ void Item_decimal::set_decimal_value(const my_decimal *value_par) {
35373537

35383538
String *Item_float::val_str(String *str) {
35393539
// following assert is redundant, because fixed=1 assigned in constructor
3540-
assert(fixed == 1);
3540+
assert(fixed);
35413541
str->set_real(value, decimals, &my_charset_bin);
35423542
return str;
35433543
}
35443544

35453545
my_decimal *Item_float::val_decimal(my_decimal *decimal_value) {
35463546
// following assert is redundant, because fixed=1 assigned in constructor
3547-
assert(fixed == 1);
3547+
assert(fixed);
35483548
double2my_decimal(E_DEC_FATAL_ERROR, value, decimal_value);
35493549
return (decimal_value);
35503550
}
@@ -3645,7 +3645,7 @@ double double_from_string_with_check(const CHARSET_INFO *cs, const char *cptr,
36453645
}
36463646

36473647
double Item_string::val_real() {
3648-
assert(fixed == 1);
3648+
assert(fixed);
36493649
return double_from_string_with_check(str_value.charset(), str_value.ptr(),
36503650
str_value.ptr() + str_value.length());
36513651
}
@@ -3710,20 +3710,20 @@ bool Item_null::eq(const Item *item, bool) const {
37103710

37113711
double Item_null::val_real() {
37123712
// following assert is redundant, because fixed=1 assigned in constructor
3713-
assert(fixed == 1);
3713+
assert(fixed);
37143714
null_value = true;
37153715
return 0.0;
37163716
}
37173717
longlong Item_null::val_int() {
37183718
// following assert is redundant, because fixed=1 assigned in constructor
3719-
assert(fixed == 1);
3719+
assert(fixed);
37203720
null_value = true;
37213721
return 0;
37223722
}
37233723

37243724
String *Item_null::val_str(String *) {
37253725
// following assert is redundant, because fixed=1 assigned in constructor
3726-
assert(fixed == 1);
3726+
assert(fixed);
37273727
null_value = true;
37283728
return nullptr;
37293729
}
@@ -5021,7 +5021,7 @@ bool Item::fix_fields(THD *, Item **) {
50215021
assert(is_contextualized());
50225022

50235023
// We do not check fields which are fixed during construction
5024-
assert(fixed == 0 || basic_const_item());
5024+
assert(!fixed || basic_const_item());
50255025
fixed = true;
50265026
return false;
50275027
}
@@ -7218,7 +7218,7 @@ void Item_hex_string::hex_string_init(const char *str, uint str_length) {
72187218

72197219
longlong Item_hex_string::val_int() {
72207220
// following assert is redundant, because fixed=1 assigned in constructor
7221-
assert(fixed == 1);
7221+
assert(fixed);
72227222
const char *end = str_value.ptr() + str_value.length();
72237223
const char *ptr;
72247224

@@ -7257,7 +7257,7 @@ longlong Item_hex_string::val_int() {
72577257

72587258
my_decimal *Item_hex_string::val_decimal(my_decimal *decimal_value) {
72597259
// following assert is redundant, because fixed=1 assigned in constructor
7260-
assert(fixed == 1);
7260+
assert(fixed);
72617261
const ulonglong value = (ulonglong)val_int();
72627262
int2my_decimal(E_DEC_FATAL_ERROR, value, true, decimal_value);
72637263
return (decimal_value);
@@ -9316,7 +9316,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **) {
93169316
parsing! So we have little to do in fix_fields. :)
93179317
*/
93189318

9319-
assert(fixed == 0);
9319+
assert(!fixed);
93209320

93219321
/* Set field. */
93229322

@@ -9736,28 +9736,28 @@ void Item_cache_int::store_value(Item *item, longlong val_arg) {
97369736
}
97379737

97389738
String *Item_cache_int::val_str(String *str) {
9739-
assert(fixed == 1);
9739+
assert(fixed);
97409740
if (!has_value()) return nullptr;
97419741
str->set_int(value, unsigned_flag, default_charset());
97429742
return str;
97439743
}
97449744

97459745
my_decimal *Item_cache_int::val_decimal(my_decimal *decimal_val) {
9746-
assert(fixed == 1);
9746+
assert(fixed);
97479747
if (!has_value()) return nullptr;
97489748
int2my_decimal(E_DEC_FATAL_ERROR, value, unsigned_flag, decimal_val);
97499749
return decimal_val;
97509750
}
97519751

97529752
double Item_cache_int::val_real() {
9753-
assert(fixed == 1);
9753+
assert(fixed);
97549754
if (!has_value()) return 0.0;
97559755
if (unsigned_flag) return static_cast<unsigned long long>(value);
97569756
return value;
97579757
}
97589758

97599759
longlong Item_cache_int::val_int() {
9760-
assert(fixed == 1);
9760+
assert(fixed);
97619761
if (!has_value()) return 0;
97629762
return value;
97639763
}
@@ -9823,7 +9823,7 @@ void Item_cache_datetime::store(Item *item) {
98239823
}
98249824

98259825
String *Item_cache_datetime::val_str(String *) {
9826-
assert(fixed == 1);
9826+
assert(fixed);
98279827

98289828
if ((value_cached || str_value_cached) && null_value) return nullptr;
98299829

@@ -9851,7 +9851,7 @@ String *Item_cache_datetime::val_str(String *) {
98519851
}
98529852

98539853
my_decimal *Item_cache_datetime::val_decimal(my_decimal *decimal_val) {
9854-
assert(fixed == 1);
9854+
assert(fixed);
98559855

98569856
if (str_value_cached) {
98579857
switch (data_type()) {
@@ -9934,7 +9934,7 @@ bool Item_cache_datetime::get_time(MYSQL_TIME *ltime) {
99349934
double Item_cache_datetime::val_real() { return val_real_from_decimal(); }
99359935

99369936
longlong Item_cache_datetime::val_time_temporal() {
9937-
assert(fixed == 1);
9937+
assert(fixed);
99389938
if ((!value_cached && !cache_value_int()) || null_value) return 0;
99399939
if (is_temporal_with_date()) {
99409940
/* Convert packed date to packed time */
@@ -9947,7 +9947,7 @@ longlong Item_cache_datetime::val_time_temporal() {
99479947
}
99489948

99499949
longlong Item_cache_datetime::val_date_temporal() {
9950-
assert(fixed == 1);
9950+
assert(fixed);
99519951
if ((!value_cached && !cache_value_int()) || null_value) return 0;
99529952
if (data_type() == MYSQL_TYPE_TIME) {
99539953
/* Convert packed time to packed date */
@@ -10096,26 +10096,26 @@ void Item_cache_real::store_value(Item *expr, double d) {
1009610096
}
1009710097

1009810098
double Item_cache_real::val_real() {
10099-
assert(fixed == 1);
10099+
assert(fixed);
1010010100
if (!has_value()) return 0.0;
1010110101
return value;
1010210102
}
1010310103

1010410104
longlong Item_cache_real::val_int() {
10105-
assert(fixed == 1);
10105+
assert(fixed);
1010610106
if (!has_value()) return 0;
1010710107
return (longlong)rint(value);
1010810108
}
1010910109

1011010110
String *Item_cache_real::val_str(String *str) {
10111-
assert(fixed == 1);
10111+
assert(fixed);
1011210112
if (!has_value()) return nullptr;
1011310113
str->set_real(value, decimals, default_charset());
1011410114
return str;
1011510115
}
1011610116

1011710117
my_decimal *Item_cache_real::val_decimal(my_decimal *decimal_val) {
10118-
assert(fixed == 1);
10118+
assert(fixed);
1011910119
if (!has_value()) return nullptr;
1012010120
double2my_decimal(E_DEC_FATAL_ERROR, value, decimal_val);
1012110121
return decimal_val;
@@ -10201,7 +10201,7 @@ void Item_cache_str::store_value(Item *expr, String &s) {
1020110201
}
1020210202

1020310203
double Item_cache_str::val_real() {
10204-
assert(fixed == 1);
10204+
assert(fixed);
1020510205
int err_not_used;
1020610206
const char *end_not_used;
1020710207
if (!has_value()) return 0.0;
@@ -10212,7 +10212,7 @@ double Item_cache_str::val_real() {
1021210212
}
1021310213

1021410214
longlong Item_cache_str::val_int() {
10215-
assert(fixed == 1);
10215+
assert(fixed);
1021610216
int err;
1021710217
if (!has_value()) return 0;
1021810218
if (value)
@@ -10223,13 +10223,13 @@ longlong Item_cache_str::val_int() {
1022310223
}
1022410224

1022510225
String *Item_cache_str::val_str(String *) {
10226-
assert(fixed == 1);
10226+
assert(fixed);
1022710227
if (!has_value()) return nullptr;
1022810228
return value;
1022910229
}
1023010230

1023110231
my_decimal *Item_cache_str::val_decimal(my_decimal *decimal_val) {
10232-
assert(fixed == 1);
10232+
assert(fixed);
1023310233
if (!has_value()) return nullptr;
1023410234
if (value)
1023510235
str2my_decimal(E_DEC_FATAL_ERROR, value->ptr(), value->length(),

sql/item.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5371,7 +5371,7 @@ class Item_float : public Item_num {
53715371
return value;
53725372
}
53735373
longlong val_int() override {
5374-
assert(fixed == 1);
5374+
assert(fixed);
53755375
if (value <= LLONG_MIN) {
53765376
return LLONG_MIN;
53775377
} else if (value > LLONG_MAX_DOUBLE) {
@@ -5538,7 +5538,7 @@ class Item_string : public Item_basic_constant {
55385538
double val_real() override;
55395539
longlong val_int() override;
55405540
String *val_str(String *) override {
5541-
assert(fixed == 1);
5541+
assert(fixed);
55425542
return &str_value;
55435543
}
55445544
my_decimal *val_decimal(my_decimal *) override;

0 commit comments

Comments
 (0)