Skip to content

Commit 9c18b57

Browse files
author
jimw@rama.(none)
committed
Bug #18539: uncompress(d) is null: impossible?
The UNCOMPRESS() function was not marked as maybe_null, even though it returns NULL on invalid data. This confused the optimizer.
1 parent 72fa488 commit 9c18b57

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

mysql-test/r/func_compress.result

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,31 @@ uncompress(a) uncompressed_length(a)
7979
NULL NULL
8080
a 1
8181
drop table t1;
82+
create table t1 (a varchar(32) not null);
83+
insert into t1 values ('foo');
84+
explain select * from t1 where uncompress(a) is null;
85+
id select_type table type possible_keys key key_len ref rows Extra
86+
1 SIMPLE t1 system NULL NULL NULL NULL 1
87+
Warnings:
88+
Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted)
89+
select * from t1 where uncompress(a) is null;
90+
a
91+
foo
92+
Warnings:
93+
Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted)
94+
explain select *, uncompress(a) from t1;
95+
id select_type table type possible_keys key key_len ref rows Extra
96+
1 SIMPLE t1 system NULL NULL NULL NULL 1
97+
select *, uncompress(a) from t1;
98+
a uncompress(a)
99+
foo NULL
100+
Warnings:
101+
Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted)
102+
select *, uncompress(a), uncompress(a) is null from t1;
103+
a uncompress(a) uncompress(a) is null
104+
foo NULL 1
105+
Warnings:
106+
Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted)
107+
Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted)
108+
drop table t1;
109+
End of 5.0 tests

mysql-test/t/func_compress.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,17 @@ select uncompress(a), uncompressed_length(a) from t1;
5757
drop table t1;
5858

5959
# End of 4.1 tests
60+
61+
#
62+
# Bug #18539: uncompress(d) is null: impossible?
63+
#
64+
create table t1 (a varchar(32) not null);
65+
insert into t1 values ('foo');
66+
explain select * from t1 where uncompress(a) is null;
67+
select * from t1 where uncompress(a) is null;
68+
explain select *, uncompress(a) from t1;
69+
select *, uncompress(a) from t1;
70+
select *, uncompress(a), uncompress(a) is null from t1;
71+
drop table t1;
72+
73+
--echo End of 5.0 tests

sql/item_strfunc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ class Item_func_uncompress: public Item_str_func
784784
String buffer;
785785
public:
786786
Item_func_uncompress(Item *a): Item_str_func(a){}
787-
void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;}
787+
void fix_length_and_dec(){ maybe_null= 1; max_length= MAX_BLOB_WIDTH; }
788788
const char *func_name() const{return "uncompress";}
789789
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
790790
};

0 commit comments

Comments
 (0)