Commit d6220164 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-29447 WIP Refactor spider_db_mbase_util::open_item_func

WIP: incorporating comments from
https://lists.launchpad.net/maria-developers/msg13283.html

spider_db_mbase_util::open_item_func() is a monster function.
It is difficult to maintain while it is expected that we need to
modify it when a new SQL function or a new func_type is added.

We split the function into two distinct functions: one handles the
case of str != NULL and the other handles the case of str == NULL.

This refactoring was done in a conservative way because we do not
have comprehensive tests on the function.

It also fixes a problem (MDEV-29447) where field items that are
arguments of a func item may be used before created / initialised.

Note this commit is a port of
3836098c (MDEV-26285) to current
versions 10.3+.
Signed-off-by: default avatarYuchen Pei <yuchen.pei@mariadb.com>
parent e51a1d6f
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
--echo #
--echo # MDEV-29447 SIGSEGV in spider_db_open_item_field and SIGSEGV spider_db_print_item_type, on SELECT
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
--connection child2_1
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
eval CREATE TABLE tbl_a (
a INT
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
--connection master_1
CREATE DATABASE auto_test_local;
USE auto_test_local;
eval CREATE TABLE tbl_a (
a INT
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"';
SELECT TRIM(LEADING 'c' FROM a) FROM tbl_a;
--connection child2_1
DROP DATABASE auto_test_remote;
--connection master_1
DROP DATABASE auto_test_local;
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_query_log
--enable_result_log
This diff is collapsed.
......@@ -99,6 +99,25 @@ class spider_db_mbase_util: public spider_db_util
bool use_fields,
spider_fields *fields
);
protected:
int check_item_func(
Item_func *item_func,
ha_spider *spider,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
int print_item_func(
Item_func *item_func,
ha_spider *spider,
spider_string *str,
const char *alias,
uint alias_length,
bool use_fields,
spider_fields *fields
);
public:
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
int open_item_sum_func(
Item_sum *item_sum,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment