System.Data.SQLite
Check-in [9a64daea7c]
Not logged in

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

Overview
Comment:Update SQLite core library to the latest 3.7.16 pre-release code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9a64daea7c6502f80da1a97126fd37d9d68ada47
User & Date: mistachkin 2013-03-13 02:59:38
Context
2013-03-13
19:40
Add ARM to the processor-to-platform name map used by the native library pre-loading feature. check-in: b4709d3ca1 user: mistachkin tags: trunk
02:59
Update SQLite core library to the latest 3.7.16 pre-release code. check-in: 9a64daea7c user: mistachkin tags: trunk
2013-03-11
01:48
More precise handling of slashes in the file names constructed during the setup. check-in: ac94d2bde1 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to SQLite.Interop/src/core/sqlite3.c.

   302    302   #endif
   303    303   
   304    304   /* Needed for various definitions... */
   305    305   #ifndef _GNU_SOURCE
   306    306   # define _GNU_SOURCE
   307    307   #endif
   308    308   
          309  +#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
          310  +# define _BSD_SOURCE
          311  +#endif
          312  +
   309    313   /*
   310    314   ** Include standard header files as necessary
   311    315   */
   312    316   #ifdef HAVE_STDINT_H
   313    317   #include <stdint.h>
   314    318   #endif
   315    319   #ifdef HAVE_INTTYPES_H
................................................................................
   672    676   **
   673    677   ** See also: [sqlite3_libversion()],
   674    678   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   675    679   ** [sqlite_version()] and [sqlite_source_id()].
   676    680   */
   677    681   #define SQLITE_VERSION        "3.7.16"
   678    682   #define SQLITE_VERSION_NUMBER 3007016
   679         -#define SQLITE_SOURCE_ID      "2013-03-06 11:44:57 66576b450a0f0329571e344280994a964c967f8f"
          683  +#define SQLITE_SOURCE_ID      "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b"
   680    684   
   681    685   /*
   682    686   ** CAPI3REF: Run-Time Library Version Numbers
   683    687   ** KEYWORDS: sqlite3_version, sqlite3_sourceid
   684    688   **
   685    689   ** These interfaces provide the same information as the [SQLITE_VERSION],
   686    690   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
   851    855   ** host languages that are garbage collected, and where the order in which
   852    856   ** destructors are called is arbitrary.
   853    857   **
   854    858   ** Applications should [sqlite3_finalize | finalize] all [prepared statements],
   855    859   ** [sqlite3_blob_close | close] all [BLOB handles], and 
   856    860   ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
   857    861   ** with the [sqlite3] object prior to attempting to close the object.  ^If
   858         -** sqlite3_close() is called on a [database connection] that still has
          862  +** sqlite3_close_v2() is called on a [database connection] that still has
   859    863   ** outstanding [prepared statements], [BLOB handles], and/or
   860    864   ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation
   861    865   ** of resources is deferred until all [prepared statements], [BLOB handles],
   862    866   ** and [sqlite3_backup] objects are also destroyed.
   863    867   **
   864    868   ** ^If an [sqlite3] object is destroyed while a transaction is open,
   865    869   ** the transaction is automatically rolled back.
................................................................................
 12336  12340   #else
 12337  12341     #define sqlite3BeginBenignMalloc()
 12338  12342     #define sqlite3EndBenignMalloc()
 12339  12343   #endif
 12340  12344   
 12341  12345   #define IN_INDEX_ROWID           1
 12342  12346   #define IN_INDEX_EPH             2
 12343         -#define IN_INDEX_INDEX           3
        12347  +#define IN_INDEX_INDEX_ASC       3
        12348  +#define IN_INDEX_INDEX_DESC      4
 12344  12349   SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, int*);
 12345  12350   
 12346  12351   #ifdef SQLITE_ENABLE_ATOMIC_WRITE
 12347  12352   SQLITE_PRIVATE   int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
 12348  12353   SQLITE_PRIVATE   int sqlite3JournalSize(sqlite3_vfs *);
 12349  12354   SQLITE_PRIVATE   int sqlite3JournalCreate(sqlite3_file *);
 12350  12355   SQLITE_PRIVATE   int sqlite3JournalExists(sqlite3_file *p);
................................................................................
 48400  48405   ** This routine is used to extract the "offset to cell content area" value
 48401  48406   ** from the header of a btree page.  If the page size is 65536 and the page
 48402  48407   ** is empty, the offset should be 65536, but the 2-byte value stores zero.
 48403  48408   ** This routine makes the necessary adjustment to 65536.
 48404  48409   */
 48405  48410   #define get2byteNotZero(X)  (((((int)get2byte(X))-1)&0xffff)+1)
 48406  48411   
        48412  +/*
        48413  +** Values passed as the 5th argument to allocateBtreePage()
        48414  +*/
        48415  +#define BTALLOC_ANY   0           /* Allocate any page */
        48416  +#define BTALLOC_EXACT 1           /* Allocate exact page if possible */
        48417  +#define BTALLOC_LE    2           /* Allocate any page <= the parameter */
        48418  +
        48419  +/*
        48420  +** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not 
        48421  +** defined, or 0 if it is. For example:
        48422  +**
        48423  +**   bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum);
        48424  +*/
        48425  +#ifndef SQLITE_OMIT_AUTOVACUUM
        48426  +#define IfNotOmitAV(expr) (expr)
        48427  +#else
        48428  +#define IfNotOmitAV(expr) 0
        48429  +#endif
        48430  +
 48407  48431   #ifndef SQLITE_OMIT_SHARED_CACHE
 48408  48432   /*
 48409  48433   ** A list of BtShared objects that are eligible for participation
 48410  48434   ** in shared cache.  This variable has file scope during normal builds,
 48411  48435   ** but the test harness needs to access it so we make it global for 
 48412  48436   ** test builds.
 48413  48437   **
................................................................................
 50952  50976     /* If the btree is already in a write-transaction, or it
 50953  50977     ** is already in a read-transaction and a read-transaction
 50954  50978     ** is requested, this is a no-op.
 50955  50979     */
 50956  50980     if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){
 50957  50981       goto trans_begun;
 50958  50982     }
 50959         -  assert( pBt->bDoTruncate==0 );
        50983  +  assert( IfNotOmitAV(pBt->bDoTruncate)==0 );
 50960  50984   
 50961  50985     /* Write transactions are not possible on a read-only database */
 50962  50986     if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){
 50963  50987       rc = SQLITE_READONLY;
 50964  50988       goto trans_begun;
 50965  50989     }
 50966  50990   
