mariadb/mysql-test/suite/vcol/t
Monty ca5c122adc MDEV-9938 Prepared statement return wrong result (missing row)
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>
2023-08-15 21:41:01 +03:00
..
alter_inplace-9045.test
binlog.test [1/2] MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols 2021-07-12 22:00:39 +03:00
charsets.test
cross_db.test
delayed.test
index.test
innodb_autoinc_vcol.test
innodb_virtual_fk.test MDEV-31853 Assertion failure in Column_definition::check_vcol_for_key upon adding FK 2023-08-06 20:08:51 +02:00
load_data.test MDEV-31003: Second execution for ps-protocol 2023-07-26 17:15:00 +07:00
mrr.test
myisam_repair_prefix_varchar.test
not_supported.test try harder to reject not strictly deterministic vcols in indexes/stored 2022-12-02 16:19:13 +01:00
partition.test MDEV-18734 ASAN heap-use-after-free upon sorting by blob column from partitioned table 2021-08-05 23:48:02 +03:00
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 Merge branch '10.4' into 10.5 2023-07-27 15:43:21 +02:00
vcol_memory.test
vcol_merge.test
vcol_misc.opt vcols: cannot use CONTEXT_ANALYSIS_ONLY_VCOL_EXPR on fix_fields 2022-04-19 17:10:05 +02:00
vcol_misc.test Merge branch '10.4' into 10.5 2022-08-03 07:12:27 +02:00
vcol_non_stored_columns_innodb.test
vcol_non_stored_columns_myisam.test
vcol_partition_innodb.test
vcol_partition_myisam.test
vcol_select_innodb.test MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent 2021-08-31 13:55:02 +03:00
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 MDEV-9938 Prepared statement return wrong result (missing row) 2023-08-15 21:41:01 +03:00
vcol_trigger_sp_innodb.test
vcol_trigger_sp_myisam.test
vcol_view_innodb.test MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent 2021-08-31 13:55:02 +03:00
vcol_view_myisam.test
wrong_arena.test MDEV-31003: Second execution for ps-protocol 2023-07-26 17:15:00 +07:00