Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use the new API calls more consistently. (CVS 1459) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
17e7db488dac6b30d174f2272edf1046 |
User & Date: | danielk1977 2004-05-26 02:04:57.000 |
Context
2004-05-26
| ||
06:18 | Use the new form of the sqlite3_create_function() API. (CVS 1460) (check-in: 0317bef4b0 user: danielk1977 tags: trunk) | |
02:04 | Use the new API calls more consistently. (CVS 1459) (check-in: 17e7db488d user: danielk1977 tags: trunk) | |
00:07 | More changes to do with the new sqlite3_step() API. (CVS 1458) (check-in: e83138250c user: danielk1977 tags: trunk) | |
Changes
Changes to src/legacy.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: legacy.c,v 1.2 2004/05/26 02:04:57 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* |
︙ | ︙ | |||
51 52 53 54 55 56 57 | while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0] ){ int nCol; char **azVals = 0; pStmt = 0; rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover); if( rc!=SQLITE_OK ){ | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0] ){ int nCol; char **azVals = 0; pStmt = 0; rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover); if( rc!=SQLITE_OK ){ if( pStmt ) sqlite3_finalize(pStmt); continue; } if( !pStmt ){ /* this happens for a comment or white-space */ zSql = zLeftover; continue; } |
︙ | ︙ | |||
96 97 98 99 100 101 102 | if( xCallback(pArg, nCol, azVals, azCols) ){ rc = SQLITE_ABORT; goto exec_out; } } if( rc!=SQLITE_ROW ){ | | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | if( xCallback(pArg, nCol, azVals, azCols) ){ rc = SQLITE_ABORT; goto exec_out; } } if( rc!=SQLITE_ROW ){ rc = sqlite3_finalize(pStmt); pStmt = 0; if( db->pVdbe==0 ){ nChange = db->nChange; } if( rc!=SQLITE_SCHEMA ){ nRetry = 0; zSql = zLeftover; while( isspace(zSql[0]) ) zSql++; } break; } } sqliteFree(azCols); azCols = 0; } exec_out: if( pStmt ) sqlite3_finalize(pStmt); if( azCols ) sqliteFree(azCols); if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){ *pzErrMsg = malloc(1+strlen(sqlite3_errmsg(db))); if( *pzErrMsg ){ strcpy(*pzErrMsg, sqlite3_errmsg(db)); } |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.190 2004/05/26 02:04:57 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** A pointer to this structure is used to communicate information |
︙ | ︙ | |||
478 479 480 481 482 483 484 | db->aDb[i].inTrans = 0; } } sqlite3ResetInternalSchema(db, 0); /* sqlite3RollbackInternalChanges(db); */ } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | db->aDb[i].inTrans = 0; } } sqlite3ResetInternalSchema(db, 0); /* sqlite3RollbackInternalChanges(db); */ } /* ** Return a static string that describes the kind of error specified in the ** argument. */ const char *sqlite3_error_string(int rc){ const char *z; switch( rc ){ |
︙ | ︙ | |||
1248 1249 1250 1251 1252 1253 1254 | ** the sqlite3_compile() routine. The integer returned is an SQLITE_ ** success/failure code that describes the result of executing the virtual ** machine. ** ** This routine sets the error code and string returned by ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). */ | | | | 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | ** the sqlite3_compile() routine. The integer returned is an SQLITE_ ** success/failure code that describes the result of executing the virtual ** machine. ** ** This routine sets the error code and string returned by ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). */ int sqlite3_finalize(sqlite3_stmt *pStmt){ return sqlite3VdbeFinalize((Vdbe*)pStmt, 0); } /* ** Terminate the current execution of an SQL statement and reset it ** back to its starting state so that it can be reused. A success code from ** the prior execution is returned. ** ** This routine sets the error code and string returned by ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16(). */ int sqlite3_reset(sqlite3_stmt *pStmt){ int rc = sqlite3VdbeReset((Vdbe*)pStmt, 0); sqlite3VdbeMakeReady((Vdbe*)pStmt, -1, 0); return rc; } |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** ** @(#) $Id: sqlite.h.in,v 1.79 2004/05/26 02:04:57 danielk1977 Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. |
︙ | ︙ | |||
538 539 540 541 542 543 544 | /* ** Register a function that is called at every invocation of sqlite3_exec() ** or sqlite3_prepare(). This function can be used (for example) to generate ** a log file of all SQL executed against a database. */ void *sqlite3_trace(sqlite*, void(*xTrace)(void*,const char*), void*); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | /* ** Register a function that is called at every invocation of sqlite3_exec() ** or sqlite3_prepare(). This function can be used (for example) to generate ** a log file of all SQL executed against a database. */ void *sqlite3_trace(sqlite*, void(*xTrace)(void*,const char*), void*); /* ** This routine configures a callback function - the progress callback - that ** is invoked periodically during long running calls to sqlite3_exec(), ** sqlite3_step() and sqlite3_get_table(). An example use for this API is to keep ** a GUI updated during a large query. ** ** The progress callback is invoked once for every N virtual machine opcodes, ** where N is the second argument to this function. The progress callback ** itself is identified by the third argument to this function. The fourth ** argument to this function is a void pointer passed to the progress callback ** function each time it is invoked. ** ** If a call to sqlite3_exec(), sqlite3_step() or sqlite3_get_table() results ** in less than N opcodes being executed, then the progress callback is not ** invoked. ** ** To remove the progress callback altogether, pass NULL as the third ** argument to this function. ** ** If the progress callback returns a result other than 0, then the current ** query is immediately terminated and any database changes rolled back. If the ** query was part of a larger transaction, then the transaction is not rolled ** back and remains active. The sqlite3_exec() call returns SQLITE_ABORT. |
︙ | ︙ | |||
751 752 753 754 755 756 757 | ** ** The "in" and "out" parameters may point to the same buffer in order ** to decode a string in place. */ int sqlite_decode_binary(const unsigned char *in, unsigned char *out); | < | | > | 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | ** ** The "in" and "out" parameters may point to the same buffer in order ** to decode a string in place. */ int sqlite_decode_binary(const unsigned char *in, unsigned char *out); typedef sqlite sqlite3; typedef struct sqlite3_stmt sqlite3_stmt; /* ** This routine is used to bind a 32-bit integer value to a variable ** in an SQL statement compiled by sqlite3_prepare(). See comments for ** sqlite3_prepare() for more details on SQL statement variables. ** ** The first argument is a pointer to an SQL statement previously |
︙ | ︙ | |||
1080 1081 1082 1083 1084 1085 1086 1087 | /* ** The sqlite3_finalize() function is called to delete a compiled ** SQL statement obtained by a previous call to sqlite3_prepare() ** or sqlite3_prepare16(). If the statement was executed successfully, or ** not executed at all, then SQLITE_OK is returned. If execution of the ** statement failed then an error code is returned. */ | > > > > > > > | | | 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | /* ** The sqlite3_finalize() function is called to delete a compiled ** SQL statement obtained by a previous call to sqlite3_prepare() ** or sqlite3_prepare16(). If the statement was executed successfully, or ** not executed at all, then SQLITE_OK is returned. If execution of the ** statement failed then an error code is returned. ** ** This routine can be called at any point during the execution of the ** virtual machine. If the virtual machine has not completed execution ** when this routine is called, that is like encountering an error or ** an interrupt. (See sqlite3_interrupt().) Incomplete updates may be ** rolled back and transactions cancelled, depending on the circumstances, ** and the result code returned will be SQLITE_ABORT. */ int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** The sqlite3_reset() function is called to reset a compiled SQL ** statement obtained by a previous call to sqlite3_prepare() or ** sqlite3_prepare16() back to it's initial state, ready to be re-executed. ** Any SQL statement variables that had values bound to them using ** the sqlite3_bind_*() API retain their values. */ int sqlite3_reset(sqlite3_stmt *pStmt); /* ** Open the sqlite database file "filename", where "filename" is UTF-8 ** encoded. An sqlite3* handle is returned in *ppDb, even if an error ** occurs. If the database is opened (or created) successfully, then ** SQLITE_OK is returned. Otherwise an error code is returned and the ** sqlite3_errmsg() function may be used to obtain an English language |
︙ | ︙ |
Changes to src/tclsqlite.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 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. ** ************************************************************************* ** A TCL Interface to SQLite ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 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. ** ************************************************************************* ** A TCL Interface to SQLite ** ** $Id: tclsqlite.c,v 1.70 2004/05/26 02:04:57 danielk1977 Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
1214 1215 1216 1217 1218 1219 1220 | extern int Sqlitetest3_Init(Tcl_Interp*); extern int Sqlitetest4_Init(Tcl_Interp*); extern int Sqlitetest5_Init(Tcl_Interp*); extern int Md5_Init(Tcl_Interp*); Sqlitetest1_Init(interp); Sqlitetest2_Init(interp); Sqlitetest3_Init(interp); | | | 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 | extern int Sqlitetest3_Init(Tcl_Interp*); extern int Sqlitetest4_Init(Tcl_Interp*); extern int Sqlitetest5_Init(Tcl_Interp*); extern int Md5_Init(Tcl_Interp*); Sqlitetest1_Init(interp); Sqlitetest2_Init(interp); Sqlitetest3_Init(interp); Sqlitetest4_Init(interp); Sqlitetest5_Init(interp); Md5_Init(interp); } #endif if( argc>=2 ){ int i; Tcl_SetVar(interp,"argv0",argv[1],TCL_GLOBAL_ONLY); |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.54 2004/05/26 02:04:57 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
69 70 71 72 73 74 75 | static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite **ppDb){ if( sscanf(zA, PTR_FMT, (void**)ppDb)!=1 && (zA[0]!='0' || zA[1]!='x' || sscanf(&zA[2], PTR_FMT, (void**)ppDb)!=1) ){ Tcl_AppendResult(interp, "\"", zA, "\" is not a valid pointer value", 0); return TCL_ERROR; } | < < < < < < < < < < < | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite **ppDb){ if( sscanf(zA, PTR_FMT, (void**)ppDb)!=1 && (zA[0]!='0' || zA[1]!='x' || sscanf(&zA[2], PTR_FMT, (void**)ppDb)!=1) ){ Tcl_AppendResult(interp, "\"", zA, "\" is not a valid pointer value", 0); return TCL_ERROR; } return TCL_OK; } /* ** Decode a pointer to an sqlite3_stmt object. */ static int getStmtPointer( |
︙ | ︙ | |||
776 777 778 779 780 781 782 | Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " <STMT>", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | | | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " <STMT>", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; rc = sqlite3_finalize(pStmt); if( rc ){ return TCL_ERROR; } return TCL_OK; } /* |
︙ | ︙ | |||
805 806 807 808 809 810 811 | Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " <STMT>", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | | | 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 | Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " <STMT>", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; rc = sqlite3_reset(pStmt); if( rc ){ return TCL_ERROR; } return TCL_OK; } /* |
︙ | ︙ | |||
840 841 842 843 844 845 846 | */ static int test_bind( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ char **argv /* Text of each argument */ ){ | | | | | | | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 | */ static int test_bind( void *NotUsed, Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int argc, /* Number of arguments */ char **argv /* Text of each argument */ ){ sqlite3_stmt *pStmt; int rc; int idx; if( argc!=5 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " VM IDX VALUE (null|static|normal)\"", 0); return TCL_ERROR; } if( getStmtPointer(interp, argv[1], &pStmt) ) return TCL_ERROR; if( Tcl_GetInt(interp, argv[2], &idx) ) return TCL_ERROR; if( strcmp(argv[4],"null")==0 ){ rc = sqlite3_bind_null(pStmt, idx); }else if( strcmp(argv[4],"static")==0 ){ rc = sqlite3_bind_text(pStmt, idx, sqlite_static_bind_value, -1, 0); }else if( strcmp(argv[4],"normal")==0 ){ rc = sqlite3_bind_text(pStmt, idx, argv[3], -1, 1); }else{ Tcl_AppendResult(interp, "4th argument should be " "\"null\" or \"static\" or \"normal\"", 0); return TCL_ERROR; } if( rc ){ char zBuf[50]; |
︙ | ︙ |
Changes to src/test4.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2003 December 18 ** ** 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 the the SQLite library in a multithreaded environment. ** | | > | 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 | /* ** 2003 December 18 ** ** 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 the the SQLite library in a multithreaded environment. ** ** $Id: test4.c,v 1.7 2004/05/26 02:04:57 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #if defined(OS_UNIX) && OS_UNIX==1 && defined(THREADSAFE) && THREADSAFE==1 #include <stdlib.h> #include <string.h> #include <pthread.h> #include <sched.h> #include <ctype.h> |
︙ | ︙ | |||
36 37 38 39 40 41 42 | int opnum; /* Operation number */ int busy; /* True if this thread is in use */ /* The next group of fields are writable by the thread but read-only to the ** master. */ int completed; /* Number of operations completed */ sqlite *db; /* Open database */ | | | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | int opnum; /* Operation number */ int busy; /* True if this thread is in use */ /* The next group of fields are writable by the thread but read-only to the ** master. */ int completed; /* Number of operations completed */ sqlite *db; /* Open database */ sqlite3_stmt *pStmt; /* Pending operation */ char *zErr; /* operation error */ char *zStaticErr; /* Static error message */ int rc; /* operation return code */ int argc; /* number of columns in result */ const char *argv[100]; /* result columns */ const char *colv[100]; /* result column names */ }; /* ** There can be as many as 26 threads running at once. Each is named ** by a capital letter: A, B, C, ..., Y, Z. */ #define N_THREAD 26 |
︙ | ︙ | |||
67 68 69 70 71 72 73 | } sqlite3_open(p->zFilename, &p->db, 0); if( SQLITE_OK!=sqlite3_errcode(p->db) ){ p->zErr = strdup(sqlite3_errmsg(p->db)); sqlite3_close(p->db); p->db = 0; } | | | | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | } sqlite3_open(p->zFilename, &p->db, 0); if( SQLITE_OK!=sqlite3_errcode(p->db) ){ p->zErr = strdup(sqlite3_errmsg(p->db)); sqlite3_close(p->db); p->db = 0; } p->pStmt = 0; p->completed = 1; while( p->opnum<=p->completed ) sched_yield(); while( p->xOp ){ if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite3_freemem(p->zErr); p->zErr = 0; } (*p->xOp)(p); p->completed++; while( p->opnum<=p->completed ) sched_yield(); } if( p->pStmt ){ sqlite3_finalize(p->pStmt); p->pStmt = 0; } if( p->db ){ sqlite3_close(p->db); p->db = 0; } if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite3_freemem(p->zErr); |
︙ | ︙ | |||
441 442 443 444 445 446 447 | */ static void do_compile(Thread *p){ if( p->db==0 ){ p->zErr = p->zStaticErr = "no database is open"; p->rc = SQLITE_ERROR; return; } | | | | | | 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | */ static void do_compile(Thread *p){ if( p->db==0 ){ p->zErr = p->zStaticErr = "no database is open"; p->rc = SQLITE_ERROR; return; } if( p->pStmt ){ sqlite3_finalize(p->pStmt); p->pStmt = 0; } p->rc = sqlite3_prepare(p->db, p->zArg, -1, &p->pStmt, 0); } /* ** Usage: thread_compile ID SQL ** ** Compile a new virtual machine. */ |
︙ | ︙ | |||
483 484 485 486 487 488 489 | return TCL_OK; } /* ** This procedure runs in the thread to step the virtual machine. */ static void do_step(Thread *p){ | > | | > > > > > > > > > | 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 | return TCL_OK; } /* ** This procedure runs in the thread to step the virtual machine. */ static void do_step(Thread *p){ int i; if( p->pStmt==0 ){ p->zErr = p->zStaticErr = "no virtual machine available"; p->rc = SQLITE_ERROR; return; } p->rc = sqlite3_step(p->pStmt); if( p->rc==SQLITE_ROW ){ p->argc = sqlite3_column_count(p->pStmt); for(i=0; i<sqlite3_data_count(p->pStmt); i++){ p->argv[i] = sqlite3_column_data(p->pStmt, i); } for(i=0; i<p->argc; i++){ p->colv[i] = sqlite3_column_name(p->pStmt, i); } } } /* ** Usage: thread_step ID ** ** Advance the virtual machine by one step */ |
︙ | ︙ | |||
524 525 526 527 528 529 530 | return TCL_OK; } /* ** This procedure runs in the thread to finalize a virtual machine. */ static void do_finalize(Thread *p){ | | | | | 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | return TCL_OK; } /* ** This procedure runs in the thread to finalize a virtual machine. */ static void do_finalize(Thread *p){ if( p->pStmt==0 ){ p->zErr = p->zStaticErr = "no virtual machine available"; p->rc = SQLITE_ERROR; return; } p->rc = sqlite3_finalize(p->pStmt); p->pStmt = 0; } /* ** Usage: thread_finalize ID ** ** Finalize the virtual machine. */ |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** The code in this file implements execution method of the ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c") ** handles housekeeping details such as creating and deleting ** VDBE instances. This file is solely interested in executing ** the VDBE program. ** | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ************************************************************************* ** The code in this file implements execution method of the ** Virtual Database Engine (VDBE). A separate file ("vdbeaux.c") ** handles housekeeping details such as creating and deleting ** VDBE instances. This file is solely interested in executing ** the VDBE program. ** ** In the external interface, an "sqlite3_stmt*" is an opaque pointer ** to a VDBE. ** ** The SQL parser generates a program which is then executed by ** the VDBE to do the work of the SQL statement. VDBE programs are ** similar in form to assembly language. The program consists of ** a linear sequence of operations. Each operation has an opcode ** and 3 operands. Operands P1 and P2 are integers. Operand P3 |
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.331 2004/05/26 02:04:58 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
307 308 309 310 311 312 313 | int csChange; /* Current statement change count (from db->csChange) */ }; /* ** An instance of the virtual machine. This structure contains the complete ** state of the virtual machine. ** | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | int csChange; /* Current statement change count (from db->csChange) */ }; /* ** An instance of the virtual machine. This structure contains the complete ** state of the virtual machine. ** ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_compile() ** is really a pointer to an instance of this structure. */ struct Vdbe { sqlite *db; /* The whole database */ Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ FILE *trace; /* Write an execution trace here, if not NULL */ int nOp; /* Number of instructions in the program */ |
︙ | ︙ |
Changes to src/vdbeaux.c.
1 2 3 4 5 6 7 8 9 10 11 12 | /* ** 2003 September 6 ** ** 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 contains code used for creating, destroying, and populating | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* ** 2003 September 6 ** ** 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 contains code used for creating, destroying, and populating ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior ** to version 2.8.7, all this code was combined into the vdbe.c source file. ** But that file was getting too big so this subroutines were split out. */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" |
︙ | ︙ | |||
993 994 995 996 997 998 999 | } if( rc==SQLITE_SCHEMA ){ sqlite3ResetInternalSchema(db, 0); } return rc; } | < < < < < < < < < < < < | 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | } if( rc==SQLITE_SCHEMA ){ sqlite3ResetInternalSchema(db, 0); } return rc; } /* ** Delete an entire VDBE. */ void sqlite3VdbeDelete(Vdbe *p){ int i; if( p==0 ) return; Cleanup(p); |
︙ | ︙ |