mariadb/include
Alexander Barkov 2b6d241ee4 MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE
The crash happened with an indexed virtual column whose
value is evaluated using a function that has a different meaning
in sql_mode='' vs sql_mode=ORACLE:

- DECODE()
- LTRIM()
- RTRIM()
- LPAD()
- RPAD()
- REPLACE()
- SUBSTR()

For example:

CREATE TABLE t1 (
  b VARCHAR(1),
  g CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL,
  KEY g(g)
);

So far we had replacement XXX_ORACLE() functions for all mentioned function,
e.g. SUBSTR_ORACLE() for SUBSTR(). So it was possible to correctly re-parse
SUBSTR_ORACLE() even in sql_mode=''.

But it was not possible to re-parse the MariaDB version of SUBSTR()
after switching to sql_mode=ORACLE. It was erroneously mis-interpreted
as SUBSTR_ORACLE().

As a result, this combination worked fine:

SET sql_mode=ORACLE;
CREATE TABLE t1 ... g CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL, ...;
INSERT ...
FLUSH TABLES;
SET sql_mode='';
INSERT ...

But the other way around it crashed:

SET sql_mode='';
CREATE TABLE t1 ... g CHAR(1) GENERATED ALWAYS AS (SUBSTR(b,0,0)) VIRTUAL, ...;
INSERT ...
FLUSH TABLES;
SET sql_mode=ORACLE;
INSERT ...

At CREATE time, SUBSTR was instantiated as Item_func_substr and printed
in the FRM file as substr(). At re-open time with sql_mode=ORACLE, "substr()"
was erroneously instantiated as Item_func_substr_oracle.

Fix:

The fix proposes a symmetric solution. It provides a way to re-parse reliably
all sql_mode dependent functions to their original CREATE TABLE time meaning,
no matter what the open-time sql_mode is.

We take advantage of the same idea we previously used to resolve sql_mode
dependent data types.

Now all sql_mode dependent functions are printed by SHOW using a schema
qualifier when the current sql_mode differs from the function sql_mode:

SET sql_mode='';
CREATE TABLE t1 ... SUBSTR(a,b,c) ..;
SET sql_mode=ORACLE;
SHOW CREATE TABLE t1;   ->   mariadb_schema.substr(a,b,c)

SET sql_mode=ORACLE;
CREATE TABLE t2 ... SUBSTR(a,b,c) ..;
SET sql_mode='';
SHOW CREATE TABLE t1;   ->   oracle_schema.substr(a,b,c)

