diff options
author | unknown <jimw@rama.(none)> | 2006-07-10 19:50:40 -0700 |
---|---|---|
committer | unknown <jimw@rama.(none)> | 2006-07-10 19:50:40 -0700 |
commit | 8dc1fa1cf1aa8f04d2b52db26512f142bb1156ad (patch) | |
tree | 071591d27875662133e93f5967d673f319ab92fe | |
parent | 66fc547d1bd6f267e47ac170f3038f5dd6559691 (diff) | |
download | mariadb-git-8dc1fa1cf1aa8f04d2b52db26512f142bb1156ad.tar.gz |
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.
mysql-test/r/func_compress.result:
Add new results
mysql-test/t/func_compress.test:
Add new regression test
sql/item_strfunc.h:
Set maybe_null within Item_func_uncompress::fix_length_and_dec()
-rw-r--r-- | mysql-test/r/func_compress.result | 28 | ||||
-rw-r--r-- | mysql-test/t/func_compress.test | 14 | ||||
-rw-r--r-- | sql/item_strfunc.h | 2 |
3 files changed, 43 insertions, 1 deletions
diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index e3d31566741..df8939d98f1 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -79,3 +79,31 @@ uncompress(a) uncompressed_length(a) NULL NULL a 1 drop table t1; +create table t1 (a varchar(32) not null); +insert into t1 values ('foo'); +explain select * from t1 where uncompress(a) is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +select * from t1 where uncompress(a) is null; +a +foo +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +explain select *, uncompress(a) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 +select *, uncompress(a) from t1; +a uncompress(a) +foo NULL +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +select *, uncompress(a), uncompress(a) is null from t1; +a uncompress(a) uncompress(a) is null +foo NULL 1 +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test index 4ae749f2343..eeb5d509b94 100644 --- a/mysql-test/t/func_compress.test +++ b/mysql-test/t/func_compress.test @@ -57,3 +57,17 @@ select uncompress(a), uncompressed_length(a) from t1; drop table t1; # End of 4.1 tests + +# +# Bug #18539: uncompress(d) is null: impossible? +# +create table t1 (a varchar(32) not null); +insert into t1 values ('foo'); +explain select * from t1 where uncompress(a) is null; +select * from t1 where uncompress(a) is null; +explain select *, uncompress(a) from t1; +select *, uncompress(a) from t1; +select *, uncompress(a), uncompress(a) is null from t1; +drop table t1; + +--echo End of 5.0 tests diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index af59b8d740b..d685bd63467 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -784,7 +784,7 @@ class Item_func_uncompress: public Item_str_func String buffer; public: Item_func_uncompress(Item *a): Item_str_func(a){} - void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;} + void fix_length_and_dec(){ maybe_null= 1; max_length= MAX_BLOB_WIDTH; } const char *func_name() const{return "uncompress";} String *val_str(String *) ZLIB_DEPENDED_FUNCTION }; |