/ Check-in [1f28b7e4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Get the quick.test script running with SQLITE_THREADSAFE enabled. (CVS 4269)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1f28b7e47bba221c14a10a37e7425c9975bb2312
User & Date: drh 2007-08-22 11:41:18
Context
2007-08-22
18:54
Fix a bug in the logic for journaling pages when the device sector-size is greater than the page size. (CVS 4270) check-in: b6399dff user: danielk1977 tags: trunk
11:41
Get the quick.test script running with SQLITE_THREADSAFE enabled. (CVS 4269) check-in: 1f28b7e4 user: drh tags: trunk
11:22
Add code for the atomic-write optimisation. Disabled by default. (CVS 4268) check-in: 581fadfe user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.408 2007/08/22 02:56:43 drh Exp $
           12  +** $Id: btree.c,v 1.409 2007/08/22 11:41:18 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** See the header comment on "btreeInt.h" for additional information.
    16     16   ** Including a description of file format and an overview of operation.
    17     17   */
    18     18   #include "btreeInt.h"
    19     19   
................................................................................
  1368   1368         pBt->xFreeSchema(pBt->pSchema);
  1369   1369       }
  1370   1370       sqlite3_free(pBt->pSchema);
  1371   1371       sqlite3_free(pBt);
  1372   1372     }
  1373   1373   
  1374   1374   #ifndef SQLITE_OMIT_SHARED_CACHE
  1375         -  else{
  1376         -    assert( p->wantToLock==0 );
  1377         -    assert( p->locked==0 );
  1378         -    assert( p->sharable );
  1379         -    if( p->pPrev ) p->pPrev->pNext = p->pNext;
  1380         -    if( p->pNext ) p->pNext->pPrev = p->pPrev;
  1381         -  }
         1375  +  assert( p->wantToLock==0 );
         1376  +  assert( p->locked==0 );
         1377  +  if( p->pPrev ) p->pPrev->pNext = p->pNext;
         1378  +  if( p->pNext ) p->pNext->pPrev = p->pPrev;
  1382   1379   #endif
  1383   1380   
  1384   1381     sqlite3_free(p);
  1385   1382     return SQLITE_OK;
  1386   1383   }
  1387   1384   
  1388   1385   #if SQLITE_THREADSAFE && !defined(SQLITE_OMIT_SHARED_CACHE)
