/ Check-in [7c8f992c]
Login

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

Overview
Comment:Merge the latest trunk changes into the NGQP branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nextgen-query-plan-exp
Files: files | file ages | folders
SHA1: 7c8f992c04504a132686ad0652efdff19e43480d
User & Date: drh 2013-05-24 13:55:23
Context
2013-05-24
14:52
Record in the WhereLoop object the set of virtual table constraints that need not be separately checked. check-in: b49fa745 user: drh tags: nextgen-query-plan-exp
13:55
Merge the latest trunk changes into the NGQP branch. check-in: 7c8f992c user: drh tags: nextgen-query-plan-exp
12:47
Set _XOPEN_SOURCE to 600 so that fchmod() will (hopefully) work on FreeBSD. check-in: 61a10452 user: drh tags: trunk
2013-05-22
20:49
Use the NGQP plan for EXPLAIN QUERY PLAN output. This change causes 207 errors in veryquick.test, many of which are benign. check-in: f783e8e6 user: drh tags: nextgen-query-plan-exp
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to magic.txt.

    15     15   # its identifier long before "PRAGMA application_id" became available.
    16     16   # The user_version is very similar to application_id except that it is
    17     17   # stored at offset 68 instead of offset 60.  The application_id pragma
    18     18   # is preferred.  The rule using offset 60 for Monotone is for historical
    19     19   # compatibility only.
    20     20   #
    21     21   0    string  =SQLite\ format\ 3
    22         ->68  belong  =0x0f055111  Fossil repository -
    23     22   >68  belong  =0x0f055112  Fossil checkout - 
    24     23   >68  belong  =0x0f055113  Fossil global configuration - 
           24  +>68  belong  =0x0f055111  Fossil repository -
    25     25   >68  belong  =0x42654462  Bentley Systems BeSQLite Database -
    26     26   >68  belong  =0x42654c6e  Bentley Systems Localization File -
    27     27   >60  belong  =0x5f4d544e  Monotone source repository -
           28  +>68  belong  =0x47504b47  OGC GeoPackage file -
    28     29   >0   string  =SQLite      SQLite3 database

Changes to src/os_unix.c.

  3771   3771           unixGetTempname(pFile->pVfs->mxPathname, zTFile);
  3772   3772           *(char**)pArg = zTFile;
  3773   3773         }
  3774   3774         return SQLITE_OK;
  3775   3775       }
  3776   3776       case SQLITE_FCNTL_MMAP_SIZE: {
  3777   3777         i64 newLimit = *(i64*)pArg;
         3778  +      int rc = SQLITE_OK;
  3778   3779         if( newLimit>sqlite3GlobalConfig.mxMmap ){
  3779   3780           newLimit = sqlite3GlobalConfig.mxMmap;
  3780   3781         }
  3781   3782         *(i64*)pArg = pFile->mmapSizeMax;
  3782         -      if( newLimit>=0 ){
         3783  +      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
  3783   3784           pFile->mmapSizeMax = newLimit;
  3784         -        if( newLimit<pFile->mmapSize ) pFile->mmapSize = newLimit;
         3785  +        if( pFile->mmapSize>0 ){
         3786  +          unixUnmapfile(pFile);
         3787  +          rc = unixMapfile(pFile, -1);
         3788  +        }
  3785   3789         }
  3786         -      return SQLITE_OK;
         3790  +      return rc;
  3787   3791       }
  3788   3792   #ifdef SQLITE_DEBUG
  3789   3793       /* The pager calls this method to signal that it has done
  3790   3794       ** a rollback and that the database is therefore unchanged and
  3791   3795       ** it hence it is OK for the transaction change counter to be
  3792   3796       ** unchanged.
  3793   3797       */