................................................................................
 51267  51291       }
 51268  51292     }
 51269  51293     return rc;
 51270  51294   }
 51271  51295   
 51272  51296   /* Forward declaration required by incrVacuumStep(). */
 51273  51297   static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);
 51274         -#define BTALLOC_ANY   0           /* Allocate any page */
 51275         -#define BTALLOC_EXACT 1           /* Allocate exact page if possible */
 51276         -#define BTALLOC_LE    2           /* Allocate any page <= the parameter */
 51277  51298   
 51278  51299   /*
 51279  51300   ** Perform a single step of an incremental-vacuum. If successful, return
 51280  51301   ** SQLITE_OK. If there is no work to do (and therefore no point in 
 51281  51302   ** calling this function again), return SQLITE_DONE. Or, if an error 
 51282  51303   ** occurs, return some other error code.
 51283  51304   **
................................................................................
 53259  53280     u32 n;     /* Number of pages on the freelist */
 53260  53281     u32 k;     /* Number of leaves on the trunk of the freelist */
 53261  53282     MemPage *pTrunk = 0;
 53262  53283     MemPage *pPrevTrunk = 0;
 53263  53284     Pgno mxPage;     /* Total size of the database file */
 53264  53285   
 53265  53286     assert( sqlite3_mutex_held(pBt->mutex) );
 53266         -  assert( eMode==BTALLOC_ANY || (nearby>0 && pBt->autoVacuum) );
        53287  +  assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
 53267  53288     pPage1 = pBt->pPage1;
 53268  53289     mxPage = btreePagecount(pBt);
 53269  53290     n = get4byte(&pPage1->aData[36]);
 53270  53291     testcase( n==mxPage-1 );
 53271  53292     if( n>=mxPage ){
 53272  53293       return SQLITE_CORRUPT_BKPT;
 53273  53294     }
................................................................................
 53492  53513       **
 53493  53514       ** Note that the pager will not actually attempt to load or journal 
 53494  53515       ** content for any page that really does lie past the end of the database
 53495  53516       ** file on disk. So the effects of disabling the no-content optimization
 53496  53517       ** here are confined to those pages that lie between the end of the
 53497  53518       ** database image and the end of the database file.
 53498  53519       */
 53499         -    int bNoContent = (0==pBt->bDoTruncate);
        53520  +    int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate));
 53500  53521   
 53501  53522       rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
 53502  53523       if( rc ) return rc;
 53503  53524       pBt->nPage++;
 53504  53525       if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;
 53505  53526   
 53506  53527   #ifndef SQLITE_OMIT_AUTOVACUUM
