MDEV-10991: Server crashes in spider_udf_direct_sql_create_conn - tests in spider/oracle* suites crash the server

The crash occurs due to code that is #ifdef'd out with HAVE_ORACLE_OCI that
pertains to the use of Spider with an Oracle data tier. Enabling this code
eliminates the crash.

The reason that MariaDB needs to support Oracle storage at the data tier is
to help customers migrate from Oracle. It is necessary to build Spider with
the additional build flag -DHAVE_ORACLE_OCI, and install and start Oracle
before running the Oracle test suite or any tests within it. Nevertheless,
if Spider is built normally and Oracle has not been started, these tests
should not cause the MariaDB server to crash. The bug fix replaces the
crash with the following error:
  ERROR 12501 (HY000) at line 4: The connect info 'ORACLE' is invalid

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.
This commit is contained in:
Jacob Mathew 2018-03-19 12:49:22 -07:00
commit 7cf2428db3
2 changed files with 21 additions and 1 deletions

View file

@ -29,6 +29,10 @@
#endif
#ifdef HAVE_ORACLE_OCI
#if (defined(WIN32) || defined(_WIN32) || defined(WINDOWS) || defined(_WINDOWS))
#include <Shlwapi.h>
#define strcasestr StrStr
#endif
#include <oci.h>
#include "spd_err.h"
#include "spd_param.h"
@ -3817,7 +3821,7 @@ int spider_db_oracle_util::open_item_func(
{
Item_func_conv_charset *item_func_conv_charset =
(Item_func_conv_charset *)item_func;
CHARSET_INFO *conv_charset = item_func_conv_charset->conv_charset;
CHARSET_INFO *conv_charset = item_func_conv_charset->collation.collation;
uint cset_length = strlen(conv_charset->csname);
if (str->reserve(SPIDER_SQL_USING_LEN + cset_length))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);

View file

@ -371,6 +371,14 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
if (direct_sql->access_mode == 0)
{
#endif
if (direct_sql->dbton_id == SPIDER_DBTON_SIZE)
{
/* Invalid target wrapper */
*error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM;
my_printf_error(*error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), direct_sql->tgt_wrapper);
goto error_alloc_conn;
}
if (!(conn = (SPIDER_CONN *)
spider_bulk_malloc(spider_current_trx, 32, MYF(MY_WME | MY_ZEROFILL),
&conn, sizeof(*conn),
@ -398,6 +406,14 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
conn->default_database.init_calc_mem(138);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
if (direct_sql->dbton_id == SPIDER_DBTON_SIZE)
{
/* Invalid target wrapper */
*error_num = ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM;
my_printf_error(*error_num, ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR,
MYF(0), direct_sql->tgt_wrapper);
goto error_alloc_conn;
}
if (!(conn = (SPIDER_CONN *)
spider_bulk_malloc(spider_current_trx, 33, MYF(MY_WME | MY_ZEROFILL),
&conn, sizeof(*conn),