Changes to src/os_win.c.

  2812   2812     }else{
  2813   2813       pFile->ctrlFlags |= mask;
  2814   2814     }
  2815   2815   }
  2816   2816   
  2817   2817   /* Forward declaration */
  2818   2818   static int getTempname(int nBuf, char *zBuf);
         2819  +#if SQLITE_MAX_MMAP_SIZE>0
         2820  +static int winMapfile(winFile*, sqlite3_int64);
         2821  +#endif
  2819   2822   
  2820   2823   /*
  2821   2824   ** Control and query of the open file handle.
  2822   2825   */
  2823   2826   static int winFileControl(sqlite3_file *id, int op, void *pArg){
  2824   2827     winFile *pFile = (winFile*)id;
  2825   2828     OSTRACE(("FCNTL file=%p, op=%d, pArg=%p\n", pFile->h, op, pArg));
................................................................................
  2895   2898         }
  2896   2899         OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2897   2900         return SQLITE_OK;
  2898   2901       }
  2899   2902   #if SQLITE_MAX_MMAP_SIZE>0
  2900   2903       case SQLITE_FCNTL_MMAP_SIZE: {
  2901   2904         i64 newLimit = *(i64*)pArg;
         2905  +      int rc = SQLITE_OK;
  2902   2906         if( newLimit>sqlite3GlobalConfig.mxMmap ){
  2903   2907           newLimit = sqlite3GlobalConfig.mxMmap;
  2904   2908         }
  2905   2909         *(i64*)pArg = pFile->mmapSizeMax;
  2906         -      if( newLimit>=0 ) pFile->mmapSizeMax = newLimit;
  2907         -      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  2908         -      return SQLITE_OK;
         2910  +      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
         2911  +        pFile->mmapSizeMax = newLimit;
         2912  +        if( pFile->mmapSize>0 ){
         2913  +          (void)winUnmapfile(pFile);
         2914  +          rc = winMapfile(pFile, -1);
         2915  +        }
         2916  +      }
         2917  +      OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
         2918  +      return rc;
  2909   2919       }
  2910   2920   #endif
  2911   2921     }
  2912   2922     OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
  2913   2923     return SQLITE_NOTFOUND;
  2914   2924   }
  2915   2925   

Changes to src/pager.c.

  4210   4210     }
  4211   4211   
  4212   4212     /* Before the first write, give the VFS a hint of what the final
  4213   4213     ** file size will be.
  4214   4214     */
  4215   4215     assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
  4216   4216     if( rc==SQLITE_OK 
  4217         -   && (pList->pDirty ? pPager->dbSize : pList->pgno+1)>pPager->dbHintSize 
         4217  +   && pPager->dbHintSize<pPager->dbSize
         4218  +   && (pList->pDirty || pList->pgno>pPager->dbHintSize)
  4218   4219     ){
  4219   4220       sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
  4220   4221       sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
  4221   4222       pPager->dbHintSize = pPager->dbSize;
  4222   4223     }
  4223   4224   
  4224   4225     while( rc==SQLITE_OK && pList ){

Changes to src/pragma.c.

   770    770         for(ii=db->nDb-1; ii>=0; ii--){
   771    771           if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
   772    772             sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, sz);
   773    773           }
   774    774         }
   775    775       }
   776    776       sz = -1;
   777         -    if( sqlite3_file_control(db,zDb,SQLITE_FCNTL_MMAP_SIZE,&sz)==SQLITE_OK ){
          777  +    rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_MMAP_SIZE, &sz);
   778    778   #if SQLITE_MAX_MMAP_SIZE==0
   779         -      sz = 0;
          779  +    sz = 0;
   780    780   #endif
          781  +    if( rc==SQLITE_OK ){
   781    782         returnSingleInt(pParse, "mmap_size", sz);
          783  +    }else if( rc!=SQLITE_NOTFOUND ){
          784  +      pParse->nErr++;
          785  +      pParse->rc = rc;
   782    786       }
   783    787     }else
   784    788   
   785    789     /*
   786    790     **   PRAGMA temp_store
   787    791     **   PRAGMA temp_store = "default"|"memory"|"file"
   788    792     **

Changes to src/shell.c.

  1560   1560     int isNeg = 0;
  1561   1561     if( zArg[0]=='-' ){
  1562   1562       isNeg = 1;
  1563   1563       zArg++;
  1564   1564     }else if( zArg[0]=='+' ){
  1565   1565       zArg++;
  1566   1566     }
  1567         -  while( isdigit(zArg[0]) ){
         1567  +  while( IsDigit(zArg[0]) ){
  1568   1568       v = v*10 + zArg[0] - '0';
  1569   1569       zArg++;
  1570   1570     }
  1571         -  for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
         1571  +  for(i=0; i<ArraySize(aMult); i++){
  1572   1572       if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
  1573   1573         v *= aMult[i].iMult;
  1574   1574         break;
  1575   1575       }
  1576   1576     }
  1577   1577     return isNeg? -v : v;
  1578   1578   }

Changes to src/sqliteInt.h.

   189    189   */
   190    190   #if !defined(SQLITE_MALLOC_SOFT_LIMIT)
   191    191   # define SQLITE_MALLOC_SOFT_LIMIT 1024
   192    192   #endif
   193    193   
   194    194   /*
   195    195   ** We need to define _XOPEN_SOURCE as follows in order to enable
   196         -** recursive mutexes on most Unix systems.  But Mac OS X is different.
   197         -** The _XOPEN_SOURCE define causes problems for Mac OS X we are told,
   198         -** so it is omitted there.  See ticket #2673.
   199         -**
   200         -** Later we learn that _XOPEN_SOURCE is poorly or incorrectly
   201         -** implemented on some systems.  So we avoid defining it at all
   202         -** if it is already defined or if it is unneeded because we are
   203         -** not doing a threadsafe build.  Ticket #2681.
   204         -**
   205         -** See also ticket #2741.
          196  +** recursive mutexes on most Unix systems and fchmod() on OpenBSD.
          197  +** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit
          198  +** it.
   206    199   */
   207         -#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) \
   208         - && !defined(__APPLE__) && SQLITE_THREADSAFE
   209         -#  define _XOPEN_SOURCE 500  /* Needed to enable pthread recursive mutexes */
          200  +#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
          201  +#  define _XOPEN_SOURCE 600
   210    202   #endif
   211    203   
   212    204   /*
   213    205   ** The TCL headers are only needed when compiling the TCL bindings.
   214    206   */
   215    207   #if defined(SQLITE_TCL) || defined(TCLSH)
   216    208   # include <tcl.h>

