$(TOP)/src/test_backup.c \
$(TOP)/src/test_btree.c \
$(TOP)/src/test_config.c \
+ $(TOP)/src/test_cursorhint.c \
$(TOP)/src/test_demovfs.c \
$(TOP)/src/test_devsym.c \
$(TOP)/src/test_fs.c \
-C In\sthe\sexpression\spassed\sto\ssqlite3BtreeCursorHint()\sfor\sthe\sinner\sloops\sof\sjoins,\sreplace\sany\sTK_COLUMN\sreferences\sto\scolumns\sin\sthe\souter\sloops\swith\sTK_REGISTER\sexpressions\s(Expr.iTable\sindicates\sthe\sspecific\sregister\scontaining\sthe\svalue).
-D 2014-07-14T19:04:29.385
+C Add\ssimple\stests\sfor\snew\ssqlite3BtreeCursorHint()\sfunctionality.
+D 2014-07-15T11:59:44.612
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt f439556c5ce01ced70987e5ee86549a45165d9ff
-F main.mk 82fd90375561d7b66287ae5a8b09e1e027394019
+F main.mk a6fa2dee82ed65ef48edc82baa0b480366f53212
F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh d2a981497b404d6498f5ff3e3b1f3816bdfcb338
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
-F src/tclsqlite.c 651b10698c87bbc3ae5772e2491e3444c5bbf153
+F src/tclsqlite.c 571af8d366a8c00106c8c4bfa5b2ab07a9e58baf
F src/test1.c 760e0419705f712d80595f47199568cd7e3b57a4
F src/test2.c 7355101c085304b90024f2261e056cdff13c6c35
F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c
F src/test_backup.c 3875e899222b651e18b662f86e0e50daa946344e
F src/test_btree.c 5b89601dcb42a33ba8b820a6b763cc9cb48bac16
F src/test_config.c 10d0e00dd6315879a6d9fac20bd063c7bbbfb8f8
+F src/test_cursorhint.c 7c37315e15d6543689e8b48979a8eb370baa3cfc
F src/test_demovfs.c 69b2085076654ebc18014cbc6386f04409c959a9
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_fs.c ced436e3d4b8e4681328409b8081051ce614e28f
F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
F src/util.c 76ed0519296e3f62e97e57dab1999e34184c8e49
F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
-F src/vdbe.c 88a037e01278bd8c8093bb3399b250cb02c6e865
+F src/vdbe.c 54e269c6268a6f37697e27d6bc572674f14b1581
F src/vdbe.h 57b87844270b2e92647b8b82a8948f7a29efae8d
F src/vdbeInt.h 05fbda0e061dbc4aaa2709a8cccf3515c245b263
F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
F src/walker.c e9e593d5bb798c3e67fc3893dfe7055c9e7d8d74
-F src/where.c dcea6104452e837cc63bd1c3c5cb05868bb356ba
+F src/where.c 907fd82f4f8fc89d8a72d44caf5a5679c0769630
F src/whereInt.h 96a75c61f1d2b9d4a8e4bb17d89deb0cf7cba358
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8
F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c
F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47
+F test/cursorhint.test e55ad8c466327ffb3511b60007102bca22314d0a
F test/date.test 42973251b9429f2c41b77eb98a7b0b0ba2d3b2c0
F test/dbstatus.test 8de104bb5606f19537d23cd553b41349b5ab1204
F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P bfefc57554853e467ee6aeaba8d08331406fa216
-R d30e9be65b11497e93ad990065d669d6
+P f9dddd008c6ef7940a1d66363fbb456cff7207c1
+R 9fb1051a18f0e187efee634c86c45e62
U dan
-Z c72f8637bcd1205d8e636acedbe3ca98
+Z 04e07c13931dc702da8721e6980ca969
-f9dddd008c6ef7940a1d66363fbb456cff7207c1
\ No newline at end of file
+1efa6ed584172291edce78faf9021e577583d03b
\ No newline at end of file
extern int Sqlitetest9_Init(Tcl_Interp*);
extern int Sqlitetestasync_Init(Tcl_Interp*);
extern int Sqlitetest_autoext_Init(Tcl_Interp*);
+ extern int Sqlitetest_cursorhint_Init(Tcl_Interp*);
extern int Sqlitetest_demovfs_Init(Tcl_Interp *);
extern int Sqlitetest_func_Init(Tcl_Interp*);
extern int Sqlitetest_hexio_Init(Tcl_Interp*);
Sqlitetest9_Init(interp);
Sqlitetestasync_Init(interp);
Sqlitetest_autoext_Init(interp);
+ Sqlitetest_cursorhint_Init(interp);
Sqlitetest_demovfs_Init(interp);
Sqlitetest_func_Init(interp);
Sqlitetest_hexio_Init(interp);
--- /dev/null
+/*
+** 2008 March 19
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+** Code for testing all sorts of SQLite interfaces. This code
+** implements new SQL functions used by the test scripts.
+*/
+#include "sqlite3.h"
+#include "tcl.h"
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "sqliteInt.h"
+#include "vdbeInt.h"
+
+struct CursorHintGlobal {
+ Tcl_Interp *interp;
+ Tcl_Obj *pScript;
+} cursorhintglobal;
+
+static char *exprToString(Mem *aMem, Expr *pExpr){
+ char *zRet = 0;
+ char *zBinOp = 0;
+
+ switch( pExpr->op ){
+ case TK_STRING:
+ zRet = sqlite3_mprintf("%Q", pExpr->u.zToken);
+ break;
+
+ case TK_INTEGER:
+ zRet = sqlite3_mprintf("%d", pExpr->u.iValue);
+ break;
+
+ case TK_NULL:
+ zRet = sqlite3_mprintf("%s", "NULL");
+ break;
+
+ case TK_REGISTER: {
+ Mem *pMem = &aMem[pExpr->iTable];
+ if( pMem->flags & MEM_Int ){
+ zRet = sqlite3_mprintf("%lld", pMem->u.i);
+ }
+ else if( pMem->flags & MEM_Real ){
+ zRet = sqlite3_mprintf("%f", pMem->r);
+ }
+ else if( pMem->flags & MEM_Str ){
+ zRet = sqlite3_mprintf("%.*Q", pMem->n, pMem->z);
+ }
+ else if( pMem->flags & MEM_Blob ){
+ }
+ else{
+ zRet = sqlite3_mprintf("%s", "NULL");
+ }
+ break;
+ }
+
+ case TK_COLUMN: {
+ zRet = sqlite3_mprintf("col(%d)", (int)pExpr->iColumn);
+ break;
+ }
+
+ case TK_LT: zBinOp = "<"; break;
+ case TK_LE: zBinOp = "<="; break;
+ case TK_GT: zBinOp = ">"; break;
+ case TK_GE: zBinOp = ">="; break;
+ case TK_NE: zBinOp = "!="; break;
+ case TK_EQ: zBinOp = "=="; break;
+ case TK_IS: zBinOp = "IS"; break;
+ case TK_ISNOT: zBinOp = "IS NOT"; break;
+ case TK_AND: zBinOp = "AND"; break;
+ case TK_OR: zBinOp = "OR"; break;
+ case TK_PLUS: zBinOp = "+"; break;
+ case TK_STAR: zBinOp = "*"; break;
+ case TK_MINUS: zBinOp = "-"; break;
+ case TK_REM: zBinOp = "%"; break;
+ case TK_BITAND: zBinOp = "&"; break;
+ case TK_BITOR: zBinOp = "|"; break;
+ case TK_SLASH: zBinOp = "/"; break;
+ case TK_LSHIFT: zBinOp = "<<"; break;
+ case TK_RSHIFT: zBinOp = ">>"; break;
+ case TK_CONCAT: zBinOp = "||"; break;
+
+ default:
+ zRet = sqlite3_mprintf("%s", "expr");
+ break;
+ }
+
+ if( zBinOp ){
+ zRet = sqlite3_mprintf("(%z %s %z)",
+ exprToString(aMem, pExpr->pLeft),
+ zBinOp,
+ exprToString(aMem, pExpr->pRight)
+ );
+ }
+
+ return zRet;
+}
+
+void sqlite3BtreeCursorHintTest(Mem *aMem, Expr *pExpr){
+ if( cursorhintglobal.pScript ){
+ Tcl_Obj *pEval = Tcl_DuplicateObj(cursorhintglobal.pScript);
+ char *zExpr;
+ Tcl_Obj *pObj;
+ Tcl_IncrRefCount(pEval);
+ zExpr = exprToString(aMem, pExpr);
+ pObj = Tcl_NewStringObj(zExpr, -1);
+ sqlite3_free(zExpr);
+ Tcl_ListObjAppendElement(cursorhintglobal.interp, pEval, pObj);
+ Tcl_EvalObjEx(cursorhintglobal.interp, pEval, TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(pEval);
+ }
+}
+
+/*
+** Usage: cursorhint_hook SCRIPT
+*/
+static int install_cursorhint_hook(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ if( objc!=1 && objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "?SCRIPT?");
+ return TCL_ERROR;
+ }
+ if( cursorhintglobal.pScript ){
+ Tcl_DecrRefCount(cursorhintglobal.pScript);
+ memset(&cursorhintglobal, 0, sizeof(cursorhintglobal));
+ }
+ if( objc==2 ){
+ cursorhintglobal.interp = interp;
+ cursorhintglobal.pScript = Tcl_DuplicateObj(objv[1]);
+ }
+ return TCL_OK;
+}
+
+/*
+** Register commands with the TCL interpreter.
+*/
+int Sqlitetest_cursorhint_Init(Tcl_Interp *interp){
+ static struct {
+ char *zName;
+ Tcl_ObjCmdProc *xProc;
+ } aObjCmd[] = {
+ { "cursorhint_hook", install_cursorhint_hook },
+ };
+ int i;
+ for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
+ Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);
+ }
+ sqlite3_initialize();
+ return TCL_OK;
+}
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
assert( pOp->p4type==P4_EXPR );
pC = p->apCsr[pOp->p1];
- if( pC ) sqlite3BtreeCursorHint(pC->pCursor, pOp->p2, pOp->p4.pExpr);
+ if( pC ){
+ sqlite3BtreeCursorHint(pC->pCursor, pOp->p2, pOp->p4.pExpr);
+#ifdef SQLITE_TEST
+ void sqlite3BtreeCursorHintTest(Mem*, Expr*);
+ sqlite3BtreeCursorHintTest(p->aMem, pOp->p4.pExpr);
+#endif
+ }
break;
}
#endif /* SQLITE_ENABLE_CURSOR_HINTS */
WhereLevel *pLevel;
Expr *pExpr = 0;
int iCur;
- Bitmask msk;
WhereClause *pWC;
WhereTerm *pTerm;
WhereLoop *pWLoop;
--- /dev/null
+# 2014 July 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix cursorhint
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a,b);
+ CREATE TABLE t2(x,y);
+ INSERT INTO t1 VALUES(10, 15);
+ INSERT INTO t1 VALUES(20, 25);
+ INSERT INTO t2 VALUES('ten', 'fifteen');
+ INSERT INTO t2 VALUES('twenty', 'twentyfive');
+ PRAGMA automatic_index = 0;
+}
+
+proc H {expr} {
+ lappend ::cursorhint $expr
+}
+
+proc do_cursorhint_test {tn sql hints} {
+ cursorhint_hook H
+ set ::cursorhint [list]
+ set testbody [subst {
+ execsql {$sql}
+ set ::cursorhint
+ }]
+ uplevel [list do_test $tn $testbody [list {*}$hints]]
+ cursorhint_hook
+}
+
+
+do_cursorhint_test 1.1 {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE a=x;
+} {
+ {(10 == col(0))}
+ {(20 == col(0))}
+}
+
+do_cursorhint_test 1.2 {
+ SELECT * FROM t2 CROSS JOIN t1 WHERE a=x;
+} {
+ {(col(0) == 'ten')}
+ {(col(0) == 'twenty')}
+}
+
+do_cursorhint_test 1.3 {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE b=15;
+} {
+ {(col(1) == 15)}
+}
+
+do_cursorhint_test 1.3 {
+ SELECT * FROM t1 CROSS JOIN t2 WHERE y=b+1;
+} {
+ {(col(1) == (15 + 1))}
+ {(col(1) == (25 + 1))}
+}
+
+
+finish_test