Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The COMMIT command now works even if there are pending queries, as long as the pending queries are reading and not writing the database. (CVS 5864) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
51f04aaff2803487933b9dfcf39f27a2 |
User & Date: | drh 2008-11-05 16:37:35.000 |
Context
2008-11-05
| ||
17:41 | Fix memory allocation problems when string length exceeds limits. (CVS 5865) (check-in: b568e32520 user: drh tags: trunk) | |
16:37 | The COMMIT command now works even if there are pending queries, as long as the pending queries are reading and not writing the database. (CVS 5864) (check-in: 51f04aaff2 user: drh tags: trunk) | |
2008-11-04
| ||
21:51 | Should be 'memjournal.lo' instead of 'memjournal.o'. Ticket #3480. (CVS 5863) (check-in: 8b86860421 user: shane tags: trunk) | |
Changes
Changes to src/sqliteInt.h.
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. ** ************************************************************************* ** Internal interface definitions for 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. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.788 2008/11/05 16:37:35 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build |
︙ | ︙ | |||
695 696 697 698 699 700 701 702 703 704 705 706 707 708 | int newTnum; /* Rootpage of table being initialized */ u8 busy; /* TRUE if currently initializing */ } init; int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared libraray handles */ struct Vdbe *pVdbe; /* List of active virtual machines */ int activeVdbeCnt; /* Number of vdbes currently executing */ void (*xTrace)(void*,const char*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ void *pCommitArg; /* Argument to xCommitCallback() */ int (*xCommitCallback)(void*); /* Invoked at every commit. */ void *pRollbackArg; /* Argument to xRollbackCallback() */ | > | 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | int newTnum; /* Rootpage of table being initialized */ u8 busy; /* TRUE if currently initializing */ } init; int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared libraray handles */ struct Vdbe *pVdbe; /* List of active virtual machines */ int activeVdbeCnt; /* Number of vdbes currently executing */ int writeVdbeCnt; /* Number of active VDBEs that are writing */ void (*xTrace)(void*,const char*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ void *pCommitArg; /* Argument to xCommitCallback() */ int (*xCommitCallback)(void*); /* Invoked at every commit. */ void *pRollbackArg; /* Argument to xRollbackCallback() */ |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
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.786 2008/11/05 16:37:35 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" /* ** The following global variable is incremented every time a cursor |
︙ | ︙ | |||
2389 2390 2391 2392 2393 2394 2395 | ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll ** back any currently active btree transactions. If there are any active ** VMs (apart from this one), then the COMMIT or ROLLBACK statement fails. ** ** This instruction causes the VM to halt. */ case OP_AutoCommit: { | | | > | | | | | | > | > > > > > | | | | | | 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 | ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll ** back any currently active btree transactions. If there are any active ** VMs (apart from this one), then the COMMIT or ROLLBACK statement fails. ** ** This instruction causes the VM to halt. */ case OP_AutoCommit: { int desiredAutoCommit = pOp->p1; int rollback = pOp->p2; int turnOnAC = desiredAutoCommit && !db->autoCommit; assert( desiredAutoCommit==1 || desiredAutoCommit==0 ); assert( desiredAutoCommit==1 || rollback==0 ); assert( db->activeVdbeCnt>0 ); /* At least this one VM is active */ if( turnOnAC && rollback && db->activeVdbeCnt>1 ){ /* If this instruction implements a ROLLBACK and other VMs are ** still running, and a transaction is active, return an error indicating ** that the other VMs must complete first. */ sqlite3SetString(&p->zErrMsg, db, "cannot rollback transaction - " "SQL statements in progress"); rc = SQLITE_BUSY; }else if( turnOnAC && !rollback && db->writeVdbeCnt>1 ){ /* If this instruction implements a COMMIT and other VMs are writing ** return an error indicating that the other VMs must complete first. */ sqlite3SetString(&p->zErrMsg, db, "cannot commit transaction - " "SQL statements in progress"); rc = SQLITE_BUSY; }else if( desiredAutoCommit!=db->autoCommit ){ if( pOp->p2 ){ assert( desiredAutoCommit==1 ); sqlite3RollbackAll(db); db->autoCommit = 1; }else{ db->autoCommit = desiredAutoCommit; if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){ p->pc = pc; db->autoCommit = 1-desiredAutoCommit; p->rc = rc = SQLITE_BUSY; goto vdbe_return; } } if( p->rc==SQLITE_OK ){ rc = SQLITE_DONE; }else{ rc = SQLITE_ERROR; } goto vdbe_return; }else{ sqlite3SetString(&p->zErrMsg, db, (!desiredAutoCommit)?"cannot start a transaction within a transaction":( (rollback)?"cannot rollback - no transaction is active": "cannot commit - no transaction is active")); rc = SQLITE_ERROR; } break; } |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** This is the header file for information that is private to the ** VDBE. This information used to all be at the top of the single ** source code file "vdbe.c". When that file became too big (over ** 6000 lines long) it was split up into several smaller files and ** this header information was factored out. ** | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ************************************************************************* ** This is the header file for information that is private to the ** VDBE. This information used to all be at the top of the single ** source code file "vdbe.c". When that file became too big (over ** 6000 lines long) it was split up into several smaller files and ** this header information was factored out. ** ** $Id: vdbeInt.h,v 1.157 2008/11/05 16:37:35 drh Exp $ */ #ifndef _VDBEINT_H_ #define _VDBEINT_H_ /* ** intToKey() and keyToInt() used to transform the rowid. But with ** the latest versions of the design they are no-ops. |
︙ | ︙ | |||
315 316 317 318 319 320 321 322 323 324 325 326 327 328 | char *zErrMsg; /* Error message written here */ Mem *pResultSet; /* Pointer to an array of results */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ int nChange; /* Number of db changes made since last reset */ i64 startTime; /* Time when query started - used for profiling */ int btreeMask; /* Bitmask of db->aDb[] entries referenced */ BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */ int aCounter[2]; /* Counters used by sqlite3_stmt_status() */ int nSql; /* Number of bytes in zSql */ char *zSql; /* Text of the SQL statement that generated this */ | > > | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | char *zErrMsg; /* Error message written here */ Mem *pResultSet; /* Pointer to an array of results */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ u8 usesStmtJournal; /* True if uses a statement journal */ u8 readOnly; /* True for read-only statements */ int nChange; /* Number of db changes made since last reset */ i64 startTime; /* Time when query started - used for profiling */ int btreeMask; /* Bitmask of db->aDb[] entries referenced */ BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */ int aCounter[2]; /* Counters used by sqlite3_stmt_status() */ int nSql; /* Number of bytes in zSql */ char *zSql; /* Text of the SQL statement that generated this */ |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains code use to implement APIs that are part of the ** VDBE. ** | | | 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. ** ************************************************************************* ** ** This file contains code use to implement APIs that are part of the ** VDBE. ** ** $Id: vdbeapi.c,v 1.148 2008/11/05 16:37:35 drh Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" #if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) /* ** The following structure contains pointers to the end points of a |
︙ | ︙ | |||
464 465 466 467 468 469 470 471 472 473 474 475 476 477 | double rNow; sqlite3OsCurrentTime(db->pVfs, &rNow); p->startTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0; } #endif db->activeVdbeCnt++; p->pc = 0; stmtLruRemove(p); } #ifndef SQLITE_OMIT_EXPLAIN if( p->explain ){ rc = sqlite3VdbeList(p); }else | > | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | double rNow; sqlite3OsCurrentTime(db->pVfs, &rNow); p->startTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0; } #endif db->activeVdbeCnt++; if( p->readOnly==0 ) db->writeVdbeCnt++; p->pc = 0; stmtLruRemove(p); } #ifndef SQLITE_OMIT_EXPLAIN if( p->explain ){ rc = sqlite3VdbeList(p); }else |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** 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. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** 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. ** ** $Id: vdbeaux.c,v 1.417 2008/11/05 16:37:35 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include "vdbeInt.h" |
︙ | ︙ | |||
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ int i; int nMaxArgs = 0; Op *pOp; int *aLabel = p->aLabel; int doesStatementRollback = 0; int hasStatementBegin = 0; for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ u8 opcode = pOp->opcode; if( opcode==OP_Function || opcode==OP_AggStep ){ if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; #ifndef SQLITE_OMIT_VIRTUALTABLE }else if( opcode==OP_VUpdate ){ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; #endif } if( opcode==OP_Halt ){ if( pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort ){ doesStatementRollback = 1; } }else if( opcode==OP_Statement ){ hasStatementBegin = 1; }else if( opcode==OP_Destroy ){ doesStatementRollback = 1; #ifndef SQLITE_OMIT_VIRTUALTABLE }else if( opcode==OP_VUpdate || opcode==OP_VRename ){ doesStatementRollback = 1; }else if( opcode==OP_VFilter ){ int n; assert( p->nOp - i >= 3 ); assert( pOp[-1].opcode==OP_Integer ); | > > > > > | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ int i; int nMaxArgs = 0; Op *pOp; int *aLabel = p->aLabel; int doesStatementRollback = 0; int hasStatementBegin = 0; p->readOnly = 1; p->usesStmtJournal = 0; for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ u8 opcode = pOp->opcode; if( opcode==OP_Function || opcode==OP_AggStep ){ if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; #ifndef SQLITE_OMIT_VIRTUALTABLE }else if( opcode==OP_VUpdate ){ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; #endif } if( opcode==OP_Halt ){ if( pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort ){ doesStatementRollback = 1; } }else if( opcode==OP_Statement ){ hasStatementBegin = 1; p->usesStmtJournal = 1; }else if( opcode==OP_Destroy ){ doesStatementRollback = 1; }else if( opcode==OP_Transaction && pOp->p2!=0 ){ p->readOnly = 0; #ifndef SQLITE_OMIT_VIRTUALTABLE }else if( opcode==OP_VUpdate || opcode==OP_VRename ){ doesStatementRollback = 1; }else if( opcode==OP_VFilter ){ int n; assert( p->nOp - i >= 3 ); assert( pOp[-1].opcode==OP_Integer ); |
︙ | ︙ | |||
309 310 311 312 313 314 315 316 317 318 319 320 321 322 | /* If we never rollback a statement transaction, then statement ** transactions are not needed. So change every OP_Statement ** opcode into an OP_Noop. This avoid a call to sqlite3OsOpenExclusive() ** which can be expensive on some platforms. */ if( hasStatementBegin && !doesStatementRollback ){ for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ if( pOp->opcode==OP_Statement ){ pOp->opcode = OP_Noop; } } } } | > | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | /* If we never rollback a statement transaction, then statement ** transactions are not needed. So change every OP_Statement ** opcode into an OP_Noop. This avoid a call to sqlite3OsOpenExclusive() ** which can be expensive on some platforms. */ if( hasStatementBegin && !doesStatementRollback ){ p->usesStmtJournal = 0; for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ if( pOp->opcode==OP_Statement ){ pOp->opcode = OP_Noop; } } } } |
︙ | ︙ | |||
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 | ** ** This is a no-op if NDEBUG is defined. */ #ifndef NDEBUG static void checkActiveVdbeCnt(sqlite3 *db){ Vdbe *p; int cnt = 0; p = db->pVdbe; while( p ){ if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){ cnt++; } p = p->pNext; } assert( cnt==db->activeVdbeCnt ); } #else #define checkActiveVdbeCnt(x) #endif /* ** For every Btree that in database connection db which | > > > | 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 | ** ** This is a no-op if NDEBUG is defined. */ #ifndef NDEBUG static void checkActiveVdbeCnt(sqlite3 *db){ Vdbe *p; int cnt = 0; int nWrite = 0; p = db->pVdbe; while( p ){ if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){ cnt++; if( p->readOnly==0 ) nWrite++; } p = p->pNext; } assert( cnt==db->activeVdbeCnt ); assert( nWrite==db->writeVdbeCnt ); } #else #define checkActiveVdbeCnt(x) #endif /* ** For every Btree that in database connection db which |
︙ | ︙ | |||
1545 1546 1547 1548 1549 1550 1551 | sqlite3BtreeMutexArrayEnter(&p->aMutex); /* Check for one of the special errors */ mrc = p->rc & 0xff; isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL; if( isSpecialError ){ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | > | | | 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 | sqlite3BtreeMutexArrayEnter(&p->aMutex); /* Check for one of the special errors */ mrc = p->rc & 0xff; isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL; if( isSpecialError ){ /* If the query was read-only, we need do no rollback at all. Otherwise, ** proceed with the special handling. */ if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){ if( p->rc==SQLITE_IOERR_BLOCKED && p->usesStmtJournal ){ xFunc = sqlite3BtreeRollbackStmt; p->rc = SQLITE_BUSY; }else if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && p->usesStmtJournal ){ xFunc = sqlite3BtreeRollbackStmt; }else{ /* We are forced to roll back the active transaction. Before doing ** so, abort any other statements this handle currently has active. */ invalidateCursorsOnModifiedBtrees(db); sqlite3RollbackAll(db); db->autoCommit = 1; } } } /* If the auto-commit flag is set and this is the only active vdbe, then ** we do either a commit or rollback of the current transaction. ** ** Note: This block also runs if one of the special errors handled ** above has occurred. */ if( db->autoCommit && db->writeVdbeCnt==(p->readOnly==0) ){ if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){ /* The auto-commit flag is true, and the vdbe program was ** successful or hit an 'OR FAIL' constraint. This means a commit ** is required. */ int rc = vdbeCommit(db, p); if( rc==SQLITE_BUSY ){ |
︙ | ︙ | |||
1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 | /* Release the locks */ sqlite3BtreeMutexArrayLeave(&p->aMutex); } /* We have successfully halted and closed the VM. Record this fact. */ if( p->pc>=0 ){ db->activeVdbeCnt--; } p->magic = VDBE_MAGIC_HALT; checkActiveVdbeCnt(db); if( p->db->mallocFailed ){ p->rc = SQLITE_NOMEM; } | > > > > | 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 | /* Release the locks */ sqlite3BtreeMutexArrayLeave(&p->aMutex); } /* We have successfully halted and closed the VM. Record this fact. */ if( p->pc>=0 ){ db->activeVdbeCnt--; if( !p->readOnly ){ db->writeVdbeCnt--; } assert( db->activeVdbeCnt>=db->writeVdbeCnt ); } p->magic = VDBE_MAGIC_HALT; checkActiveVdbeCnt(db); if( p->db->mallocFailed ){ p->rc = SQLITE_NOMEM; } |
︙ | ︙ |
Changes to test/capi3.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 January 29 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # # $Id: capi3.test,v 1.69 2008/11/05 16:37:35 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the UTF-16 representation of the supplied UTF-8 string $str. # If $nt is true, append two 0x00 bytes as a nul terminator. |
︙ | ︙ | |||
829 830 831 832 833 834 835 836 837 838 839 | do_test capi3-11.1.1 { sqlite3_get_autocommit $DB } 0 do_test capi3-11.2 { set STMT [sqlite3_prepare $DB "SELECT func(b, a) FROM t1" -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} do_test capi3-11.3.1 { catchsql { COMMIT; } | > > > > | | | > > > > < < < < < < < < | 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 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | do_test capi3-11.1.1 { sqlite3_get_autocommit $DB } 0 do_test capi3-11.2 { set STMT [sqlite3_prepare $DB "SELECT func(b, a) FROM t1" -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} # As of 3.6.5 a COMMIT is OK during while a query is still running - # as long as it is a read-only query and not an incremental BLOB write. # do_test capi3-11.3.1 { catchsql { COMMIT; } } {0 {}} do_test capi3-11.3.2 { sqlite3_extended_errcode $DB } {SQLITE_OK} do_test capi3-11.3.3 { sqlite3_get_autocommit $DB } 1 do_test capi3-11.3.4 { db eval {PRAGMA lock_status} } {main shared temp closed} do_test capi3-11.4 { sqlite3_step $STMT } {SQLITE_ERROR} do_test capi3-11.5 { sqlite3_finalize $STMT } {SQLITE_ERROR} do_test capi3-11.6 { catchsql { SELECT * FROM t1; } } {0 {1 int 2 notatype}} do_test capi3-11.7 { sqlite3_get_autocommit $DB } 1 do_test capi3-11.8 { execsql { CREATE TABLE t2(a); INSERT INTO t2 VALUES(1); INSERT INTO t2 VALUES(2); |
︙ | ︙ | |||
946 947 948 949 950 951 952 | sqlite3_step $STMT } {SQLITE_ROW} do_test capi3-11.20 { catchsql { BEGIN; COMMIT; } | | | | 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 | sqlite3_step $STMT } {SQLITE_ROW} do_test capi3-11.20 { catchsql { BEGIN; COMMIT; } } {0 {}} do_test capi3-11.20 { sqlite3_reset $STMT catchsql { COMMIT; } } {1 {cannot commit - no transaction is active}} do_test capi3-11.21 { sqlite3_finalize $STMT } {SQLITE_OK} # The following tests - capi3-12.* - check that its Ok to start a # transaction while other VMs are active, and that its Ok to execute # atomic updates in the same situation |
︙ | ︙ |
Changes to test/capi3c.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This is a copy of the capi3.test file that has been adapted to # test the new sqlite3_prepare_v2 interface. # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This is a copy of the capi3.test file that has been adapted to # test the new sqlite3_prepare_v2 interface. # # $Id: capi3c.test,v 1.22 2008/11/05 16:37:35 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl # Return the UTF-16 representation of the supplied UTF-8 string $str. # If $nt is true, append two 0x00 bytes as a nul terminator. |
︙ | ︙ | |||
784 785 786 787 788 789 790 | do_test capi3c-11.1.1 { sqlite3_get_autocommit $DB } 0 do_test capi3c-11.2 { set STMT [sqlite3_prepare_v2 $DB "SELECT func(b, a) FROM t1" -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} | > > > > | | | > > > | > > > > < < < < < < < < | 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | do_test capi3c-11.1.1 { sqlite3_get_autocommit $DB } 0 do_test capi3c-11.2 { set STMT [sqlite3_prepare_v2 $DB "SELECT func(b, a) FROM t1" -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} # As of 3.6.5 a COMMIT is OK during while a query is still running - # as long as it is a read-only query and not an incremental BLOB write. # do_test capi3-11.3.1 { catchsql { COMMIT; } } {0 {}} do_test capi3-11.3.2 { sqlite3_extended_errcode $DB } {SQLITE_OK} do_test capi3-11.3.3 { sqlite3_get_autocommit $DB } 1 do_test capi3-11.3.4 { db eval {PRAGMA lock_status} } {main shared temp closed} do_test capi3c-11.4 { sqlite3_step $STMT } {SQLITE_ERROR} do_test capi3c-11.5 { sqlite3_finalize $STMT } {SQLITE_ERROR} do_test capi3c-11.6 { catchsql { SELECT * FROM t1; } } {0 {1 int 2 notatype}} do_test capi3c-11.7 { sqlite3_get_autocommit $DB } 1 do_test capi3c-11.8 { execsql { CREATE TABLE t2(a); INSERT INTO t2 VALUES(1); INSERT INTO t2 VALUES(2); |
︙ | ︙ | |||
898 899 900 901 902 903 904 | sqlite3_step $STMT } {SQLITE_ROW} do_test capi3c-11.20 { catchsql { BEGIN; COMMIT; } | | | | 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | sqlite3_step $STMT } {SQLITE_ROW} do_test capi3c-11.20 { catchsql { BEGIN; COMMIT; } } {0 {}} do_test capi3c-11.20 { sqlite3_reset $STMT catchsql { COMMIT; } } {1 {cannot commit - no transaction is active}} do_test capi3c-11.21 { sqlite3_finalize $STMT } {SQLITE_OK} # The following tests - capi3c-12.* - check that its Ok to start a # transaction while other VMs are active, and that its Ok to execute # atomic updates in the same situation |
︙ | ︙ |
Changes to test/incrblob.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2007 May 1 # # 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. # #*********************************************************************** # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2007 May 1 # # 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. # #*********************************************************************** # # $Id: incrblob.test,v 1.23 2008/11/05 16:37:35 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable {!autovacuum || !pragma || !incrblob} { finish_test |
︙ | ︙ | |||
446 447 448 449 450 451 452 | } {10} do_test incrblob-6.9 { seek $::blob 0 puts -nonewline $::blob "invocation" flush $::blob } {} | | | > > | < < < | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | } {10} do_test incrblob-6.9 { seek $::blob 0 puts -nonewline $::blob "invocation" flush $::blob } {} # At this point rollback should be illegal (because # there is an open blob channel). But commit is allowed because # the blob is read-only. # do_test incrblob-6.10 { catchsql { ROLLBACK; } db2 } {1 {cannot rollback transaction - SQL statements in progress}} do_test incrblob-6.11 { catchsql { COMMIT; } db2 } {0 {}} do_test incrblob-6.12 { execsql { SELECT * FROM blobs WHERE rowid = 4; } } {} do_test incrblob-6.13 { close $::blob } {} do_test incrblob-6.14 { execsql { SELECT * FROM blobs WHERE rowid = 4; } } {a different invocation} db2 close |
︙ | ︙ |
Changes to test/tkt3080.test.
︙ | ︙ | |||
10 11 12 13 14 15 16 | #*********************************************************************** # # Ticket #3080 # # Make sure that application-defined functions are able to recursively # invoke SQL statements that create and drop virtual tables. # | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #*********************************************************************** # # Ticket #3080 # # Make sure that application-defined functions are able to recursively # invoke SQL statements that create and drop virtual tables. # # $Id: tkt3080.test,v 1.2 2008/11/05 16:37:35 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl do_test tkt3080.1 { db function execsql execsql |
︙ | ︙ | |||
44 45 46 47 48 49 50 | SELECT execsql(x) FROM t1 WHERE rowid=2; } } {1 {database table is locked}} do_test tkt3080.4 { db eval { SELECT name FROM sqlite_master; } | | | | 44 45 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 | SELECT execsql(x) FROM t1 WHERE rowid=2; } } {1 {database table is locked}} do_test tkt3080.4 { db eval { SELECT name FROM sqlite_master; } } {t1 t2 t3} ifcapable vtab { register_echo_module [sqlite3_connection_pointer db] do_test tkt3080.10 { set sql { CREATE VIRTUAL TABLE t4 USING echo(t2); INSERT INTO t4 VALUES(123); DROP TABLE t4; } execsql { DELETE FROM t1; INSERT INTO t1 VALUES($sql); } db eval { SELECT execsql(x) FROM t1 } execsql {SELECT name FROM sqlite_master} } {t1 t2 t3} do_test tkt3080.11 { execsql {SELECT * FROM t2} } {123} } finish_test |
Changes to test/trans3.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # # This file implements regression tests for SQLite library. The # focus of this script is the response of COMMIT and ROLLBACK when # statements are still pending. # | | | | | > > > < | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # #*********************************************************************** # # This file implements regression tests for SQLite library. The # focus of this script is the response of COMMIT and ROLLBACK when # statements are still pending. # # $Id: trans3.test,v 1.2 2008/11/05 16:37:35 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl unset -nocomplain ecode do_test trans3-1.1 { db eval { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); SELECT * FROM t1; } } {1 2 3} do_test trans3-1.2 { db eval BEGIN db eval {INSERT INTO t1 VALUES(4);} set ::ecode {} set x [catch { db eval {SELECT * FROM t1 LIMIT 1} { if {[catch {db eval COMMIT} errmsg]} { set ::ecode [sqlite3_extended_errcode db] error $errmsg } } } errmsg] lappend x $errmsg } {0 {}} do_test trans3-1.3 { set ::ecode } {} do_test trans3-1.3.1 { sqlite3_get_autocommit db } 1 do_test trans3-1.4 { db eval {SELECT * FROM t1} } {1 2 3 4} do_test trans3-1.5 { db eval BEGIN db eval {INSERT INTO t1 VALUES(5);} set ::ecode {} set x [catch { |
︙ | ︙ |