/ Check-in [c13df031]
Login

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

Overview
Comment:Continuing to refactor os_unix.c. This is an incremental check-in. (CVS 5967)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c13df0311ef4f6a510f42105293f7c53c323fda8
User & Date: drh 2008-11-29 02:20:27
Context
2008-11-29
22:49
Fully initialize the unused bytes of the buffer that will become the journal file header, in order to silence a complaint from valgrind. (CVS 5968) check-in: 2822cbb9 user: drh tags: trunk
02:20
Continuing to refactor os_unix.c. This is an incremental check-in. (CVS 5967) check-in: c13df031 user: drh tags: trunk
00:56
Continuing work on the os_unix.c refactoring. Removed all of the LOCKING_STYLE_* constants and instead pass around pointers to the underlying sqlite3_io_method objects. (CVS 5966) check-in: 1017d2fb user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

    15     15   **
    16     16   ** There are actually several different VFS implementations in this file.
    17     17   ** The differences are in the way that file locking is done.  The default
    18     18   ** implementation uses Posix Advisory Locks.  Alternative implementations
    19     19   ** use flock(), dot-files, various proprietary locking schemas, or simply
    20     20   ** skip locking all together.
    21     21   **
    22         -** This source file is group into divisions where the logic for various
           22  +** This source file is organized into divisions where the logic for various
    23     23   ** subfunctions is contained within the appropriate division.  PLEASE
    24     24   ** KEEP THE STRUCTURE OF THIS FILE INTACT.  New code should be placed
    25     25   ** in the correct division and should be clearly labeled.
    26     26   **
    27     27   ** The current set of divisions is as follows:
    28     28   **
    29     29   **   *  General-purpose declarations and utility functions.
................................................................................
    32     32   **      + for Posix Advisory Locks
    33     33   **      + for no-op locks
    34     34   **      + for dot-file locks
    35     35   **      + for flock() locking
    36     36   **      + for named semaphore locks (VxWorks only)
    37     37   **      + for AFP filesystem locks (MacOSX only)
    38     38   **      + for proxy locks (MacOSX only)
    39         -**   *  The routine used to detect an appropriate locking style
    40         -**   *  sqlite3_file methods not associated with locking
    41         -**   *  Implementations of sqlite3_os_init() and sqlite3_os_end()
           39  +**   *  sqlite3_file methods not associated with locking.
           40  +**   *  Definitions of sqlite3_io_methods objects for all locking
           41  +**      methods plus "finder" functions for each locking method.
           42  +**   *  VFS method implementations.
           43  +**   *  Definitions of sqlite3_vfs objects for all locking methods
           44  +**      plus implementations of sqlite3_os_init() and sqlite3_os_end().
    42     45   **
    43         -** $Id: os_unix.c,v 1.223 2008/11/29 00:56:53 drh Exp $
           46  +** $Id: os_unix.c,v 1.224 2008/11/29 02:20:27 drh Exp $
    44     47   */
    45     48   #include "sqliteInt.h"
    46     49   #if SQLITE_OS_UNIX              /* This file is used on unix only */
    47     50   
    48     51   /*
    49     52   ** This module implements the following locking styles:
    50     53   **
................................................................................
    56     59   **   6. Named POSIX semaphores (VXWorks only),
    57     60   **   7. proxy locking. (OSX only)
    58     61   **
    59     62   ** Styles 4, 5, and 7 are only available of SQLITE_ENABLE_LOCKING_STYLE
    60     63   ** is defined to 1.  The SQLITE_ENABLE_LOCKING_STYLE also enables automatic
    61     64   ** selection of the appropriate locking style based on the filesystem
    62     65   ** where the database is located.  
    63         -**
    64         -** SQLITE_ENABLE_LOCKING_STYLE only works on a Mac. It is turned on by
    65         -** default on a Mac and disabled on all other posix platforms.
    66     66   */
    67     67   #if !defined(SQLITE_ENABLE_LOCKING_STYLE)
    68     68   #  if defined(__DARWIN__)
    69     69   #    define SQLITE_ENABLE_LOCKING_STYLE 1
    70     70   #  else
    71     71   #    define SQLITE_ENABLE_LOCKING_STYLE 0
    72     72   #  endif
