~prafulla-t/drizzle/drz-bugfix-586051

« back to all changes in this revision

Viewing changes to tests/t/optimizer.test

  • Committer: Prafulla Tekawade
  • Date: 2010-08-06 11:21:12 UTC
  • Revision ID: prafulla_t@users.sourceforge.net-20100806112112-7w5u0s3nx9u67nzt
Fix for Bug 586051

1. test_if_ref method which checks whether predicate is already evaluated
   due to ref/eq_ref access or not was incorrectly removing a predicate 
   that was not implicitly evaluated due to ref access (due to presence of filesort ?)
   It was field=NULL predicate.
   Such predicate should be kept and execution engine will filter out rows
   correctly. Removal of such predicate led to returning of rows which had
   NULL for join/predicate columns.
2. field COMP_OP NULL will always false for all fields except when COMP_OP
   is NULL-safe equality operator. Modified range optimizer to return zero
   row count in such cases.
   Query now does not even run. It returns zero result. As such Fix(1) is not
   required but we might hit that case in some other query (I have not tried it
   yet)
3. Fixed Field::val_str to print "NULL" for literal NULL instead of "0". It
   added lot of confusion while debugging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
216
216
# Cleanup
217
217
DROP TABLE a, d, h, k, n , p ;
218
218
--echo End Bug#592444 test
 
219
 
 
220
--echo Bug#586051 start
 
221
--echo -Server allowing JOIN on NULL values in certain cases if query includes ORDER BY clause
 
222
 
 
223
--disable_warnings
 
224
DROP TABLE IF EXISTS `i`;
 
225
CREATE TABLE `i` (
 
226
  `col_int_key` int DEFAULT NULL,
 
227
  `pk` int NOT NULL AUTO_INCREMENT,
 
228
  PRIMARY KEY (`pk`),
 
229
  KEY `col_int_key` (`col_int_key`)
 
230
) ENGINE=InnoDB;
 
231
 
 
232
ALTER TABLE `i` DISABLE KEYS;
 
233
INSERT INTO `i` VALUES (-480247808,1),(-1066663936,2),(NULL,3),(NULL,4),(-1583808512,5),(NULL,6),(NULL,7),(NULL,8),(0,9),(-219152384,10);
 
234
ALTER TABLE `i` ENABLE KEYS;
 
235
 
 
236
DROP TABLE IF EXISTS `b`;
 
237
CREATE TABLE `b` (
 
238
  `col_int_key` int DEFAULT NULL,
 
239
  `col_int` int DEFAULT NULL,
 
240
  `pk` int NOT NULL AUTO_INCREMENT,
 
241
  PRIMARY KEY (`pk`),
 
242
  KEY `col_int_key` (`col_int_key`)
 
243
) ENGINE=InnoDB;
 
244
 
 
245
ALTER TABLE `b` DISABLE KEYS;
 
246
INSERT INTO `b` VALUES (NULL,7,1);
 
247
ALTER TABLE `b` ENABLE KEYS;
 
248
--enable_warnings
 
249
 
 
250
#/* Begin test case for query 0 */
 
251
 
 
252
SELECT table2 .`col_int` field3
 
253
FROM i table1 JOIN b table2 ON table1 .`col_int_key` = table2 .`col_int_key`
 
254
WHERE table1 .`pk` IN ( 4 ) 
 
255
ORDER BY field3 ;
 
256
#/* End of test case for query 0 */
 
257
 
 
258
#/* Begin test case for query 1 */
 
259
 
 
260
SELECT table2 .`col_int` field3
 
261
FROM i table1 JOIN b table2 ON table1 .`col_int_key` = table2 .`col_int_key`
 
262
WHERE table1 .`pk` IN ( 4 ) /* TRANSFORM_OUTCOME_UNORDERED_MATCH */ ;
 
263
 
 
264
#/* End of test case for query 1 */
 
265
 
 
266
DROP TABLE i;
 
267
DROP TABLE b;
 
268
 
 
269
--echo End Bug#586051 test