Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove the sqlite3_reoptimize() API. The same functionality is now provided automatically to queries prepared using prepare_v2(). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2c50b3d5aab7cd8cc841d61f8c3b2b34 |
User & Date: | dan 2009-10-19 18:11:10.000 |
Context
2009-10-19
| ||
18:30 | Fix an assert() that may fail if sqlite3_step() is called on a statement after a previous call has already returned SQLITE_SCHEMA. (check-in: 63bf73452d user: dan tags: trunk) | |
18:11 | Remove the sqlite3_reoptimize() API. The same functionality is now provided automatically to queries prepared using prepare_v2(). (check-in: 2c50b3d5aa user: dan tags: trunk) | |
15:52 | When generating WHERE clause terms internally for NATURAL and USING joins, identify the table by its position in the FROM list, not by its name or alias. Fix for [b73fb0bd64]. (check-in: 6fe6371175 user: dan tags: trunk) | |
Changes
Changes to src/sqlite.h.in.
︙ | ︙ | |||
5739 5740 5741 5742 5743 5744 5745 | ** The [sqlite3_strnicmp()] API allows applications and extensions to ** compare the contents of two buffers containing UTF-8 strings in a ** case-indendent fashion, using the same definition of case independence ** that SQLite uses internally when comparing identifiers. */ int sqlite3_strnicmp(const char *, const char *, int); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 | ** The [sqlite3_strnicmp()] API allows applications and extensions to ** compare the contents of two buffers containing UTF-8 strings in a ** case-indendent fashion, using the same definition of case independence ** that SQLite uses internally when comparing identifiers. */ int sqlite3_strnicmp(const char *, const char *, int); /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. */ #ifdef SQLITE_OMIT_FLOATING_POINT # undef double #endif |
︙ | ︙ |
Changes to src/tclsqlite.c.
︙ | ︙ | |||
1125 1126 1127 1128 1129 1130 1131 | sqlite3_bind_null(pStmt, i); } } } pPreStmt->nParm = iParm; *ppPreStmt = pPreStmt; | < < < < < < < < < | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 | sqlite3_bind_null(pStmt, i); } } } pPreStmt->nParm = iParm; *ppPreStmt = pPreStmt; return TCL_OK; } /* ** Release a statement reference obtained by calling dbPrepareAndBind(). ** There should be exactly one call to this function for each call to |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
2045 2046 2047 2048 2049 2050 2051 | } if( Tcl_GetBooleanFromObj(interp, objv[3], &resetFlag) ) return TCL_ERROR; iValue = sqlite3_stmt_status(pStmt, op, resetFlag); Tcl_SetObjResult(interp, Tcl_NewIntObj(iValue)); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 | } if( Tcl_GetBooleanFromObj(interp, objv[3], &resetFlag) ) return TCL_ERROR; iValue = sqlite3_stmt_status(pStmt, op, resetFlag); Tcl_SetObjResult(interp, Tcl_NewIntObj(iValue)); return TCL_OK; } /* ** Usage: sqlite3_next_stmt DB STMT ** ** Return the next statment in sequence after STMT. */ static int test_next_stmt( void * clientData, |
︙ | ︙ | |||
5027 5028 5029 5030 5031 5032 5033 | { "sqlite3_reset", test_reset ,0 }, { "sqlite3_expired", test_expired ,0 }, { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, { "sqlite3_changes", test_changes ,0 }, { "sqlite3_step", test_step ,0 }, { "sqlite3_sql", test_sql ,0 }, { "sqlite3_next_stmt", test_next_stmt ,0 }, | < | 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 | { "sqlite3_reset", test_reset ,0 }, { "sqlite3_expired", test_expired ,0 }, { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, { "sqlite3_changes", test_changes ,0 }, { "sqlite3_step", test_step ,0 }, { "sqlite3_sql", test_sql ,0 }, { "sqlite3_next_stmt", test_next_stmt ,0 }, { "sqlite3_release_memory", test_release_memory, 0}, { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, { "sqlite3_thread_cleanup", test_thread_cleanup, 0}, { "sqlite3_pager_refcounts", test_pager_refcounts, 0}, { "sqlite3_load_extension", test_load_extension, 0}, |
︙ | ︙ |
Changes to src/vdbe.h.
︙ | ︙ | |||
199 200 201 202 203 204 205 | void sqlite3VdbeCountChanges(Vdbe*); sqlite3 *sqlite3VdbeDb(Vdbe*); void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); void sqlite3VdbeSwap(Vdbe*,Vdbe*); VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); void sqlite3VdbeProgramDelete(sqlite3 *, SubProgram *, int); sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | void sqlite3VdbeCountChanges(Vdbe*); sqlite3 *sqlite3VdbeDb(Vdbe*); void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); void sqlite3VdbeSwap(Vdbe*,Vdbe*); VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); void sqlite3VdbeProgramDelete(sqlite3 *, SubProgram *, int); sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); void sqlite3VdbeSetVarmask(Vdbe*, int); #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT int sqlite3VdbeReleaseMemory(int); #endif UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*); int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
319 320 321 322 323 324 325 | i64 nStmtDefCons; /* Number of def. constraints when stmt started */ int iStatement; /* Statement number (or 0 if has not opened stmt) */ #ifdef SQLITE_DEBUG FILE *trace; /* Write an execution trace here, if not NULL */ #endif VdbeFrame *pFrame; /* Parent frame */ int nFrame; /* Number of frames in pFrame list */ | < < | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | i64 nStmtDefCons; /* Number of def. constraints when stmt started */ int iStatement; /* Statement number (or 0 if has not opened stmt) */ #ifdef SQLITE_DEBUG FILE *trace; /* Write an execution trace here, if not NULL */ #endif VdbeFrame *pFrame; /* Parent frame */ int nFrame; /* Number of frames in pFrame list */ u32 expmask; /* Binding to these vars invalidates VM */ }; /* ** The following are allowed values for Vdbe.magic */ #define VDBE_MAGIC_INIT 0x26bceaa5 /* Building a VDBE program */ |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
911 912 913 914 915 916 917 | } i--; pVar = &p->aVar[i]; sqlite3VdbeMemRelease(pVar); pVar->flags = MEM_Null; sqlite3Error(p->db, SQLITE_OK, 0); | | < < < < | < < > | < < | 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 | } i--; pVar = &p->aVar[i]; sqlite3VdbeMemRelease(pVar); pVar->flags = MEM_Null; sqlite3Error(p->db, SQLITE_OK, 0); /* If the bit corresponding to this variable in Vdbe.expmask is set, then ** binding a new value to this variable invalidates the current query plan. */ assert( p->isPrepareV2 || p->expmask==0 ); if( (i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff ){ p->expired = 1; } return SQLITE_OK; } /* |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){ Vdbe *pVdbe = (Vdbe*)pStmt; int v = pVdbe->aCounter[op-1]; if( resetFlag ) pVdbe->aCounter[op-1] = 0; return v; } | < < < < < < < < < < < < < < < < < < < < < | 1210 1211 1212 1213 1214 1215 1216 | int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){ Vdbe *pVdbe = (Vdbe*)pStmt; int v = pVdbe->aCounter[op-1]; if( resetFlag ) pVdbe->aCounter[op-1] = 0; return v; } |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 | return p; } /* ** Remember the SQL string for a prepared statement. */ void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){ if( p==0 ) return; #ifdef SQLITE_OMIT_TRACE if( !isPrepareV2 ) return; #endif assert( p->zSql==0 ); p->zSql = sqlite3DbStrNDup(p->db, z, n); | > | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | return p; } /* ** Remember the SQL string for a prepared statement. */ void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){ assert( isPrepareV2==1 || isPrepareV2==0 ); if( p==0 ) return; #ifdef SQLITE_OMIT_TRACE if( !isPrepareV2 ) return; #endif assert( p->zSql==0 ); p->zSql = sqlite3DbStrNDup(p->db, z, n); p->isPrepareV2 = isPrepareV2; } /* ** Return the SQL associated with a prepared statement */ const char *sqlite3_sql(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe *)pStmt; |
︙ | ︙ | |||
3049 3050 3051 3052 3053 3054 3055 | } /* ** Configure SQL variable iVar so that binding a new value to it signals ** to sqlite3_reoptimize() that re-preparing the statement may result ** in a better query plan. */ | | < | | | 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 | } /* ** Configure SQL variable iVar so that binding a new value to it signals ** to sqlite3_reoptimize() that re-preparing the statement may result ** in a better query plan. */ void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){ assert( iVar>0 ); if( iVar>32 ){ v->expmask = 0xffffffff; }else{ v->expmask |= ((u32)1 << (iVar-1)); } } |
Changes to src/where.c.
︙ | ︙ | |||
667 668 669 670 671 672 673 | } if( op==TK_VARIABLE ){ Vdbe *pReprepare = pParse->pReprepare; pVal = sqlite3VdbeGetValue(pReprepare, pRight->iColumn, SQLITE_AFF_NONE); if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){ z = (char *)sqlite3_value_text(pVal); } | | | | 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | } if( op==TK_VARIABLE ){ Vdbe *pReprepare = pParse->pReprepare; pVal = sqlite3VdbeGetValue(pReprepare, pRight->iColumn, SQLITE_AFF_NONE); if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){ z = (char *)sqlite3_value_text(pVal); } sqlite3VdbeSetVarmask(pParse->pVdbe, pRight->iColumn); assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER ); }else if( op==TK_STRING ){ z = pRight->u.zToken; } if( z ){ cnt = 0; while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ cnt++; } if( cnt!=0 && c!=0 && 255!=(u8)z[cnt-1] ){ Expr *pPrefix; *pisComplete = z[cnt]==wc[0] && z[cnt+1]==0; pPrefix = sqlite3Expr(db, TK_STRING, z); if( pPrefix ) pPrefix->u.zToken[cnt] = 0; *ppPrefix = pPrefix; if( op==TK_VARIABLE ){ Vdbe *v = pParse->pVdbe; sqlite3VdbeSetVarmask(v, pRight->iColumn); if( *pisComplete && pRight->u.zToken[1] ){ /* If the rhs of the LIKE expression is a variable, and the current ** value of the variable means there is no need to invoke the LIKE ** function, then no OP_Variable will be added to the program. ** This causes problems for the sqlite3_bind_parameter_name() ** API. To workaround them, add a dummy OP_Variable here. */ |
︙ | ︙ | |||
2041 2042 2043 2044 2045 2046 2047 | u8 aff, sqlite3_value **pp ){ if( (pExpr->op==TK_VARIABLE) || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) ){ int iVar = pExpr->iColumn; | | | 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 | u8 aff, sqlite3_value **pp ){ if( (pExpr->op==TK_VARIABLE) || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) ){ int iVar = pExpr->iColumn; sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); return SQLITE_OK; } return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp); } #endif |
︙ | ︙ |
Changes to test/analyze3.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 2009 August 06 # # 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. This file | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2009 August 06 # # 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. This file # implements tests for range and LIKE constraints that use bound variables # instead of literal constant arguments. # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !stat2 { finish_test |
︙ | ︙ | |||
28 29 30 31 32 33 34 | # in the same way as constants when planning queries that # use range constraints. # # analyze3-2.*: Test that the values of bound parameters are considered # in the same way as constants when planning queries that # use LIKE expressions in the WHERE clause. # | | | | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # in the same way as constants when planning queries that # use range constraints. # # analyze3-2.*: Test that the values of bound parameters are considered # in the same way as constants when planning queries that # use LIKE expressions in the WHERE clause. # # analyze3-3.*: Test that binding to a variable does not invalidate the # query plan when there is no way in which replanning the # query may produce a superior outcome. # # analyze3-4.*: Test that SQL or authorization callback errors occuring # within sqlite3Reprepare() are handled correctly. # proc getvar {varname} { uplevel #0 set $varname } db function var getvar proc eqp {sql {db db}} { uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db |
︙ | ︙ | |||
65 66 67 68 69 70 71 | # Show that there are two possible plans for querying the table with # a range constraint on the indexed column - "full table scan" or "use # the index". When the range is specified using literal values, SQLite # is able to pick the best plan based on the samples in sqlite_stat2. # # analyze3-1.1.4 - 3.1.9 # Show that using SQL variables produces the same results as using | | < | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # Show that there are two possible plans for querying the table with # a range constraint on the indexed column - "full table scan" or "use # the index". When the range is specified using literal values, SQLite # is able to pick the best plan based on the samples in sqlite_stat2. # # analyze3-1.1.4 - 3.1.9 # Show that using SQL variables produces the same results as using # literal values to constrain the range scan. # # These tests also check that the compiler code considers column # affinities when estimating the number of rows scanned by the "use # index strategy". # do_test analyze3-1.1.1 { execsql { |
︙ | ︙ | |||
263 264 265 266 267 268 269 | do_test analyze3-2.5 { set like "%a" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } } {999 999 100} #------------------------------------------------------------------------- | | | < < < < < < | < < < < < < < < < < < < < < < | | < < < | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | < < < | | | < < < | | | | < < < | | < < < < < < | | | | | | | | | | | > < < < | | | > < < < | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | do_test analyze3-2.5 { set like "%a" sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like } } {999 999 100} #------------------------------------------------------------------------- # This block of tests checks that statements are correctly marked as # expired when the values bound to any parameters that may affect the # query plan are modified. # drop_all_tables db auth auth proc auth {args} { set ::auth 1 return SQLITE_OK } do_test analyze3-3.1 { execsql { BEGIN; CREATE TABLE t1(a, b, c); CREATE INDEX i1 ON t1(b); } for {set i 0} {$i < 100} {incr i} { execsql { INSERT INTO t1 VALUES($i, $i, $i) } } execsql COMMIT execsql ANALYZE } {} do_test analyze3-3.2.1 { set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE b>?" -1 dummy] sqlite3_expired $S } {0} do_test analyze3-3.2.2 { sqlite3_bind_text $S 1 "abc" 3 sqlite3_expired $S } {1} do_test analyze3-3.2.4 { sqlite3_finalize $S } {SQLITE_OK} do_test analyze3-3.2.5 { set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE b=?" -1 dummy] sqlite3_expired $S } {0} do_test analyze3-3.2.6 { sqlite3_bind_text $S 1 "abc" 3 sqlite3_expired $S } {0} do_test analyze3-3.2.7 { sqlite3_finalize $S } {SQLITE_OK} do_test analyze3-3.4.1 { set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy] sqlite3_expired $S } {0} do_test analyze3-3.4.2 { sqlite3_bind_text $S 1 "abc" 3 sqlite3_expired $S } {0} do_test analyze3-3.4.3 { sqlite3_bind_text $S 2 "def" 3 sqlite3_expired $S } {1} do_test analyze3-3.4.4 { sqlite3_bind_text $S 2 "ghi" 3 sqlite3_expired $S } {1} do_test analyze3-3.4.5 { sqlite3_expired $S } {1} do_test analyze3-3.4.6 { sqlite3_finalize $S } {SQLITE_OK} do_test analyze3-3.5.1 { set S [sqlite3_prepare_v2 db { SELECT * FROM t1 WHERE a IN ( ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31 ) AND b>?32; } -1 dummy] sqlite3_expired $S } {0} do_test analyze3-3.5.2 { sqlite3_bind_text $S 31 "abc" 3 sqlite3_expired $S } {0} do_test analyze3-3.5.3 { sqlite3_bind_text $S 32 "def" 3 sqlite3_expired $S } {1} do_test analyze3-3.5.5 { sqlite3_finalize $S } {SQLITE_OK} do_test analyze3-3.6.1 { set S [sqlite3_prepare_v2 db { SELECT * FROM t1 WHERE a IN ( ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32 ) AND b>?33; } -1 dummy] sqlite3_expired $S } {0} do_test analyze3-3.6.2 { sqlite3_bind_text $S 32 "abc" 3 sqlite3_expired $S } {1} do_test analyze3-3.6.3 { sqlite3_bind_text $S 33 "def" 3 sqlite3_expired $S } {1} do_test analyze3-3.6.5 { sqlite3_finalize $S } {SQLITE_OK} do_test analyze3-3.7.1 { breakpoint set S [sqlite3_prepare_v2 db { SELECT * FROM t1 WHERE a IN ( ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?33, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32 ) AND b>?10; } -1 dummy] sqlite3_expired $S } {0} do_test analyze3-3.7.2 { sqlite3_bind_text $S 32 "abc" 3 sqlite3_expired $S } {0} do_test analyze3-3.7.3 { sqlite3_bind_text $S 33 "def" 3 sqlite3_expired $S } {0} do_test analyze3-3.7.4 { sqlite3_bind_text $S 10 "def" 3 sqlite3_expired $S } {1} do_test analyze3-3.7.6 { sqlite3_finalize $S } {SQLITE_OK} do_test analyze3-3.8.1 { execsql { CREATE TABLE t4(x, y TEXT COLLATE NOCASE); CREATE INDEX i4 ON t4(y); } } {} do_test analyze3-3.8.2 { set S [sqlite3_prepare_v2 db { SELECT * FROM t4 WHERE x != ? AND y LIKE ? } -1 dummy] sqlite3_expired $S } {0} do_test analyze3-3.8.3 { sqlite3_bind_text $S 1 "abc" 3 sqlite3_expired $S } {0} do_test analyze3-3.8.4 { sqlite3_bind_text $S 2 "def" 3 sqlite3_expired $S } {1} do_test analyze3-3.8.7 { sqlite3_bind_text $S 2 "ghi%" 4 sqlite3_expired $S } {1} do_test analyze3-3.8.8 { sqlite3_expired $S } {1} do_test analyze3-3.8.9 { sqlite3_bind_text $S 2 "ghi%def" 7 sqlite3_expired $S } {1} do_test analyze3-3.8.10 { sqlite3_expired $S } {1} do_test analyze3-3.8.11 { sqlite3_bind_text $S 2 "%ab" 3 sqlite3_expired $S } {1} do_test analyze3-3.8.12 { sqlite3_expired $S } {1} do_test analyze3-3.8.12 { sqlite3_bind_text $S 2 "%de" 3 sqlite3_expired $S } {1} do_test analyze3-3.8.13 { sqlite3_expired $S } {1} do_test analyze3-3.8.14 { sqlite3_finalize $S } {SQLITE_OK} #------------------------------------------------------------------------- # These tests check that errors encountered while repreparing an SQL # statement within sqlite3Reprepare() are handled correctly. # # Check a schema error. # do_test analyze3-4.1.1 { set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy] sqlite3_step $S } {SQLITE_DONE} do_test analyze3-4.1.2 { sqlite3_reset $S sqlite3_bind_text $S 2 "abc" 3 execsql { DROP TABLE t1 } sqlite3_step $S } {SQLITE_SCHEMA} do_test analyze3-4.1.3 { sqlite3_finalize $S } {SQLITE_SCHEMA} # Check an authorization error. # do_test analyze3-4.2.1 { execsql { BEGIN; CREATE TABLE t1(a, b, c); CREATE INDEX i1 ON t1(b); } for {set i 0} {$i < 100} {incr i} { execsql { INSERT INTO t1 VALUES($i, $i, $i) } } execsql COMMIT execsql ANALYZE set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy] sqlite3_step $S } {SQLITE_DONE} db auth auth proc auth {args} { if {[lindex $args 0] == "SQLITE_READ"} {return SQLITE_DENY} return SQLITE_OK } do_test analyze3-4.2.2 { sqlite3_reset $S sqlite3_bind_text $S 2 "abc" 3 sqlite3_step $S } {SQLITE_SCHEMA} do_test analyze3-4.2.4 { sqlite3_finalize $S } {SQLITE_SCHEMA} # Check the effect of an authorization error that occurs in a re-prepare # performed by sqlite3_step() is the same as one that occurs within # sqlite3Reprepare(). # do_test analyze3-4.3.1 { db auth {} set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy] execsql { CREATE TABLE t2(d, e, f) } db auth auth sqlite3_step $S } {SQLITE_SCHEMA} do_test analyze3-4.3.2 { sqlite3_finalize $S } {SQLITE_SCHEMA} finish_test |