Skip to content

Commit 8c26dd6

Browse files
committed
Bug#33516898: BIGINT converted to UNSIGNED_BIGINT with boolean operation
Bug#33117410 changed the resolved type of a boolean expression from signed integer to unsigned bigint, in order to simplify the type handling and facilitate another bugfix. However, what appeared as a harmless metadata change turned out to be a more serious issue for various connectors. This patch will revert the metadata change. It will also fix the actual problem solved by that change in a slightly different manner, by adjusting "max_length" for a negation of an integer to at least two characters. No test case is required, the metadata decision is sufficiently documented in the test cases. Change-Id: Ifb5e98bdef347cbddef0be082e13cd8eecaebb48
1 parent 322f94c commit 8c26dd6

File tree

6 files changed

+49
-48
lines changed

6 files changed

+49
-48
lines changed

mysql-test/r/regular_expressions_utf-8.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ SHOW CREATE TABLE t1;
913913
Table Create Table
914914
t1 CREATE TABLE `t1` (
915915
`a` bigint NOT NULL DEFAULT '0',
916-
`b` int unsigned NOT NULL DEFAULT '0',
916+
`b` int NOT NULL DEFAULT '0',
917917
`c` longtext CHARACTER SET latin1 NOT NULL,
918918
`d` varchar(1) CHARACTER SET latin1 DEFAULT NULL,
919919
`e` varchar(512) CHARACTER SET latin1 DEFAULT NULL,

mysql-test/r/view.result

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,42 +3328,42 @@ ISNULL(d)
33283328
from table_24532;
33293329
describe view_24532_a;
33303330
Field Type Null Key Default Extra
3331-
a IS TRUE int unsigned NO 0
3332-
a IS NOT TRUE int unsigned NO 0
3333-
a IS FALSE int unsigned NO 0
3334-
a IS NOT FALSE int unsigned NO 0
3335-
a IS UNKNOWN int unsigned NO 0
3336-
a IS NOT UNKNOWN int unsigned NO 0
3337-
a is NULL int unsigned NO 0
3338-
a IS NOT NULL int unsigned NO 0
3339-
ISNULL(a) int unsigned NO 0
3340-
b IS TRUE int unsigned NO 0
3341-
b IS NOT TRUE int unsigned NO 0
3342-
b IS FALSE int unsigned NO 0
3343-
b IS NOT FALSE int unsigned NO 0
3344-
b IS UNKNOWN int unsigned NO 0
3345-
b IS NOT UNKNOWN int unsigned NO 0
3346-
b is NULL int unsigned NO 0
3347-
b IS NOT NULL int unsigned NO 0
3348-
ISNULL(b) int unsigned NO 0
3349-
c IS TRUE int unsigned NO 0
3350-
c IS NOT TRUE int unsigned NO 0
3351-
c IS FALSE int unsigned NO 0
3352-
c IS NOT FALSE int unsigned NO 0
3353-
c IS UNKNOWN int unsigned NO 0
3354-
c IS NOT UNKNOWN int unsigned NO 0
3355-
c is NULL int unsigned NO 0
3356-
c IS NOT NULL int unsigned NO 0
3357-
ISNULL(c) int unsigned NO 0
3358-
d IS TRUE int unsigned NO 0
3359-
d IS NOT TRUE int unsigned NO 0
3360-
d IS FALSE int unsigned NO 0
3361-
d IS NOT FALSE int unsigned NO 0
3362-
d IS UNKNOWN int unsigned NO 0
3363-
d IS NOT UNKNOWN int unsigned NO 0
3364-
d is NULL int unsigned NO 0
3365-
d IS NOT NULL int unsigned NO 0
3366-
ISNULL(d) int unsigned NO 0
3331+
a IS TRUE int NO 0
3332+
a IS NOT TRUE int NO 0
3333+
a IS FALSE int NO 0
3334+
a IS NOT FALSE int NO 0
3335+
a IS UNKNOWN int NO 0
3336+
a IS NOT UNKNOWN int NO 0
3337+
a is NULL int NO 0
3338+
a IS NOT NULL int NO 0
3339+
ISNULL(a) int NO 0
3340+
b IS TRUE int NO 0
3341+
b IS NOT TRUE int NO 0
3342+
b IS FALSE int NO 0
3343+
b IS NOT FALSE int NO 0
3344+
b IS UNKNOWN int NO 0
3345+
b IS NOT UNKNOWN int NO 0
3346+
b is NULL int NO 0
3347+
b IS NOT NULL int NO 0
3348+
ISNULL(b) int NO 0
3349+
c IS TRUE int NO 0
3350+
c IS NOT TRUE int NO 0
3351+
c IS FALSE int NO 0
3352+
c IS NOT FALSE int NO 0
3353+
c IS UNKNOWN int NO 0
3354+
c IS NOT UNKNOWN int NO 0
3355+
c is NULL int NO 0
3356+
c IS NOT NULL int NO 0
3357+
ISNULL(c) int NO 0
3358+
d IS TRUE int NO 0
3359+
d IS NOT TRUE int NO 0
3360+
d IS FALSE int NO 0
3361+
d IS NOT FALSE int NO 0
3362+
d IS UNKNOWN int NO 0
3363+
d IS NOT UNKNOWN int NO 0
3364+
d is NULL int NO 0
3365+
d IS NOT NULL int NO 0
3366+
ISNULL(d) int NO 0
33673367
create view view_24532_b as
33683368
select
33693369
a IS TRUE,
@@ -3377,13 +3377,13 @@ if(ifnull(a, 1), 1, 0) as old_isnotfalse
33773377
from table_24532;
33783378
describe view_24532_b;
33793379
Field Type Null Key Default Extra
3380-
a IS TRUE int unsigned NO 0
3380+
a IS TRUE int NO 0
33813381
old_istrue int NO 0
3382-
a IS NOT TRUE int unsigned NO 0
3382+
a IS NOT TRUE int NO 0
33833383
old_isnottrue int NO 0
3384-
a IS FALSE int unsigned NO 0
3384+
a IS FALSE int NO 0
33853385
old_isfalse int NO 0
3386-
a IS NOT FALSE int unsigned NO 0
3386+
a IS NOT FALSE int NO 0
33873387
old_isnotfalse int NO 0
33883388
show create view view_24532_b;
33893389
View Create View character_set_client collation_connection

mysql-test/suite/sysschema/r/v_schema_auto_increment_columns_cs.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ table_name varchar(64) NO NULL
55
column_name varchar(64) YES NULL
66
data_type longtext YES NULL
77
column_type mediumtext NO NULL
8-
is_signed int unsigned NO 0
9-
is_unsigned int unsigned NO 0
8+
is_signed int NO 0
9+
is_unsigned int NO 0
1010
max_value bigint unsigned YES NULL
1111
auto_increment bigint unsigned YES NULL
1212
auto_increment_ratio decimal(25,4) unsigned YES NULL

mysql-test/suite/test_service_sql_api/r/test_sql_complex.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,7 @@ EXECUTING:[9][SELECT @a]
28842884
[meta][field] org col name:
28852885
[meta][field] length: 21
28862886
[meta][field] charsetnr: 33
2887-
[meta][field] flags: 160 (UNSIGNED BINARY )
2887+
[meta][field] flags: 128 (BINARY )
28882888
[meta][field] decimals: 0
28892889
[meta][field] type: LONGLONG (8)
28902890

@@ -2916,7 +2916,7 @@ EXECUTING:[9][SELECT @a]
29162916
[meta][field] org col name:
29172917
[meta][field] length: 21
29182918
[meta][field] charsetnr: 33
2919-
[meta][field] flags: 160 (UNSIGNED BINARY )
2919+
[meta][field] flags: 128 (BINARY )
29202920
[meta][field] decimals: 0
29212921
[meta][field] type: LONGLONG (8)
29222922

@@ -6093,7 +6093,7 @@ EXECUTING:[9][SELECT @a]
60936093
[meta][field] org col name:
60946094
[meta][field] length: 21
60956095
[meta][field] charsetnr: 33
6096-
[meta][field] flags: 160 (UNSIGNED BINARY )
6096+
[meta][field] flags: 128 (BINARY )
60976097
[meta][field] decimals: 0
60986098
[meta][field] type: LONGLONG (8)
60996099

@@ -6125,7 +6125,7 @@ EXECUTING:[9][SELECT @a]
61256125
[meta][field] org col name:
61266126
[meta][field] length: 21
61276127
[meta][field] charsetnr: 33
6128-
[meta][field] flags: 160 (UNSIGNED BINARY )
6128+
[meta][field] flags: 128 (BINARY )
61296129
[meta][field] decimals: 0
61306130
[meta][field] type: LONGLONG (8)
61316131

sql/item.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,6 @@ class Item : public Parse_tree_node {
13341334
set_data_type(MYSQL_TYPE_LONGLONG);
13351335
collation.set_numeric();
13361336
max_length = 1;
1337-
unsigned_flag = true;
13381337
}
13391338

13401339
/**

sql/item_func.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,8 @@ my_decimal *Item_func_neg::decimal_op(my_decimal *decimal_value) {
26582658
void Item_func_neg::fix_num_length_and_dec() {
26592659
decimals = args[0]->decimals;
26602660
max_length = args[0]->max_length + (args[0]->unsigned_flag ? 1 : 0);
2661+
// Booleans have max_length = 1, but need to add the minus sign
2662+
if (max_length == 1) max_length++;
26612663
}
26622664

26632665
bool Item_func_neg::resolve_type(THD *thd) {

0 commit comments

Comments
 (0)