................................................................................
 57552  57573   ** routine is a no-op.
 57553  57574   **
 57554  57575   ** SQLITE_OK is returned if the conversion is successful (or not required).
 57555  57576   ** SQLITE_NOMEM may be returned if a malloc() fails during conversion
 57556  57577   ** between formats.
 57557  57578   */
 57558  57579   SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
        57580  +#ifndef SQLITE_OMIT_UTF16
 57559  57581     int rc;
        57582  +#endif
 57560  57583     assert( (pMem->flags&MEM_RowSet)==0 );
 57561  57584     assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE
 57562  57585              || desiredEnc==SQLITE_UTF16BE );
 57563  57586     if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){
 57564  57587       return SQLITE_OK;
 57565  57588     }
 57566  57589     assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
................................................................................
 75402  75425   ** all members of the RHS set, skipping duplicates.
 75403  75426   **
 75404  75427   ** A cursor is opened on the b-tree object that the RHS of the IN operator
 75405  75428   ** and pX->iTable is set to the index of that cursor.
 75406  75429   **
 75407  75430   ** The returned value of this function indicates the b-tree type, as follows:
 75408  75431   **
 75409         -**   IN_INDEX_ROWID - The cursor was opened on a database table.
 75410         -**   IN_INDEX_INDEX - The cursor was opened on a database index.
 75411         -**   IN_INDEX_EPH -   The cursor was opened on a specially created and
 75412         -**                    populated epheremal table.
        75432  +**   IN_INDEX_ROWID      - The cursor was opened on a database table.
        75433  +**   IN_INDEX_INDEX_ASC  - The cursor was opened on an ascending index.
        75434  +**   IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.
        75435  +**   IN_INDEX_EPH        - The cursor was opened on a specially created and
        75436  +**                         populated epheremal table.
 75413  75437   **
 75414  75438   ** An existing b-tree might be used if the RHS expression pX is a simple
 75415  75439   ** subquery such as:
 75416  75440   **
 75417  75441   **     SELECT <column> FROM <table>
 75418  75442   **
 75419  75443   ** If the RHS of the IN operator is a list or a more complex subquery, then
................................................................................
 75528  75552     
 75529  75553             pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx);
 75530  75554             iAddr = sqlite3CodeOnce(pParse);
 75531  75555     
 75532  75556             sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb,
 75533  75557                                  pKey,P4_KEYINFO_HANDOFF);
 75534  75558             VdbeComment((v, "%s", pIdx->zName));
 75535         -          eType = IN_INDEX_INDEX;
        75559  +          assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
        75560  +          eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
 75536  75561   
 75537  75562             sqlite3VdbeJumpHere(v, iAddr);
 75538  75563             if( prNotFound && !pTab->aCol[iCol].notNull ){
 75539  75564               *prNotFound = ++pParse->nMem;
 75540  75565               sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound);
 75541  75566             }
 75542  75567           }