Changes to test/all.test.

    35     35   run_test_suite inmemory_journal
    36     36   run_test_suite pcache0 
    37     37   run_test_suite pcache10 
    38     38   run_test_suite pcache50 
    39     39   run_test_suite pcache90 
    40     40   run_test_suite pcache100
    41     41   run_test_suite prepare
           42  +run_test_suite mmap
    42     43   
    43     44   if {$::tcl_platform(platform)=="unix"} {
    44     45     ifcapable !default_autovacuum {
    45     46       run_test_suite autovacuum_crash
    46     47     }
    47     48   }
    48     49   
    49     50   finish_test
    50     51   
    51     52   

Added test/mmap3.test.

            1  +# 2013-05-23
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +
           13  +set testdir [file dirname $argv0]
           14  +source $testdir/tester.tcl
           15  +ifcapable !mmap {
           16  +  finish_test
           17  +  return
           18  +}
           19  +source $testdir/lock_common.tcl
           20  +set testprefix mmap3
           21  +
           22  +do_test mmap3-1.0 {
           23  +  load_static_extension db wholenumber
           24  +  db eval {
           25  +    PRAGMA mmap_size=100000;
           26  +    CREATE TABLE t1(x, y);
           27  +    CREATE VIRTUAL TABLE nums USING wholenumber;
           28  +    INSERT INTO t1 SELECT value, randomblob(value) FROM nums
           29  +                    WHERE value BETWEEN 1 and 1000;
           30  +    SELECT sum(x), sum(length(y)) from t1;
           31  +    PRAGMA mmap_size;
           32  +  }
           33  +} {100000 500500 500500 100000}
           34  +do_test mmap3-1.2 {
           35  +  db eval {
           36  +    PRAGMA mmap_size=50000;
           37  +    CREATE TABLE t2(a,b);
           38  +    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
           39  +    PRAGMA quick_check;
           40  +    PRAGMA mmap_size;
           41  +  }
           42  +} {50000 nums t1 t2 ok 50000}
           43  +do_test mmap3-1.3 {
           44  +  db eval {
           45  +    PRAGMA mmap_size=250000;
           46  +    DROP TABLE t2;
           47  +    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
           48  +    PRAGMA quick_check;
           49  +    PRAGMA mmap_size;
           50  +  }
           51  +} {250000 nums t1 ok 250000}
           52  +do_test mmap3-1.4 {
           53  +  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
           54  +    db eval {PRAGMA mmap_size=150000}
           55  +  }
           56  +  db eval {
           57  +    PRAGMA quick_check;
           58  +    PRAGMA mmap_size;
           59  +  }
           60  +} {ok 250000}
           61  +do_test mmap3-1.5 {
           62  +  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
           63  +    db eval {PRAGMA mmap_size=0}
           64  +  }
           65  +  db eval {
           66  +    PRAGMA quick_check;
           67  +    PRAGMA mmap_size;
           68  +  }
           69  +} {ok 250000}
           70  +do_test mmap3-1.6 {
           71  +  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
           72  +    set x [db one {PRAGMA mmap_size}]
           73  +  }
           74  +  set x [concat $x [db eval {
           75  +    PRAGMA quick_check;
           76  +    PRAGMA mmap_size;
           77  +  }]]
           78  +} {250000 ok 250000}
           79  +do_test mmap3-1.7 {
           80  +  db eval {
           81  +    PRAGMA mmap_size(0);
           82  +    CREATE TABLE t3(a,b,c);
           83  +    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;
           84  +    PRAGMA quick_check;
           85  +    PRAGMA mmap_size;
           86  +  }
           87  +} {0 nums t1 t3 ok 0}
           88  +do_test mmap3-1.8 {
           89  +  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {
           90  +    db eval {PRAGMA mmap_size=75000}
           91  +  }
           92  +  db eval {
           93  +    PRAGMA quick_check;
           94  +    PRAGMA mmap_size;
           95  +  }
           96  +} {ok 75000}
           97  +
           98  +finish_test