[Tarantool-patches] [PATCH v1 8/8] sql: refactor LIKE() function
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sat Oct 9 01:02:35 MSK 2021
Thanks for the patch!
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index 1b4d52225..27106ced6 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -1281,46 +1281,28 @@ likeFunc(sql_context *context, int argc, struct Mem *argv)
> {
> u32 escape = SQL_END_OF_STRING;
> int nPat;
> - if (argc != 2 && argc != 3) {
> - diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT,
> - "LIKE", "2 or 3", argc);
> - context->is_aborted = true;
> - return;
> - }
> - sql *db = sql_context_db_handle(context);
> - int rhs_type = sql_value_type(&argv[0]);
> - int lhs_type = sql_value_type(&argv[1]);
> -
> - if (lhs_type != MP_STR || rhs_type != MP_STR) {
> - if (lhs_type == MP_NIL || rhs_type == MP_NIL)
> - return;
> - const char *str = rhs_type != MP_STR ?
> - mem_str(&argv[0]) : mem_str(&argv[1]);
> - diag_set(ClientError, ER_INCONSISTENT_TYPES, "string", str);
> - context->is_aborted = true;
> + assert(argc == 2 || argc == 3);
> + struct sql *db = sql_context_db_handle(context);
You can get the db after the is_null check below. It is not
used when the check passes.
> + if (mem_is_any_null(&argv[0], &argv[1]))
> return;
More information about the Tarantool-patches
mailing list