It seems that we have a mess here. How would we overload/replace the "like" function with things like this done internally by sqlite without public documentaion ?
Also I do not see a setting of SQLITE_DETERMINISTIC isn't like deterministic ? Cheers ! /* ** Set the LIKEOPT flag on the 2-argument function with the given name. */ static void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){ ? FuncDef *pDef; ? pDef = sqlite3FindFunction(db, zName, 2, SQLITE_UTF8, 0); ? if( ALWAYS(pDef) ){ ??? pDef->funcFlags |= flagVal; ? } } /* ** Register the built-in LIKE and GLOB functions.? The caseSensitive ** parameter determines whether or not the LIKE operator is case ** sensitive.? GLOB is always case sensitive. */ void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){ ? struct compareInfo *pInfo; ? if( caseSensitive ){ ??? pInfo = (struct compareInfo*)&likeInfoAlt; ? }else{ ??? pInfo = (struct compareInfo*)&likeInfoNorm; ? } ? sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); ? sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); ? sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, ????? (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); ? setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); ? setLikeOptFlag(db, "like", ????? caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); } /* ** pExpr points to an expression which implements a function.? If ** it is appropriate to apply the LIKE optimization to that function ** then set aWc[0] through aWc[2] to the wildcard characters and ** return TRUE.? If the function is not a LIKE-style function then ** return FALSE. ** ** *pIsNocase is set to true if uppercase and lowercase are equivalent for ** the function (default for LIKE).? If the function makes the distinction ** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to ** false. */ int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){ ? FuncDef *pDef; ? if( pExpr->op!=TK_FUNCTION ?? || !pExpr->x.pList ?? || pExpr->x.pList->nExpr!=2 ? ){ ??? return 0; ? } ? assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); ? pDef = sqlite3FindFunction(db, pExpr->u.zToken, 2, SQLITE_UTF8, 0); ? if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_FUNC_LIKE)==0 ){ ??? return 0; ? } ? /* The memcpy() statement assumes that the wildcard characters are ? ** the first three statements in the compareInfo structure.? The ? ** asserts() that follow verify that assumption ? */ ? memcpy(aWc, pDef->pUserData, 3); ? assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll ); ? assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne ); ? assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet ); ? *pIsNocase = (pDef->funcFlags & SQLITE_FUNC_CASE)==0; ? return 1; } ?