| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2003 December 18 | 2 ** 2003 December 18 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** Code for testing the SQLite library in a multithreaded environment. | 12 ** Code for testing the SQLite library in a multithreaded environment. |
| 13 */ | 13 */ |
| 14 #include "sqliteInt.h" | 14 #include "sqliteInt.h" |
| 15 #include "tcl.h" | 15 #if defined(INCLUDE_SQLITE_TCL_H) |
| 16 # include "sqlite_tcl.h" |
| 17 #else |
| 18 # include "tcl.h" |
| 19 #endif |
| 16 #if SQLITE_OS_UNIX && SQLITE_THREADSAFE | 20 #if SQLITE_OS_UNIX && SQLITE_THREADSAFE |
| 17 #include <stdlib.h> | 21 #include <stdlib.h> |
| 18 #include <string.h> | 22 #include <string.h> |
| 19 #include <pthread.h> | 23 #include <pthread.h> |
| 20 #include <sched.h> | 24 #include <sched.h> |
| 21 #include <ctype.h> | 25 #include <ctype.h> |
| 22 | 26 |
| 23 extern const char *sqlite3ErrName(int); | 27 extern const char *sqlite3ErrName(int); |
| 24 | 28 |
| 25 /* | 29 /* |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 118 } |
| 115 return zArg[0] - 'A'; | 119 return zArg[0] - 'A'; |
| 116 } | 120 } |
| 117 | 121 |
| 118 /* | 122 /* |
| 119 ** Usage: thread_create NAME FILENAME | 123 ** Usage: thread_create NAME FILENAME |
| 120 ** | 124 ** |
| 121 ** NAME should be an upper case letter. Start the thread running with | 125 ** NAME should be an upper case letter. Start the thread running with |
| 122 ** an open connection to the given database. | 126 ** an open connection to the given database. |
| 123 */ | 127 */ |
| 124 static int tcl_thread_create( | 128 static int SQLITE_TCLAPI tcl_thread_create( |
| 125 void *NotUsed, | 129 void *NotUsed, |
| 126 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 130 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 127 int argc, /* Number of arguments */ | 131 int argc, /* Number of arguments */ |
| 128 const char **argv /* Text of each argument */ | 132 const char **argv /* Text of each argument */ |
| 129 ){ | 133 ){ |
| 130 int i; | 134 int i; |
| 131 pthread_t x; | 135 pthread_t x; |
| 132 int rc; | 136 int rc; |
| 133 | 137 |
| 134 if( argc!=3 ){ | 138 if( argc!=3 ){ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 163 */ | 167 */ |
| 164 static void thread_wait(Thread *p){ | 168 static void thread_wait(Thread *p){ |
| 165 while( p->opnum>p->completed ) sched_yield(); | 169 while( p->opnum>p->completed ) sched_yield(); |
| 166 } | 170 } |
| 167 | 171 |
| 168 /* | 172 /* |
| 169 ** Usage: thread_wait ID | 173 ** Usage: thread_wait ID |
| 170 ** | 174 ** |
| 171 ** Wait on thread ID to reach its idle state. | 175 ** Wait on thread ID to reach its idle state. |
| 172 */ | 176 */ |
| 173 static int tcl_thread_wait( | 177 static int SQLITE_TCLAPI tcl_thread_wait( |
| 174 void *NotUsed, | 178 void *NotUsed, |
| 175 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 179 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 176 int argc, /* Number of arguments */ | 180 int argc, /* Number of arguments */ |
| 177 const char **argv /* Text of each argument */ | 181 const char **argv /* Text of each argument */ |
| 178 ){ | 182 ){ |
| 179 int i; | 183 int i; |
| 180 | 184 |
| 181 if( argc!=2 ){ | 185 if( argc!=2 ){ |
| 182 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 186 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 183 " ID", 0); | 187 " ID", 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 207 p->zFilename = 0; | 211 p->zFilename = 0; |
| 208 p->busy = 0; | 212 p->busy = 0; |
| 209 } | 213 } |
| 210 | 214 |
| 211 /* | 215 /* |
| 212 ** Usage: thread_halt ID | 216 ** Usage: thread_halt ID |
| 213 ** | 217 ** |
| 214 ** Cause a thread to shut itself down. Wait for the shutdown to be | 218 ** Cause a thread to shut itself down. Wait for the shutdown to be |
| 215 ** completed. If ID is "*" then stop all threads. | 219 ** completed. If ID is "*" then stop all threads. |
| 216 */ | 220 */ |
| 217 static int tcl_thread_halt( | 221 static int SQLITE_TCLAPI tcl_thread_halt( |
| 218 void *NotUsed, | 222 void *NotUsed, |
| 219 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 223 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 220 int argc, /* Number of arguments */ | 224 int argc, /* Number of arguments */ |
| 221 const char **argv /* Text of each argument */ | 225 const char **argv /* Text of each argument */ |
| 222 ){ | 226 ){ |
| 223 int i; | 227 int i; |
| 224 | 228 |
| 225 if( argc!=2 ){ | 229 if( argc!=2 ){ |
| 226 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 230 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 227 " ID", 0); | 231 " ID", 0); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 242 } | 246 } |
| 243 return TCL_OK; | 247 return TCL_OK; |
| 244 } | 248 } |
| 245 | 249 |
| 246 /* | 250 /* |
| 247 ** Usage: thread_argc ID | 251 ** Usage: thread_argc ID |
| 248 ** | 252 ** |
| 249 ** Wait on the most recent thread_step to complete, then return the | 253 ** Wait on the most recent thread_step to complete, then return the |
| 250 ** number of columns in the result set. | 254 ** number of columns in the result set. |
| 251 */ | 255 */ |
| 252 static int tcl_thread_argc( | 256 static int SQLITE_TCLAPI tcl_thread_argc( |
| 253 void *NotUsed, | 257 void *NotUsed, |
| 254 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 258 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 255 int argc, /* Number of arguments */ | 259 int argc, /* Number of arguments */ |
| 256 const char **argv /* Text of each argument */ | 260 const char **argv /* Text of each argument */ |
| 257 ){ | 261 ){ |
| 258 int i; | 262 int i; |
| 259 char zBuf[100]; | 263 char zBuf[100]; |
| 260 | 264 |
| 261 if( argc!=2 ){ | 265 if( argc!=2 ){ |
| 262 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 266 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 11 matching lines...) Expand all Loading... |
| 274 Tcl_AppendResult(interp, zBuf, 0); | 278 Tcl_AppendResult(interp, zBuf, 0); |
| 275 return TCL_OK; | 279 return TCL_OK; |
| 276 } | 280 } |
| 277 | 281 |
| 278 /* | 282 /* |
| 279 ** Usage: thread_argv ID N | 283 ** Usage: thread_argv ID N |
| 280 ** | 284 ** |
| 281 ** Wait on the most recent thread_step to complete, then return the | 285 ** Wait on the most recent thread_step to complete, then return the |
| 282 ** value of the N-th columns in the result set. | 286 ** value of the N-th columns in the result set. |
| 283 */ | 287 */ |
| 284 static int tcl_thread_argv( | 288 static int SQLITE_TCLAPI tcl_thread_argv( |
| 285 void *NotUsed, | 289 void *NotUsed, |
| 286 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 290 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 287 int argc, /* Number of arguments */ | 291 int argc, /* Number of arguments */ |
| 288 const char **argv /* Text of each argument */ | 292 const char **argv /* Text of each argument */ |
| 289 ){ | 293 ){ |
| 290 int i; | 294 int i; |
| 291 int n; | 295 int n; |
| 292 | 296 |
| 293 if( argc!=3 ){ | 297 if( argc!=3 ){ |
| 294 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 298 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 15 matching lines...) Expand all Loading... |
| 310 Tcl_AppendResult(interp, threadset[i].argv[n], 0); | 314 Tcl_AppendResult(interp, threadset[i].argv[n], 0); |
| 311 return TCL_OK; | 315 return TCL_OK; |
| 312 } | 316 } |
| 313 | 317 |
| 314 /* | 318 /* |
| 315 ** Usage: thread_colname ID N | 319 ** Usage: thread_colname ID N |
| 316 ** | 320 ** |
| 317 ** Wait on the most recent thread_step to complete, then return the | 321 ** Wait on the most recent thread_step to complete, then return the |
| 318 ** name of the N-th columns in the result set. | 322 ** name of the N-th columns in the result set. |
| 319 */ | 323 */ |
| 320 static int tcl_thread_colname( | 324 static int SQLITE_TCLAPI tcl_thread_colname( |
| 321 void *NotUsed, | 325 void *NotUsed, |
| 322 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 326 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 323 int argc, /* Number of arguments */ | 327 int argc, /* Number of arguments */ |
| 324 const char **argv /* Text of each argument */ | 328 const char **argv /* Text of each argument */ |
| 325 ){ | 329 ){ |
| 326 int i; | 330 int i; |
| 327 int n; | 331 int n; |
| 328 | 332 |
| 329 if( argc!=3 ){ | 333 if( argc!=3 ){ |
| 330 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 334 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 15 matching lines...) Expand all Loading... |
| 346 Tcl_AppendResult(interp, threadset[i].colv[n], 0); | 350 Tcl_AppendResult(interp, threadset[i].colv[n], 0); |
| 347 return TCL_OK; | 351 return TCL_OK; |
| 348 } | 352 } |
| 349 | 353 |
| 350 /* | 354 /* |
| 351 ** Usage: thread_result ID | 355 ** Usage: thread_result ID |
| 352 ** | 356 ** |
| 353 ** Wait on the most recent operation to complete, then return the | 357 ** Wait on the most recent operation to complete, then return the |
| 354 ** result code from that operation. | 358 ** result code from that operation. |
| 355 */ | 359 */ |
| 356 static int tcl_thread_result( | 360 static int SQLITE_TCLAPI tcl_thread_result( |
| 357 void *NotUsed, | 361 void *NotUsed, |
| 358 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 362 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 359 int argc, /* Number of arguments */ | 363 int argc, /* Number of arguments */ |
| 360 const char **argv /* Text of each argument */ | 364 const char **argv /* Text of each argument */ |
| 361 ){ | 365 ){ |
| 362 int i; | 366 int i; |
| 363 const char *zName; | 367 const char *zName; |
| 364 | 368 |
| 365 if( argc!=2 ){ | 369 if( argc!=2 ){ |
| 366 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 370 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 11 matching lines...) Expand all Loading... |
| 378 Tcl_AppendResult(interp, zName, 0); | 382 Tcl_AppendResult(interp, zName, 0); |
| 379 return TCL_OK; | 383 return TCL_OK; |
| 380 } | 384 } |
| 381 | 385 |
| 382 /* | 386 /* |
| 383 ** Usage: thread_error ID | 387 ** Usage: thread_error ID |
| 384 ** | 388 ** |
| 385 ** Wait on the most recent operation to complete, then return the | 389 ** Wait on the most recent operation to complete, then return the |
| 386 ** error string. | 390 ** error string. |
| 387 */ | 391 */ |
| 388 static int tcl_thread_error( | 392 static int SQLITE_TCLAPI tcl_thread_error( |
| 389 void *NotUsed, | 393 void *NotUsed, |
| 390 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 394 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 391 int argc, /* Number of arguments */ | 395 int argc, /* Number of arguments */ |
| 392 const char **argv /* Text of each argument */ | 396 const char **argv /* Text of each argument */ |
| 393 ){ | 397 ){ |
| 394 int i; | 398 int i; |
| 395 | 399 |
| 396 if( argc!=2 ){ | 400 if( argc!=2 ){ |
| 397 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 401 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 398 " ID", 0); | 402 " ID", 0); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 423 p->pStmt = 0; | 427 p->pStmt = 0; |
| 424 } | 428 } |
| 425 p->rc = sqlite3_prepare(p->db, p->zArg, -1, &p->pStmt, 0); | 429 p->rc = sqlite3_prepare(p->db, p->zArg, -1, &p->pStmt, 0); |
| 426 } | 430 } |
| 427 | 431 |
| 428 /* | 432 /* |
| 429 ** Usage: thread_compile ID SQL | 433 ** Usage: thread_compile ID SQL |
| 430 ** | 434 ** |
| 431 ** Compile a new virtual machine. | 435 ** Compile a new virtual machine. |
| 432 */ | 436 */ |
| 433 static int tcl_thread_compile( | 437 static int SQLITE_TCLAPI tcl_thread_compile( |
| 434 void *NotUsed, | 438 void *NotUsed, |
| 435 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 439 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 436 int argc, /* Number of arguments */ | 440 int argc, /* Number of arguments */ |
| 437 const char **argv /* Text of each argument */ | 441 const char **argv /* Text of each argument */ |
| 438 ){ | 442 ){ |
| 439 int i; | 443 int i; |
| 440 if( argc!=3 ){ | 444 if( argc!=3 ){ |
| 441 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 445 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 442 " ID SQL", 0); | 446 " ID SQL", 0); |
| 443 return TCL_ERROR; | 447 return TCL_ERROR; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 p->colv[i] = sqlite3_column_name(p->pStmt, i); | 480 p->colv[i] = sqlite3_column_name(p->pStmt, i); |
| 477 } | 481 } |
| 478 } | 482 } |
| 479 } | 483 } |
| 480 | 484 |
| 481 /* | 485 /* |
| 482 ** Usage: thread_step ID | 486 ** Usage: thread_step ID |
| 483 ** | 487 ** |
| 484 ** Advance the virtual machine by one step | 488 ** Advance the virtual machine by one step |
| 485 */ | 489 */ |
| 486 static int tcl_thread_step( | 490 static int SQLITE_TCLAPI tcl_thread_step( |
| 487 void *NotUsed, | 491 void *NotUsed, |
| 488 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 492 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 489 int argc, /* Number of arguments */ | 493 int argc, /* Number of arguments */ |
| 490 const char **argv /* Text of each argument */ | 494 const char **argv /* Text of each argument */ |
| 491 ){ | 495 ){ |
| 492 int i; | 496 int i; |
| 493 if( argc!=2 ){ | 497 if( argc!=2 ){ |
| 494 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 498 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 495 " IDL", 0); | 499 " IDL", 0); |
| 496 return TCL_ERROR; | 500 return TCL_ERROR; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 518 } | 522 } |
| 519 p->rc = sqlite3_finalize(p->pStmt); | 523 p->rc = sqlite3_finalize(p->pStmt); |
| 520 p->pStmt = 0; | 524 p->pStmt = 0; |
| 521 } | 525 } |
| 522 | 526 |
| 523 /* | 527 /* |
| 524 ** Usage: thread_finalize ID | 528 ** Usage: thread_finalize ID |
| 525 ** | 529 ** |
| 526 ** Finalize the virtual machine. | 530 ** Finalize the virtual machine. |
| 527 */ | 531 */ |
| 528 static int tcl_thread_finalize( | 532 static int SQLITE_TCLAPI tcl_thread_finalize( |
| 529 void *NotUsed, | 533 void *NotUsed, |
| 530 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 534 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 531 int argc, /* Number of arguments */ | 535 int argc, /* Number of arguments */ |
| 532 const char **argv /* Text of each argument */ | 536 const char **argv /* Text of each argument */ |
| 533 ){ | 537 ){ |
| 534 int i; | 538 int i; |
| 535 if( argc!=2 ){ | 539 if( argc!=2 ){ |
| 536 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 540 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 537 " IDL", 0); | 541 " IDL", 0); |
| 538 return TCL_ERROR; | 542 return TCL_ERROR; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 549 threadset[i].zArg = 0; | 553 threadset[i].zArg = 0; |
| 550 threadset[i].opnum++; | 554 threadset[i].opnum++; |
| 551 return TCL_OK; | 555 return TCL_OK; |
| 552 } | 556 } |
| 553 | 557 |
| 554 /* | 558 /* |
| 555 ** Usage: thread_swap ID ID | 559 ** Usage: thread_swap ID ID |
| 556 ** | 560 ** |
| 557 ** Interchange the sqlite* pointer between two threads. | 561 ** Interchange the sqlite* pointer between two threads. |
| 558 */ | 562 */ |
| 559 static int tcl_thread_swap( | 563 static int SQLITE_TCLAPI tcl_thread_swap( |
| 560 void *NotUsed, | 564 void *NotUsed, |
| 561 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 565 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 562 int argc, /* Number of arguments */ | 566 int argc, /* Number of arguments */ |
| 563 const char **argv /* Text of each argument */ | 567 const char **argv /* Text of each argument */ |
| 564 ){ | 568 ){ |
| 565 int i, j; | 569 int i, j; |
| 566 sqlite3 *temp; | 570 sqlite3 *temp; |
| 567 if( argc!=3 ){ | 571 if( argc!=3 ){ |
| 568 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 572 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 569 " ID1 ID2", 0); | 573 " ID1 ID2", 0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 589 return TCL_OK; | 593 return TCL_OK; |
| 590 } | 594 } |
| 591 | 595 |
| 592 /* | 596 /* |
| 593 ** Usage: thread_db_get ID | 597 ** Usage: thread_db_get ID |
| 594 ** | 598 ** |
| 595 ** Return the database connection pointer for the given thread. Then | 599 ** Return the database connection pointer for the given thread. Then |
| 596 ** remove the pointer from the thread itself. Afterwards, the thread | 600 ** remove the pointer from the thread itself. Afterwards, the thread |
| 597 ** can be stopped and the connection can be used by the main thread. | 601 ** can be stopped and the connection can be used by the main thread. |
| 598 */ | 602 */ |
| 599 static int tcl_thread_db_get( | 603 static int SQLITE_TCLAPI tcl_thread_db_get( |
| 600 void *NotUsed, | 604 void *NotUsed, |
| 601 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 605 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 602 int argc, /* Number of arguments */ | 606 int argc, /* Number of arguments */ |
| 603 const char **argv /* Text of each argument */ | 607 const char **argv /* Text of each argument */ |
| 604 ){ | 608 ){ |
| 605 int i; | 609 int i; |
| 606 char zBuf[100]; | 610 char zBuf[100]; |
| 607 extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*); | 611 extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*); |
| 608 if( argc!=2 ){ | 612 if( argc!=2 ){ |
| 609 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 613 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 620 sqlite3TestMakePointerStr(interp, zBuf, threadset[i].db); | 624 sqlite3TestMakePointerStr(interp, zBuf, threadset[i].db); |
| 621 threadset[i].db = 0; | 625 threadset[i].db = 0; |
| 622 Tcl_AppendResult(interp, zBuf, (char*)0); | 626 Tcl_AppendResult(interp, zBuf, (char*)0); |
| 623 return TCL_OK; | 627 return TCL_OK; |
| 624 } | 628 } |
| 625 | 629 |
| 626 /* | 630 /* |
| 627 ** Usage: thread_db_put ID DB | 631 ** Usage: thread_db_put ID DB |
| 628 ** | 632 ** |
| 629 */ | 633 */ |
| 630 static int tcl_thread_db_put( | 634 static int SQLITE_TCLAPI tcl_thread_db_put( |
| 631 void *NotUsed, | 635 void *NotUsed, |
| 632 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 636 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 633 int argc, /* Number of arguments */ | 637 int argc, /* Number of arguments */ |
| 634 const char **argv /* Text of each argument */ | 638 const char **argv /* Text of each argument */ |
| 635 ){ | 639 ){ |
| 636 int i; | 640 int i; |
| 637 extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*); | 641 extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*); |
| 638 extern void *sqlite3TestTextToPtr(const char *); | 642 extern void *sqlite3TestTextToPtr(const char *); |
| 639 if( argc!=3 ){ | 643 if( argc!=3 ){ |
| 640 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 644 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 11 matching lines...) Expand all Loading... |
| 652 threadset[i].db = (sqlite3*)sqlite3TestTextToPtr(argv[2]); | 656 threadset[i].db = (sqlite3*)sqlite3TestTextToPtr(argv[2]); |
| 653 return TCL_OK; | 657 return TCL_OK; |
| 654 } | 658 } |
| 655 | 659 |
| 656 /* | 660 /* |
| 657 ** Usage: thread_stmt_get ID | 661 ** Usage: thread_stmt_get ID |
| 658 ** | 662 ** |
| 659 ** Return the database stmt pointer for the given thread. Then | 663 ** Return the database stmt pointer for the given thread. Then |
| 660 ** remove the pointer from the thread itself. | 664 ** remove the pointer from the thread itself. |
| 661 */ | 665 */ |
| 662 static int tcl_thread_stmt_get( | 666 static int SQLITE_TCLAPI tcl_thread_stmt_get( |
| 663 void *NotUsed, | 667 void *NotUsed, |
| 664 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 668 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 665 int argc, /* Number of arguments */ | 669 int argc, /* Number of arguments */ |
| 666 const char **argv /* Text of each argument */ | 670 const char **argv /* Text of each argument */ |
| 667 ){ | 671 ){ |
| 668 int i; | 672 int i; |
| 669 char zBuf[100]; | 673 char zBuf[100]; |
| 670 extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*); | 674 extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*); |
| 671 if( argc!=2 ){ | 675 if( argc!=2 ){ |
| 672 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 676 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 int i; | 717 int i; |
| 714 | 718 |
| 715 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ | 719 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ |
| 716 Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); | 720 Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); |
| 717 } | 721 } |
| 718 return TCL_OK; | 722 return TCL_OK; |
| 719 } | 723 } |
| 720 #else | 724 #else |
| 721 int Sqlitetest4_Init(Tcl_Interp *interp){ return TCL_OK; } | 725 int Sqlitetest4_Init(Tcl_Interp *interp){ return TCL_OK; } |
| 722 #endif /* SQLITE_OS_UNIX */ | 726 #endif /* SQLITE_OS_UNIX */ |
| OLD | NEW |