File: odbc.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (75 lines) | stat: -rw-r--r-- 2,165 bytes parent folder | download
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

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

set @@session.sql_auto_is_null=1;

#
# Test some ODBC compatibility
#

select {fn length("hello")}, { date "1997-10-20" };

#
# Test retreiving row with last insert_id value.
#

create table t1 (a int not null auto_increment,b int not null,primary key (a,b));
insert into t1 SET A=NULL,B=1;
insert into t1 SET a=null,b=2;
select * from t1 where a is null and b=2;
select * from t1 where a is null;
analyze table t1;
explain select * from t1 where b is null;
drop table t1;

#
# Bug #14553: NULL in WHERE resets LAST_INSERT_ID
#
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
INSERT INTO t1 VALUES (NULL);
SELECT a, last_insert_id() FROM t1 WHERE a IS NULL;
SELECT a, last_insert_id() FROM t1 WHERE a IS NULL;
SELECT a, last_insert_id() FROM t1;
DROP TABLE t1;

# End of 4.1 tests

--echo #
--echo # Bug#29171668: ODBC SUBSTITUTION FOR LAST_INSERT_ID() TRIGGERS
--echo #               A NON-DETERMINISTIC TRANSFORMATION
--echo #
CREATE TABLE t1(a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2(b INT);
INSERT INTO t2 VALUES (2),(3),(4);

# Test that the transformation doesn't happen when the auto-increment
# column is in the inner table of an outer join. (For additional test
# coverage only. Not changed by the bug fix.)
INSERT INTO t1 VALUES ();
SELECT * FROM t2 LEFT JOIN t1 ON a=b WHERE a IS NULL;
INSERT INTO t1 VALUES ();
SELECT * FROM t2 LEFT JOIN t1 ON a=b WHERE a IS NULL;

# Only rewrite WHERE, leave HAVING and the select list as they are.
# (For additional coverage. Not changed by the bug fix.)
INSERT INTO t1 VALUES ();
SELECT * FROM t1 HAVING a IS NULL;
SELECT a, a IS NULL FROM t1 WHERE a IS NULL;

# Test that the substitution is done on subsequent executions, not
# only on the first one.
SELECT * FROM t1 WHERE a IS NULL;
SELECT * FROM t1 WHERE a IS NULL;

# Test that the transformation also works for auto-increment values
# outside of the signed bigint range.
INSERT INTO t1 VALUES (9223372036854775807); # max signed bigint
INSERT INTO t1 VALUES ();
SELECT * FROM t1 WHERE a IS NULL;

DROP TABLE t1, t2;

set @@session.sql_auto_is_null=default;