................................................................................
 85355  85380   SQLITE_PRIVATE void sqlite3MaterializeView(
 85356  85381     Parse *pParse,       /* Parsing context */
 85357  85382     Table *pView,        /* View definition */
 85358  85383     Expr *pWhere,        /* Optional WHERE clause to be added */
 85359  85384     int iCur             /* Cursor number for ephemerial table */
 85360  85385   ){
 85361  85386     SelectDest dest;
 85362         -  Select *pDup;
        85387  +  Select *pSel;
        85388  +  SrcList *pFrom;
 85363  85389     sqlite3 *db = pParse->db;
        85390  +  int iDb = sqlite3SchemaToIndex(db, pView->pSchema);
 85364  85391   
 85365         -  pDup = sqlite3SelectDup(db, pView->pSelect, 0);
 85366         -  if( pWhere ){
 85367         -    SrcList *pFrom;
 85368         -    
 85369         -    pWhere = sqlite3ExprDup(db, pWhere, 0);
 85370         -    pFrom = sqlite3SrcListAppend(db, 0, 0, 0);
 85371         -    if( pFrom ){
 85372         -      assert( pFrom->nSrc==1 );
 85373         -      pFrom->a[0].zAlias = sqlite3DbStrDup(db, pView->zName);
 85374         -      pFrom->a[0].pSelect = pDup;
 85375         -      assert( pFrom->a[0].pOn==0 );
 85376         -      assert( pFrom->a[0].pUsing==0 );
 85377         -    }else{
 85378         -      sqlite3SelectDelete(db, pDup);
 85379         -    }
 85380         -    pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
 85381         -    if( pDup ) pDup->selFlags |= SF_Materialize;
        85392  +  pWhere = sqlite3ExprDup(db, pWhere, 0);
        85393  +  pFrom = sqlite3SrcListAppend(db, 0, 0, 0);
        85394  +
        85395  +  if( pFrom ){
        85396  +    assert( pFrom->nSrc==1 );
        85397  +    pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);
        85398  +    pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);
        85399  +    assert( pFrom->a[0].pOn==0 );
        85400  +    assert( pFrom->a[0].pUsing==0 );
 85382  85401     }
        85402  +
        85403  +  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
        85404  +  if( pSel ) pSel->selFlags |= SF_Materialize;
        85405  +
 85383  85406     sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);
 85384         -  sqlite3Select(pParse, pDup, &dest);
 85385         -  sqlite3SelectDelete(db, pDup);
        85407  +  sqlite3Select(pParse, pSel, &dest);
        85408  +  sqlite3SelectDelete(db, pSel);
 85386  85409   }
 85387  85410   #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */
 85388  85411   
 85389  85412   #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
 85390  85413   /*
 85391  85414   ** Generate an expression tree to implement the WHERE, ORDER BY,
 85392  85415   ** and LIMIT/OFFSET portion of DELETE and UPDATE statements.
................................................................................
 86916  86939     }
 86917  86940     for(i=0; i<argc; i++){
 86918  86941       sqlite3_int64 x;
 86919  86942       unsigned c;
 86920  86943       x = sqlite3_value_int64(argv[i]);
 86921  86944       if( x<0 || x>0x10ffff ) x = 0xfffd;
 86922  86945       c = (unsigned)(x & 0x1fffff);
 86923         -    if( c<=0xFFFF ){
 86924         -      if( c>=0xd800 && c<=0xdfff ) c = 0xfffd;
 86925         -      *zOut++ = (u8)(c&0x00FF);
 86926         -      *zOut++ = (u8)((c>>8)&0x00FF);
        86946  +    if( c<0x00080 ){
        86947  +      *zOut++ = (u8)(c&0xFF);
        86948  +    }else if( c<0x00800 ){
        86949  +      *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);
        86950  +      *zOut++ = 0x80 + (u8)(c & 0x3F);
        86951  +    }else if( c<0x10000 ){
        86952  +      *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);
        86953  +      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);
        86954  +      *zOut++ = 0x80 + (u8)(c & 0x3F);
 86927  86955       }else{
 86928         -      *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));
 86929         -      *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));
 86930         -      *zOut++ = (u8)(c&0x00FF);
 86931         -      *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));
 86932         -    }
        86956  +      *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);
        86957  +      *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);
        86958  +      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);
        86959  +      *zOut++ = 0x80 + (u8)(c & 0x3F);
        86960  +    }                                                    \
 86933  86961     }
 86934         -  sqlite3_result_text16le(context, (char*)z, (int)(zOut-z), sqlite3_free);
        86962  +  sqlite3_result_text(context, (char*)z, (int)(zOut-z), sqlite3_free);
 86935  86963   }
 86936  86964   
 86937  86965   /*
 86938  86966   ** The hex() function.  Interpret the argument as a blob.  Return
 86939  86967   ** a hexadecimal rendering as text.
 86940  86968   */
 86941  86969   static void hexFunc(
................................................................................
 93195  93223           }
 93196  93224         }
 93197  93225       }
 93198  93226     }else
 93199  93227   #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
 93200  93228   
 93201  93229   #ifndef SQLITE_OMIT_FOREIGN_KEY
        93230  +#ifndef SQLITE_OMIT_TRIGGER
 93202  93231     if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){
 93203  93232       FKey *pFK;             /* A foreign key constraint */
 93204  93233       Table *pTab;           /* Child table contain "REFERENCES" keyword */
 93205  93234       Table *pParent;        /* Parent table that child points to */
 93206  93235       Index *pIdx;           /* Index in the parent table */
 93207  93236       int i;                 /* Loop counter:  Foreign key number for pTab */
 93208  93237       int j;                 /* Loop counter:  Field of the foreign key */
................................................................................
 93306  93335           sqlite3VdbeResolveLabel(v, addrOk);
 93307  93336           sqlite3DbFree(db, aiCols);
 93308  93337         }
 93309  93338         sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1);
 93310  93339         sqlite3VdbeJumpHere(v, addrTop);
 93311  93340       }
 93312  93341     }else
        93342  +#endif /* !defined(SQLITE_OMIT_TRIGGER) */
 93313  93343   #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
 93314  93344   
 93315  93345   #ifndef NDEBUG
 93316  93346     if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){
 93317  93347       if( zRight ){
 93318  93348         if( sqlite3GetBoolean(zRight, 0) ){
 93319  93349           sqlite3ParserTrace(stderr, "parser: ");
................................................................................
 94102  94132     /* If opening a non-empty database, check the text encoding. For the
 94103  94133     ** main database, set sqlite3.enc to the encoding of the main database.
 94104  94134     ** For an attached db, it is an error if the encoding is not the same
 94105  94135     ** as sqlite3.enc.
 94106  94136     */
 94107  94137     if( meta[BTREE_TEXT_ENCODING-1] ){  /* text encoding */
 94108  94138       if( iDb==0 ){
        94139  +#ifndef SQLITE_OMIT_UTF16
 94109  94140         u8 encoding;
 94110  94141         /* If opening the main database, set ENC(db). */
 94111  94142         encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;
 94112  94143         if( encoding==0 ) encoding = SQLITE_UTF8;
 94113  94144         ENC(db) = encoding;
        94145  +#else
        94146  +      ENC(db) = SQLITE_UTF8;
        94147  +#endif
 94114  94148       }else{
 94115  94149         /* If opening an attached database, the encoding much match ENC(db) */
 94116  94150         if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){
 94117  94151           sqlite3SetString(pzErrMsg, db, "attached databases must use the same"
 94118  94152               " text encoding as main database");
 94119  94153           rc = SQLITE_ERROR;
 94120  94154           goto initone_error_out;
................................................................................
106714 106748   ** For a constraint of the form X=expr, the expression is evaluated and its
106715 106749   ** result is left on the stack.  For constraints of the form X IN (...)
106716 106750   ** this routine sets up a loop that will iterate over all values of X.
106717 106751   */
106718 106752   static int codeEqualityTerm(
106719 106753     Parse *pParse,      /* The parsing context */
106720 106754     WhereTerm *pTerm,   /* The term of the WHERE clause to be coded */
106721         -  WhereLevel *pLevel, /* When level of the FROM clause we are working on */
       106755  +  WhereLevel *pLevel, /* The level of the FROM clause we are working on */
       106756  +  int iEq,            /* Index of the equality term within this level */
106722 106757     int iTarget         /* Attempt to leave results in this register */
106723 106758   ){
106724 106759     Expr *pX = pTerm->pExpr;
106725 106760     Vdbe *v = pParse->pVdbe;
106726 106761     int iReg;                  /* Register holding results */
106727 106762   
106728 106763     assert( iTarget>0 );
................................................................................
106734 106769   #ifndef SQLITE_OMIT_SUBQUERY
106735 106770     }else{
106736 106771       int eType;
106737 106772       int iTab;
106738 106773       struct InLoop *pIn;
106739 106774       u8 bRev = (pLevel->plan.wsFlags & WHERE_REVERSE)!=0;
106740 106775   
       106776  +    if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 
       106777  +      && pLevel->plan.u.pIdx->aSortOrder[iEq]
       106778  +    ){
       106779  +      testcase( iEq==0 );
       106780  +      testcase( iEq==pLevel->plan.u.pIdx->nColumn-1 );
       106781  +      testcase( iEq>0 && iEq+1<pLevel->plan.u.pIdx->nColumn );
       106782  +      testcase( bRev );
       106783  +      bRev = !bRev;
       106784  +    }
106741 106785       assert( pX->op==TK_IN );
106742 106786       iReg = iTarget;
106743 106787       eType = sqlite3FindInIndex(pParse, pX, 0);
       106788  +    if( eType==IN_INDEX_INDEX_DESC ){
       106789  +      testcase( bRev );
       106790  +      bRev = !bRev;
       106791  +    }
106744 106792       iTab = pX->iTable;
106745 106793       sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
106746 106794       assert( pLevel->plan.wsFlags & WHERE_IN_ABLE );
106747 106795       if( pLevel->u.in.nIn==0 ){
106748 106796         pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
106749 106797       }
106750 106798       pLevel->u.in.nIn++;
................................................................................
106851 106899       int k = pIdx->aiColumn[j];
106852 106900       pTerm = findTerm(pWC, iCur, k, notReady, pLevel->plan.wsFlags, pIdx);
106853 106901       if( pTerm==0 ) break;
106854 106902       /* The following true for indices with redundant columns. 
106855 106903       ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
106856 106904       testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
106857 106905       testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
106858         -    r1 = codeEqualityTerm(pParse, pTerm, pLevel, regBase+j);
       106906  +    r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, regBase+j);
106859 106907       if( r1!=regBase+j ){
106860 106908         if( nReg==1 ){
106861 106909           sqlite3ReleaseTempReg(pParse, regBase);
106862 106910           regBase = r1;
106863 106911         }else{
106864 106912           sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
106865 106913         }
................................................................................
107128 107176       addrNotFound = pLevel->addrBrk;
107129 107177       for(j=1; j<=nConstraint; j++){
107130 107178         for(k=0; k<nConstraint; k++){
107131 107179           if( aUsage[k].argvIndex==j ){
107132 107180             int iTarget = iReg+j+1;
107133 107181             pTerm = &pWC->a[aConstraint[k].iTermOffset];
107134 107182             if( pTerm->eOperator & WO_IN ){
107135         -            codeEqualityTerm(pParse, pTerm, pLevel, iTarget);
       107183  +            codeEqualityTerm(pParse, pTerm, pLevel, k, iTarget);
107136 107184               addrNotFound = pLevel->addrNxt;
107137 107185             }else{
107138 107186               sqlite3ExprCode(pParse, pTerm->pExpr->pRight, iTarget);
107139 107187             }
107140 107188             break;
107141 107189           }
107142 107190         }
................................................................................
107169 107217       */
107170 107218       iReleaseReg = sqlite3GetTempReg(pParse);
107171 107219       pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0);
107172 107220       assert( pTerm!=0 );
107173 107221       assert( pTerm->pExpr!=0 );
107174 107222       assert( omitTable==0 );
107175 107223       testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
107176         -    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, iReleaseReg);
       107224  +    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, iReleaseReg);
107177 107225       addrNxt = pLevel->addrNxt;
107178 107226       sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
107179 107227       sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);
107180 107228       sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);
107181 107229       sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);
107182 107230       VdbeComment((v, "pk"));
107183 107231       pLevel->op = OP_Noop;

