/ Check-in [6cf725d2]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:The quick test runs again with a handfull of errors after adding the mutex locks to btree, the VFS registration interfaces, and FTS3. (CVS 4254)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6cf725d212d468cbd7c7cbc22ca5ab13f1d77939
User & Date: drh 2007-08-20 23:50:25
Context
2007-08-21
10:44
Remove unnecessary #includes of "os.h". New mutex implementations. (CVS 4255) check-in: fbbd5bda user: drh tags: trunk
2007-08-20
23:50
The quick test runs again with a handfull of errors after adding the mutex locks to btree, the VFS registration interfaces, and FTS3. (CVS 4254) check-in: 6cf725d2 user: drh tags: trunk
22:48
Work toward multithreading support. Currently crashes quickly on a test. (CVS 4253) check-in: 1315bd8e user: drh 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.403 2007/08/20 22:48:42 drh Exp $
           12  +** $Id: btree.c,v 1.404 2007/08/20 23:50:25 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   
................................................................................
  1046   1046   ** reaches zero.  We need to unref the pParent pointer when that
  1047   1047   ** happens.
  1048   1048   */
  1049   1049   static void pageDestructor(DbPage *pData, int pageSize){
  1050   1050     MemPage *pPage;
  1051   1051     assert( (pageSize & 7)==0 );
  1052   1052     pPage = (MemPage *)sqlite3PagerGetExtra(pData);
  1053         -  assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  1054   1053     if( pPage->pParent ){
  1055   1054       MemPage *pParent = pPage->pParent;
         1055  +    assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  1056   1056       pPage->pParent = 0;
  1057   1057       releasePage(pParent);
  1058   1058     }
  1059   1059     pPage->isInit = 0;
  1060   1060   }
  1061   1061   
  1062   1062   /*
................................................................................
  1067   1067   ** This routine needs to reset the extra data section at the end of the
  1068   1068   ** page to agree with the restored data.
  1069   1069   */
  1070   1070   static void pageReinit(DbPage *pData, int pageSize){
  1071   1071     MemPage *pPage;
  1072   1072     assert( (pageSize & 7)==0 );
  1073   1073     pPage = (MemPage *)sqlite3PagerGetExtra(pData);
  1074         -  assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  1075   1074     if( pPage->isInit ){
         1075  +    assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  1076   1076       pPage->isInit = 0;
  1077   1077       sqlite3BtreeInitPage(pPage, pPage->pParent);
  1078   1078     }
  1079   1079   }
  1080   1080   
  1081   1081   /*
  1082   1082   ** Open a database file.

Changes to src/test3.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the btree.c module in SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test3.c,v 1.78 2007/08/16 11:36:15 danielk1977 Exp $
           16  +** $Id: test3.c,v 1.79 2007/08/20 23:50:25 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "pager.h"
    20     20   #include "btree.h"
    21     21   #include "tcl.h"
    22     22   #include <stdlib.h>
    23     23   #include <string.h>
................................................................................
    44     44       case SQLITE_EMPTY:      zName = "SQLITE_EMPTY";       break;
    45     45       case SQLITE_LOCKED:     zName = "SQLITE_LOCKED";      break;
    46     46       default:                zName = "SQLITE_Unknown";     break;
    47     47     }
    48     48     return zName;
    49     49   }
    50     50   
           51  +/*
           52  +** A bogus sqlite3 connection structure for use in the btree
           53  +** tests.
           54  +*/
           55  +static sqlite3 sDb;
           56  +static int nRefSqlite3 = 0;
           57  +
    51     58   /*
    52     59   ** Usage:   btree_open FILENAME NCACHE FLAGS
    53     60   **
    54     61   ** Open a new database
    55     62   */
    56     63   static int btree_open(
    57     64     void *NotUsed,
................................................................................
    65     72     if( argc!=4 ){
    66     73       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    67     74          " FILENAME NCACHE FLAGS\"", 0);
    68     75       return TCL_ERROR;
    69     76     }
    70     77     if( Tcl_GetInt(interp, argv[2], &nCache) ) return TCL_ERROR;
    71     78     if( Tcl_GetInt(interp, argv[3], &flags) ) return TCL_ERROR;
    72         -  rc = sqlite3BtreeOpen(argv[1], 0, &pBt, flags);
           79  +  nRefSqlite3++;
           80  +  if( nRefSqlite3==1 ){
           81  +    sDb.pVfs = sqlite3_vfs_find(0);
           82  +    sDb.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);
           83  +  }
           84  +  rc = sqlite3BtreeOpen(argv[1], &sDb, &pBt, flags);
    73     85     if( rc!=SQLITE_OK ){
    74     86       Tcl_AppendResult(interp, errorName(rc), 0);
    75     87       return TCL_ERROR;
    76     88     }
    77     89     sqlite3BtreeSetCacheSize(pBt, nCache);
    78     90     sqlite3_snprintf(sizeof(zBuf), zBuf,"%p", pBt);
    79     91     Tcl_AppendResult(interp, zBuf, 0);
................................................................................
   100    112     }
   101    113     pBt = sqlite3TextToPtr(argv[1]);
   102    114     rc = sqlite3BtreeClose(pBt);
   103    115     if( rc!=SQLITE_OK ){
   104    116       Tcl_AppendResult(interp, errorName(rc), 0);
   105    117       return TCL_ERROR;
   106    118     }
          119  +  nRefSqlite3--;
          120  +  if( nRefSqlite3==0 ){
          121  +    sqlite3_mutex_free(sDb.mutex);
          122  +    sDb.mutex = 0;
          123  +    sqlite3_vfs_release(sDb.pVfs);
          124  +    sDb.pVfs = 0;
          125  +  }
   107    126     return TCL_OK;
   108    127   }
   109    128   
   110    129   /*
   111    130   ** Usage:   btree_begin_transaction ID
   112    131   **
   113    132   ** Start a new transaction

Changes to src/test_config.c.

    12     12   ** 
    13     13   ** This file contains code used for testing the SQLite system.
    14     14   ** None of the code in this file goes into a deliverable build.
    15     15   ** 
    16     16   ** The focus of this file is providing the TCL testing layer
    17     17   ** access to compile-time constants.
    18     18   **
    19         -** $Id: test_config.c,v 1.9 2007/08/20 22:48:43 drh Exp $
           19  +** $Id: test_config.c,v 1.10 2007/08/20 23:50:25 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include "tcl.h"
    23     23   #include "os.h"
    24     24   #include <stdlib.h>
    25     25   #include <string.h>
    26     26   
................................................................................
   192    192   #endif
   193    193   
   194    194   #ifdef SQLITE_ENABLE_FTS2
   195    195     Tcl_SetVar2(interp, "sqlite_options", "fts2", "1", TCL_GLOBAL_ONLY);
   196    196   #else
   197    197     Tcl_SetVar2(interp, "sqlite_options", "fts2", "0", TCL_GLOBAL_ONLY);
   198    198   #endif
          199  +
          200  +#ifdef SQLITE_ENABLE_FTS3
          201  +  Tcl_SetVar2(interp, "sqlite_options", "fts3", "1", TCL_GLOBAL_ONLY);
          202  +#else
          203  +  Tcl_SetVar2(interp, "sqlite_options", "fts3", "0", TCL_GLOBAL_ONLY);
          204  +#endif
   199    205   
   200    206   #ifdef SQLITE_OMIT_GLOBALRECOVER
   201    207     Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "0", TCL_GLOBAL_ONLY);
   202    208   #else
   203    209     Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "1", TCL_GLOBAL_ONLY);
   204    210   #endif
   205    211