~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/tests/t/innodb-system-table-view.test

  • Committer: Stewart Smith
  • Date: 2010-08-12 16:48:46 UTC
  • mto: This revision was merged to the branch mainline in revision 1707.
  • Revision ID: stewart@flamingspork.com-20100812164846-s9bhy47g60bvqs41
bug lp:611379 Equivalent queries with Impossible where return different results

The following two equivalent queries return different results in maria 5.2 and 5.3 (and identical results in mysql 5.5.5) :

SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` ;

SELECT * FROM ( SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` );

MariaDB returns 0 on the second query and NULL on the first, whereas MySQL returns NULL on both. In MariaDB, both EXPLAIN plans agree that "Impossible WHERE noticed after reading const tables"



We have some slightly different output in drizzle:

main.bug_lp611379 [ fail ]
drizzletest: At line 9: query 'explain select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a)
as t' failed: 1048: Column 'sum(distinct t1.a)' cannot be null

but the fix gets us the correct query results, although with slightly different execution plans.



This fix is directly ported from MariaDB.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This is the test for Information Schema System Table View
2
 
# that displays the InnoDB system table content through
3
 
# information schema tables.
4
 
 
5
 
--source include/have_innodb.inc
6
 
 
7
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_TABLES;
8
 
 
9
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_INDEXES;
10
 
 
11
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_COLUMNS;
12
 
 
13
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_FIELDS;
14
 
 
15
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_FOREIGN;
16
 
 
17
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_FOREIGN_COLS;
18
 
 
19
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_TABLESTATS;
20
 
 
21
 
# Create a foreign key constraint, and verify the information
22
 
# in DATA_DICTIONARY.INNODB_SYS_FOREIGN and
23
 
# DATA_DICTIONARY.INNODB_SYS_FOREIGN_COLS
24
 
CREATE TABLE parent (id INT NOT NULL,
25
 
                     PRIMARY KEY (id)) ENGINE=INNODB;
26
 
 
27
 
CREATE TABLE child (id INT, parent_id INT,
28
 
                    INDEX par_ind (parent_id),
29
 
                    CONSTRAINT constraint_test
30
 
                    FOREIGN KEY (parent_id) REFERENCES parent(id)
31
 
                      ON DELETE CASCADE) ENGINE=INNODB;
32
 
 
33
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_FOREIGN;
34
 
 
35
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_FOREIGN_COLS;
36
 
 
37
 
# Insert a row in the table "parent", and see whether that reflected in
38
 
# INNODB_SYS_TABLESTATS
39
 
INSERT INTO parent VALUES(1);
40
 
 
41
 
SELECT name, num_rows, handles_opened
42
 
FROM DATA_DICTIONARY.INNODB_SYS_TABLESTATS
43
 
WHERE name LIKE "%parent";
44
 
 
45
 
SELECT NAME, FLAG, N_COLS, SPACE FROM DATA_DICTIONARY.INNODB_SYS_TABLES;
46
 
 
47
 
SELECT name, n_fields
48
 
from DATA_DICTIONARY.INNODB_SYS_INDEXES
49
 
WHERE table_id In (SELECT table_id from
50
 
        DATA_DICTIONARY.INNODB_SYS_TABLES
51
 
        WHERE name LIKE "%parent%");
52
 
 
53
 
SELECT name, n_fields
54
 
from DATA_DICTIONARY.INNODB_SYS_INDEXES
55
 
WHERE table_id In (SELECT table_id from
56
 
        DATA_DICTIONARY.INNODB_SYS_TABLES
57
 
        WHERE name LIKE "%child%");
58
 
 
59
 
SELECT name, pos, mtype, len
60
 
from DATA_DICTIONARY.INNODB_SYS_COLUMNS
61
 
WHERE table_id In (SELECT table_id from
62
 
        DATA_DICTIONARY.INNODB_SYS_TABLES
63
 
        WHERE name LIKE "%child%");
64
 
 
65
 
DROP TABLE child;
66
 
 
67
 
DROP TABLE parent;
68
 
 
69
 
# Create table with 2 columns in the foreign key constraint
70
 
CREATE TABLE parent (id INT NOT NULL, newid INT NOT NULL,
71
 
                     PRIMARY KEY (id, newid)) ENGINE=INNODB;
72
 
 
73
 
CREATE TABLE child (id INT, parent_id INT,
74
 
                    INDEX par_ind (parent_id),
75
 
                    CONSTRAINT constraint_test
76
 
                    FOREIGN KEY (id, parent_id) REFERENCES parent(id, newid)
77
 
                      ON DELETE CASCADE) ENGINE=INNODB;
78
 
 
79
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_FOREIGN;
80
 
 
81
 
SELECT * FROM DATA_DICTIONARY.INNODB_SYS_FOREIGN_COLS;
82
 
 
83
 
INSERT INTO parent VALUES(1, 9);
84
 
 
85
 
# Nested query will open the table handle twice
86
 
SELECT * FROM parent WHERE id IN (SELECT id FROM parent);
87
 
 
88
 
SELECT name, num_rows, handles_opened
89
 
FROM DATA_DICTIONARY.INNODB_SYS_TABLESTATS
90
 
WHERE name LIKE "%parent";
91
 
 
92
 
DROP TABLE child;
93
 
 
94
 
DROP TABLE parent;