mariadb/mysql-test/suite/compat/oracle/t
Alexander Barkov c5d8b9963a MDEV-36716 A case expression with ROW arguments in THEN crashes
The patch for SYS_REFCURSOR (MDEV-20034) overrode these methods:
- Item_func_case_searched::check_arguments()
- Item_func_if::check_arguments()

to validate WHEN-style arguments (e.g. args[0] in case of IF) for being
able to return a boolean result.

However, this unintentionally removed the test for the THEN-style arguments
that they are not expressions of the ROW data type.

This led to a crash inside Type_handler_hybrid_field_type::aggregate_for_result
on a DBUG_ASSERT that arguments are not of the ROW data type.

Fix:

The fix restores blocking ROW expressions in the not supported cases,
to avoid the DBUG_ASSERT and to raise an SQL error instead.

Blocking ROW_RESULT expressions is done per Item_func_case_expression
descendant individually, instead of blocking any ROW_RESULT arguments
at the Item_func_case_expression level.

The fix is done taking into account the upcoming patch for associative arrays
(MDEV-34319). It should be possible to pass associative array expressions into
some hybrid type functions, where ROW type expressions are not possible.

As a side effect, some lecagy ER_OPERAND_COLUMNS changed to
a newer ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION

Changes in the top affected class Item_func_case_expression:

- item_func.h:
  Overriding Item_func_case_expression::check_arguments() to return false,
  without checking any arguments. Descendant validate arguments
  in a various different ways. No needs to block all non-scalar data type at
  this level, to prevent disallowing associative arrays.

Changes in descendants:

- item_cmpfunc.cc:
  Adding a test in Item_func_case_simple::aggregate_switch_and_when_arguments()
  preventing passing ROW_RESULT expression in predicant and WHEN in a
  simple CASE:
    CASE predicant WHEN when1 THEN .. WHEN when2 THEN .. END;
  This is not supported yet. Should be preferrably fixed before MDEV-34319.

- item_cmpfunc.cc:
  Calling args[0]->type_handler()->Item_hybrid_func_fix_attributes()
  from Item_func_nullif::fix_length_and_dec().
  This prevents a ROW expression to be passed to args[0] of NULLIF().
  But will allow to pass associative arrays.

  args[1] is still only checked to be comparable with args[0].
  No needs to add additional tests for it.

- item_cmpfunc.h:
  Adding a call for Item_hybrid_func_fix_attributes() in
  Item_func_case_abbreviation2::cache_type_info().
  This prevents calling the descendant functions with
  a ROW expression in combination with an explicit NULL
  in the THEN-style arguments (but will allow to pass associative arrays):

    IFNULL(row_expression, NULL)
    IFNULL(NULL, row_expression)
    IF(switch, row_expression, NULL)
    IF(switch, NULL, row_expression)
    NVL2(switch, row_expression, NULL)
    NVL2(switch, NULL, row_expression)
  Adding a THD* argument into involved methods.

- item_cmpfunc.h:
  Overriding Item_func_case_abbreviation2_switch::check_arguments() to
  check that the first argument in IF() and NVL2() can return bool.
  Removing Item_func_if::check_arguments(), as it become redundant.

- sql_type.cc:
  Fixing sql_type.cc not to disallow items[0] with ROW_RESULT.
  This makes it call Item_hybrid_func_fix_attributes() at the end,
  which block ROW arguments into THEN-style arguments of hybrid functions.
  But this will allow to pass Type_handler_assoc_array expressions.

- sql_type.cc:
  Changing Type_handler_row::Item_hybrid_func_fix_attributes to raise the
  ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION error instead of the DBUG_ASSERT.