Old replacement names like substr_oracle() are still understood for
backward compatibility and used in FRM files (for downgrade compatibility),
but they are not printed by SHOW any more.
2023-11-08 15:01:20 +04:00
..
atomic MDEV-19696 - Cleanup gcc sync builtins 2019-07-03 12:11:22 +03:00
mysql MDEV-27295 Backport SQL service, introduced by MDEV-19275. 2023-11-05 23:35:32 +04:00
aria_backup.h
big_endian.h
byte_order_generic.h Fix all warnings given by UBSAN 2021-04-20 12:30:09 +03:00
byte_order_generic_x86.h Fix all warnings given by UBSAN 2021-04-20 12:30:09 +03:00
byte_order_generic_x86_64.h typo fixed. HAVE_mi_uint8korr 2023-11-02 19:42:39 +11:00
CMakeLists.txt post fix for "move alloca() definition from all *.h files to one new header file" 2023-03-08 17:36:36 +01:00
decimal.h
dur_prop.h
errmsg.h test cases for MySQL bugs 2022-01-21 16:02:34 +01:00
ft_global.h MDEV-23269 SIGSEGV in ft_boolean_check_syntax_string on setting ft_boolean_syntax 2021-10-11 17:43:23 +04:00
handler_ername.h MDEV-26258 Various crashes/asserts/corruptions when Aria encryption is enabled/used, but the encryption plugin is not loaded 2023-05-02 23:37:10 +03:00
handler_state.h
hash.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
heap.h header typos 2022-12-20 08:55:48 +11:00
ilist.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
json_lib.h MDEV-23187: Assorted assertion failures in json_find_path with certain 2023-05-16 01:52:16 +05:30
keycache.h
lf.h Shrink my_atomic.h and my_cpu.h scope 2020-04-15 22:23:03 +04:00
little_endian.h
m_ctype.h MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE 2023-11-08 15:01:20 +04:00
m_string.h Avoid triggering stringop-truncation warning in safe_strcpy 2023-07-20 15:20:56 +01:00
ma_dyncol.h header typos 2022-12-20 08:55:48 +11:00
maria.h MDEV-20001 Potential dangerous regression: INSERT INTO >=100 rows fail for myisam table with HASH indexes 2020-02-03 12:44:31 +05:30
mariadb_capi_rename.h MDEV-27295 Backport SQL service, introduced by MDEV-19275. 2023-11-05 23:35:32 +04:00
my_alarm.h Fix warning with signal typedef for *BSD 2022-10-31 09:28:17 +11:00
my_alloc.h MDEV-14959: Control over memory allocated for SP/PS 2023-09-02 13:00:00 +07:00
my_alloca.h alloca() fix 2023-04-13 21:47:56 +08:00
my_atomic.h MDEV-17441 fixup: Remove unused my_atomic long macros 2022-03-24 09:53:52 +02:00
my_atomic_wrapper.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
my_attribute.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
my_base.h MDEV-31400 Simple plugin dependency resolution 2023-07-25 18:24:20 +10:00
my_bit.h Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
my_bitmap.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
my_byteorder.h Fix all warnings given by UBSAN 2021-04-20 12:30:09 +03:00
my_check_opt.h
my_compare.h MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB 2023-10-24 03:35:48 +04:00
my_compiler.h Merge 10.2 into 10.3 2020-06-05 16:51:26 +03:00
my_context.h Xcode compatibility update 2021-10-12 18:10:56 -04:00
my_counter.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
my_cpu.h MDEV-23633 fixup: Add missing semicolon 2020-09-04 11:40:17 +03:00
my_crypt.h
my_dbug.h MDEV-29613 Improve WITH_DBUG_TRACE=OFF 2022-09-23 13:40:42 +03:00
my_decimal_limits.h header typos 2022-12-20 08:55:48 +11:00
my_default.h
my_dir.h header typos 2022-12-20 08:55:48 +11:00
my_getopt.h MDEV-18215: mariabackup does not report unknown command line options 2020-06-14 13:23:07 +03:00
my_global.h move alloca() definition from all *.h files to one new header file 2023-03-07 03:15:54 +01:00
my_handler_errors.h MDEV-26258 Various crashes/asserts/corruptions when Aria encryption is enabled/used, but the encryption plugin is not loaded 2023-05-02 23:37:10 +03:00
my_libwrap.h
my_list.h
my_md5.h
my_minidump.h MDEV-11499 mysqltest, Windows : improve diagnostics if server fails to shutdown 2021-09-24 11:49:28 +02:00
my_net.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
my_nosys.h
my_pthread.h Merge 10.3 into 10.4 2021-10-28 08:28:39 +03:00
my_rdtsc.h header typos 2022-12-20 10:23:42 +11:00
my_rnd.h
my_service_manager.h
my_stacktrace.h Merge 10.2 into 10.3 2020-08-20 09:12:16 +03:00
my_sys.h MDEV-381: fdatasync() does not correctly flush growing binlog file 2023-08-10 19:52:04 +02:00
my_time.h Merge 10.3 into 10.4 2022-04-06 08:59:09 +03:00
my_tree.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
my_uctype.h
my_user.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
my_valgrind.h MDEV-20377 post-fix: Introduce MEM_MAKE_ADDRESSABLE 2020-07-02 17:59:28 +03:00
my_xml.h
myisam.h Merge 10.3 into 10.4 2023-01-03 16:10:02 +02:00
myisamchk.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
myisammrg.h Merge 10.3 into 10.4 2023-01-03 16:10:02 +02:00
myisampack.h MDEV-29473 UBSAN: Signed integer overflow: X * Y cannot be represented in type 'int' in strings/dtoa.c 2022-11-17 17:51:01 +04:00
mysql.h MDEV-27595 Backport SQL service, introduced by MDEV-19275. 2023-11-05 23:35:31 +04:00
mysql_async.h
mysql_com.h Remove CLIENT_SSL_VERIFY_SERVER_CERT 2023-07-23 19:23:51 +02:00
mysql_com_server.h
mysql_embed.h Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
mysql_time.h
mysql_version.h.in Merge 10.3 into 10.4 2020-10-29 13:38:38 +02:00
mysqld_default_groups.h Fixed that mariadb-# binaries reads their corresponding entry from my.cnf 2019-07-18 15:32:22 +03:00
mysys_err.h
no_valgrind_without_big.inc MDEV-31893 Valgrind reports issues in main.join_cache_notasan 2023-08-10 17:35:37 +03:00
pack.h
password.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
probes_mysql.d.base
probes_mysql.h
probes_mysql_nodtrace.h.in
queues.h header typos 2022-12-20 08:55:48 +11:00
rijndael.h
scope.h MDEV-18543 IMPORT TABLESPACE fails after instant DROP COLUMN 2021-10-26 22:50:58 +06:00
service_versions.h MDEV-27595 Backport SQL service, introduced by MDEV-19275. 2023-11-05 23:35:31 +04:00
source_revision.h.in
span.h Apply clang-tidy to remove empty constructors / destructors 2023-02-09 16:09:08 +02:00
sql_common.h MDEV-27595 Backport SQL service, introduced by MDEV-19275. 2023-11-05 23:35:31 +04:00
ssl_compat.h Adjust OpenSSL context sizes for CiscoSSL 2023-06-22 15:26:23 +02:00
sslopt-case.h Merge 10.3 into 10.4 2019-12-13 17:30:37 +02:00
sslopt-longopts.h MDEV-29817: Issues with handling options for SSL CRLs (and some others) 2022-11-22 15:16:12 +01:00
sslopt-vars.h MDEV-14101 Provide an option to select TLS protocol version 2019-06-17 12:26:25 +02:00
t_ctype.h
thr_alarm.h
thr_lock.h MDEV-20848 Fixes for MTR test galera_sr.GCF-1060 (#1421) 2019-12-04 09:21:14 +02:00
thr_timer.h
thread_pool_priv.h Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
typelib.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
violite.h Merge 10.3 into 10.4 2020-08-10 21:08:46 +03:00
waiting_threads.h header typos 2022-12-20 08:55:48 +11:00
welcome_copyright_notice.h
wqueue.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
wsrep.h Reduce compilation dependencies on wsrep_mysqld.h 2022-08-31 11:05:23 +03:00