File: empty_table.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (65 lines) | stat: -rw-r--r-- 1,986 bytes parent folder | download | duplicates (4)
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
#
# Some special cases with empty tables
#

--disable_warnings
drop table if exists t1;
--enable_warnings

# Enable after fix MDEV-31721
--disable_cursor_protocol
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
--disable_ps2_protocol
select count(*) from t1;
select * from t1;
select * from t1 limit 0;
--enable_ps2_protocol
show status like "Empty_queries";
drop table t1;

#
# Accessing a non existing table should not increase Empty_queries
#

--disable_ps2_protocol
--error 1146
select * from t2;
--enable_ps2_protocol
show status like "Empty_queries";
--enable_cursor_protocol

--echo # End of 4.1 tests

--echo #
--echo # MDEV-30333 Wrong result with not_null_range_scan and LEFT JOIN with empty table
--echo #

set @save_optimizer_switch=@@optimizer_switch;
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 (b) VALUES (1),(2);
CREATE TABLE t2 (c INT) ENGINE=MyISAM;
SET optimizer_switch= 'not_null_range_scan=off'; # Default
explain extended SELECT b FROM t1 LEFT JOIN t2 ON t2.c = a WHERE a IS NULL ORDER BY b;
SELECT b FROM t1 LEFT JOIN t2 ON t2.c = a WHERE a IS NULL ORDER BY b;
SET optimizer_switch = 'not_null_range_scan=on';
explain extended SELECT b FROM t1 LEFT JOIN t2 ON t2.c = a WHERE a IS NULL ORDER BY b;
SELECT b FROM t1 LEFT JOIN t2 ON t2.c = a WHERE a IS NULL ORDER BY b;
flush tables;
SELECT b FROM t1 LEFT JOIN t2 ON t2.c = a WHERE a IS NULL ORDER BY b;
drop table t1,t2;

--echo # Second test in MDEV-30333

CREATE TABLE t1 (a int, b varchar(10)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (69,'foo'),(71,'bar');
CREATE TABLE t2 (c int) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t3 (d int, e int, KEY(e)) ENGINE=MyISAM;
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t3.e = t3.d ON 1;
SET optimizer_switch = 'not_null_range_scan=on';
SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON t3.e = t3.d ON 1;
DROP TABLE t1, t2, t3;
set @@optimizer_switch=@save_optimizer_switch;

--echo End of 10.5 tests