diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 21a69aa51087498cd3972c0ef2e5214c14e3b7c1..ac09606849dad5243f8c5ebe928939d4070dd701 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -826,7 +826,6 @@ likeFunc(sql_context *context, int argc, sql_value **argv) sql *db = sql_context_db_handle(context); int is_like_ci = SQL_PTR_TO_INT(sql_user_data(context)); -#ifdef SQL_LIKE_DOESNT_MATCH_BLOBS if (sql_value_type(argv[0]) == SQL_BLOB || sql_value_type(argv[1]) == SQL_BLOB) { #ifdef SQL_TEST @@ -835,7 +834,6 @@ likeFunc(sql_context *context, int argc, sql_value **argv) sql_result_int(context, 0); return; } -#endif const char *zB = (const char *) sql_value_text(argv[0]); const char *zA = (const char *) sql_value_text(argv[1]); const char *zB_end = zB + sql_value_bytes(argv[0]); diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index eb148857681fd238b8fd965b20eec3a42059646d..c63ff1cff2179fcd8eb845b51d06c90687c914c9 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -291,8 +291,6 @@ void sqlCoverage(int); */ #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0) -#define SQL_LIKE_DOESNT_MATCH_BLOBS - #include "hash.h" #include "parse.h" #include <stdio.h> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index c1da9a4aab66597877158d82ba364718ca1521f8..d66fdd1f320768ea0131f7c151d49c011aa6b52e 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -1201,14 +1201,6 @@ case OP_String: { /* out2 */ pOut->z = pOp->p4.z; pOut->n = pOp->p1; UPDATE_MAX_BLOBSIZE(pOut); -#ifndef SQL_LIKE_DOESNT_MATCH_BLOBS - if (pOp->p3>0) { - assert(pOp->p3<=(p->nMem+1 - p->nCursor)); - pIn3 = &aMem[pOp->p3]; - assert(pIn3->flags & MEM_Int); - if (pIn3->u.i==pOp->p5) pOut->flags = MEM_Blob|MEM_Static|MEM_Term; - } -#endif break; } diff --git a/src/box/sql/where.c b/src/box/sql/where.c index 5a3c9be1a5eda420341f4c30e6e322b75055fdb0..b46b7c31529c0a9d6facafb8771ac8d77a84a71d 100644 --- a/src/box/sql/where.c +++ b/src/box/sql/where.c @@ -4778,14 +4778,6 @@ sqlWhereEnd(WhereInfo * pWInfo) sqlVdbeJumpHere(v, pLevel->addrSkip); sqlVdbeJumpHere(v, pLevel->addrSkip - 2); } -#ifndef SQL_LIKE_DOESNT_MATCH_BLOBS - if (pLevel->addrLikeRep) { - sqlVdbeAddOp2(v, OP_DecrJumpZero, - (int)(pLevel->iLikeRepCntr >> 1), - pLevel->addrLikeRep); - VdbeCoverage(v); - } -#endif if (pLevel->iLeftJoin) { int ws = pLoop->wsFlags; addr = diff --git a/src/box/sql/whereInt.h b/src/box/sql/whereInt.h index 1f4b22abb4243cfa1b5da34faa61635f4790e52a..47430aef17b93b9658ce723a2faf3bee0516d205 100644 --- a/src/box/sql/whereInt.h +++ b/src/box/sql/whereInt.h @@ -86,10 +86,6 @@ struct WhereLevel { int addrCont; /* Jump here to continue with the next loop cycle */ int addrFirst; /* First instruction of interior of the loop */ int addrBody; /* Beginning of the body of this loop */ -#ifndef SQL_LIKE_DOESNT_MATCH_BLOBS - u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */ - int addrLikeRep; /* LIKE range processing address */ -#endif u8 iFrom; /* Which entry in the FROM clause */ u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */ int p1, p2; /* Operands of the opcode used to ends the loop */ diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c index 018fd8a28c9d1b93824a87b696e124b3bb87f7c1..f7b604f6abae750518632faebafbbe63cbfaa56d 100644 --- a/src/box/sql/wherecode.c +++ b/src/box/sql/wherecode.c @@ -785,44 +785,6 @@ codeAllEqualityTerms(Parse * pParse, /* Parsing context */ return regBase; } -#ifndef SQL_LIKE_DOESNT_MATCH_BLOBS -/* - * If the most recently coded instruction is a constant range constraint - * (a string literal) that originated from the LIKE optimization, then - * set P3 and P5 on the OP_String opcode so that the string will be cast - * to a BLOB at appropriate times. - * - * The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range - * expression: "x>='ABC' AND x<'abd'". But this requires that the range - * scan loop run twice, once for strings and a second time for BLOBs. - * The OP_String opcodes on the second pass convert the upper and lower - * bound string constants to blobs. This routine makes the necessary changes - * to the OP_String opcodes for that to happen. - * - * Except, of course, if SQL_LIKE_DOESNT_MATCH_BLOBS is defined, then - * only the one pass through the string space is required, so this routine - * becomes a no-op. - */ -static void -whereLikeOptimizationStringFixup(Vdbe * v, /* prepared statement under construction */ - WhereLevel * pLevel, /* The loop that contains the LIKE operator */ - WhereTerm * pTerm) /* The upper or lower bound just coded */ -{ - if (pTerm->wtFlags & TERM_LIKEOPT) { - VdbeOp *pOp; - assert(pLevel->iLikeRepCntr > 0); - pOp = sqlVdbeGetOp(v, -1); - assert(pOp != 0); - assert(pOp->opcode == OP_String8 - || pTerm->pWC->pWInfo->pParse->db->mallocFailed); - pOp->p3 = (int)(pLevel->iLikeRepCntr >> 1); /* Register holding counter */ - pOp->p5 = (u8) (pLevel->iLikeRepCntr & 1); /* ASC or DESC */ - } -} -#else -#define whereLikeOptimizationStringFixup(A,B,C) -#endif - /* * If the expression passed as the second argument is a vector, generate * code to write the first nReg elements of the vector into an array @@ -1056,29 +1018,6 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W if (pLoop->wsFlags & WHERE_TOP_LIMIT) { pRangeEnd = pLoop->aLTerm[j++]; nExtraReg = MAX(nExtraReg, pLoop->nTop); -#ifndef SQL_LIKE_DOESNT_MATCH_BLOBS - if ((pRangeEnd->wtFlags & TERM_LIKEOPT) != 0) { - assert(pRangeStart != 0); /* LIKE opt constraints */ - assert(pRangeStart->wtFlags & TERM_LIKEOPT); /* occur in pairs */ - pLevel->iLikeRepCntr = (u32)++ pParse->nMem; - sqlVdbeAddOp2(v, OP_Integer, 1, - (int)pLevel->iLikeRepCntr); - VdbeComment((v, "LIKE loop counter")); - pLevel->addrLikeRep = sqlVdbeCurrentAddr(v); - /* iLikeRepCntr actually stores 2x the counter register number. The - * bottom bit indicates whether the search order is ASC or DESC. - */ - testcase(bRev); - testcase(pIdx->aSortOrder[nEq] == - SORT_ORDER_DESC); - assert((bRev & ~1) == 0); - struct key_def *def = idx_def->key_def; - pLevel->iLikeRepCntr <<= 1; - pLevel->iLikeRepCntr |= - bRev ^ (def->parts[nEq].sort_order == - SORT_ORDER_DESC); - } -#endif if (pRangeStart == 0) { j = idx_def->key_def->parts[nEq].fieldno; if (is_format_set && @@ -1133,8 +1072,6 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W Expr *pRight = pRangeStart->pExpr->pRight; codeExprOrVector(pParse, pRight, regBase + nEq, nBtm); - whereLikeOptimizationStringFixup(v, pLevel, - pRangeStart); if ((pRangeStart->wtFlags & TERM_VNULL) == 0 && sqlExprCanBeNull(pRight)) { sqlVdbeAddOp2(v, OP_IsNull, regBase + nEq, @@ -1232,7 +1169,6 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W Expr *pRight = pRangeEnd->pExpr->pRight; sqlExprCacheRemove(pParse, regBase + nEq, 1); codeExprOrVector(pParse, pRight, regBase + nEq, nTop); - whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); if ((pRangeEnd->wtFlags & TERM_VNULL) == 0 && sqlExprCanBeNull(pRight)) { sqlVdbeAddOp2(v, OP_IsNull, regBase + nEq, @@ -1672,16 +1608,7 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo, /* Complete information about the W * for strings. So do not skip the call to the function on the pass * that compares BLOBs. */ -#ifdef SQL_LIKE_DOESNT_MATCH_BLOBS continue; -#else - u32 x = pLevel->iLikeRepCntr; - assert(x > 0); - skipLikeAddr = - sqlVdbeAddOp1(v, (x & 1) ? OP_IfNot : OP_If, - (int)(x >> 1)); - VdbeCoverage(v); -#endif } sqlExprIfFalse(pParse, pE, addrCont, SQL_JUMPIFNULL); if (skipLikeAddr)