2025-05-05 19:44:04 +04:00
..
anonymous_derived.test MDEV-19162 anonymous derived tables part 2020-11-17 20:11:39 +01:00
binlog_ptr_mysqlbinlog-master.opt MDEV-23108: Point in time recovery of binary log fails when sql_mode=ORACLE 2020-07-22 11:34:50 +05:30
binlog_ptr_mysqlbinlog.test Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
binlog_stm_ps.test
binlog_stm_sp.test
binlog_stm_sp_package.test
column_compression.test MDEV-19123 Change default charset from latin1 to utf8mb4 2024-07-11 10:21:07 +04:00
custom_aggregate_functions.test
empty_string_literal.test
events.test fix tests for embedded 2022-05-18 01:22:29 +02:00
exception.test Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
func_add_months.test MDEV-20025: ADD_MONTHS() Oracle function 2021-05-19 22:54:12 +02:00
func_case.test
func_concat.test MDEV-31910 ASAN memcpy-param-overlap upon CONCAT in ORACLE mode 2024-11-06 11:39:50 +04:00
func_decode.test MDEV-31184 Remove parser tokens DECODE_MARIADB_SYM and DECODE_ORACLE_SYM 2023-10-24 01:45:47 +04:00
func_length.test
func_misc.test
func_pad.test
func_qualified.test MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode 2024-01-24 10:59:17 +04:00
func_regexp_replace.test MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode 2024-01-24 10:59:17 +04:00
func_replace.test
func_substr.test
func_time.test
func_to_char.test MDEV-29152: Assertion failed ... upon TO_CHAR with wrong argument 2023-07-12 12:05:59 +03:00
func_trim.test
gis-debug.test
gis.test
information_schema_parameters.test
keywords.test
lower_case_table_names.opt MDEV-31340 Remove MY_COLLATION_HANDLER::strcasecmp() 2024-04-18 15:22:10 +04:00
lower_case_table_names.test MDEV-31340 Remove MY_COLLATION_HANDLER::strcasecmp() 2024-04-18 15:22:10 +04:00
minus.test MDEV-20021 sql_mode="oracle" does not support MINUS set operator 2021-05-19 22:54:12 +02:00
misc.test An additional patch for MDEV-27690 Crash on CHARACTER SET csname COLLATE DEFAULT in column definition 2022-04-14 12:22:28 +04:00
mysqldump_restore.test
mysqldump_restore_func_qualified.test MDEV-32250 Enable --no-autocommit by default in mysqldump 2024-12-03 20:25:04 +05:30
parser.test Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
plugin.test
ps.test MDEV-20634 Report disallowed subquery errors as such (instead of parse error) 2019-09-20 10:36:20 +04:00
rpl_mariadb_date.test MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode 2020-08-01 07:43:50 +04:00
rpl_sp_package.test
rpl_sp_package_variables.test
sequence.test MDEV-31003: Second execution for ps-protocol 2023-07-26 17:15:00 +07:00
sp-anchor-row-type-table.test MDEV-12252 ROW data type for stored function return values 2024-10-21 07:59:29 +04:00
sp-anchor-type.test MDEV-12252 ROW data type for stored function return values 2024-10-21 07:59:29 +04:00
sp-anonymous.test
sp-cache-invalidate.inc
sp-code.test MDEV-10862: Stored procedures: default values for parameters (optional parameters) 2025-01-31 19:42:04 +04:00
sp-cursor-decl.test
sp-cursor-pkg-01.inc MDEV-36047 Package body variables are not allowed as FETCH targets 2025-02-09 13:56:19 +04:00
sp-cursor-pkg-02.inc MDEV-36047 Package body variables are not allowed as FETCH targets 2025-02-09 13:56:19 +04:00
sp-cursor-pkg-03.inc MDEV-36047 Package body variables are not allowed as FETCH targets 2025-02-09 13:56:19 +04:00
sp-cursor-rowtype.test MDEV-21998: Server crashes in st_select_lex::add_table_to_list upon mix of KILL and sequences 2020-07-28 08:23:57 +02:00
sp-cursor.test Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
sp-default-param.test MDEV-10862: Stored procedures: default values for parameters (optional parameters) 2025-01-31 19:42:04 +04:00
sp-expr.test
sp-goto-debug.test MDEV-20667 Server crash on pop_cursor 2019-12-12 16:25:16 +04:00
sp-goto.test Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
sp-inout.test MDEV-33616 Tests failing on macOS 2024-04-24 08:44:24 -04:00
sp-memory-leak.test MDEV-26186 280 Bytes lost in mysys/array.c, mysys/hash.c, sql/sp.cc, sql/sp.cc, sql/item_create.cc, sql/item_create.cc, sql/sql_yacc.yy:10748 when using oracle sql_mode 2023-07-18 12:19:16 +04:00
sp-package-code.test MDEV-36047 Package body variables are not allowed as FETCH targets 2025-02-09 13:56:19 +04:00
sp-package-concurrent-dml-db.test
sp-package-concurrent-dml-package.test
sp-package-concurrent-dml-trigger.test
sp-package-concurrent-dml-view.test
sp-package-concurrent-dml.inc
sp-package-i_s.test MDEV-30662 SQL/PL package body does not appear in I_S.ROUTINES.ROUTINE_DEFINITION 2023-07-14 13:26:26 +04:00
sp-package-innodb.test MDEV-16708: fix in test failures(added --enable_prepared_warnings/--disable_prepared_warnings) 2021-06-17 19:30:24 +02:00
sp-package-mdl.test
sp-package-mysqldump.test
sp-package-security.test
sp-package.test MDEV-36067 Assertion failure in TABLE_SHARE::init_from_sql_statement_string 2025-04-18 09:41:23 +02:00
sp-param.inc
sp-param.test MDEV-35229 NOCOPY has become reserved word bringing wide incompatibility 2024-10-30 13:58:20 +04:00
sp-record.test MDEV-34317: Implement RECORD type 2025-01-28 09:23:04 +04:00
sp-row-vs-var.inc
sp-row.test MDEV-36716 A case expression with ROW arguments in THEN crashes 2025-05-05 19:44:04 +04:00
sp-security.test
sp-sys_refcursor-alias.test MDEV-20034 Add support for the pre-defined weak SYS_REFCURSOR 2025-04-19 10:59:58 +04:00
sp-sys_refcursor-func_hybrid.test MDEV-20034 Add support for the pre-defined weak SYS_REFCURSOR 2025-04-19 10:59:58 +04:00
sp-sys_refcursor.test MDEV-20034 Add support for the pre-defined weak SYS_REFCURSOR 2025-04-19 10:59:58 +04:00
sp.test Fix typos in mysql-test/ 2025-04-29 13:53:16 +10:00
statement-expr.test MDEV-20634 Report disallowed subquery errors as such (instead of parse error) 2019-09-20 10:36:20 +04:00
table_value_constr.test Update row and key fetch cost models to take into account data copy costs 2023-02-02 21:43:30 +03:00
trigger.test
truncate.test
type_blob.test
type_clob.test
type_date.test MDEV-12252 ROW data type for stored function return values 2024-10-21 07:59:29 +04:00
type_number.test
type_raw.test
type_varchar.test
type_varchar2.test
update.test MDEV-27769 Assertion failed in Field::ptr_in_record upon UPDATE in ORACLE mode 2025-01-26 16:15:46 +01:00
update_innodb.test Merge 10.5 into 10.6 2024-10-03 09:31:39 +03:00
variables.test
vcol.test
vcol_innodb.test MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE 2023-11-08 15:01:20 +04:00
versioning.test
win.test