................................................................................
    92     92   ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
    93     93   ** on the compiler command line.  This is necessary if you are compiling
    94     94   ** on a recent machine (ex: RedHat 7.2) but you want your code to work
    95     95   ** on an older machine (ex: RedHat 6.0).  If you compile on RedHat 7.2
    96     96   ** without this option, LFS is enable.  But LFS does not exist in the kernel
    97     97   ** in RedHat 6.0, so the code won't work.  Hence, for maximum binary
    98     98   ** portability you should omit LFS.
           99  +**
          100  +** The previous paragraph was written in 2005.  (This paragraph is written
          101  +** on 2008-11-28.) These days, all Linux kernels support large files, so
          102  +** you should probably leave LFS enabled.  But some embedded platforms might
          103  +** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
    99    104   */
   100    105   #ifndef SQLITE_DISABLE_LFS
   101    106   # define _LARGE_FILE       1
   102    107   # ifndef _FILE_OFFSET_BITS
   103    108   #   define _FILE_OFFSET_BITS 64
   104    109   # endif
   105    110   # define _LARGEFILE_SOURCE 1
................................................................................
   115    120   #include <time.h>
   116    121   #include <sys/time.h>
   117    122   #include <errno.h>
   118    123   
   119    124   #if SQLITE_ENABLE_LOCKING_STYLE
   120    125   # include <sys/ioctl.h>
   121    126   # if OS_VXWORKS
   122         -#  define lstat stat
   123    127   #  include <semaphore.h>
   124    128   #  include <limits.h>
   125    129   # else
          130  +#  include <sys/file.h>
   126    131   #  include <sys/param.h>
   127    132   #  include <sys/mount.h>
   128    133   # endif
   129    134   #endif /* SQLITE_ENABLE_LOCKING_STYLE */
   130    135   
   131    136   /*
   132    137   ** If we are to be thread-safe, include the pthreads header and define
................................................................................
   160    165   ** Only set the lastErrno if the error code is a real error and not 
   161    166   ** a normal expected return code of SQLITE_BUSY or SQLITE_OK
   162    167   */
   163    168   #define IS_LOCK_ERROR(x)  ((x != SQLITE_OK) && (x != SQLITE_BUSY))
   164    169   
   165    170   
   166    171   /*
   167         -** The unixFile structure is subclass of sqlite3_file specific for the unix
   168         -** protability layer.
          172  +** The unixFile structure is subclass of sqlite3_file specific to the unix
          173  +** VFS implementations.
   169    174   */
   170    175   typedef struct unixFile unixFile;
   171    176   struct unixFile {
   172    177     sqlite3_io_methods const *pMethod;  /* Always the first entry */
   173    178     struct unixOpenCnt *pOpen;       /* Info about all open fd's on this inode */
   174    179     struct unixLockInfo *pLock;      /* Info about locks on this inode */
   175    180     int h;                           /* The file descriptor */
................................................................................
   415    420     int nRef;                     /* Number of references to this one */
   416    421     int nName;                    /* Length of the zCanonicalName[] string */
   417    422     char *zCanonicalName;         /* Canonical filename */
   418    423   };
   419    424   
   420    425   #if OS_VXWORKS
   421    426   /* 
   422         -** All unique filesname are held on a linked list headed by this
          427  +** All unique filenames are held on a linked list headed by this
   423    428   ** variable:
   424    429   */
   425    430   static struct vxworksFileId *vxworksFileList = 0;
   426    431   
   427    432   /*
   428    433   ** Simplify a filename into its canonical form
   429    434   ** by making the following changes:
   430    435   **
   431    436   **  * removing any trailing and duplicate /
   432         -**  * removing /./
   433         -**  * removing /A/../
          437  +**  * convert /./ into just /
          438  +**  * convert /A/../ where A is any simple name into just /
   434    439   **
   435    440   ** Changes are made in-place.  Return the new name length.
   436    441   **
   437    442   ** The original filename is in z[0..n-1].  Return the number of
   438    443   ** characters in the simplified name.
   439    444   */
   440    445   static int vxworksSimplifyName(char *z, int n){
................................................................................
   530    535   /*************** End of Unique File ID Utility Used By VxWorks ****************
   531    536   ******************************************************************************/
   532    537   
   533    538   
   534    539   /******************************************************************************
   535    540   *************************** Posix Advisory Locking ****************************
   536    541   **
   537         -** POSIX advisory locks broken by design.  ANSI STD 1003.1 (1996)
          542  +** POSIX advisory locks are broken by design.  ANSI STD 1003.1 (1996)
   538    543   ** section 6.5.2.2 lines 483 through 490 specify that when a process
   539    544   ** sets or clears a lock, that operation overrides any prior locks set
   540    545   ** by the same process.  It does not explicitly say so, but this implies
   541    546   ** that it overrides locks set by the same process using a different
   542    547   ** file descriptor.  Consider this test case:
   543    548   **
   544    549   **       int fd1 = open("./file1", O_RDWR|O_CREAT, 0644);
................................................................................
   562    567   ** on its own.  Whenever a new database is opened, we have to find the
   563    568   ** specific inode of the database file (the inode is determined by the
   564    569   ** st_dev and st_ino fields of the stat structure that fstat() fills in)
   565    570   ** and check for locks already existing on that inode.  When locks are
   566    571   ** created or removed, we have to look at our own internal record of the
   567    572   ** locks to see if another thread has previously set a lock on that same
   568    573   ** inode.
          574  +**
          575  +** (Aside: The use of inode numbers as unique IDs does not work on VxWorks.
          576  +** For VxWorks, we have to use the alternative unique ID system based on
          577  +** canonical filename and implemented in the previous division.)
   569    578   **
   570    579   ** The sqlite3_file structure for POSIX is no longer just an integer file
   571    580   ** descriptor.  It is now a structure that holds the integer file
   572    581   ** descriptor and a pointer to a structure that describes the internal
   573    582   ** locks on the corresponding inode.  There is one locking structure
   574    583   ** per inode, so if the same inode is opened twice, both unixFile structures
   575    584   ** point to the same locking structure.  The locking structure keeps
................................................................................
   593    602   ** unixOpenCnt.  When an attempt is made to close an unixFile, if there are
   594    603   ** other unixFile open on the same inode that are holding locks, the call
   595    604   ** to close() the file descriptor is deferred until all of the locks clear.
   596    605   ** The unixOpenCnt structure keeps a list of file descriptors that need to
   597    606   ** be closed and that list is walked (and cleared) when the last lock
   598    607   ** clears.
   599    608   **
   600         -** Yet another problem with posix locks and threads:
          609  +** Yet another problem:  LinuxThreads do not play well with posix locks.
   601    610   **
   602         -** Many older versions of linux us the LinuxThreads library which is
   603         -** not posix compliant.  Under LinuxThreads, a lock created thread
          611  +** Many older versions of linux use the LinuxThreads library which is
          612  +** not posix compliant.  Under LinuxThreads, a lock created by thread
   604    613   ** A cannot be modified or overridden by a different thread B.
   605    614   ** Only thread A can modify the lock.  Locking behavior is correct
   606    615   ** if the appliation uses the newer Native Posix Thread Library (NPTL)
   607    616   ** on linux - with NPTL a lock created by thread A can override locks
   608    617   ** in thread B.  But there is no way to know at compile-time which
   609    618   ** threading library is being used.  So there is no way to know at
   610    619   ** compile-time whether or not thread A can override locks on thread B.
   611    620   ** We have to do a run-time check to discover the behavior of the
   612    621   ** current process.
   613    622   **
   614    623   ** On systems where thread A is unable to modify locks created by
   615    624   ** thread B, we have to keep track of which thread created each
   616         -** lock.  So there is an extra field in the key to the unixLockInfo
          625  +** lock.  Hence there is an extra field in the key to the unixLockInfo
   617    626   ** structure to record this information.  And on those systems it
   618    627   ** is illegal to begin a transaction in one thread and finish it
   619    628   ** in another.  For this latter restriction, there is no work-around.
   620    629   ** It is a limitation of LinuxThreads.
   621    630   */
   622    631   
   623    632   /*
................................................................................
   673    682   #if SQLITE_THREADSAFE && defined(__linux__)
   674    683     pthread_t tid;  /* Thread ID of lock owner. Zero if not using LinuxThreads */
   675    684   #endif
   676    685   };
   677    686   
   678    687   /*
   679    688   ** An instance of the following structure is allocated for each open
   680         -** inode on each thread with a different process ID.  (Threads have
   681         -** different process IDs on some versions of linux, but not on most
   682         -** other unixes.)
          689  +** inode.  Or, on LinuxThreads, there is one of these structures for
          690  +** each inode opened by each thread.
   683    691   **
   684    692   ** A single inode can have multiple file descriptors, so each unixFile
   685    693   ** structure contains a pointer to an instance of this object and this
   686    694   ** object keeps a count of the number of unixFile pointing to it.
   687    695   */
   688    696   struct unixLockInfo {
   689    697     struct unixLockKey lockKey;     /* The lookup key */
................................................................................
   696    704   
   697    705   /*
   698    706   ** An instance of the following structure is allocated for each open
   699    707   ** inode.  This structure keeps track of the number of locks on that
   700    708   ** inode.  If a close is attempted against an inode that is holding
   701    709   ** locks, the close is deferred until all locks clear by adding the
   702    710   ** file descriptor to be closed to the pending list.
          711  +**
          712  +** TODO:  Consider changing this so that there is only a single file
          713  +** descriptor for each open file, even when it is opened multiple times.
          714  +** The close() system call would only occur when the last database
          715  +** using the file closes.
   703    716   */
   704    717   struct unixOpenCnt {
   705    718     struct unixFileId fileId;   /* The lookup key */
   706    719     int nRef;                   /* Number of pointers to this structure */
   707    720     int nLock;                  /* Number of outstanding locks */
   708    721     int nPending;               /* Number of pending close() operations */
   709    722     int *aPending;            /* Malloced space holding fd's awaiting a close() */
................................................................................
   711    724     sem_t *pSem;                     /* Named POSIX semaphore */
   712    725     char aSemName[MAX_PATHNAME+1];   /* Name of that semaphore */
   713    726   #endif
   714    727     struct unixOpenCnt *pNext, *pPrev;   /* List of all unixOpenCnt objects */
   715    728   };
   716    729   
   717    730   /*
   718         -** List of all unixLockInfo and unixOpenCnt objects.  This used to be a hash
   719         -** table.  But the number of objects is rarely more than a dozen and
          731  +** Lists of all unixLockInfo and unixOpenCnt objects.  These used to be hash
          732  +** tables.  But the number of objects is rarely more than a dozen and
   720    733   ** never exceeds a few thousand.  And lookup is not on a critical
   721    734   ** path so a simple linked list will suffice.
   722    735   */
   723    736   static struct unixLockInfo *lockList = 0;
   724    737   static struct unixOpenCnt *openList = 0;
   725    738   
   726    739   /*
   727         -** This variable records whether or not threads can override each others
          740  +** This variable remembers whether or not threads can override each others
   728    741   ** locks.
   729    742   **
   730         -**    0:  No.  Threads cannot override each others locks.
   731         -**    1:  Yes.  Threads can override each others locks.
          743  +**    0:  No.  Threads cannot override each others locks.  (LinuxThreads)
          744  +**    1:  Yes.  Threads can override each others locks.  (Posix & NLPT)
   732    745   **   -1:  We don't know yet.
   733    746   **
   734    747   ** On some systems, we know at compile-time if threads can override each
   735    748   ** others locks.  On those systems, the SQLITE_THREAD_OVERRIDE_LOCK macro
   736    749   ** will be set appropriately.  On other systems, we have to check at
   737    750   ** runtime.  On these latter systems, SQLTIE_THREAD_OVERRIDE_LOCK is
   738    751   ** undefined.
................................................................................
   862    875           pOpen->pNext->pPrev = pOpen->pPrev;
   863    876         }
   864    877         sqlite3_free(pOpen->aPending);
   865    878         sqlite3_free(pOpen);
   866    879       }
   867    880     }
   868    881   }
   869         -
   870    882   
   871    883   /*
   872    884   ** Given a file descriptor, locate unixLockInfo and unixOpenCnt structures that
   873    885   ** describes that file descriptor.  Create new ones if necessary.  The
   874    886   ** return values might be uninitialized if an error occurs.
   875    887   **
   876    888   ** Return an appropriate error code.
................................................................................
  1455   1467   }
  1456   1468   
  1457   1469   /*
  1458   1470   ** This function performs the parts of the "close file" operation 
  1459   1471   ** common to all locking schemes. It closes the directory and file
  1460   1472   ** handles, if they are valid, and sets all fields of the unixFile
  1461   1473   ** structure to 0.
         1474  +**
         1475  +** It is *not* necessary to hold the mutex when this routine is called,
         1476  +** even on VxWorks.  A mutex will be acquired on VxWorks by the
         1477  +** vxworksReleaseFileId() routine.
  1462   1478   */
  1463   1479   static int closeUnixFile(sqlite3_file *id){
  1464   1480     unixFile *pFile = (unixFile*)id;
  1465   1481     if( pFile ){
  1466   1482       if( pFile->dirfd>=0 ){
  1467   1483         int err = close(pFile->dirfd);
  1468   1484         if( err ){
................................................................................
  1478   1494           pFile->lastErrno = errno;
  1479   1495           return SQLITE_IOERR_CLOSE;
  1480   1496         }
  1481   1497       }
  1482   1498   #if OS_VXWORKS
  1483   1499       if( pFile->pId ){
  1484   1500         if( pFile->isDelete ){
  1485         -         unlink(pFile->pId->zCanonicalName);
         1501  +        unlink(pFile->pId->zCanonicalName);
  1486   1502         }
  1487   1503         vxworksReleaseFileId(pFile->pId);
  1488   1504         pFile->pId = 0;
  1489   1505       }
  1490   1506   #endif
  1491   1507       OSTRACE2("CLOSE   %-3d\n", pFile->h);
  1492   1508       OpenCounter(-1);
................................................................................
  1546   1562   ** prevent simultaneous access of the same database by two or more
  1547   1563   ** database connections.  But there is a serious risk of database
  1548   1564   ** corruption if this locking mode is used in situations where multiple
  1549   1565   ** database connections are accessing the same database file at the same
  1550   1566   ** time and one or more of those connections are writing.
  1551   1567   */
  1552   1568   
  1553         -/*
  1554         -** The nolockLockingContext is void
  1555         -*/
  1556         -typedef void nolockLockingContext;
  1557         -
  1558   1569   static int nolockCheckReservedLock(sqlite3_file *NotUsed, int *pResOut){
  1559   1570     UNUSED_PARAMETER(NotUsed);
  1560   1571     *pResOut = 0;
  1561   1572     return SQLITE_OK;
  1562   1573   }
  1563         -
  1564   1574   static int nolockLock(sqlite3_file *NotUsed, int NotUsed2){
  1565   1575     UNUSED_PARAMETER2(NotUsed, NotUsed2);
  1566   1576     return SQLITE_OK;
  1567   1577   }
  1568         -
  1569   1578   static int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2){
  1570   1579     UNUSED_PARAMETER2(NotUsed, NotUsed2);
  1571   1580     return SQLITE_OK;
  1572   1581   }
  1573   1582   
  1574   1583   /*
  1575         -** Close a file.
         1584  +** Close the file.
  1576   1585   */
  1577   1586   static int nolockClose(sqlite3_file *id) {
  1578         -  int rc;
  1579         -  if( OS_VXWORKS ) unixEnterMutex();
  1580         -  rc = closeUnixFile(id);
  1581         -  if( OS_VXWORKS ) unixLeaveMutex();
  1582         -  return rc;
         1587  +  return closeUnixFile(id);
  1583   1588   }
  1584   1589   
  1585   1590   /******************* End of the no-op lock implementation *********************
  1586   1591   ******************************************************************************/
  1587   1592   
  1588   1593   /******************************************************************************
  1589   1594   ************************* Begin dot-file Locking ******************************
................................................................................
  1762   1767       return rc; 
  1763   1768     }
  1764   1769     pFile->locktype = NO_LOCK;
  1765   1770     return SQLITE_OK;
  1766   1771   }
  1767   1772   
  1768   1773   /*
  1769         -** Close a file.
         1774  +** Close a file.  Make sure the lock has been released before closing.
  1770   1775   */
  1771   1776   static int dotlockClose(sqlite3_file *id) {
  1772   1777     int rc;
  1773   1778     if( id ){
  1774   1779       unixFile *pFile = (unixFile*)id;
  1775   1780       dotlockUnlock(id, NO_LOCK);
  1776   1781       sqlite3_free(pFile->lockingContext);
  1777   1782     }
  1778         -  if( OS_VXWORKS ) unixEnterMutex();
  1779   1783     rc = closeUnixFile(id);
  1780         -  if( OS_VXWORKS ) unixLeaveMutex();
  1781   1784     return rc;
  1782   1785   }
  1783   1786   /****************** End of the dot-file lock implementation *******************
  1784   1787   ******************************************************************************/
  1785   1788   
  1786   1789   /******************************************************************************
  1787   1790   ************************** Begin flock Locking ********************************
................................................................................
  1788   1791   **
  1789   1792   ** Use the flock() system call to do file locking.
  1790   1793   **
  1791   1794   ** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off or if
  1792   1795   ** compiling for VXWORKS.
  1793   1796   */
  1794   1797   #if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
  1795         -#include <sys/file.h>
  1796         -
  1797         -/*
  1798         -** The flockLockingContext is not used
  1799         -*/
  1800         -typedef void flockLockingContext;
  1801   1798   
  1802   1799   /* flock-style reserved lock checking following the behavior of 
  1803   1800    ** unixCheckReservedLock, see the unixCheckReservedLock function comments */
  1804   1801   static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
  1805   1802     int rc = SQLITE_OK;
  1806   1803     int reserved = 0;
  1807   1804     unixFile *pFile = (unixFile*)id;

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing all sorts of SQLite interfaces.  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: test1.c,v 1.333 2008/11/29 00:56:53 drh Exp $
           16  +** $Id: test1.c,v 1.334 2008/11/29 02:20:27 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   /*
................................................................................
  4523   4523     if( objc!=2 ){
  4524   4524       Tcl_AppendResult(interp, "wrong # args: should be \"",
  4525   4525                        Tcl_GetStringFromObj(objv[0], 0), " DB", 0);
  4526   4526       return TCL_ERROR;
  4527   4527     }
  4528   4528     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  4529   4529     
  4530         -#if defined(SQLITE_ENABLE_LOCKING_STYLE) && defined(__DARWIN__)
         4530  +#if !defined(SQLITE_ENABLE_LOCKING_STYLE)
         4531  +#  if defined(__DARWIN__)
         4532  +#    define SQLITE_ENABLE_LOCKING_STYLE 1
         4533  +#  else
         4534  +#    define SQLITE_ENABLE_LOCKING_STYLE 0
         4535  +#  endif
         4536  +#endif
         4537  +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__)
  4531   4538     {
  4532   4539       char *proxyPath = "test.proxy";
  4533   4540       char *testPath;
  4534   4541       rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath);
  4535   4542       if( rc ){
  4536   4543         Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return TCL_ERROR;
  4537   4544       }

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.44 2008/11/29 00:56:54 drh Exp $
           19  +** $Id: test_config.c,v 1.45 2008/11/29 02:20:27 drh Exp $
    20     20   */
    21     21   
    22     22   #include "sqliteLimit.h"
    23     23   
    24     24   #include "sqliteInt.h"
    25     25   #include "tcl.h"
    26     26   #include <stdlib.h>
................................................................................
   388    388   
   389    389   #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
   390    390     Tcl_SetVar2(interp, "sqlite_options", "schema_version", "0", TCL_GLOBAL_ONLY);
   391    391   #else
   392    392     Tcl_SetVar2(interp, "sqlite_options", "schema_version", "1", TCL_GLOBAL_ONLY);
   393    393   #endif
   394    394   
   395         -#if defined(SQLITE_ENABLE_LOCKING_STYLE) && defined(__DARWIN__)
          395  +#if !defined(SQLITE_ENABLE_LOCKING_STYLE)
          396  +#  if defined(__DARWIN__)
          397  +#    define SQLITE_ENABLE_LOCKING_STYLE 1
          398  +#  else
          399  +#    define SQLITE_ENABLE_LOCKING_STYLE 0
          400  +#  endif
          401  +#endif
          402  +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__)
   396    403     Tcl_SetVar2(interp,"sqlite_options","lock_proxy_pragmas","1",TCL_GLOBAL_ONLY);
   397    404   #else
   398    405     Tcl_SetVar2(interp,"sqlite_options","lock_proxy_pragmas","0",TCL_GLOBAL_ONLY);
   399    406   #endif
   400    407       
   401    408       
   402    409   #ifdef SQLITE_OMIT_SHARED_CACHE

Changes to test/lock5.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is database locks.
    13     13   #
    14         -# $Id: lock5.test,v 1.4 2008/11/21 00:10:35 aswift Exp $
           14  +# $Id: lock5.test,v 1.5 2008/11/29 02:20:27 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # This file is only run if using the unix backend compiled with the
    20     20   # SQLITE_ENABLE_LOCKING_STYLE macro.
    21     21   db close
    22     22   if {[catch {sqlite3 db test.db -vfs unix-none} msg]} {
    23     23     finish_test
    24     24     return
    25     25   }
    26     26   db close
           27  +file delete -force test.db.lock
    27     28   
    28     29   ifcapable lock_proxy_pragmas {
    29     30     set ::using_proxy 0
    30     31     foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
    31     32       set ::using_proxy $value
    32     33     }
    33     34     # Disable the proxy locking for these tests