func_compress.test 2.53 KB
Newer Older
1 2 3 4
-- source include/have_compress.inc
#
# Test for compress and uncompress functions:
#
5 6
# Note that this test gives error in the gzip library when running under
# valgrind, but these warnings can be ignored
7 8 9 10 11

select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ';
select length(@test_compress_string);

select uncompress(compress(@test_compress_string));
12
explain extended select uncompress(compress(@test_compress_string));
13
select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
14
explain extended select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
15 16 17
select uncompressed_length(compress(@test_compress_string));
select length(compress(@test_compress_string))<length(@test_compress_string);

18
create table t1 (a text, b char(255), c char(4)) engine=myisam;
19 20 21 22
insert into t1 (a,b,c) values (compress(@test_compress_string),compress(@test_compress_string),'d ');
select uncompress(a) from t1;
select uncompress(b) from t1;
select concat('|',c,'|') from t1;
23 24 25 26 27 28 29
drop table t1;

select compress("");
select uncompress("");
select uncompress(compress(""));
select uncompressed_length("");

30
#
31
# errors
32 33
#

34 35 36 37 38 39
create table t1 (a text);
insert t1 values (compress(null)), ('A\0\0\0BBBBBBBB'), (compress(space(50000))), (space(50000));
select length(a) from t1;
select length(uncompress(a)) from t1;
drop table t1;

40 41 42

#
# Bug #5497: a problem with large strings
43
# note that when LOW_MEMORY is set the "test" below is meaningless
44 45 46
#

set @@max_allowed_packet=1048576*100;
47 48 49
--replace_result "''" XXX "'1'" XXX
eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is null;

50 51 52 53 54 55 56 57 58
#
# Bug #18643: problem with null values
#

create table t1(a blob);
insert into t1 values(NULL), (compress('a'));
select uncompress(a), uncompressed_length(a) from t1;
drop table t1;

59 60 61 62 63 64 65 66 67 68 69 70 71
#
# Bug #23254: problem with compress(NULL)
#

create table t1(a blob);
insert into t1 values ('0'), (NULL), ('0');
--disable_result_log
select compress(a), compress(a) from t1;
--enable_result_log
select compress(a) is null from t1;
drop table t1;

--echo End of 4.1 tests
72 73 74 75 76 77 78 79 80 81 82 83 84 85

#
# 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