................................................................................
  1478   1475   
  1479   1476   
  1480   1477   #if SQLITE_THREADSAFE && !defined(SQLITE_OMIT_SHARED_CACHE)
  1481   1478   /*
  1482   1479   ** Short-cuts for entering and leaving mutexes on a cursor.
  1483   1480   */
  1484   1481   static void cursorLeave(BtCursor *p){
  1485         -  sqlite3BtreeLeave(p->pBt);
         1482  +  sqlite3BtreeLeave(p->pBtree);
  1486   1483   }
  1487   1484   static void cursorEnter(BtCursor *pCur){
  1488         -  sqlite3BtreeEnter(pCur->pBt);
         1485  +  sqlite3BtreeEnter(pCur->pBtree);
  1489   1486   }
  1490   1487   #else
  1491   1488   # define cursorEnter(X)
  1492   1489   # define cursorLeave(X)
  1493   1490   #endif /* !SQLITE_OMIT_SHARED_CACHE */
  1494   1491   
  1495   1492   /*
................................................................................
  3755   3752         *pRes = 0;
  3756   3753         return rc;
  3757   3754       }
  3758   3755       do{
  3759   3756         if( sqlite3BtreeIsRootPage(pPage) ){
  3760   3757           *pRes = 1;
  3761   3758           pCur->eState = CURSOR_INVALID;
  3762         -        cursorLeave(pCur);
  3763   3759           return SQLITE_OK;
  3764   3760         }
  3765   3761         sqlite3BtreeMoveToParent(pCur);
  3766   3762         pPage = pCur->pPage;
  3767   3763       }while( pCur->idx>=pPage->nCell );
  3768   3764       *pRes = 0;
  3769   3765       if( pPage->leafData ){

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.596 2007/08/22 11:22:04 danielk1977 Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.597 2007/08/22 11:41:18 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   #include "sqliteLimit.h"
    19     19   
    20     20   
    21     21   #if defined(SQLITE_TCL) || defined(TCLSH)
................................................................................
    38     38   ** Older versions of SQLite used an optional THREADSAFE macro.
    39     39   ** We support that for legacy
    40     40   */
    41     41   #if !defined(SQLITE_THREADSAFE)
    42     42   #if defined(THREADSAFE)
    43     43   # define SQLITE_THREADSAFE THREADSAFE
    44     44   #else
    45         -# define SQLTIE_THREADSAFE 1
           45  +# define SQLITE_THREADSAFE 1
    46     46   #endif
    47     47   #endif
    48     48   
    49     49   /*
    50     50   ** These #defines should enable >2GB file support on Posix if the
    51     51   ** underlying operating system supports it.  If the OS lacks
    52     52   ** large file support, or if the OS is windows, these should be no-ops.

Changes to src/test4.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the the SQLite library in a multithreaded environment.
    13     13   **
    14         -** $Id: test4.c,v 1.20 2007/08/21 10:44:16 drh Exp $
           14  +** $Id: test4.c,v 1.21 2007/08/22 11:41:18 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "tcl.h"
    18     18   #if defined(OS_UNIX) && OS_UNIX==1 && SQLITE_THREADSAFE
    19     19   #include <stdlib.h>
    20     20   #include <string.h>
    21     21   #include <pthread.h>
................................................................................
   137    137     i = parse_thread_id(interp, argv[1]);
   138    138     if( i<0 ) return TCL_ERROR;
   139    139     if( threadset[i].busy ){
   140    140       Tcl_AppendResult(interp, "thread ", argv[1], " is already running", 0);
   141    141       return TCL_ERROR;
   142    142     }
   143    143     threadset[i].busy = 1;
   144         -  sqliteFree(threadset[i].zFilename);
          144  +  sqlite3_free(threadset[i].zFilename);
   145    145     threadset[i].zFilename = sqlite3StrDup(argv[2]);
   146    146     threadset[i].opnum = 1;
   147    147     threadset[i].completed = 0;
   148    148     rc = pthread_create(&x, 0, thread_main, &threadset[i]);
   149    149     if( rc ){
   150    150       Tcl_AppendResult(interp, "failed to create the thread", 0);
   151         -    sqliteFree(threadset[i].zFilename);
          151  +    sqlite3_free(threadset[i].zFilename);
   152    152       threadset[i].busy = 0;
   153    153       return TCL_ERROR;
   154    154     }
   155    155     pthread_detach(x);
   156    156     return TCL_OK;
   157    157   }
   158    158   
................................................................................
   195    195   ** Stop a thread.
   196    196   */
   197    197   static void stop_thread(Thread *p){
   198    198     thread_wait(p);
   199    199     p->xOp = 0;
   200    200     p->opnum++;
   201    201     thread_wait(p);
   202         -  sqliteFree(p->zArg);
          202  +  sqlite3_free(p->zArg);
   203    203     p->zArg = 0;
   204         -  sqliteFree(p->zFilename);
          204  +  sqlite3_free(p->zFilename);
   205    205     p->zFilename = 0;
   206    206     p->busy = 0;
   207    207   }
   208    208   
   209    209   /*
   210    210   ** Usage:  thread_halt ID
   211    211   **
................................................................................
   471    471     if( i<0 ) return TCL_ERROR;
   472    472     if( !threadset[i].busy ){
   473    473       Tcl_AppendResult(interp, "no such thread", 0);
   474    474       return TCL_ERROR;
   475    475     }
   476    476     thread_wait(&threadset[i]);
   477    477     threadset[i].xOp = do_compile;
   478         -  sqliteFree(threadset[i].zArg);
          478  +  sqlite3_free(threadset[i].zArg);
   479    479     threadset[i].zArg = sqlite3StrDup(argv[2]);
   480    480     threadset[i].opnum++;
   481    481     return TCL_OK;
   482    482   }
   483    483   
   484    484   /*
   485    485   ** This procedure runs in the thread to step the virtual machine.
................................................................................
   566    566     if( i<0 ) return TCL_ERROR;
   567    567     if( !threadset[i].busy ){
   568    568       Tcl_AppendResult(interp, "no such thread", 0);
   569    569       return TCL_ERROR;
   570    570     }
   571    571     thread_wait(&threadset[i]);
   572    572     threadset[i].xOp = do_finalize;
   573         -  sqliteFree(threadset[i].zArg);
          573  +  sqlite3_free(threadset[i].zArg);
   574    574     threadset[i].zArg = 0;
   575    575     threadset[i].opnum++;
   576    576     return TCL_OK;
   577    577   }
   578    578   
   579    579   /*
   580    580   ** Usage: thread_swap ID ID

Changes to src/test7.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the client/server version of the SQLite library.
    13     13   ** Derived from test4.c.
    14     14   **
    15         -** $Id: test7.c,v 1.7 2007/08/21 10:44:16 drh Exp $
           15  +** $Id: test7.c,v 1.8 2007/08/22 11:41:18 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include "tcl.h"
    19     19   
    20     20   /*
    21     21   ** This test only works on UNIX with a SQLITE_THREADSAFE build that includes
    22     22   ** the SQLITE_SERVER option.
................................................................................
   159    159     i = parse_client_id(interp, argv[1]);
   160    160     if( i<0 ) return TCL_ERROR;
   161    161     if( threadset[i].busy ){
   162    162       Tcl_AppendResult(interp, "thread ", argv[1], " is already running", 0);
   163    163       return TCL_ERROR;
   164    164     }
   165    165     threadset[i].busy = 1;
   166         -  sqliteFree(threadset[i].zFilename);
          166  +  sqlite3_free(threadset[i].zFilename);
   167    167     threadset[i].zFilename = sqlite3StrDup(argv[2]);
   168    168     threadset[i].opnum = 1;
   169    169     threadset[i].completed = 0;
   170    170     rc = pthread_create(&x, 0, client_main, &threadset[i]);
   171    171     if( rc ){
   172    172       Tcl_AppendResult(interp, "failed to create the thread", 0);
   173         -    sqliteFree(threadset[i].zFilename);
          173  +    sqlite3_free(threadset[i].zFilename);
   174    174       threadset[i].busy = 0;
   175    175       return TCL_ERROR;
   176    176     }
   177    177     pthread_detach(x);
   178    178     sqlite3_server_start();
   179    179     return TCL_OK;
   180    180   }
................................................................................
   218    218   ** Stop a thread.
   219    219   */
   220    220   static void stop_thread(Thread *p){
   221    221     client_wait(p);
   222    222     p->xOp = 0;
   223    223     p->opnum++;
   224    224     client_wait(p);
   225         -  sqliteFree(p->zArg);
          225  +  sqlite3_free(p->zArg);
   226    226     p->zArg = 0;
   227         -  sqliteFree(p->zFilename);
          227  +  sqlite3_free(p->zFilename);
   228    228     p->zFilename = 0;
   229    229     p->busy = 0;
   230    230   }
   231    231   
   232    232   /*
   233    233   ** Usage:  client_halt ID
   234    234   **
................................................................................
   502    502     if( i<0 ) return TCL_ERROR;
   503    503     if( !threadset[i].busy ){
   504    504       Tcl_AppendResult(interp, "no such thread", 0);
   505    505       return TCL_ERROR;
   506    506     }
   507    507     client_wait(&threadset[i]);
   508    508     threadset[i].xOp = do_compile;
   509         -  sqliteFree(threadset[i].zArg);
          509  +  sqlite3_free(threadset[i].zArg);
   510    510     threadset[i].zArg = sqlite3StrDup(argv[2]);
   511    511     threadset[i].opnum++;
   512    512     return TCL_OK;
   513    513   }
   514    514   
   515    515   /*
   516    516   ** This procedure runs in the thread to step the virtual machine.
................................................................................
   597    597     if( i<0 ) return TCL_ERROR;
   598    598     if( !threadset[i].busy ){
   599    599       Tcl_AppendResult(interp, "no such thread", 0);
   600    600       return TCL_ERROR;
   601    601     }
   602    602     client_wait(&threadset[i]);
   603    603     threadset[i].xOp = do_finalize;
   604         -  sqliteFree(threadset[i].zArg);
          604  +  sqlite3_free(threadset[i].zArg);
   605    605     threadset[i].zArg = 0;
   606    606     threadset[i].opnum++;
   607    607     return TCL_OK;
   608    608   }
   609    609   
   610    610   /*
   611    611   ** This procedure runs in the thread to reset a virtual machine.
................................................................................
   641    641     if( i<0 ) return TCL_ERROR;
   642    642     if( !threadset[i].busy ){
   643    643       Tcl_AppendResult(interp, "no such thread", 0);
   644    644       return TCL_ERROR;
   645    645     }
   646    646     client_wait(&threadset[i]);
   647    647     threadset[i].xOp = do_reset;
   648         -  sqliteFree(threadset[i].zArg);
          648  +  sqlite3_free(threadset[i].zArg);
   649    649     threadset[i].zArg = 0;
   650    650     threadset[i].opnum++;
   651    651     return TCL_OK;
   652    652   }
   653    653   
   654    654   /*
   655    655   ** Usage: client_swap ID ID