Changes to SQLite.Interop/src/core/sqlite3.h.

   105    105   **
   106    106   ** See also: [sqlite3_libversion()],
   107    107   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   108    108   ** [sqlite_version()] and [sqlite_source_id()].
   109    109   */
   110    110   #define SQLITE_VERSION        "3.7.16"
   111    111   #define SQLITE_VERSION_NUMBER 3007016
   112         -#define SQLITE_SOURCE_ID      "2013-03-06 11:44:57 66576b450a0f0329571e344280994a964c967f8f"
          112  +#define SQLITE_SOURCE_ID      "2013-03-13 00:13:25 839aa91faf1db7025d90fa3c65e50efb829b053b"
   113    113   
   114    114   /*
   115    115   ** CAPI3REF: Run-Time Library Version Numbers
   116    116   ** KEYWORDS: sqlite3_version, sqlite3_sourceid
   117    117   **
   118    118   ** These interfaces provide the same information as the [SQLITE_VERSION],
   119    119   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
   284    284   ** host languages that are garbage collected, and where the order in which
   285    285   ** destructors are called is arbitrary.
   286    286   **
   287    287   ** Applications should [sqlite3_finalize | finalize] all [prepared statements],
   288    288   ** [sqlite3_blob_close | close] all [BLOB handles], and 
   289    289   ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
   290    290   ** with the [sqlite3] object prior to attempting to close the object.  ^If
   291         -** sqlite3_close() is called on a [database connection] that still has
          291  +** sqlite3_close_v2() is called on a [database connection] that still has
   292    292   ** outstanding [prepared statements], [BLOB handles], and/or
   293    293   ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation
   294    294   ** of resources is deferred until all [prepared statements], [BLOB handles],
   295    295   ** and [sqlite3_backup] objects are also destroyed.
   296    296   **
   297    297   ** ^If an [sqlite3] object is destroyed while a transaction is open,
   298    298   ** the transaction is automatically rolled back.