diff options
author | drh <drh@noemail.net> | 2013-09-13 17:47:57 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-09-13 17:47:57 +0000 |
commit | a496fa7c0248bd666d1260f51b93f9b4ab0732df (patch) | |
tree | a80f8e3f1c330e3797a27dbb356756bd2e67397b /src/func.c | |
parent | 6bb64f6a31a7d0ac3f4af854ca2b34f5ed1267cb (diff) | |
parent | ebb6a65d16bb653b06df6b6e4e0c17c72de6de3d (diff) | |
download | sqlite-a496fa7c0248bd666d1260f51b93f9b4ab0732df.tar.gz sqlite-a496fa7c0248bd666d1260f51b93f9b4ab0732df.zip |
Adjust the query planner to take into account WHERE clause terms that do not
drive indices. Add the unlikely() and likelihood() functions used to give
hints to the query planner about the selectivity of WHERE clause terms.
FossilOrigin-Name: bc446449a19171c0fa0681973b06bc80d3c0517f
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/func.c b/src/func.c index 570b493dd..e2ab68f03 100644 --- a/src/func.c +++ b/src/func.c @@ -418,14 +418,14 @@ static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ } /* -** The COALESCE() and IFNULL() functions are implemented as VDBE code so -** that unused argument values do not have to be computed. However, we -** still need some kind of function implementation for this routines in -** the function table. That function implementation will never be called -** so it doesn't matter what the implementation is. We might as well use -** the "version()" function as a substitute. +** Some functions like COALESCE() and IFNULL() and UNLIKELY() are implemented +** as VDBE code so that unused argument values do not have to be computed. +** However, we still need some kind of function implementation for this +** routines in the function table. The noopFunc macro provides this. +** noopFunc will never be called so it doesn't matter what the implementation +** is. We might as well use the "version()" function as a substitute. */ -#define ifnullFunc versionFunc /* Substitute function - never called */ +#define noopFunc versionFunc /* Substitute function - never called */ /* ** Implementation of random(). Return a random integer. @@ -1659,9 +1659,11 @@ void sqlite3RegisterGlobalFunctions(void){ FUNCTION(lower, 1, 0, 0, lowerFunc ), FUNCTION(coalesce, 1, 0, 0, 0 ), FUNCTION(coalesce, 0, 0, 0, 0 ), - FUNCTION2(coalesce, -1, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE), + FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE), FUNCTION(hex, 1, 0, 0, hexFunc ), - FUNCTION2(ifnull, 2, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE), + FUNCTION2(ifnull, 2, 0, 0, noopFunc, SQLITE_FUNC_COALESCE), + FUNCTION2(unlikely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), + FUNCTION2(likelihood, 2, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), FUNCTION(random, 0, 0, 0, randomFunc ), FUNCTION(randomblob, 1, 0, 0, randomBlob ), FUNCTION(nullif, 2, 0, 1, nullifFunc ), |