From 6ab1b829a084005dbad747c3f31af2411107585c Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Mon, 12 Oct 2020 15:20:49 +0000 Subject: [PATCH] MCOL-4334 Enable Select Handler for queries run inside Stored Procedures There is another session variable to enable/disable SH in SP --- dbcon/mysql/ha_mcs_pushdown.cpp | 9 ++------- dbcon/mysql/ha_mcs_sysvars.cpp | 20 ++++++++++++++++++++ dbcon/mysql/ha_mcs_sysvars.h | 3 +++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index ca6d52a11..450424c01 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -747,13 +747,8 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) // Check the session variable value to enable/disable use of // select_handler - if (!get_select_handler(thd)) - { - return handler; - } - - // Disable SP support in the select_handler for now. - if ((thd->lex)->sphead) + if (!get_select_handler(thd) || + ((thd->lex)->sphead && !get_select_handler_in_stored_procedures(thd))) { return handler; } diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index eb1c1c531..02f89ab50 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -98,6 +98,15 @@ static MYSQL_THDVAR_BOOL( 1 ); +static MYSQL_THDVAR_BOOL( + select_handler_in_stored_procedures, + PLUGIN_VAR_NOCMDARG, + "Enable/Disable the MCS select_handler for Stored Procedures", + NULL, + NULL, + 1 +); + static MYSQL_THDVAR_UINT( orderby_threads, PLUGIN_VAR_RQCMDARG, @@ -332,6 +341,7 @@ st_mysql_sys_var* mcs_system_variables[] = MYSQL_SYSVAR(select_handler), MYSQL_SYSVAR(derived_handler), MYSQL_SYSVAR(group_by_handler), + MYSQL_SYSVAR(select_handler_in_stored_procedures), MYSQL_SYSVAR(orderby_threads), MYSQL_SYSVAR(decimal_scale), MYSQL_SYSVAR(use_decimal_scale), @@ -419,6 +429,16 @@ void set_group_by_handler(THD* thd, bool value) THDVAR(thd, group_by_handler) = value; } +bool get_select_handler_in_stored_procedures(THD* thd) +{ + return ( thd == NULL ) ? true : + THDVAR(thd, select_handler_in_stored_procedures); +} +void set_select_handler_in_stored_procedures(THD* thd, bool value) +{ + THDVAR(thd, select_handler_in_stored_procedures) = value; +} + void set_compression_type(THD* thd, ulong value) { THDVAR(thd, compression_type) = value; diff --git a/dbcon/mysql/ha_mcs_sysvars.h b/dbcon/mysql/ha_mcs_sysvars.h index ffb9f2fae..1bb01307f 100644 --- a/dbcon/mysql/ha_mcs_sysvars.h +++ b/dbcon/mysql/ha_mcs_sysvars.h @@ -62,6 +62,9 @@ void set_derived_handler(THD* thd, bool value); bool get_group_by_handler(THD* thd); void set_group_by_handler(THD* thd, bool value); +bool get_select_handler_in_stored_procedures(THD* thd); +void set_select_handler_in_stored_procedures(THD* thd, bool value); + uint get_orderby_threads(THD* thd); void set_orderby_threads(THD* thd, uint value);