diff options
-rw-r--r-- | sql/sql_select.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 29560e8701b..d3e8b3ab9e7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1072,7 +1072,14 @@ JOIN::exec() else { result->send_fields(fields_list,1); - if (cond_value != Item::COND_FALSE && (!having || having->val_int())) + /* + We have to test for 'conds' here as the WHERE may not be constant + even if we don't have any tables for prepared statements or if + conds uses something like 'rand()'. + */ + if (cond_value != Item::COND_FALSE && + (!conds || conds->val_int()) && + (!having || having->val_int())) { if (do_send_rows && (procedure ? (procedure->send_row(fields_list) || procedure->end_of_records()) |