mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
ca5c122adc
The problem is that the first execution of the prepared statement makes a permanent optimization of converting the LEFT JOIN to an INNER JOIN. This is based on the assumption that all the user parameters (?) are always constants and that parameters to Item_cond() will not change value from true and false between different executions. (The example was using IS NULL, which will change value if parameter depending on if the parameter is NULL or not). The fix is to change Item_cond::fix_fields() and Item_cond::eval_not_null_tables() to not threat user parameters as constants. This will ensure that we don't do the LEFT_JOIN -> INNER JOIN conversion that causes problems. There is also some things that needs to be improved regarding calculations of not_null_tables_cache as we get a different value for WHERE 1 or t1.a=1 compared to WHERE t1.a= or 1 Changes done: - Mark Item_param with the PARAM flag to be able to quickly check in Item_cond::eval_not_null_tables() if an item contains a prepared statement parameter (just like we check for stored procedure parameters). - Fixed that Item_cond::not_null_tables_cache is not depending on order of arguments. - Don't call item->eval_const_cond() for items that are NOT on the top level of the WHERE clause. This removed a lot of unnecessary warnings in the test suite! - Do not reset not_null_tables_cache for not top level items. - Simplified Item_cond::fix_fields by calling eval_not_null_tables() instead of having duplication of all the code in eval_not_null_tables(). - Return an error if Item_cond::fix_field() generates an error The old code did generate an error in some cases, but not in all cases. - Fixed all handling of the above error in make_cond_for_tables(). The error handling by the callers did not exists before which could lead to asserts in many different places in the old code). - All changes in sql_select.cc are just checking the return value of fix_fields() and make_cond_for_tables() and returning an error value if fix_fields() returns true or make_cond_for_tables() returns NULL and is_error() is set. - Mark Item_cond as const_item if all arguments returns true for can_eval_in_optimize(). Reviewer: Sergei Petrunia <sergey@mariadb.com> |
||
---|---|---|
.. | ||
alter_inplace-9045.test | ||
binlog.test | ||
charsets.test | ||
cross_db.test | ||
delayed.test | ||
index.test | ||
innodb_autoinc_vcol.test | ||
innodb_virtual_fk.test | ||
load_data.test | ||
mrr.test | ||
myisam_repair_prefix_varchar.test | ||
not_supported.test | ||
partition.test | ||
races.test | ||
range.test | ||
rpl_vcol.test | ||
update.test | ||
update_binlog.test | ||
upgrade.test | ||
vcol_archive.test | ||
vcol_blackhole.test | ||
vcol_blocked_sql_funcs.test | ||
vcol_blocked_sql_funcs_main.inc | ||
vcol_column_def_options_innodb.test | ||
vcol_column_def_options_myisam.test | ||
vcol_csv.test | ||
vcol_handler_aria.test | ||
vcol_handler_innodb.test | ||
vcol_handler_myisam.test | ||
vcol_ins_upd_innodb.test | ||
vcol_ins_upd_myisam.test | ||
vcol_keys_aria.test | ||
vcol_keys_innodb.opt | ||
vcol_keys_innodb.test | ||
vcol_keys_myisam.test | ||
vcol_memory.test | ||
vcol_merge.test | ||
vcol_misc.opt | ||
vcol_misc.test | ||
vcol_non_stored_columns_innodb.test | ||
vcol_non_stored_columns_myisam.test | ||
vcol_partition_innodb.test | ||
vcol_partition_myisam.test | ||
vcol_select_innodb.test | ||
vcol_select_myisam.test | ||
vcol_sql_mode.test | ||
vcol_sql_mode_datetime.test | ||
vcol_sql_mode_time.test | ||
vcol_sql_mode_timestamp.test | ||
vcol_sql_mode_upgrade.test | ||
vcol_supported_sql_funcs.test | ||
vcol_supported_sql_funcs_main.inc | ||
vcol_syntax.test | ||
vcol_trigger_sp_innodb.test | ||
vcol_trigger_sp_myisam.test | ||
vcol_view_innodb.test | ||
vcol_view_myisam.test | ||
wrong_arena.test |