1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-24517: JSON_EXTRACT as conditions triggers syntax error on Spider (#1839)

The `item_func::JSON_EXTRACT_FUNC` was not handled correctly in the previous
versions on the Spider storage engine, which makes queries like
`SELECT * FROM t1 WHERE json_extract(jdoc, '$.Age')=20`
failed with syntax error.

This patch writes specific code to handle JSON_EXTRACT in the Spider Storage
Engine and fix that bug.
This commit is contained in:
Yongxin Xu
2021-07-23 22:36:27 +08:00
committed by GitHub
parent dba7cd25e1
commit 73d32cc100
6 changed files with 230 additions and 0 deletions

View File

@@ -5084,6 +5084,23 @@ int spider_db_mbase_util::open_item_func(
#else
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
#endif
case Item_func::JSON_EXTRACT_FUNC:
func_name = (char*) item_func->func_name();
func_name_length = strlen(func_name);
if (str)
{
if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(func_name, func_name_length);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
}
func_name = SPIDER_SQL_COMMA_STR;
func_name_length = SPIDER_SQL_COMMA_LEN;
separator_str = SPIDER_SQL_COMMA_STR;
separator_str_length = SPIDER_SQL_COMMA_LEN;
last_str = SPIDER_SQL_CLOSE_PAREN_STR;
last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN;
break;
default:
THD *thd = spider->trx->thd;
SPIDER_SHARE *share = spider->share;