Bug #36195 mysqld calls handler->cond_push twice
Submitted: 18 Apr 2008 2:29 Modified: 28 Apr 2008 18:17
Reporter: Sergey Petrunya Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.1-bk OS:Any
Assigned to: CPU Architecture:Any

[18 Apr 2008 2:29] Sergey Petrunya
Description:
A problem from Arjen: MySQL calls handler->cond_push() twice even in simple cases.

How to repeat:
Apply this patch to see the cond_push calls:

===== storage/myisam/ha_myisam.h 1.89 vs edited =====
--- 1.89/storage/myisam/ha_myisam.h     2008-04-18 06:22:47 +04:00
+++ edited/storage/myisam/ha_myisam.h   2008-04-18 06:15:19 +04:00
@@ -59,6 +59,10 @@
   uint max_supported_key_length()    const { return MI_MAX_KEY_LENGTH; }
   uint max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH; }
   uint checksum() const;
+ const COND *cond_push(const COND *cond) { 
+   fprintf(stderr, "%s->cond_push(%p)\n", this->table->alias, cond);
+   return cond; 
+   };
 
   int open(const char *name, int mode, uint test_if_locked);
   int close(void);

then run:

create table t2(a int);
insert into t2 values (1),(2);
select * from t2 where a< 2;

And in server stderr see:

 t2->cond_push(0x86edc68);
 t2->cond_push(0x86edc68);

Suggested fix:
Call cond_push only once.
[18 Apr 2008 21:42] Arjen Lentz
We reckon it's the optimiser:
 - with EXPLAIN SELECT, it's only called once.
 - with normal SELECT, it's called twice.
[28 Apr 2008 18:17] Sveta Smirnova
Thank you for the report.

Verified as described.