summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_equal.test
blob: 990b6d8e74e66f60ef955521dd8d0b250c85d79f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Initialise
--disable_warnings
drop table if exists t1,t2;
--enable_warnings

#
# Testing of the <=> operator
#

#
# First some simple tests
#

select 0<=>0,0.0<=>0.0,0E0=0E0,"A"<=>"A",NULL<=>NULL;
select 1<=>0,0<=>NULL,NULL<=>0;
select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
select "A"<=>"B","A"<=>NULL,NULL<=>"A";
select 0<=>0.0, 0.0<=>0E0, 0E0<=>"0", 10.0<=>1E1, 10<=>10.0, 10<=>1E1;
select 1.0<=>0E1,10<=>NULL,NULL<=>0.0, NULL<=>0E0;

#
# Test with tables
#

create table t1 (id int, value int);
create table t2 (id int, value int);

insert into t1 values (1,null);
insert into t2 values (1,null);

select t1.*, t2.*, t1.value<=>t2.value from t1, t2 where t1.id=t2.id and t1.id=1;
select * from t1 where id <=>id;
select * from t1 where value <=> value;
select * from t1 where id <=> value or value<=>id;
drop table t1,t2;

#
# Bug #12612: quoted bigint unsigned value and the use of "in" in where clause
#
create table t1 (a bigint unsigned);
insert into t1 values (4828532208463511553);
select * from t1 where a = '4828532208463511553';
select * from t1 where a in ('4828532208463511553');
drop table t1;

--echo #End of 4.1 tests

--echo #
--echo # MDEV-5103: server crashed on singular Item_equal
--echo #

CREATE TABLE `t1` (
  `tipo` enum('p','r') NOT NULL DEFAULT 'r',
  `arquivo_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `arquivo_md5` char(32) NOT NULL,
  `conteudo` longblob NOT NULL,
  `usuario` varchar(15) NOT NULL,
  `datahora_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `tipo_arquivo` varchar(255) NOT NULL,
  `nome_arquivo` varchar(255) NOT NULL,
  `tamanho_arquivo` bigint(20) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`tipo`,`arquivo_id`),
  UNIQUE KEY `tipo` (`tipo`,`arquivo_md5`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;

INSERT INTO `t1` (`tipo`, `arquivo_id`, `arquivo_md5`, `conteudo`, `usuario`, `datahora_gmt`, `tipo_arquivo`, `nome_arquivo`, `tamanho_arquivo`) VALUES
	('r', 1, 'ad18832202b199728921807033a8a515', '', 'rspadim', '2013-10-05 13:55:50', '001_cbr643', 'CBR6431677410201314132.ret', 21306);


CREATE TABLE `t2` (
  `tipo` enum('p','r') NOT NULL DEFAULT 'p',
  `arquivo_id` bigint(20) NOT NULL DEFAULT '0',
  `usuario` varchar(25) NOT NULL,
  `datahora` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `erros` longblob NOT NULL,
  `importados` bigint(20) unsigned NOT NULL DEFAULT '0',
  `n_importados` bigint(20) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`tipo`,`arquivo_id`,`datahora`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;

INSERT INTO `t2` (`tipo`, `arquivo_id`, `usuario`, `datahora`, `erros`, `importados`, `n_importados`) VALUES
	('r', 1, 'rspadim', '2013-10-05 14:25:30', '', 32, 0);

SELECT
arquivo_id,usuario,datahora_gmt,tipo_arquivo,nome_arquivo,tamanho_arquivo
  FROM t1 AS a
  WHERE datahora_gmt>='0000-00-00 00:00:00' AND
    datahora_gmt<='2013-10-07 02:59:59' AND tipo='r' AND
    (tipo_arquivo,arquivo_id) NOT IN
      (SELECT tipo_arquivo,arquivo_id
        FROM t2
        WHERE (tipo_arquivo,arquivo_id)=(a.tipo_arquivo,a.arquivo_id))
  ORDER BY arquivo_id DESC;

drop table t2, t1;
--echo #End of 5.3 tests