~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/cache_xt.cc

  • 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:
14
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
 *
19
19
 * 2005-05-24   Paul McCullagh
20
20
 *
664
664
                        block->cb_data = buffer;
665
665
                        buffer += XT_INDEX_PAGE_SIZE;
666
666
#endif
667
 
#ifdef CHECK_BLOCK_TRAILERS
668
 
                        XT_SET_DISK_4(block->cp_check, 0xDEADBEEF);
669
 
#endif
670
667
                        ind_cac_globals.cg_free_list = block;
671
668
                        block++;
672
669
                }
683
680
        cont_(a);
684
681
}
685
682
 
686
 
#ifdef CHECK_BLOCK_TRAILERS
687
 
xtPublic void check_block_trailers()
688
 
{
689
 
        XTIndBlockPtr   block;
690
 
 
691
 
        block = ind_cac_globals.cg_blocks;
692
 
        for (u_int i=0; i<ind_cac_globals.cg_block_count; i++) {
693
 
                ASSERT_NS(XT_GET_DISK_4(block->cp_check) == 0xDEADBEEF);
694
 
                block++;
695
 
        }
696
 
}
697
 
#endif
698
 
 
699
683
xtPublic void xt_ind_exit(XTThreadPtr self)
700
684
{
701
685
#ifdef XT_USE_MYSYS
1272
1256
         * Conditionally count the number of deleted entries in the index:
1273
1257
         * We do this before other threads can read the block.
1274
1258
         */
1275
 
        if (ind && ind->mi_lazy_delete && read_data)
 
1259
        if (ind->mi_lazy_delete && read_data)
1276
1260
                xt_ind_count_deleted_items(ot->ot_table, ind, block);
1277
1261
 
1278
1262
        /* Add to the hash table: */
1365
1349
#ifdef XT_TRACK_INDEX_UPDATES
1366
1350
        ot->ot_ind_changed++;
1367
1351
#endif
1368
 
#ifdef CHECK_BLOCK_TRAILERS
1369
 
        check_block_trailers();
1370
 
#endif
1371
1352
        return OK;
1372
1353
}
1373
1354