mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
36b6bf2ef3
into mysql.com:/home/my/mysql-5.0 BitKeeper/etc/ignore: auto-union BitKeeper/deleted/.del-ctype_cp932.test: Auto merged BitKeeper/deleted/.del-isam.test~834fb0ee8196c445: Auto merged include/thr_lock.h: Auto merged mysql-test/t/alias.test: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/archive.test: Auto merged mysql-test/t/backup.test: Auto merged mysql-test/t/bool.test: Auto merged mysql-test/t/connect.test: Auto merged mysql-test/t/count_distinct2.test: Auto merged mysql-test/t/create.test: Auto merged mysql-test/t/ctype_many.test: Auto merged mysql-test/t/ctype_ucs_binlog.test: Auto merged mysql-test/t/date_formats.test: Auto merged mysql-test/t/delayed.test: Auto merged mysql-test/t/derived.test: Auto merged mysql-test/t/distinct.test: Auto merged mysql-test/t/drop.test: Auto merged mysql-test/t/endspace.test: Auto merged mysql-test/t/flush.test: Auto merged mysql-test/t/fulltext.test: Auto merged mysql-test/t/fulltext_order_by.test: Auto merged mysql-test/t/func_compress.test: Auto merged mysql-test/t/func_concat.test: Auto merged mysql-test/t/func_date_add.test: Auto merged mysql-test/t/func_equal.test: Auto merged mysql-test/t/func_if.test: Auto merged mysql-test/t/func_sapdb.test: Auto merged mysql-test/t/func_set.test: Auto merged mysql-test/t/func_str.test: Auto merged mysql-test/t/gis-rtree.test: Auto merged mysql-test/t/gis.test: Auto merged mysql-test/t/grant.test: Auto merged mysql-test/t/grant2.test: Auto merged mysql-test/t/grant_cache.test: Auto merged mysql-test/t/heap.test: Auto merged mysql-test/t/heap_btree.test: Auto merged mysql-test/t/heap_hash.test: Auto merged mysql-test/t/init_connect.test: Auto merged mysql-test/t/insert_select.test: Auto merged mysql-test/t/insert_update.test: Auto merged mysql-test/t/key.test: Auto merged mysql-test/t/keywords.test: Auto merged mysql-test/t/limit.test: Auto merged mysql-test/t/lock.test: Auto merged mysql-test/t/lowercase_table.test: Auto merged mysql-test/t/lowercase_table3.test: Auto merged mysql-test/t/merge.test: Auto merged mysql-test/t/mix_innodb_myisam_binlog.test: Auto merged mysql-test/t/myisam.test: Auto merged mysql-test/t/mysqlbinlog2.test: Auto merged mysql-test/t/ndb_alter_table.test: Auto merged mysql-test/t/ndb_autodiscover.test: Auto merged mysql-test/t/ndb_charset.test: Auto merged mysql-test/t/ndb_grant.later: Auto merged mysql-test/t/ndb_index_ordered.test: Auto merged mysql-test/t/ndb_index_unique.test: Auto merged mysql-test/t/ndb_restore.test: Auto merged mysql-test/t/ndb_types.test: Auto merged mysql-test/t/ndb_update.test: Auto merged mysql-test/t/null.test: Auto merged mysql-test/t/null_key.test: Auto merged mysql-test/t/olap.test: Auto merged mysql-test/t/openssl_1.test: Auto merged mysql-test/t/order_by.test: Auto merged mysql-test/t/ps.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/ps_4heap.test: Auto merged mysql-test/t/ps_5merge.test: Auto merged mysql-test/t/query_cache.test: Auto merged mysql-test/t/replace.test: Auto merged mysql-test/t/row.test: Auto merged mysql-test/t/rpl000001.test: Auto merged mysql-test/t/rpl000015.test: Auto merged mysql-test/t/rpl000017.test: Auto merged mysql-test/t/rpl000018.test: Auto merged mysql-test/t/rpl_EE_error.test: Auto merged mysql-test/t/rpl_change_master.test: Auto merged mysql-test/t/rpl_charset.test: Auto merged mysql-test/t/rpl_create_database.test: Auto merged mysql-test/t/rpl_ddl.test: Auto merged mysql-test/t/rpl_deadlock.test: Auto merged mysql-test/t/rpl_empty_master_crash.test: Auto merged mysql-test/t/rpl_error_ignored_table.test: Auto merged mysql-test/t/rpl_flush_log_loop.test: Auto merged mysql-test/t/rpl_flush_tables.test: Auto merged mysql-test/t/rpl_get_lock.test: Auto merged mysql-test/t/rpl_heap.test: Auto merged mysql-test/t/rpl_loaddata.test: Auto merged mysql-test/t/rpl_loaddata_rule_m.test: Auto merged mysql-test/t/rpl_log.test: Auto merged mysql-test/t/rpl_log_pos.test: Auto merged mysql-test/t/rpl_max_relay_size.test: Auto merged mysql-test/t/rpl_multi_query.test: Auto merged mysql-test/t/rpl_openssl.test: Auto merged mysql-test/t/rpl_redirect.test: Auto merged mysql-test/t/rpl_relayrotate.test: Auto merged mysql-test/t/rpl_replicate_do.test: Auto merged mysql-test/t/rpl_reset_slave.test: Auto merged mysql-test/t/rpl_server_id2.test: Auto merged mysql-test/t/rpl_temporary.test: Auto merged mysql-test/t/rpl_timezone.test: Auto merged mysql-test/t/rpl_user_variables.test: Auto merged mysql-test/t/show_check.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/symlink.test: Auto merged mysql-test/t/synchronization.test: Auto merged mysql-test/t/system_mysql_db.test: Auto merged mysql-test/t/system_mysql_db_fix.test: Auto merged mysql-test/t/temp_table.test: Auto merged mysql-test/t/timezone2.test: Auto merged mysql-test/t/timezone_grant.test: Auto merged mysql-test/t/type_float.test: Auto merged mysql-test/t/type_ranges.test: Auto merged mysql-test/t/type_timestamp.test: Auto merged mysql-test/t/union.test: Auto merged mysql-test/t/update.test: Auto merged mysql-test/t/user_var-binlog.test: Auto merged mysql-test/t/warnings.test: Auto merged mysys/thr_lock.c: Auto merged sql/slave.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_select.cc: Auto merged support-files/mysql.spec.sh: Auto merged BitKeeper/deleted/.del-rpl_trunc_binlog.test~961b1f6ac73d37c8: Simple merge mysql-test/r/ps_grant.result: Simple merge mysql-test/t/analyse.test: Simple merge mysql-test/t/auto_increment.test: Simple merge mysql-test/t/bdb.test: Simple merge mysql-test/t/bigint.test: Simple merge mysql-test/t/case.test: Simple merge mysql-test/t/cast.test: Simple merge mysql-test/t/check.test: Simple merge mysql-test/t/count_distinct.test: Simple merge mysql-test/t/ctype_latin1_de.test: Simple merge mysql-test/t/ctype_uca.test: Simple merge mysql-test/t/ctype_ucs.test: Simple merge mysql-test/t/ctype_utf8.test: Simple merge mysql-test/t/delete.test: Simple merge mysql-test/t/flush_block_commit.test: Simple merge mysql-test/t/func_default.test: Simple merge mysql-test/t/func_gconcat.test: Simple merge mysql-test/t/func_group.test: Aligned code with 4.1 mysql-test/t/func_in.test: Simple merge mysql-test/t/func_math.test: Simple merge mysql-test/t/func_misc.test: Simple merge mysql-test/t/func_test.test: Simple merge mysql-test/t/func_time.test: Simple merge mysql-test/t/group_by.test: Simple merge mysql-test/t/having.test: Simple merge mysql-test/t/innodb.test: Simple merge mysql-test/t/insert.test: Simple merge mysql-test/t/join_outer.test: Simple merge mysql-test/t/kill.test: Simple merge mysql-test/t/loaddata.test: Simple merge mysql-test/t/lock_multi.test: Simple merge mysql-test/t/multi_update.test: Simple merge mysql-test/t/mysqlbinlog.test: Simple merge mysql-test/t/mysqldump.test: Aligned code with 4.1 mysql-test/t/mysqltest.test: Simple merge mysql-test/t/ndb_basic.test: Simple merge mysql-test/t/ndb_cache.test: Simple merge mysql-test/t/ndb_subquery.test: Simple merge mysql-test/t/ps_grant.test: Simple merge mysql-test/t/range.test: Simple merge mysql-test/t/rpl_drop_temp.test: Simple merge mysql-test/t/rpl_loaddata_rule_s.test: Simple merge mysql-test/t/rpl_loaddatalocal.test: Simple merge mysql-test/t/rpl_rotate_logs.test: Simple merge mysql-test/t/rpl_until.test: Simple merge mysql-test/t/rpl_variables.test: Simple merge mysql-test/t/select.test: Simple merge mysql-test/t/sql_mode.test: Simple merge mysql-test/t/type_blob.test: Simple merge mysql-test/t/type_decimal.test: Simple merge mysql-test/t/user_var.test: Simple merge mysql-test/t/variables.test: Simple merge sql/lock.cc: Simple optimization sql/mysql_priv.h: Simple merge sql/sql_table.cc: Simple merge sql/table.cc: Simple merge sql/unireg.cc: Simple merge
193 lines
6.5 KiB
Text
193 lines
6.5 KiB
Text
# Initialise
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
|
|
#
|
|
# Testing of NULL in a lot of different places
|
|
#
|
|
|
|
select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
|
|
explain extended select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
|
|
select 1 | NULL,1 & NULL,1+NULL,1-NULL;
|
|
select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0;
|
|
select strcmp("a",NULL),(1<NULL)+0.0,NULL regexp "a",null like "a%","a%" like null;
|
|
select concat("a",NULL),replace(NULL,"a","b"),replace("string","i",NULL),replace("string",NULL,"i"),insert("abc",1,1,NULL),left(NULL,1);
|
|
select repeat("a",0),repeat("ab",5+5),repeat("ab",-1),reverse(NULL);
|
|
select field(NULL,"a","b","c");
|
|
select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
|
|
explain extended select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
|
|
SELECT NULL AND NULL, 1 AND NULL, NULL AND 1, NULL OR NULL, 0 OR NULL, NULL OR 0;
|
|
SELECT (NULL OR NULL) IS NULL;
|
|
select NULL AND 0, 0 and NULL;
|
|
select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
|
|
explain extended select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
|
|
|
|
create table t1 (x int);
|
|
insert into t1 values (null);
|
|
select * from t1 where x != 0;
|
|
drop table t1;
|
|
|
|
#
|
|
# Test problem med index on NULL columns and testing with =NULL;
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
indexed_field int default NULL,
|
|
KEY indexed_field (indexed_field)
|
|
);
|
|
INSERT INTO t1 VALUES (NULL),(NULL);
|
|
SELECT * FROM t1 WHERE indexed_field=NULL;
|
|
SELECT * FROM t1 WHERE indexed_field IS NULL;
|
|
SELECT * FROM t1 WHERE indexed_field<=>NULL;
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
# Testing of IFNULL
|
|
#
|
|
create table t1 (a int, b int) engine=myisam;
|
|
insert into t1 values(20,null);
|
|
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
|
|
t2.b=t3.a;
|
|
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
|
|
t2.b=t3.a order by 1;
|
|
insert into t1 values(10,null);
|
|
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
|
|
t2.b=t3.a order by 1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Test inserting and updating with NULL
|
|
#
|
|
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
|
|
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
|
|
UPDATE t1 SET d=1/NULL;
|
|
UPDATE t1 SET d=NULL;
|
|
--error 1048
|
|
INSERT INTO t1 (a) values (null);
|
|
--error 1048
|
|
INSERT INTO t1 (a) values (1/null);
|
|
INSERT INTO t1 (a) values (null),(null);
|
|
--error 1048
|
|
INSERT INTO t1 (b) values (null);
|
|
--error 1048
|
|
INSERT INTO t1 (b) values (1/null);
|
|
INSERT INTO t1 (b) values (null),(null);
|
|
--error 1048
|
|
INSERT INTO t1 (c) values (null);
|
|
--error 1048
|
|
INSERT INTO t1 (c) values (1/null);
|
|
INSERT INTO t1 (c) values (null),(null);
|
|
--error 1048
|
|
INSERT INTO t1 (d) values (null);
|
|
--error 1048
|
|
INSERT INTO t1 (d) values (1/null);
|
|
INSERT INTO t1 (d) values (null),(null);
|
|
select * from t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Test to check elimination of IS NULL predicate for a non-nullable attribute
|
|
# (bug #1990)
|
|
#
|
|
create table t1 (a int not null, b int not null, index idx(a));
|
|
insert into t1 values
|
|
(1,1), (2,2), (3,3), (4,4), (5,5), (6,6),
|
|
(7,7), (8,8), (9,9), (10,10), (11,11), (12,12);
|
|
explain select * from t1 where a between 2 and 3;
|
|
explain select * from t1 where a between 2 and 3 or b is null;
|
|
drop table t1;
|
|
select cast(NULL as signed);
|
|
|
|
#
|
|
# IS NULL is unable to use index in range if column is declared not null
|
|
# (Bug #4256)
|
|
#
|
|
create table t1(i int, key(i));
|
|
insert into t1 values(1);
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 select i*2 from t1;
|
|
insert into t1 values(null);
|
|
explain select * from t1 where i=2 or i is null;
|
|
select count(*) from t1 where i=2 or i is null;
|
|
alter table t1 change i i int not null;
|
|
explain select * from t1 where i=2 or i is null;
|
|
select count(*) from t1 where i=2 or i is null;
|
|
drop table t1;
|
|
|
|
#
|
|
# NULL has its own type BINARY(0) by default.
|
|
# But NULL should be weaker than a constant
|
|
# when mixing charsets/collations
|
|
#
|
|
set names latin2;
|
|
# Check that result type is taken from a non-null string
|
|
create table t1 select
|
|
null as c00,
|
|
if(1, null, 'string') as c01,
|
|
if(0, null, 'string') as c02,
|
|
ifnull(null, 'string') as c03,
|
|
ifnull('string', null) as c04,
|
|
case when 0 then null else 'string' end as c05,
|
|
case when 1 then null else 'string' end as c06,
|
|
coalesce(null, 'string') as c07,
|
|
coalesce('string', null) as c08,
|
|
least('string',null) as c09,
|
|
least(null, 'string') as c10,
|
|
greatest('string',null) as c11,
|
|
greatest(null, 'string') as c12,
|
|
nullif('string', null) as c13,
|
|
nullif(null, 'string') as c14,
|
|
trim('string' from null) as c15,
|
|
trim(null from 'string') as c16,
|
|
substring_index('string', null, 1) as c17,
|
|
substring_index(null, 'string', 1) as c18,
|
|
elt(1, null, 'string') as c19,
|
|
elt(1, 'string', null) as c20,
|
|
concat('string', null) as c21,
|
|
concat(null, 'string') as c22,
|
|
concat_ws('sep', 'string', null) as c23,
|
|
concat_ws('sep', null, 'string') as c24,
|
|
concat_ws(null, 'string', 'string') as c25,
|
|
make_set(3, 'string', null) as c26,
|
|
make_set(3, null, 'string') as c27,
|
|
export_set(3, null, 'off', 'sep') as c29,
|
|
export_set(3, 'on', null, 'sep') as c30,
|
|
export_set(3, 'on', 'off', null) as c31,
|
|
replace(null, 'from', 'to') as c32,
|
|
replace('str', null, 'to') as c33,
|
|
replace('str', 'from', null) as c34,
|
|
insert('str', 1, 2, null) as c35,
|
|
insert(null, 1, 2, 'str') as c36,
|
|
lpad('str', 10, null) as c37,
|
|
rpad(null, 10, 'str') as c38;
|
|
|
|
show create table t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Check that comparison is done according to
|
|
# non-null string collation, i.e. case insensitively,
|
|
# rather than according to NULL's collation, i.e. case sensitively
|
|
#
|
|
-- in field
|
|
select
|
|
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
|
|
case 'str' when null then 'null' when 'STR' then 'str' end as c02,
|
|
field(null, 'str1', 'str2') as c03,
|
|
field('str1','STR1', null) as c04,
|
|
field('str1', null, 'STR1') as c05,
|
|
'string' in ('STRING', null) as c08,
|
|
'string' in (null, 'STRING') as c09;
|
|
|
|
# Restore charset to the default value.
|
|
set names latin1;
|
|
|
|
# End of 4.1 tests
|