~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/db0err.h

  • 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
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/db0err.h
21
 
Global error codes for the database
22
 
 
23
 
Created 5/24/1996 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef db0err_h
27
 
#define db0err_h
28
 
 
29
 
 
30
 
enum db_err {
31
 
        DB_SUCCESS_LOCKED_REC = 9,      /*!< like DB_SUCCESS, but a new
32
 
                                        explicit record lock was created */
33
 
        DB_SUCCESS = 10,
34
 
 
35
 
        /* The following are error codes */
36
 
        DB_ERROR,
37
 
        DB_INTERRUPTED,
38
 
        DB_OUT_OF_MEMORY,
39
 
        DB_OUT_OF_FILE_SPACE,
40
 
        DB_LOCK_WAIT,
41
 
        DB_DEADLOCK,
42
 
        DB_ROLLBACK,
43
 
        DB_DUPLICATE_KEY,
44
 
        DB_QUE_THR_SUSPENDED,
45
 
        DB_MISSING_HISTORY,             /* required history data has been
46
 
                                        deleted due to lack of space in
47
 
                                        rollback segment */
48
 
        DB_CLUSTER_NOT_FOUND = 30,
49
 
        DB_TABLE_NOT_FOUND,
50
 
        DB_MUST_GET_MORE_FILE_SPACE,    /* the database has to be stopped
51
 
                                        and restarted with more file space */
52
 
        DB_TABLE_IS_BEING_USED,
53
 
        DB_TOO_BIG_RECORD,              /* a record in an index would not fit
54
 
                                        on a compressed page, or it would
55
 
                                        become bigger than 1/2 free space in
56
 
                                        an uncompressed page frame */
57
 
        DB_LOCK_WAIT_TIMEOUT,           /* lock wait lasted too long */
58
 
        DB_NO_REFERENCED_ROW,           /* referenced key value not found
59
 
                                        for a foreign key in an insert or
60
 
                                        update of a row */
61
 
        DB_ROW_IS_REFERENCED,           /* cannot delete or update a row
62
 
                                        because it contains a key value
63
 
                                        which is referenced */
64
 
        DB_CANNOT_ADD_CONSTRAINT,       /* adding a foreign key constraint
65
 
                                        to a table failed */
66
 
        DB_CORRUPTION,                  /* data structure corruption noticed */
67
 
        DB_COL_APPEARS_TWICE_IN_INDEX,  /* InnoDB cannot handle an index
68
 
                                        where same column appears twice */
69
 
        DB_CANNOT_DROP_CONSTRAINT,      /* dropping a foreign key constraint
70
 
                                        from a table failed */
71
 
        DB_NO_SAVEPOINT,                /* no savepoint exists with the given
72
 
                                        name */
73
 
        DB_TABLESPACE_ALREADY_EXISTS,   /* we cannot create a new single-table
74
 
                                        tablespace because a file of the same
75
 
                                        name already exists */
76
 
        DB_TABLESPACE_DELETED,          /* tablespace does not exist or is
77
 
                                        being dropped right now */
78
 
        DB_LOCK_TABLE_FULL,             /* lock structs have exhausted the
79
 
                                        buffer pool (for big transactions,
80
 
                                        InnoDB stores the lock structs in the
81
 
                                        buffer pool) */
82
 
        DB_FOREIGN_DUPLICATE_KEY,       /* foreign key constraints
83
 
                                        activated by the operation would
84
 
                                        lead to a duplicate key in some
85
 
                                        table */
86
 
        DB_TOO_MANY_CONCURRENT_TRXS,    /* when InnoDB runs out of the
87
 
                                        preconfigured undo slots, this can
88
 
                                        only happen when there are too many
89
 
                                        concurrent transactions */
90
 
        DB_UNSUPPORTED,                 /* when InnoDB sees any artefact or
91
 
                                        a feature that it can't recoginize or
92
 
                                        work with e.g., FT indexes created by
93
 
                                        a later version of the engine. */
94
 
 
95
 
        DB_PRIMARY_KEY_IS_NULL,         /* a column in the PRIMARY KEY
96
 
                                        was found to be NULL */
97
 
 
98
 
        DB_STATS_DO_NOT_EXIST,          /* an operation that requires the
99
 
                                        persistent storage, used for recording
100
 
                                        table and index statistics, was
101
 
                                        requested but this storage does not
102
 
                                        exist itself or the stats for a given
103
 
                                        table do not exist */
104
 
        DB_FOREIGN_EXCEED_MAX_CASCADE,  /* Foreign key constraint related
105
 
                                        cascading delete/update exceeds
106
 
                                        maximum allowed depth */
107
 
 
108
 
        /* The following are partial failure codes */
109
 
        DB_FAIL = 1000,
110
 
        DB_OVERFLOW,
111
 
        DB_UNDERFLOW,
112
 
        DB_STRONG_FAIL,
113
 
        DB_ZIP_OVERFLOW,
114
 
        DB_RECORD_NOT_FOUND = 1500,
115
 
        DB_END_OF_INDEX
116
 
};
117
 
 
118
 
#endif