Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove cruft: (1) The sqlite4_prepare_v2() function becomes sqlite4_prepare and all other prepare functions are removed. (2) sqlite4_extended_result_codes() is removed. Extended result codes are now always enabled. (3) The sqlite4_busy_handler() and sqlite4_busy_timeout() functions are removed. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e45457498190edf16a301a28ec47d1cc |
User & Date: | drh 2012-04-21 00:40:42.264 |
Context
2012-04-21
| ||
12:49 | Remove the last traces of shared cache mode. check-in: 27e0994174 user: drh tags: trunk | |
00:40 | Remove cruft: (1) The sqlite4_prepare_v2() function becomes sqlite4_prepare and all other prepare functions are removed. (2) sqlite4_extended_result_codes() is removed. Extended result codes are now always enabled. (3) The sqlite4_busy_handler() and sqlite4_busy_timeout() functions are removed. check-in: e454574981 user: drh tags: trunk | |
2012-04-20
| ||
20:41 | Move development back to trunk. check-in: 76ca8d1bee user: drh tags: trunk | |
Changes
Changes to main.mk.
︙ | ︙ | |||
191 192 193 194 195 196 197 | # TESTSRC = \ $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_test.c \ $(TOP)/src/test1.c \ $(TOP)/src/test4.c \ $(TOP)/src/test5.c \ | < < | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | # TESTSRC = \ $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_test.c \ $(TOP)/src/test1.c \ $(TOP)/src/test4.c \ $(TOP)/src/test5.c \ $(TOP)/src/test7.c \ $(TOP)/src/test8.c \ $(TOP)/src/test9.c \ $(TOP)/src/test_config.c \ $(TOP)/src/test_demovfs.c \ $(TOP)/src/test_devsym.c \ $(TOP)/src/test_fuzzer.c \ $(TOP)/src/test_hexio.c \ $(TOP)/src/test_init.c \ $(TOP)/src/test_intarray.c \ $(TOP)/src/test_malloc.c \ $(TOP)/src/test_mutex.c \ $(TOP)/src/test_onefile.c \ $(TOP)/src/test_osinst.c \ $(TOP)/src/test_rtree.c \ $(TOP)/src/test_schema.c \ $(TOP)/src/test_storage.c \ |
︙ | ︙ | |||
487 488 489 490 491 492 493 | fulltest: testfixture$(EXE) sqlite4$(EXE) ./testfixture$(EXE) $(TOP)/test/all.test soaktest: testfixture$(EXE) sqlite4$(EXE) ./testfixture$(EXE) $(TOP)/test/all.test -soak=1 test: testfixture$(EXE) sqlite4$(EXE) | | | 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | fulltest: testfixture$(EXE) sqlite4$(EXE) ./testfixture$(EXE) $(TOP)/test/all.test soaktest: testfixture$(EXE) sqlite4$(EXE) ./testfixture$(EXE) $(TOP)/test/all.test -soak=1 test: testfixture$(EXE) sqlite4$(EXE) ./testfixture$(EXE) $(TOP)/test/src4.test # The next two rules are used to support the "threadtest" target. Building # threadtest runs a few thread-safety tests that are implemented in C. This # target is invoked by the releasetest.tcl script. # threadtest3$(EXE): sqlite4.o $(TOP)/test/threadtest3.c $(TOP)/test/tt3_checkpoint.c $(TCCX) -O2 sqlite4.o $(TOP)/test/threadtest3.c \ |
︙ | ︙ |
Changes to src/legacy.c.
︙ | ︙ | |||
133 134 135 136 137 138 139 | rc = SQLITE_NOMEM; sqlite4Error(db, SQLITE_NOMEM, 0); } }else if( pzErrMsg ){ *pzErrMsg = 0; } | < | 133 134 135 136 137 138 139 140 141 142 | rc = SQLITE_NOMEM; sqlite4Error(db, SQLITE_NOMEM, 0); } }else if( pzErrMsg ){ *pzErrMsg = 0; } sqlite4_mutex_leave(db->mutex); return rc; } |
Changes to src/main.c.
︙ | ︙ | |||
859 860 861 862 863 864 865 | if( ALWAYS(rc>=0) && rc<(int)(sizeof(aMsg)/sizeof(aMsg[0])) && aMsg[rc]!=0 ){ return aMsg[rc]; }else{ return "unknown error"; } } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | if( ALWAYS(rc>=0) && rc<(int)(sizeof(aMsg)/sizeof(aMsg[0])) && aMsg[rc]!=0 ){ return aMsg[rc]; }else{ return "unknown error"; } } #ifndef SQLITE_OMIT_PROGRESS_CALLBACK /* ** This routine sets the progress callback for an Sqlite database to the ** given callback function with the given argument. The progress callback will ** be invoked every nOps opcodes. */ void sqlite4_progress_handler( |
︙ | ︙ | |||
966 967 968 969 970 971 972 | db->nProgressOps = 0; db->pProgressArg = 0; } sqlite4_mutex_leave(db->mutex); } #endif | < < < < < < < < < < < < < < < | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | db->nProgressOps = 0; db->pProgressArg = 0; } sqlite4_mutex_leave(db->mutex); } #endif /* ** Cause any pending operation to stop at its earliest opportunity. */ void sqlite4_interrupt(sqlite4 *db){ db->u1.isInterrupted = 1; } |
︙ | ︙ | |||
1531 1532 1533 1534 1535 1536 1537 | int sqlite4_errcode(sqlite4 *db){ if( db && !sqlite4SafetyCheckSickOrOk(db) ){ return SQLITE_MISUSE_BKPT; } if( !db || db->mallocFailed ){ return SQLITE_NOMEM; } | < < < < < < < < < | 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 | int sqlite4_errcode(sqlite4 *db){ if( db && !sqlite4SafetyCheckSickOrOk(db) ){ return SQLITE_MISUSE_BKPT; } if( !db || db->mallocFailed ){ return SQLITE_NOMEM; } return db->errCode; } /* ** Create a new collating function for database "db". The name is zName ** and the encoding is enc. */ |
︙ | ︙ | |||
2044 2045 2046 2047 2048 2049 2050 | if( db->mutex==0 ){ sqlite4_free(db); db = 0; goto opendb_out; } } sqlite4_mutex_enter(db->mutex); | < | 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 | if( db->mutex==0 ){ sqlite4_free(db); db = 0; goto opendb_out; } } sqlite4_mutex_enter(db->mutex); db->nDb = 2; db->magic = SQLITE_MAGIC_BUSY; db->aDb = db->aDbStatic; assert( sizeof(db->aLimit)==sizeof(aHardLimit) ); memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit)); db->autoCommit = 1; |
︙ | ︙ | |||
2386 2387 2388 2389 2390 2391 2392 | /* This function works in milliseconds, but the underlying OsSleep() ** API uses microseconds. Hence the 1000's. */ rc = (sqlite4OsSleep(pVfs, 1000*ms)/1000); return rc; } | < < < < < < < < < < | 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 | /* This function works in milliseconds, but the underlying OsSleep() ** API uses microseconds. Hence the 1000's. */ rc = (sqlite4OsSleep(pVfs, 1000*ms)/1000); return rc; } /* ** Interface to the testing logic. */ int sqlite4_test_control(int op, ...){ int rc = 0; #ifndef SQLITE_OMIT_BUILTIN_TEST |
︙ | ︙ |
Changes to src/malloc.c.
︙ | ︙ | |||
770 771 772 773 774 775 776 | */ assert( !db || sqlite4_mutex_held(db->mutex) ); if( db && (db->mallocFailed || rc==SQLITE_IOERR_NOMEM) ){ sqlite4Error(db, SQLITE_NOMEM, 0); db->mallocFailed = 0; rc = SQLITE_NOMEM; } | | | 770 771 772 773 774 775 776 777 778 | */ assert( !db || sqlite4_mutex_held(db->mutex) ); if( db && (db->mallocFailed || rc==SQLITE_IOERR_NOMEM) ){ sqlite4Error(db, SQLITE_NOMEM, 0); db->mallocFailed = 0; rc = SQLITE_NOMEM; } return rc; } |
Changes to src/prepare.c.
︙ | ︙ | |||
450 451 452 453 454 455 456 | /* ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. */ static int sqlite4Prepare( sqlite4 *db, /* Database handle. */ const char *zSql, /* UTF-8 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ | < | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | /* ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. */ static int sqlite4Prepare( sqlite4 *db, /* Database handle. */ const char *zSql, /* UTF-8 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ Vdbe *pReprepare, /* VM being reprepared */ sqlite4_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ const char **pzTail /* OUT: End of parsed string */ ){ Parse *pParse; /* Parsing context */ char *zErrMsg = 0; /* Error message */ int rc = SQLITE_OK; /* Result code */ |
︙ | ︙ | |||
536 537 538 539 540 541 542 | for(i=iFirst; i<mx; i++){ sqlite4VdbeSetColName(pParse->pVdbe, i-iFirst, COLNAME_NAME, azColName[i], SQLITE_STATIC); } } #endif | < | | 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | for(i=iFirst; i<mx; i++){ sqlite4VdbeSetColName(pParse->pVdbe, i-iFirst, COLNAME_NAME, azColName[i], SQLITE_STATIC); } } #endif if( db->init.busy==0 ){ Vdbe *pVdbe = pParse->pVdbe; sqlite4VdbeSetSql(pVdbe, zSql, (int)(pParse->zTail-zSql)); } if( pParse->pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){ sqlite4VdbeFinalize(pParse->pVdbe); assert(!(*ppStmt)); }else{ *ppStmt = (sqlite4_stmt*)pParse->pVdbe; } |
︙ | ︙ | |||
566 567 568 569 570 571 572 | sqlite4DbFree(db, pT); } end_prepare: sqlite4StackFree(db, pParse); rc = sqlite4ApiExit(db, rc); | < < | | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | sqlite4DbFree(db, pT); } end_prepare: sqlite4StackFree(db, pParse); rc = sqlite4ApiExit(db, rc); return rc; } static int sqlite4LockAndPrepare( sqlite4 *db, /* Database handle. */ const char *zSql, /* UTF-8 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ Vdbe *pOld, /* VM being reprepared */ sqlite4_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ const char **pzTail /* OUT: End of parsed string */ ){ int rc; assert( ppStmt!=0 ); *ppStmt = 0; if( !sqlite4SafetyCheckOk(db) ){ return SQLITE_MISUSE_BKPT; } sqlite4_mutex_enter(db->mutex); rc = sqlite4Prepare(db, zSql, nBytes, pOld, ppStmt, pzTail); if( rc==SQLITE_SCHEMA ){ sqlite4_finalize(*ppStmt); rc = sqlite4Prepare(db, zSql, nBytes, pOld, ppStmt, pzTail); } sqlite4_mutex_leave(db->mutex); return rc; } /* ** Rerun the compilation of a statement after a schema change. |
︙ | ︙ | |||
610 611 612 613 614 615 616 | int rc; sqlite4_stmt *pNew; const char *zSql; sqlite4 *db; assert( sqlite4_mutex_held(sqlite4VdbeDb(p)->mutex) ); zSql = sqlite4_sql((sqlite4_stmt *)p); | < | | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | int rc; sqlite4_stmt *pNew; const char *zSql; sqlite4 *db; assert( sqlite4_mutex_held(sqlite4VdbeDb(p)->mutex) ); zSql = sqlite4_sql((sqlite4_stmt *)p); db = sqlite4VdbeDb(p); assert( sqlite4_mutex_held(db->mutex) ); rc = sqlite4LockAndPrepare(db, zSql, -1, p, &pNew, 0); if( rc ){ if( rc==SQLITE_NOMEM ){ db->mallocFailed = 1; } assert( pNew==0 ); return rc; }else{ |
︙ | ︙ | |||
647 648 649 650 651 652 653 | sqlite4 *db, /* Database handle. */ const char *zSql, /* UTF-8 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ sqlite4_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ const char **pzTail /* OUT: End of parsed string */ ){ int rc; | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 642 643 644 645 646 647 648 649 650 651 652 | sqlite4 *db, /* Database handle. */ const char *zSql, /* UTF-8 encoded SQL statement. */ int nBytes, /* Length of zSql in bytes. */ sqlite4_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ const char **pzTail /* OUT: End of parsed string */ ){ int rc; rc = sqlite4LockAndPrepare(db,zSql,nBytes,0,ppStmt,pzTail); assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */ return rc; } |
Changes to src/shell.c.
︙ | ︙ | |||
1093 1094 1095 1096 1097 1098 1099 | const char *zLeftover; /* Tail of unprocessed SQL */ if( pzErrMsg ){ *pzErrMsg = NULL; } while( zSql[0] && (SQLITE_OK == rc) ){ | | | 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 | const char *zLeftover; /* Tail of unprocessed SQL */ if( pzErrMsg ){ *pzErrMsg = NULL; } while( zSql[0] && (SQLITE_OK == rc) ){ rc = sqlite4_prepare(db, zSql, -1, &pStmt, &zLeftover); if( SQLITE_OK != rc ){ if( pzErrMsg ){ *pzErrMsg = save_err_msg(db); } }else{ if( !pStmt ){ /* this happens for a comment or white-space */ |
︙ | ︙ | |||
1393 1394 1395 1396 1397 1398 1399 | " LIKE pattern TABLE.\n" ".separator STRING Change separator used by output mode and .import\n" ".show Show the current values for various settings\n" ".stats ON|OFF Turn stats on or off\n" ".tables ?TABLE? List names of tables\n" " If TABLE specified, only list tables matching\n" " LIKE pattern TABLE.\n" | < | 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 | " LIKE pattern TABLE.\n" ".separator STRING Change separator used by output mode and .import\n" ".show Show the current values for various settings\n" ".stats ON|OFF Turn stats on or off\n" ".tables ?TABLE? List names of tables\n" " If TABLE specified, only list tables matching\n" " LIKE pattern TABLE.\n" ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n" ; static char zTimerHelp[] = ".timer ON|OFF Turn the CPU timer measurement on or off\n" ; |
︙ | ︙ | |||
2248 2249 2250 2251 2252 2253 2254 | default: fprintf(stderr,"Error: CLI support for testctrl %s not implemented\n", azArg[1]); break; } } }else | < < < < < | 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 | default: fprintf(stderr,"Error: CLI support for testctrl %s not implemented\n", azArg[1]); break; } } }else if( HAS_TIMER && c=='t' && n>=5 && strncmp(azArg[0], "timer", n)==0 && nArg==2 ){ enableTimer = booleanValue(azArg[1]); }else |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
120 121 122 123 124 125 126 | ** ** <blockquote><pre> ** assert( sqlite4_libversion_number()==SQLITE_VERSION_NUMBER ); ** assert( strcmp(sqlite4_sourceid(),SQLITE_SOURCE_ID)==0 ); ** assert( strcmp(sqlite4_libversion(),SQLITE_VERSION)==0 ); ** </pre></blockquote>)^ ** | < | < < | < | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | ** ** <blockquote><pre> ** assert( sqlite4_libversion_number()==SQLITE_VERSION_NUMBER ); ** assert( strcmp(sqlite4_sourceid(),SQLITE_SOURCE_ID)==0 ); ** assert( strcmp(sqlite4_libversion(),SQLITE_VERSION)==0 ); ** </pre></blockquote>)^ ** ** ^The sqlite4_libversion() function returns a pointer to a string ** constant that contains the text of [SQLITE_VERSION]. ^The ** sqlite4_libversion_number() function returns an integer equal to ** [SQLITE_VERSION_NUMBER]. ^The sqlite4_sourceid() function returns ** a pointer to a string constant whose value is the same as the ** [SQLITE_SOURCE_ID] C preprocessor macro. ** ** See also: [sqlite_version()] and [sqlite_source_id()]. */ const char *sqlite4_libversion(void); const char *sqlite4_sourceid(void); int sqlite4_libversion_number(void); /* ** CAPI3REF: Run-Time Library Compilation Options Diagnostics ** |
︙ | ︙ | |||
521 522 523 524 525 526 527 | #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 | < < < < < < < < < < < < < | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 /* ** CAPI3REF: Synchronization Type Flags ** ** When SQLite invokes the xSync() method of an ** [sqlite4_io_methods] object it uses a combination of ** these integer values as the second argument. ** |
︙ | ︙ | |||
1595 1596 1597 1598 1599 1600 1601 | ** </dl> */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ | < < < < < < < < < | 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 | ** </dl> */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ /* ** CAPI3REF: Last Insert Rowid ** ** ^Each entry in an SQLite table has a unique 64-bit signed ** integer key called the [ROWID | "rowid"]. ^The rowid is always available ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those ** names are not also used by explicitly declared columns. ^If |
︙ | ︙ | |||
1808 1809 1810 1811 1812 1813 1814 | ** ** The input to [sqlite4_complete16()] must be a zero-terminated ** UTF-16 string in native byte order. */ int sqlite4_complete(const char *sql); int sqlite4_complete16(const void *sql); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 | ** ** The input to [sqlite4_complete16()] must be a zero-terminated ** UTF-16 string in native byte order. */ int sqlite4_complete(const char *sql); int sqlite4_complete16(const void *sql); /* ** CAPI3REF: Convenience Routines For Running Queries ** ** This is a legacy interface that is preserved for backwards compatibility. ** Use of this interface is not recommended. ** ** Definition: A <b>result table</b> is memory data structure created by the |
︙ | ︙ | |||
2662 2663 2664 2665 2666 2667 2668 | int sqlite4_uri_boolean(const char *zFile, const char *zParam, int bDefault); sqlite4_int64 sqlite4_uri_int64(const char*, const char*, sqlite4_int64); /* ** CAPI3REF: Error Codes And Messages ** | | | < < < | 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 | int sqlite4_uri_boolean(const char *zFile, const char *zParam, int bDefault); sqlite4_int64 sqlite4_uri_int64(const char*, const char*, sqlite4_int64); /* ** CAPI3REF: Error Codes And Messages ** ** ^The sqlite4_errcode() interface returns the numeric ** [extended result code] for the most recent failed sqlite4_* API call ** associated with a [database connection]. If a prior API call failed ** but the most recent API call succeeded, the return value from ** sqlite4_errcode() is undefined. ** ** ^The sqlite4_errmsg() and sqlite4_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions.)^ |
︙ | ︙ | |||
2693 2694 2695 2696 2697 2698 2699 | ** all calls to the interfaces listed here are completed. ** ** If an interface fails with SQLITE_MISUSE, that means the interface ** was invoked incorrectly by the application. In that case, the ** error code and message may or may not be set. */ int sqlite4_errcode(sqlite4 *db); | < | 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 | ** all calls to the interfaces listed here are completed. ** ** If an interface fails with SQLITE_MISUSE, that means the interface ** was invoked incorrectly by the application. In that case, the ** error code and message may or may not be set. */ int sqlite4_errcode(sqlite4 *db); const char *sqlite4_errmsg(sqlite4*); const void *sqlite4_errmsg16(sqlite4*); /* ** CAPI3REF: SQL Statement Object ** KEYWORDS: {prepared statement} {prepared statements} ** |
︙ | ︙ | |||
2870 2871 2872 2873 2874 2875 2876 | ** string or a comment) then *ppStmt is set to NULL. ** The calling procedure is responsible for deleting the compiled ** SQL statement using [sqlite4_finalize()] after it has finished with it. ** ppStmt may not be NULL. ** ** ^On success, the sqlite4_prepare() family of routines return [SQLITE_OK]; ** otherwise an [error code] is returned. | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 | ** string or a comment) then *ppStmt is set to NULL. ** The calling procedure is responsible for deleting the compiled ** SQL statement using [sqlite4_finalize()] after it has finished with it. ** ppStmt may not be NULL. ** ** ^On success, the sqlite4_prepare() family of routines return [SQLITE_OK]; ** otherwise an [error code] is returned. */ int sqlite4_prepare( sqlite4 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite4_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* ** CAPI3REF: Retrieving Statement SQL ** ** ^This interface can be used to retrieve a saved copy of the original ** SQL text used to create a [prepared statement] if that statement was ** compiled using either [sqlite4_prepare_v2()] or [sqlite4_prepare16_v2()]. |
︙ | ︙ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
533 534 535 536 537 538 539 | #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC # define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0) #else # define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0) #endif | < < < < < < < < < < < < < < < < | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC # define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0) #else # define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0) #endif /* ** Name of the master database table. The master database table ** is a special table that holds the names and attributes of all ** user tables and indices. */ #define MASTER_NAME "sqlite_master" #define TEMP_MASTER_NAME "sqlite_temp_master" |
︙ | ︙ | |||
677 678 679 680 681 682 683 | typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WherePlan WherePlan; typedef struct WhereInfo WhereInfo; typedef struct WhereLevel WhereLevel; | < < < < < | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WherePlan WherePlan; typedef struct WhereInfo WhereInfo; typedef struct WhereLevel WhereLevel; #include "vdbe.h" #include "storage.h" #include "os.h" #include "mutex.h" |
︙ | ︙ | |||
840 841 842 843 844 845 846 | struct sqlite4 { sqlite4_vfs *pVfs; /* OS Interface */ int nDb; /* Number of backends currently in use */ Db *aDb; /* All backends */ int flags; /* Miscellaneous flags. See below */ unsigned int openFlags; /* Flags passed to sqlite4_vfs.xOpen() */ int errCode; /* Most recent error code (SQLITE_*) */ | < | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | struct sqlite4 { sqlite4_vfs *pVfs; /* OS Interface */ int nDb; /* Number of backends currently in use */ Db *aDb; /* All backends */ int flags; /* Miscellaneous flags. See below */ unsigned int openFlags; /* Flags passed to sqlite4_vfs.xOpen() */ int errCode; /* Most recent error code (SQLITE_*) */ u8 autoCommit; /* The auto-commit flag. */ u8 temp_store; /* 1: file 2: memory 0: default */ u8 mallocFailed; /* True if we have seen a malloc failure */ u8 dfltLockMode; /* Default locking-mode for attached dbs */ signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ u8 suppressErr; /* Do not issue error messages if true */ u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ |
︙ | ︙ | |||
913 914 915 916 917 918 919 | VtabCtx *pVtabCtx; /* Context for active vtab connect/create */ VTable **aVTrans; /* Virtual tables with open transactions */ int nVTrans; /* Allocated size of aVTrans */ VTable *pDisconnect; /* Disconnect these in next sqlite4_prepare() */ #endif FuncDefHash aFunc; /* Hash table of connection functions */ Hash aCollSeq; /* All collating sequences */ | < < | 891 892 893 894 895 896 897 898 899 900 901 902 903 904 | VtabCtx *pVtabCtx; /* Context for active vtab connect/create */ VTable **aVTrans; /* Virtual tables with open transactions */ int nVTrans; /* Allocated size of aVTrans */ VTable *pDisconnect; /* Disconnect these in next sqlite4_prepare() */ #endif FuncDefHash aFunc; /* Hash table of connection functions */ Hash aCollSeq; /* All collating sequences */ Db aDbStatic[2]; /* Static space for the 2 default backends */ Savepoint *pSavepoint; /* List of active savepoints */ int nSavepoint; /* Number of non-transaction savepoints */ int nStatement; /* Number of nested statement-transactions */ u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ i64 nDeferredCons; /* Net deferred constraints this transaction. */ int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ |
︙ | ︙ | |||
3078 3079 3080 3081 3082 3083 3084 | int sqlite4ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); void sqlite4ColumnDefault(Vdbe *, Table *, int, int); void sqlite4AlterFinishAddColumn(Parse *, Token *); void sqlite4AlterBeginAddColumn(Parse *, SrcList *); CollSeq *sqlite4GetCollSeq(sqlite4*, u8, CollSeq *, const char*); char sqlite4AffinityType(const char*); void sqlite4Analyze(Parse*, Token*, Token*); | < | 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 | int sqlite4ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); void sqlite4ColumnDefault(Vdbe *, Table *, int, int); void sqlite4AlterFinishAddColumn(Parse *, Token *); void sqlite4AlterBeginAddColumn(Parse *, SrcList *); CollSeq *sqlite4GetCollSeq(sqlite4*, u8, CollSeq *, const char*); char sqlite4AffinityType(const char*); void sqlite4Analyze(Parse*, Token*, Token*); int sqlite4FindDb(sqlite4*, Token*); int sqlite4FindDbName(sqlite4 *, const char *); int sqlite4AnalysisLoad(sqlite4*,int iDB); void sqlite4DeleteIndexSamples(sqlite4*,Index*); void sqlite4DefaultRowEst(Index*); void sqlite4RegisterLikeFunctions(sqlite4*, int); int sqlite4IsLikeFunction(sqlite4*,Expr*,int*,char*); |
︙ | ︙ |
Changes to src/tclsqlite.c.
︙ | ︙ | |||
101 102 103 104 105 106 107 | int nParm; /* Size of apParm array */ Tcl_Obj **apParm; /* Array of referenced object pointers */ }; /* ** There is one instance of this structure for each SQLite database ** that has been opened by the SQLite TCL interface. | < < < < < | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | int nParm; /* Size of apParm array */ Tcl_Obj **apParm; /* Array of referenced object pointers */ }; /* ** There is one instance of this structure for each SQLite database ** that has been opened by the SQLite TCL interface. */ typedef struct SqliteDb SqliteDb; struct SqliteDb { sqlite4 *db; /* The "real" database structure. MUST BE FIRST */ Tcl_Interp *interp; /* The interpreter used for this database */ char *zBusy; /* The busy callback routine */ char *zCommit; /* The commit hook callback routine */ |
︙ | ︙ | |||
133 134 135 136 137 138 139 | Tcl_Obj *pCollateNeeded; /* Collation needed script */ SqlPreparedStmt *stmtList; /* List of prepared statements*/ SqlPreparedStmt *stmtLast; /* Last statement in the list */ int maxStmt; /* The next maximum number of stmtList */ int nStmt; /* Number of statements in stmtList */ int nStep, nSort, nIndex; /* Statistics for most recent operation */ int nTransaction; /* Number of nested [transaction] methods */ | < < < | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | Tcl_Obj *pCollateNeeded; /* Collation needed script */ SqlPreparedStmt *stmtList; /* List of prepared statements*/ SqlPreparedStmt *stmtLast; /* Last statement in the list */ int maxStmt; /* The next maximum number of stmtList */ int nStmt; /* Number of statements in stmtList */ int nStep, nSort, nIndex; /* Statistics for most recent operation */ int nTransaction; /* Number of nested [transaction] methods */ }; /* ** Compute a string length that is limited to what can be stored in ** lower 30 bits of a 32-bit signed integer. */ static int strlen30(const char *z){ |
︙ | ︙ | |||
280 281 282 283 284 285 286 | } if( pDb->pCollateNeeded ){ Tcl_DecrRefCount(pDb->pCollateNeeded); } Tcl_Free((char*)pDb); } | < < < < < < < < < < < < < < < < < | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | } if( pDb->pCollateNeeded ){ Tcl_DecrRefCount(pDb->pCollateNeeded); } Tcl_Free((char*)pDb); } #ifndef SQLITE_OMIT_PROGRESS_CALLBACK /* ** This routine is invoked as the 'progress callback' for the database. */ static int DbProgressHandler(void *cd){ SqliteDb *pDb = (SqliteDb*)cd; int rc; |
︙ | ︙ | |||
812 813 814 815 816 817 818 | sqlite4_exec(pDb->db, "ROLLBACK", 0, 0, 0); } pDb->disableAuth--; return rc; } | < < < < < < < < < < < < < < < < < < < < < | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | sqlite4_exec(pDb->db, "ROLLBACK", 0, 0, 0); } pDb->disableAuth--; return rc; } /* ** Search the cache for a prepared-statement object that implements the ** first SQL statement in the buffer pointed to by parameter zIn. If ** no such prepared-statement can be found, allocate and prepare a new ** one. In either case, bind the current values of the relevant Tcl ** variables to any $var, :var or @var variables in the statement. Before ** returning, set *ppPreStmt to point to the prepared-statement object. |
︙ | ︙ | |||
903 904 905 906 907 908 909 | } /* If no prepared statement was found. Compile the SQL text. Also allocate ** a new SqlPreparedStmt structure. */ if( pPreStmt==0 ){ int nByte; | | | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | } /* If no prepared statement was found. Compile the SQL text. Also allocate ** a new SqlPreparedStmt structure. */ if( pPreStmt==0 ){ int nByte; if( SQLITE_OK!=sqlite4_prepare(pDb->db, zSql, -1, &pStmt, pzOut) ){ Tcl_SetObjResult(interp, dbTextToObj(sqlite4_errmsg(pDb->db))); return TCL_ERROR; } if( pStmt==0 ){ if( SQLITE_OK!=sqlite4_errcode(pDb->db) ){ /* A compile-time error in the statement. */ Tcl_SetObjResult(interp, dbTextToObj(sqlite4_errmsg(pDb->db))); |
︙ | ︙ | |||
1205 1206 1207 1208 1209 1210 1211 | dbReleaseColumnNames(p); p->pPreStmt = 0; if( rcs!=SQLITE_OK ){ /* If a run-time error occurs, report the error and stop reading ** the SQL. */ dbReleaseStmt(pDb, pPreStmt, 1); | < < < < < < < < < < < | 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 | dbReleaseColumnNames(p); p->pPreStmt = 0; if( rcs!=SQLITE_OK ){ /* If a run-time error occurs, report the error and stop reading ** the SQL. */ dbReleaseStmt(pDb, pPreStmt, 1); Tcl_SetObjResult(pDb->interp, dbTextToObj(sqlite4_errmsg(pDb->db))); return TCL_ERROR; }else{ dbReleaseStmt(pDb, pPreStmt, 0); } } } |
︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 | ** subroutine to be invoked. */ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *pDb = (SqliteDb*)cd; int choice; int rc = TCL_OK; static const char *DB_strs[] = { | | | | | | | | | < | | | | | | | | | | < | | | 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 | ** subroutine to be invoked. */ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *pDb = (SqliteDb*)cd; int choice; int rc = TCL_OK; static const char *DB_strs[] = { "authorizer", "cache", "changes", "close", "collate", "collation_needed", "commit_hook", "complete", "copy", "enable_load_extension", "errorcode", "eval", "exists", "function", "interrupt", "last_insert_rowid", "nullvalue", "onecolumn", "profile", "rekey", "rollback_hook", "status", "total_changes", "trace", "transaction", "unlock_notify", "update_hook", "version", "wal_hook", 0 }; enum DB_enum { DB_AUTHORIZER, DB_CACHE, DB_CHANGES, DB_CLOSE, DB_COLLATE, DB_COLLATION_NEEDED, DB_COMMIT_HOOK, DB_COMPLETE, DB_COPY, DB_ENABLE_LOAD_EXTENSION, DB_ERRORCODE, DB_EVAL, DB_EXISTS, DB_FUNCTION, DB_INTERRUPT, DB_LAST_INSERT_ROWID, DB_NULLVALUE, DB_ONECOLUMN, DB_PROFILE, DB_REKEY, DB_ROLLBACK_HOOK, DB_STATUS, DB_TOTAL_CHANGES, DB_TRACE, DB_TRANSACTION, DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK, DB_VERSION, DB_WAL_HOOK, }; /* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */ if( objc<2 ){ Tcl_WrongNumArgs(interp, 1, objv, "SUBCOMMAND ..."); return TCL_ERROR; } |
︙ | ︙ | |||
1479 1480 1481 1482 1483 1484 1485 | pDb->interp = interp; sqlite4_set_authorizer(pDb->db, auth_callback, pDb); }else{ sqlite4_set_authorizer(pDb->db, 0, 0); } } #endif | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 | pDb->interp = interp; sqlite4_set_authorizer(pDb->db, auth_callback, pDb); }else{ sqlite4_set_authorizer(pDb->db, 0, 0); } } #endif break; } /* $db cache flush ** $db cache size n ** ** Flush the prepared statement cache, or set the maximum number of |
︙ | ︙ | |||
2214 2215 2216 2217 2218 2219 2220 | (char*)0); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(v)); break; } | < < < < < < < < < < < < < < < < | 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 | (char*)0); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(v)); break; } /* ** $db total_changes ** ** Return the number of rows that were modified, inserted, or deleted ** since the database handle was created. */ case DB_TOTAL_CHANGES: { |
︙ | ︙ | |||
2505 2506 2507 2508 2509 2510 2511 | #else flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX; #endif if( objc==2 ){ zArg = Tcl_GetStringFromObj(objv[1], 0); if( strcmp(zArg,"-version")==0 ){ | | | 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 | #else flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX; #endif if( objc==2 ){ zArg = Tcl_GetStringFromObj(objv[1], 0); if( strcmp(zArg,"-version")==0 ){ Tcl_AppendResult(interp,sqlite4_libversion(),0); return TCL_OK; } if( strcmp(zArg,"-has-codec")==0 ){ #ifdef SQLITE_HAS_CODEC Tcl_AppendResult(interp,"1",0); #else Tcl_AppendResult(interp,"0",0); |
︙ | ︙ | |||
3195 3196 3197 3198 3199 3200 3201 | return TCL_ERROR; } pDb = (SqliteDb*)cmdInfo.objClientData; if( Tcl_GetBooleanFromObj(interp, objv[2], &bPrepare) ){ return TCL_ERROR; } | < < | 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 | return TCL_ERROR; } pDb = (SqliteDb*)cmdInfo.objClientData; if( Tcl_GetBooleanFromObj(interp, objv[2], &bPrepare) ){ return TCL_ERROR; } Tcl_ResetResult(interp); return TCL_OK; } #endif /* ** Configure the interpreter passed as the first argument to have access |
︙ | ︙ | |||
3227 3228 3229 3230 3231 3232 3233 | #ifdef SQLITE_TEST { extern int Sqliteconfig_Init(Tcl_Interp*); extern int Sqlitetest1_Init(Tcl_Interp*); extern int Sqlitetest3_Init(Tcl_Interp*); extern int Sqlitetest4_Init(Tcl_Interp*); extern int Sqlitetest5_Init(Tcl_Interp*); | < | 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 | #ifdef SQLITE_TEST { extern int Sqliteconfig_Init(Tcl_Interp*); extern int Sqlitetest1_Init(Tcl_Interp*); extern int Sqlitetest3_Init(Tcl_Interp*); extern int Sqlitetest4_Init(Tcl_Interp*); extern int Sqlitetest5_Init(Tcl_Interp*); extern int Sqlitetest7_Init(Tcl_Interp*); extern int Sqlitetest8_Init(Tcl_Interp*); extern int Sqlitetest9_Init(Tcl_Interp*); extern int Sqlitetest_demovfs_Init(Tcl_Interp *); extern int Sqlitetest_func_Init(Tcl_Interp*); extern int Sqlitetest_hexio_Init(Tcl_Interp*); extern int Sqlitetest_init_Init(Tcl_Interp*); |
︙ | ︙ | |||
3267 3268 3269 3270 3271 3272 3273 | Zipvfs_Init(interp); #endif Sqliteconfig_Init(interp); Sqlitetest1_Init(interp); Sqlitetest4_Init(interp); Sqlitetest5_Init(interp); | < | 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 | Zipvfs_Init(interp); #endif Sqliteconfig_Init(interp); Sqlitetest1_Init(interp); Sqlitetest4_Init(interp); Sqlitetest5_Init(interp); Sqlitetest7_Init(interp); Sqlitetest8_Init(interp); Sqlitetest9_Init(interp); Sqlitetest_demovfs_Init(interp); Sqlitetest_hexio_Init(interp); Sqlitetest_init_Init(interp); Sqlitetest_malloc_Init(interp); |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
1459 1460 1461 1462 1463 1464 1465 | memcpy(&r, &d, sizeof(r)); z = sqlite4_mprintf(argv[1], r); Tcl_AppendResult(interp, z, 0); sqlite4_free(z); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < | 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 | memcpy(&r, &d, sizeof(r)); z = sqlite4_mprintf(argv[1], r); Tcl_AppendResult(interp, z, 0); sqlite4_free(z); return TCL_OK; } /* ** Usage: sqlite4_libversion_number ** */ static int test_libversion_number( ClientData clientData, /* Pointer to sqlite4_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
︙ | ︙ | |||
3096 3097 3098 3099 3100 3101 3102 | if( Tcl_GetIntFromObj(interp, objv[1], &ms) ){ return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite4_sleep(ms))); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < | 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 | if( Tcl_GetIntFromObj(interp, objv[1], &ms) ){ return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite4_sleep(ms))); return TCL_OK; } /* ** Usage: sqlite4_errcode DB ** ** Return the string representation of the most recent sqlite4_* API ** error code. e.g. "SQLITE_ERROR". */ |
︙ | ︙ | |||
3270 3271 3272 3273 3274 3275 3276 | if( pStmt ){ if( sqlite4TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); } return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 | if( pStmt ){ if( sqlite4TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); } return TCL_OK; } /* ** Usage: sqlite4_prepare_tkt3134 DB ** ** Generate a prepared statement for a zero-byte string as a test ** for ticket #3134. The string should be preceeded by a zero byte. */ static int test_prepare_tkt3134( |
︙ | ︙ | |||
3349 3350 3351 3352 3353 3354 3355 | if( objc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " DB sql bytes tailvar", 0); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 | if( objc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " DB sql bytes tailvar", 0); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; rc = sqlite4_prepare(db, &zSql[1], 0, &pStmt, 0); assert(rc==SQLITE_OK || pStmt==0); if( sqlite4TestErrCode(interp, db, rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ assert( pStmt==0 ); sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite4_errmsg(db), 0); return TCL_ERROR; } if( pStmt ){ if( sqlite4TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); } return TCL_OK; } /* ** Usage: sqlite4_open filename ?options-list? */ static int test_open( void * clientData, Tcl_Interp *interp, int objc, |
︙ | ︙ | |||
4176 4177 4178 4179 4180 4181 4182 | } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; sprintf(zBuf, "%d", sqlite4_get_autocommit(db)); Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 | } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; sprintf(zBuf, "%d", sqlite4_get_autocommit(db)); Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** Usage: tcl_variable_type VARIABLENAME ** ** Return the name of the internal representation for the ** value of the given variable. */ static int tcl_variable_type( |
︙ | ︙ | |||
4864 4865 4866 4867 4868 4869 4870 | ** an EXPLAIN QUERY PLAN command to report on the prepared statement, ** and prints the report to stdout using printf(). */ int printExplainQueryPlan(sqlite4_stmt *pStmt){ const char *zSql; /* Input SQL */ char *zExplain; /* SQL with EXPLAIN QUERY PLAN prepended */ sqlite4_stmt *pExplain; /* Compiled EXPLAIN QUERY PLAN command */ | | | | 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 | ** an EXPLAIN QUERY PLAN command to report on the prepared statement, ** and prints the report to stdout using printf(). */ int printExplainQueryPlan(sqlite4_stmt *pStmt){ const char *zSql; /* Input SQL */ char *zExplain; /* SQL with EXPLAIN QUERY PLAN prepended */ sqlite4_stmt *pExplain; /* Compiled EXPLAIN QUERY PLAN command */ int rc; /* Return code from sqlite4_prepare() */ zSql = sqlite4_sql(pStmt); if( zSql==0 ) return SQLITE_ERROR; zExplain = sqlite4_mprintf("EXPLAIN QUERY PLAN %s", zSql); if( zExplain==0 ) return SQLITE_NOMEM; rc = sqlite4_prepare(sqlite4_db_handle(pStmt), zExplain, -1, &pExplain, 0); sqlite4_free(zExplain); if( rc!=SQLITE_OK ) return rc; while( SQLITE_ROW==sqlite4_step(pExplain) ){ int iSelectid = sqlite4_column_int(pExplain, 0); int iOrder = sqlite4_column_int(pExplain, 1); int iFrom = sqlite4_column_int(pExplain, 2); |
︙ | ︙ | |||
5185 5186 5187 5188 5189 5190 5191 | { "sqlite4_rekey", (Tcl_CmdProc*)test_rekey }, { "sqlite_set_magic", (Tcl_CmdProc*)sqlite_set_magic }, { "sqlite4_interrupt", (Tcl_CmdProc*)test_interrupt }, { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, { "sqlite4_get_autocommit", (Tcl_CmdProc*)get_autocommit }, { "sqlite4_stack_used", (Tcl_CmdProc*)test_stack_used }, | < | 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 | { "sqlite4_rekey", (Tcl_CmdProc*)test_rekey }, { "sqlite_set_magic", (Tcl_CmdProc*)sqlite_set_magic }, { "sqlite4_interrupt", (Tcl_CmdProc*)test_interrupt }, { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, { "sqlite4_get_autocommit", (Tcl_CmdProc*)get_autocommit }, { "sqlite4_stack_used", (Tcl_CmdProc*)test_stack_used }, { "printf", (Tcl_CmdProc*)test_printf }, { "sqlite4IoTrace", (Tcl_CmdProc*)test_io_trace }, }; static struct { char *zName; Tcl_ObjCmdProc *xProc; void *clientData; |
︙ | ︙ | |||
5209 5210 5211 5212 5213 5214 5215 | { "sqlite4_bind_blob", test_bind_blob ,0 }, { "sqlite4_bind_parameter_count", test_bind_parameter_count, 0}, { "sqlite4_bind_parameter_name", test_bind_parameter_name, 0}, { "sqlite4_bind_parameter_index", test_bind_parameter_index, 0}, { "sqlite4_clear_bindings", test_clear_bindings, 0}, { "sqlite4_sleep", test_sleep, 0}, { "sqlite4_errcode", test_errcode ,0 }, | < < < < < | 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 | { "sqlite4_bind_blob", test_bind_blob ,0 }, { "sqlite4_bind_parameter_count", test_bind_parameter_count, 0}, { "sqlite4_bind_parameter_name", test_bind_parameter_name, 0}, { "sqlite4_bind_parameter_index", test_bind_parameter_index, 0}, { "sqlite4_clear_bindings", test_clear_bindings, 0}, { "sqlite4_sleep", test_sleep, 0}, { "sqlite4_errcode", test_errcode ,0 }, { "sqlite4_errmsg", test_errmsg ,0 }, { "sqlite4_errmsg16", test_errmsg16 ,0 }, { "sqlite4_open", test_open ,0 }, { "sqlite4_open16", test_open16 ,0 }, { "sqlite4_open_v2", test_open_v2 ,0 }, { "sqlite4_complete16", test_complete16 ,0 }, { "sqlite4_prepare", test_prepare ,0 }, { "sqlite4_prepare_tkt3134", test_prepare_tkt3134, 0}, { "sqlite4_finalize", test_finalize ,0 }, { "sqlite4_stmt_status", test_stmt_status ,0 }, { "sqlite4_reset", test_reset ,0 }, { "sqlite4_expired", test_expired ,0 }, { "sqlite4_transfer_bindings", test_transfer_bind ,0 }, { "sqlite4_changes", test_changes ,0 }, { "sqlite4_step", test_step ,0 }, { "sqlite4_sql", test_sql ,0 }, { "sqlite4_next_stmt", test_next_stmt ,0 }, { "sqlite4_stmt_readonly", test_stmt_readonly ,0 }, { "sqlite4_stmt_busy", test_stmt_busy ,0 }, { "uses_stmt_journal", uses_stmt_journal ,0 }, { "sqlite4_release_memory", test_release_memory, 0}, { "sqlite4_db_release_memory", test_db_release_memory, 0}, { "sqlite4_soft_heap_limit", test_soft_heap_limit, 0}, { "sqlite4_limit", test_limit, 0}, { "save_prng_state", save_prng_state, 0 }, { "restore_prng_state", restore_prng_state, 0 }, { "reset_prng_state", reset_prng_state, 0 }, { "optimization_control", optimization_control,0}, #if SQLITE_OS_WIN |
︙ | ︙ |
Deleted src/test6.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/test9.c.
︙ | ︙ | |||
141 142 143 144 145 146 147 | rc = sqlite4_prepare(db, 0, 0, &pStmt, 0); if( rc!=SQLITE_MISUSE ){ zErrFunction = "sqlite4_prepare"; goto error_out; } assert( pStmt==0 ); /* Verify that pStmt is zeroed even on a MISUSE error */ | < < < < < < < < < < < < < < < < < < < < < < < < < | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | rc = sqlite4_prepare(db, 0, 0, &pStmt, 0); if( rc!=SQLITE_MISUSE ){ zErrFunction = "sqlite4_prepare"; goto error_out; } assert( pStmt==0 ); /* Verify that pStmt is zeroed even on a MISUSE error */ return TCL_OK; error_out: Tcl_ResetResult(interp); Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0); return TCL_ERROR; } |
︙ | ︙ |
Changes to src/test_func.c.
︙ | ︙ | |||
294 295 296 297 298 299 300 | ){ sqlite4_stmt *pStmt; int rc; sqlite4 *db = sqlite4_context_db_handle(pCtx); const char *zSql; zSql = (char*)sqlite4_value_text(argv[0]); | | | | 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 | ){ sqlite4_stmt *pStmt; int rc; sqlite4 *db = sqlite4_context_db_handle(pCtx); const char *zSql; zSql = (char*)sqlite4_value_text(argv[0]); rc = sqlite4_prepare(db, zSql, -1, &pStmt, 0); if( rc==SQLITE_OK ){ rc = sqlite4_step(pStmt); if( rc==SQLITE_ROW ){ sqlite4_result_value(pCtx, sqlite4_column_value(pStmt, 0)); } rc = sqlite4_finalize(pStmt); } if( rc ){ char *zErr; assert( pStmt==0 ); zErr = sqlite4_mprintf("sqlite4_prepare() error: %s",sqlite4_errmsg(db)); sqlite4_result_text(pCtx, zErr, -1, sqlite4_free); sqlite4_result_error_code(pCtx, rc); } } /* |
︙ | ︙ |
Deleted src/test_journal.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/test_thread.c.
︙ | ︙ | |||
51 52 53 54 55 56 57 | Tcl_Interp *interp; /* The interpreter to execute it in. */ }; static Tcl_ObjCmdProc sqlthread_proc; static Tcl_ObjCmdProc clock_seconds_proc; #if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) static Tcl_ObjCmdProc blocking_step_proc; | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | Tcl_Interp *interp; /* The interpreter to execute it in. */ }; static Tcl_ObjCmdProc sqlthread_proc; static Tcl_ObjCmdProc clock_seconds_proc; #if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) static Tcl_ObjCmdProc blocking_step_proc; static Tcl_ObjCmdProc blocking_prepare_proc; #endif int Sqlitetest1_Init(Tcl_Interp *); int Sqlite3_Init(Tcl_Interp *); /* Functions from test1.c */ void *sqlite4TestTextToPtr(const char *); const char *sqlite4TestErrorName(int); |
︙ | ︙ | |||
115 116 117 118 119 120 121 | interp = Tcl_CreateInterp(); Tcl_CreateObjCommand(interp, "clock_seconds", clock_seconds_proc, 0, 0); Tcl_CreateObjCommand(interp, "sqlthread", sqlthread_proc, pSqlThread, 0); #if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) Tcl_CreateObjCommand(interp, "sqlite4_blocking_step", blocking_step_proc,0,0); Tcl_CreateObjCommand(interp, | | | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | interp = Tcl_CreateInterp(); Tcl_CreateObjCommand(interp, "clock_seconds", clock_seconds_proc, 0, 0); Tcl_CreateObjCommand(interp, "sqlthread", sqlthread_proc, pSqlThread, 0); #if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) Tcl_CreateObjCommand(interp, "sqlite4_blocking_step", blocking_step_proc,0,0); Tcl_CreateObjCommand(interp, "sqlite4_blocking_prepare", blocking_prepare_proc, (void *)1, 0); Tcl_CreateObjCommand(interp, "sqlite4_nonblocking_prepare", blocking_prepare_proc, 0, 0); #endif Sqlitetest1_Init(interp); Sqlitetest_mutex_Init(interp); Sqlite3_Init(interp); rc = Tcl_Eval(interp, p->zScript); pRes = Tcl_GetObjResult(interp); |
︙ | ︙ | |||
246 247 248 249 250 251 252 | pEvent->interp = p->interp; Tcl_ThreadQueueEvent(p->parent, (Tcl_Event *)pEvent, TCL_QUEUE_TAIL); Tcl_ThreadAlert(p->parent); return TCL_OK; } | < < < < < < < | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | pEvent->interp = p->interp; Tcl_ThreadQueueEvent(p->parent, (Tcl_Event *)pEvent, TCL_QUEUE_TAIL); Tcl_ThreadAlert(p->parent); return TCL_OK; } /* ** sqlthread open ** ** Open a database handle and return the string representation of ** the pointer value. */ static int sqlthread_open( |
︙ | ︙ | |||
294 295 296 297 298 299 300 | Tcl_AppendResult(interp, zErrMsg, (char*)0); sqlite4_free(zErrMsg); return TCL_ERROR; } } #endif Md5_Register(db); | < | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | Tcl_AppendResult(interp, zErrMsg, (char*)0); sqlite4_free(zErrMsg); return TCL_ERROR; } } #endif Md5_Register(db); if( sqlite4TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } |
︙ | ︙ | |||
435 436 437 438 439 440 441 | p->fired = 1; pthread_cond_signal(&p->cond); pthread_mutex_unlock(&p->mutex); } } /* | | | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | p->fired = 1; pthread_cond_signal(&p->cond); pthread_mutex_unlock(&p->mutex); } } /* ** This function assumes that an SQLite API call (either sqlite4_prepare() ** or sqlite4_step()) has just returned SQLITE_LOCKED. The argument is the ** associated database connection. ** ** This function calls sqlite4_unlock_notify() to register for an ** unlock-notify callback, then blocks until that callback is delivered ** and returns SQLITE_OK. The caller should then retry the failed operation. ** |
︙ | ︙ | |||
506 507 508 509 510 511 512 | if( rc!=SQLITE_OK ) break; sqlite4_reset(pStmt); } return rc; } /* | | | | | 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 | if( rc!=SQLITE_OK ) break; sqlite4_reset(pStmt); } return rc; } /* ** This function is a wrapper around the SQLite function sqlite4_prepare(). ** It functions in the same way as prepare_v2(), except that if a required ** shared-cache lock cannot be obtained, this function may block waiting for ** the lock to become available. In this scenario the normal API prepare_v2() ** function always returns SQLITE_LOCKED. ** ** If this function returns SQLITE_LOCKED, the caller should rollback ** the current transaction (if any) and try again later. Otherwise, the ** system may become deadlocked. */ int sqlite4_blocking_prepare( sqlite4 *db, /* Database handle. */ const char *zSql, /* UTF-8 encoded SQL statement. */ int nSql, /* Length of zSql in bytes. */ sqlite4_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ const char **pz /* OUT: End of parsed string */ ){ int rc; while( SQLITE_LOCKED==(rc = sqlite4_prepare(db, zSql, nSql, ppStmt, pz)) ){ rc = wait_for_unlock_notify(db); if( rc!=SQLITE_OK ) break; } return rc; } /* END_SQLITE_BLOCKING_STEP */ |
︙ | ︙ | |||
560 561 562 563 564 565 566 | rc = sqlite4_blocking_step(pStmt); Tcl_SetResult(interp, (char *)sqlite4TestErrorName(rc), 0); return TCL_OK; } /* | | | | | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | rc = sqlite4_blocking_step(pStmt); Tcl_SetResult(interp, (char *)sqlite4TestErrorName(rc), 0); return TCL_OK; } /* ** Usage: sqlite4_blocking_prepare DB sql bytes ?tailvar? ** Usage: sqlite4_nonblocking_prepare DB sql bytes ?tailvar? */ static int blocking_prepare_proc( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite4 *db; const char *zSql; |
︙ | ︙ | |||
588 589 590 591 592 593 594 | return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; zSql = Tcl_GetString(objv[2]); if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; if( isBlocking ){ | | | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; zSql = Tcl_GetString(objv[2]); if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR; if( isBlocking ){ rc = sqlite4_blocking_prepare(db, zSql, bytes, &pStmt, &zTail); }else{ rc = sqlite4_prepare(db, zSql, bytes, &pStmt, &zTail); } assert(rc==SQLITE_OK || pStmt==0); if( zTail && objc>=5 ){ if( bytes>=0 ){ bytes = bytes - (zTail-zSql); } |
︙ | ︙ | |||
628 629 630 631 632 633 634 | */ int SqlitetestThread_Init(Tcl_Interp *interp){ Tcl_CreateObjCommand(interp, "sqlthread", sqlthread_proc, 0, 0); Tcl_CreateObjCommand(interp, "clock_seconds", clock_seconds_proc, 0, 0); #if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) Tcl_CreateObjCommand(interp, "sqlite4_blocking_step", blocking_step_proc,0,0); Tcl_CreateObjCommand(interp, | | | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | */ int SqlitetestThread_Init(Tcl_Interp *interp){ Tcl_CreateObjCommand(interp, "sqlthread", sqlthread_proc, 0, 0); Tcl_CreateObjCommand(interp, "clock_seconds", clock_seconds_proc, 0, 0); #if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) Tcl_CreateObjCommand(interp, "sqlite4_blocking_step", blocking_step_proc,0,0); Tcl_CreateObjCommand(interp, "sqlite4_blocking_prepare", blocking_prepare_proc, (void *)1, 0); Tcl_CreateObjCommand(interp, "sqlite4_nonblocking_prepare", blocking_prepare_proc, 0, 0); #endif return TCL_OK; } #else int SqlitetestThread_Init(Tcl_Interp *interp){ return TCL_OK; } #endif |
Changes to src/vdbe.c.
︙ | ︙ | |||
548 549 550 551 552 553 554 | ** sqlite4_column_text16() failed. */ goto no_mem; } assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY ); p->rc = SQLITE_OK; assert( p->explain==0 ); p->pResultSet = 0; | < | 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | ** sqlite4_column_text16() failed. */ goto no_mem; } assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY ); p->rc = SQLITE_OK; assert( p->explain==0 ); p->pResultSet = 0; CHECK_FOR_INTERRUPT; sqlite4VdbeIOTraceSql(p); #ifndef SQLITE_OMIT_PROGRESS_CALLBACK checkProgress = db->xProgress!=0; #endif #ifdef SQLITE_DEBUG sqlite4BeginBenignMalloc(); |
︙ | ︙ | |||
3261 3262 3263 3264 3265 3266 3267 | ** for indices is OP_IdxInsert. */ /* Opcode: InsertInt P1 P2 P3 P4 P5 ** ** This works exactly like OP_Insert except that the key is the ** integer value P3, not the value of the integer stored in register P3. */ | | | 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 | ** for indices is OP_IdxInsert. */ /* Opcode: InsertInt P1 P2 P3 P4 P5 ** ** This works exactly like OP_Insert except that the key is the ** integer value P3, not the value of the integer stored in register P3. */ case OP_Insert: case OP_InsertInt: { Mem *pData; /* MEM cell holding data for the record to be inserted */ Mem *pKey; /* MEM cell holding key for the record */ i64 iKey; /* The integer ROWID or key for the record to be inserted */ VdbeCursor *pC; /* Cursor to table into which insert is written */ const char *zDb; /* database name - used by the update hook */ const char *zTbl; /* Table name - used by the opdate hook */ |
︙ | ︙ | |||
3287 3288 3289 3290 3291 3292 3293 | if( pOp->opcode==OP_Insert ){ pKey = &aMem[pOp->p3]; assert( pKey->flags & MEM_Int ); assert( memIsValid(pKey) ); REGISTER_TRACE(pOp->p3, pKey); iKey = pKey->u.i; }else{ | | | 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 | if( pOp->opcode==OP_Insert ){ pKey = &aMem[pOp->p3]; assert( pKey->flags & MEM_Int ); assert( memIsValid(pKey) ); REGISTER_TRACE(pOp->p3, pKey); iKey = pKey->u.i; }else{ /* assert( pOp->opcode==OP_InsertInt ); */ iKey = pOp->p3; } if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey; if( pData->flags & MEM_Null ){ pData->z = 0; |
︙ | ︙ |
Changes to src/vdbe.h.
︙ | ︙ | |||
201 202 203 204 205 206 207 | void sqlite4VdbeResetStepResult(Vdbe*); void sqlite4VdbeRewind(Vdbe*); int sqlite4VdbeReset(Vdbe*); void sqlite4VdbeSetNumCols(Vdbe*,int); int sqlite4VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); void sqlite4VdbeCountChanges(Vdbe*); sqlite4 *sqlite4VdbeDb(Vdbe*); | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | void sqlite4VdbeResetStepResult(Vdbe*); void sqlite4VdbeRewind(Vdbe*); int sqlite4VdbeReset(Vdbe*); void sqlite4VdbeSetNumCols(Vdbe*,int); int sqlite4VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); void sqlite4VdbeCountChanges(Vdbe*); sqlite4 *sqlite4VdbeDb(Vdbe*); void sqlite4VdbeSetSql(Vdbe*, const char *z, int n); void sqlite4VdbeSwap(Vdbe*,Vdbe*); VdbeOp *sqlite4VdbeTakeOpArray(Vdbe*, int*, int*); sqlite4_value *sqlite4VdbeGetValue(Vdbe*, int, u8); void sqlite4VdbeSetVarmask(Vdbe*, int); #ifndef SQLITE_OMIT_TRACE char *sqlite4VdbeExpandSql(Vdbe*, const char*); #endif |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
304 305 306 307 308 309 310 | u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ u8 runOnlyOnce; /* Automatically expire on reset */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ u8 needSavepoint; /* True if a change might abort and needs savepoint */ u8 readOnly; /* True for read-only statements */ | < | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ u8 runOnlyOnce; /* Automatically expire on reset */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ u8 needSavepoint; /* True if a change might abort and needs savepoint */ u8 readOnly; /* True for read-only statements */ int nChange; /* Number of db changes made since last reset */ yDbMask stmtTransMask; /* db->aDb[] entries that have a subtransaction */ int aCounter[3]; /* Counters used by sqlite4_stmt_status() */ #ifndef SQLITE_OMIT_TRACE i64 startTime; /* Time when query started - used for profiling */ #endif i64 nFkConstraint; /* Number of imm. FK constraints this VM */ |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
99 100 101 102 103 104 105 | if( pStmt==0 ){ rc = SQLITE_OK; }else{ Vdbe *v = (Vdbe*)pStmt; sqlite4_mutex_enter(v->db->mutex); rc = sqlite4VdbeReset(v); sqlite4VdbeRewind(v); | < | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | if( pStmt==0 ){ rc = SQLITE_OK; }else{ Vdbe *v = (Vdbe*)pStmt; sqlite4_mutex_enter(v->db->mutex); rc = sqlite4VdbeReset(v); sqlite4VdbeRewind(v); rc = sqlite4ApiExit(v->db, rc); sqlite4_mutex_leave(v->db->mutex); } return rc; } /* |
︙ | ︙ | |||
121 122 123 124 125 126 127 | sqlite4_mutex *mutex = ((Vdbe*)pStmt)->db->mutex; #endif sqlite4_mutex_enter(mutex); for(i=0; i<p->nVar; i++){ sqlite4VdbeMemRelease(&p->aVar[i]); p->aVar[i].flags = MEM_Null; } | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | sqlite4_mutex *mutex = ((Vdbe*)pStmt)->db->mutex; #endif sqlite4_mutex_enter(mutex); for(i=0; i<p->nVar; i++){ sqlite4VdbeMemRelease(&p->aVar[i]); p->aVar[i].flags = MEM_Null; } if( p->expmask ){ p->expired = 1; } sqlite4_mutex_leave(mutex); return rc; } |
︙ | ︙ | |||
416 417 418 419 420 421 422 | ** contains the value that would be returned if sqlite4_finalize() ** were called on statement p. */ assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR || rc==SQLITE_BUSY || rc==SQLITE_MISUSE ); assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE ); | | < < < < | | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | ** contains the value that would be returned if sqlite4_finalize() ** were called on statement p. */ assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR || rc==SQLITE_BUSY || rc==SQLITE_MISUSE ); assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE ); if( rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ rc = sqlite4VdbeTransferError(p); } return rc; } /* ** The maximum number of times that a statement will try to reparse ** itself before giving up and returning SQLITE_SCHEMA. */ #ifndef SQLITE_MAX_SCHEMA_RETRY |
︙ | ︙ | |||
457 458 459 460 461 462 463 | sqlite4_mutex_enter(db->mutex); while( (rc = sqlite4Step(v))==SQLITE_SCHEMA && cnt++ < SQLITE_MAX_SCHEMA_RETRY && (rc2 = rc = sqlite4Reprepare(v))==SQLITE_OK ){ sqlite4_reset(pStmt); assert( v->expired==0 ); } | | | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | sqlite4_mutex_enter(db->mutex); while( (rc = sqlite4Step(v))==SQLITE_SCHEMA && cnt++ < SQLITE_MAX_SCHEMA_RETRY && (rc2 = rc = sqlite4Reprepare(v))==SQLITE_OK ){ sqlite4_reset(pStmt); assert( v->expired==0 ); } if( rc2!=SQLITE_OK && ALWAYS(db->pErr) ){ /* This case occurs after failing to recompile an sql statement. ** The error message from the SQL compiler has already been loaded ** into the database handle. This block copies the error message ** from the database handle into the statement and sets the statement ** program counter to 0 to ensure that when the statement is ** finalized or reset the parser error message is available via ** sqlite4_errmsg() and sqlite4_errcode(). |
︙ | ︙ | |||
985 986 987 988 989 990 991 | ** ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host ** parameter in the WHERE clause might influence the choice of query plan ** for a statement, then the statement will be automatically recompiled, ** as if there had been a schema change, on the first sqlite4_step() call ** following any change to the bindings of that parameter. */ | < | | 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | ** ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host ** parameter in the WHERE clause might influence the choice of query plan ** for a statement, then the statement will be automatically recompiled, ** as if there had been a schema change, on the first sqlite4_step() call ** following any change to the bindings of that parameter. */ if( ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff) ){ p->expired = 1; } return SQLITE_OK; } /* |
︙ | ︙ | |||
1216 1217 1218 1219 1220 1221 1222 | */ int sqlite4_transfer_bindings(sqlite4_stmt *pFromStmt, sqlite4_stmt *pToStmt){ Vdbe *pFrom = (Vdbe*)pFromStmt; Vdbe *pTo = (Vdbe*)pToStmt; if( pFrom->nVar!=pTo->nVar ){ return SQLITE_ERROR; } | | | | 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 | */ int sqlite4_transfer_bindings(sqlite4_stmt *pFromStmt, sqlite4_stmt *pToStmt){ Vdbe *pFrom = (Vdbe*)pFromStmt; Vdbe *pTo = (Vdbe*)pToStmt; if( pFrom->nVar!=pTo->nVar ){ return SQLITE_ERROR; } if( pTo->expmask ){ pTo->expired = 1; } if( pFrom->expmask ){ pFrom->expired = 1; } return sqlite4TransferBindings(pFromStmt, pToStmt); } #endif /* |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
46 47 48 49 50 51 52 | p->magic = VDBE_MAGIC_INIT; return p; } /* ** Remember the SQL string for a prepared statement. */ | | < < < < < | < | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | p->magic = VDBE_MAGIC_INIT; return p; } /* ** Remember the SQL string for a prepared statement. */ void sqlite4VdbeSetSql(Vdbe *p, const char *z, int n){ if( p==0 ) return; assert( p->zSql==0 ); p->zSql = sqlite4DbStrNDup(p->db, z, n); } /* ** Return the SQL associated with a prepared statement */ const char *sqlite4_sql(sqlite4_stmt *pStmt){ Vdbe *p = (Vdbe *)pStmt; return p ? p->zSql : 0; } /* ** Swap all content between two VDBE structures. */ void sqlite4VdbeSwap(Vdbe *pA, Vdbe *pB){ Vdbe tmp, *pTmp; char *zTmp; tmp = *pA; *pA = *pB; *pB = tmp; pTmp = pA->pNext; pA->pNext = pB->pNext; pB->pNext = pTmp; pTmp = pA->pPrev; pA->pPrev = pB->pPrev; pB->pPrev = pTmp; zTmp = pA->zSql; pA->zSql = pB->zSql; pB->zSql = zTmp; } #ifdef SQLITE_DEBUG /* ** Turn tracing on or off */ void sqlite4VdbeTrace(Vdbe *p, FILE *trace){ |
︙ | ︙ | |||
1996 1997 1998 1999 2000 2001 2002 | sqlite4VdbePrintOp(out, i, &p->aOp[i]); } fclose(out); } } #endif p->magic = VDBE_MAGIC_INIT; | | < | 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 | sqlite4VdbePrintOp(out, i, &p->aOp[i]); } fclose(out); } } #endif p->magic = VDBE_MAGIC_INIT; return p->rc; } /* ** Clean up and delete a VDBE after execution. Return an integer which is ** the result code. Write any error message text into *pzErrMsg. */ int sqlite4VdbeFinalize(Vdbe *p){ int rc = SQLITE_OK; if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){ rc = sqlite4VdbeReset(p); } sqlite4VdbeDelete(p); return rc; } /* ** Call the destructor for each auxdata entry in pVdbeFunc for which |
︙ | ︙ |