~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/alter_table.result

  • 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:
8
8
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
9
9
col6 int not null, to_be_deleted int);
10
10
insert into t1 values (2,4,3,5,"PENDING",1,7);
11
 
SELECT * FROM t1;
12
 
col1    col2    col3    col4    col5    col6    to_be_deleted
13
 
2       4       3       5       PENDING 1       7
14
11
alter table t1
15
12
add column col4_5 varchar(20) not null after col4,
16
13
add column col7 varchar(30) not null after col5,
17
14
add column col8 datetime not null default '1000-01-01 00:00:00', drop column to_be_deleted,
18
15
change column col2 fourth varchar(30) not null after col3,
19
16
modify column col6 int not null first;
20
 
ERROR HY000: Either a DEFAULt value or NULL NULL description is required for a new column if table is not empty
21
 
alter table t1
22
 
add column col4_5 varchar(20) DEFAULT "added" not null after col4,
23
 
add column col7 varchar(30) DEFAULT "added" not null after col5,
24
 
add column col8 datetime not null default '1000-01-01 00:00:00',
25
 
drop column to_be_deleted,
26
 
change column col2 fourth varchar(30) not null after col3,
27
 
modify column col6 int not null first;
28
17
select * from t1;
29
18
col6    col1    col3    fourth  col4    col4_5  col5    col7    col8
30
 
1       2       3       4       5       added   PENDING added   1000-01-01 00:00:00
 
19
1       2       3       4       5               PENDING         1000-01-01 00:00:00
31
20
drop table t1;
32
21
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
33
22
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
187
176
alter table t2 rename t1, add c char(10) comment "no comment";
188
177
show columns from t1;
189
178
Field   Type    Null    Default Default_is_NULL On_Update
190
 
i       INTEGER NO              NO      
 
179
i       INTEGER NO      0       NO      
191
180
c       VARCHAR YES             YES     
192
181
drop table t1;
193
182
create table t1 (a int, b int);
364
353
SHOW CREATE TABLE t1;
365
354
Table   Create Table
366
355
t1      CREATE TABLE `t1` (
367
 
  `a` INT NOT NULL,
368
 
  `b` INT DEFAULT NULL,
 
356
  `a` int NOT NULL,
 
357
  `b` int DEFAULT NULL,
369
358
  UNIQUE KEY `b` (`b`)
370
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
359
) ENGINE=DEFAULT
371
360
ALTER TABLE t1 DROP PRIMARY KEY;
372
361
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
373
362
DROP TABLE t1;
527
516
use mysqltest;
528
517
drop database mysqltest;
529
518
alter table test.t1 rename t1;
530
 
ERROR 3D000: No schema selected
 
519
ERROR 3D000: No database selected
531
520
alter table test.t1 rename test.t1;
532
521
use test;
533
522
drop table t1;
536
525
SHOW CREATE TABLE t1;
537
526
Table   Create Table
538
527
t1      CREATE TABLE `t1` (
539
 
  `a` INT DEFAULT NULL,
 
528
  `a` int DEFAULT NULL,
540
529
  KEY `i1` (`a`)
541
 
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
 
530
) ENGINE=DEFAULT ROW_FORMAT='COMPACT'
542
531
DROP INDEX i1 ON t1;
543
532
SHOW CREATE TABLE t1;
544
533
Table   Create Table
545
534
t1      CREATE TABLE `t1` (
546
 
  `a` INT DEFAULT NULL
547
 
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
 
535
  `a` int DEFAULT NULL
 
536
) ENGINE=DEFAULT ROW_FORMAT='COMPACT'
548
537
DROP TABLE t1;
549
538
DROP TABLE IF EXISTS bug24219;
550
539
DROP TABLE IF EXISTS bug24219_2;
810
799
SHOW CREATE TABLE `tt+1`;
811
800
Table   Create Table
812
801
tt+1    CREATE TEMPORARY TABLE `tt+1` (
813
 
  `c1` INT DEFAULT NULL
814
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
802
  `c1` int DEFAULT NULL
 
803
) ENGINE=DEFAULT
815
804
SHOW CREATE TABLE `tt+2`;
816
805
Table   Create Table
817
806
tt+2    CREATE TEMPORARY TABLE `tt+2` (
818
 
  `c1` INT DEFAULT NULL
819
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
807
  `c1` int DEFAULT NULL
 
808
) ENGINE=DEFAULT
820
809
DROP TABLE   `tt+1`, `tt+2`;
821
810
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
811
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
835
824
SHOW CREATE TABLE `#sql2`;
836
825
Table   Create Table
837
826
#sql2   CREATE TEMPORARY TABLE `#sql2` (
838
 
  `c1` INT DEFAULT NULL
839
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
827
  `c1` int DEFAULT NULL
 
828
) ENGINE=DEFAULT
840
829
SHOW CREATE TABLE `@0023sql1`;
841
830
Table   Create Table
842
831
@0023sql1       CREATE TEMPORARY TABLE `@0023sql1` (
843
 
  `c1` INT DEFAULT NULL
844
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
832
  `c1` int DEFAULT NULL
 
833
) ENGINE=DEFAULT
845
834
DROP TABLE `#sql2`, `@0023sql1`;
846
835
DROP TABLE IF EXISTS t1;
847
836
DROP TABLE IF EXISTS t2;