System.Data.SQLite
Check-in [d832fb7645]
Not logged in

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

Overview
Comment:Update SQLite to the latest trunk code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d832fb7645f37edd312aea5a1eeb1d254f687c4e
User & Date: mistachkin 2013-01-04 20:47:20
Context
2013-01-05
20:40
Enable easier use of Managed Debugging Assistants during the test suite. check-in: 3d3dcd4a76 user: mistachkin tags: trunk
2013-01-04
20:48
Add Visual Studio 2012 / .NET Framework 4.5 specific binaries to the NuGet packages. check-in: d7ffaa634b user: mistachkin tags: nuget2012
20:47
Update SQLite to the latest trunk code. check-in: d832fb7645 user: mistachkin tags: trunk
15:46
Fix index page link to the CHM file. check-in: 217f1b5a6b user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

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

   671    671   **
   672    672   ** See also: [sqlite3_libversion()],
   673    673   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   674    674   ** [sqlite_version()] and [sqlite_source_id()].
   675    675   */
   676    676   #define SQLITE_VERSION        "3.7.16"
   677    677   #define SQLITE_VERSION_NUMBER 3007016
   678         -#define SQLITE_SOURCE_ID      "2012-12-21 16:15:35 ff6857b6ed6a46671006b75157d8cf853a816ef9"
          678  +#define SQLITE_SOURCE_ID      "2013-01-04 19:22:33 8285b15a058811a9a8b452837f52e6a065868115"
   679    679   
   680    680   /*
   681    681   ** CAPI3REF: Run-Time Library Version Numbers
   682    682   ** KEYWORDS: sqlite3_version, sqlite3_sourceid
   683    683   **
   684    684   ** These interfaces provide the same information as the [SQLITE_VERSION],
   685    685   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
 10553  10553   ** and the value of Index.onError indicate the which conflict resolution 
 10554  10554   ** algorithm to employ whenever an attempt is made to insert a non-unique
 10555  10555   ** element.
 10556  10556   */
 10557  10557   struct Index {
 10558  10558     char *zName;     /* Name of this index */
 10559  10559     int *aiColumn;   /* Which columns are used by this index.  1st is 0 */
 10560         -  tRowcnt *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */
        10560  +  tRowcnt *aiRowEst;       /* From ANALYZE: Est. rows selected by each column */
 10561  10561     Table *pTable;   /* The SQL table being indexed */
 10562  10562     char *zColAff;   /* String defining the affinity of each column */
 10563  10563     Index *pNext;    /* The next index associated with the same table */
 10564  10564     Schema *pSchema; /* Schema containing this index */
 10565         -  u8 *aSortOrder;  /* Array of size Index.nColumn. True==DESC, False==ASC */
        10565  +  u8 *aSortOrder;          /* for each column: True==DESC, False==ASC */
 10566  10566     char **azColl;   /* Array of collation sequence names for index */
 10567         -  int nColumn;     /* Number of columns in the table used by this index */
 10568         -  int tnum;        /* Page containing root of this index in database file */
        10567  +  int tnum;                /* DB Page containing root of this index */
        10568  +  u16 nColumn;             /* Number of columns in table used by this index */
 10569  10569     u8 onError;      /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
 10570         -  u8 autoIndex;    /* True if is automatically created (ex: by UNIQUE) */
 10571         -  u8 bUnordered;   /* Use this index for == or IN queries only */
        10570  +  unsigned autoIndex:2;    /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
        10571  +  unsigned bUnordered:1;   /* Use this index for == or IN queries only */
 10572  10572   #ifdef SQLITE_ENABLE_STAT3
 10573  10573     int nSample;             /* Number of elements in aSample[] */
 10574  10574     tRowcnt avgEq;           /* Average nEq value for key values not in aSample */
 10575  10575     IndexSample *aSample;    /* Samples of the left-most key */
 10576  10576   #endif
 10577  10577   };
 10578  10578   
................................................................................
 10838  10838   /*
 10839  10839   ** A list of expressions.  Each expression may optionally have a
 10840  10840   ** name.  An expr/name combination can be used in several ways, such
 10841  10841   ** as the list of "expr AS ID" fields following a "SELECT" or in the
 10842  10842   ** list of "ID = expr" items in an UPDATE.  A list of expressions can
 10843  10843   ** also be used as the argument to a function, in which case the a.zName
 10844  10844   ** field is not used.
        10845  +**
        10846  +** By default the Expr.zSpan field holds a human-readable description of
        10847  +** the expression that is used in the generation of error messages and
        10848  +** column labels.  In this case, Expr.zSpan is typically the text of a
        10849  +** column expression as it exists in a SELECT statement.  However, if
        10850  +** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name
        10851  +** of the result column in the form: DATABASE.TABLE.COLUMN.  This later
        10852  +** form is used for name resolution with nested FROM clauses.
 10845  10853   */
 10846  10854   struct ExprList {
 10847  10855     int nExpr;             /* Number of expressions on the list */
 10848  10856     int iECursor;          /* VDBE Cursor associated with this ExprList */
 10849  10857     struct ExprList_item { /* For each expression in the list */
 10850  10858       Expr *pExpr;           /* The list of expressions */
 10851  10859       char *zName;           /* Token associated with this expression */
 10852  10860       char *zSpan;           /* Original text of the expression */
 10853  10861       u8 sortOrder;          /* 1 for DESC or 0 for ASC */
 10854         -    u8 done;               /* A flag to indicate when processing is finished */
        10862  +    unsigned done :1;       /* A flag to indicate when processing is finished */
        10863  +    unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
 10855  10864       u16 iOrderByCol;       /* For ORDER BY, column number in result set */
 10856  10865       u16 iAlias;            /* Index into Parse.aAlias[] for zName */
 10857  10866     } *a;                  /* Alloc a power of two greater or equal to nExpr */
 10858  10867   };
 10859  10868   
 10860  10869   /*
 10861  10870   ** An instance of this structure is used by the parser to record both
................................................................................
 12139  12148   SQLITE_PRIVATE void sqlite3AlterFunctions(void);
 12140  12149   SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
 12141  12150   SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
 12142  12151   SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
 12143  12152   SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);
 12144  12153   SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);
 12145  12154   SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
        12155  +SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
 12146  12156   SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
 12147  12157   SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
 12148  12158   SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
 12149  12159   SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
 12150  12160   SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
 12151  12161   SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
 12152  12162   SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
................................................................................
 72653  72663       for(k=0; k<pUsing->nId; k++){
 72654  72664         if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1;
 72655  72665       }
 72656  72666     }
 72657  72667     return 0;
 72658  72668   }
 72659  72669   
        72670  +/*
        72671  +** Subqueries stores the original database, table and column names for their
        72672  +** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN".
        72673  +** Check to see if the zSpan given to this routine matches the zDb, zTab,
        72674  +** and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will
        72675  +** match anything.
        72676  +*/
        72677  +SQLITE_PRIVATE int sqlite3MatchSpanName(
        72678  +  const char *zSpan,
        72679  +  const char *zCol,
        72680  +  const char *zTab,
        72681  +  const char *zDb
        72682  +){
        72683  +  int n;
        72684  +  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}
        72685  +  if( zDb && sqlite3StrNICmp(zSpan, zDb, n)!=0 ){
        72686  +    return 0;
        72687  +  }
        72688  +  zSpan += n+1;
        72689  +  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}
        72690  +  if( zTab && sqlite3StrNICmp(zSpan, zTab, n)!=0 ){
        72691  +    return 0;
        72692  +  }
        72693  +  zSpan += n+1;
        72694  +  if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){
        72695  +    return 0;
        72696  +  }
        72697  +  return 1;
        72698  +}
 72660  72699   
 72661  72700   /*
 72662  72701   ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
 72663  72702   ** that name in the set of source tables in pSrcList and make the pExpr 
 72664  72703   ** expression node refer back to that source column.  The following changes
 72665  72704   ** are made to pExpr:
 72666  72705   **
................................................................................
 72708  72747     assert( zCol );    /* The Z in X.Y.Z cannot be NULL */
 72709  72748     assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
 72710  72749   
 72711  72750     /* Initialize the node to no-match */
 72712  72751     pExpr->iTable = -1;
 72713  72752     pExpr->pTab = 0;
 72714  72753     ExprSetIrreducible(pExpr);
        72754  +
        72755  +  /* Translate the schema name in zDb into a pointer to the corresponding
        72756  +  ** schema.  If not found, pSchema will remain NULL and nothing will match
        72757  +  ** resulting in an appropriate error message toward the end of this routine
        72758  +  */
        72759  +  if( zDb ){
        72760  +    for(i=0; i<db->nDb; i++){
        72761  +      assert( db->aDb[i].zName );
        72762  +      if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
        72763  +        pSchema = db->aDb[i].pSchema;
        72764  +        break;
        72765  +      }
        72766  +    }
        72767  +  }
 72715  72768   
 72716  72769     /* Start at the inner-most context and move outward until a match is found */
 72717  72770     while( pNC && cnt==0 ){
 72718  72771       ExprList *pEList;
 72719  72772       SrcList *pSrcList = pNC->pSrcList;
 72720  72773   
 72721  72774       if( pSrcList ){
 72722  72775         for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
 72723  72776           Table *pTab;
 72724         -        int iDb;
 72725  72777           Column *pCol;
 72726  72778     
 72727  72779           pTab = pItem->pTab;
 72728  72780           assert( pTab!=0 && pTab->zName!=0 );
 72729         -        iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
 72730  72781           assert( pTab->nCol>0 );
        72782  +        if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){
        72783  +          ExprList *pEList = pItem->pSelect->pEList;
        72784  +          int hit = 0;
        72785  +          for(j=0; j<pEList->nExpr; j++){
        72786  +            if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){
        72787  +              cnt++;
        72788  +              cntTab = 2;
        72789  +              pMatch = pItem;
        72790  +              pExpr->iColumn = j;
        72791  +              hit = 1;
        72792  +            }
        72793  +          }
        72794  +          if( hit || zTab==0 ) continue;
        72795  +        }
        72796  +        if( zDb && pTab->pSchema!=pSchema ){
        72797  +          continue;
        72798  +        }
 72731  72799           if( zTab ){
 72732         -          if( pItem->zAlias ){
 72733         -            char *zTabName = pItem->zAlias;
 72734         -            if( sqlite3StrICmp(zTabName, zTab)!=0 ) continue;
 72735         -          }else{
 72736         -            char *zTabName = pTab->zName;
 72737         -            if( NEVER(zTabName==0) || sqlite3StrICmp(zTabName, zTab)!=0 ){
 72738         -              continue;
 72739         -            }
 72740         -            if( zDb!=0 && sqlite3StrICmp(db->aDb[iDb].zName, zDb)!=0 ){
        72800  +          const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
        72801  +          assert( zTabName!=0 );
        72802  +          if( sqlite3StrICmp(zTabName, zTab)!=0 ){
 72741  72803                 continue;
 72742  72804               }
 72743  72805             }
 72744         -        }
 72745  72806           if( 0==(cntTab++) ){
 72746         -          pExpr->iTable = pItem->iCursor;
 72747         -          pExpr->pTab = pTab;
 72748         -          pSchema = pTab->pSchema;
 72749  72807             pMatch = pItem;
 72750  72808           }
 72751  72809           for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
 72752  72810             if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
 72753  72811               /* If there has been exactly one prior match and this match
 72754  72812               ** is for the right-hand table of a NATURAL JOIN or is in a 
 72755  72813               ** USING clause, then skip this match.
 72756  72814               */
 72757  72815               if( cnt==1 ){
 72758  72816                 if( pItem->jointype & JT_NATURAL ) continue;
 72759  72817                 if( nameInUsingClause(pItem->pUsing, zCol) ) continue;
 72760  72818               }
 72761  72819               cnt++;
 72762         -            pExpr->iTable = pItem->iCursor;
 72763         -            pExpr->pTab = pTab;
 72764  72820               pMatch = pItem;
 72765         -            pSchema = pTab->pSchema;
 72766  72821               /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
 72767  72822               pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
 72768  72823               break;
 72769  72824             }
 72770  72825           }
 72771  72826         }
        72827  +      if( pMatch ){
        72828  +        pExpr->iTable = pMatch->iCursor;
        72829  +        pExpr->pTab = pMatch->pTab;
        72830  +        pSchema = pExpr->pTab->pSchema;
 72772  72831       }
        72832  +    } /* if( pSrcList ) */
 72773  72833   
 72774  72834   #ifndef SQLITE_OMIT_TRIGGER
 72775  72835       /* If we have not already resolved the name, then maybe 
 72776  72836       ** it is a new.* or old.* trigger argument reference
 72777  72837       */
 72778  72838       if( zDb==0 && zTab!=0 && cnt==0 && pParse->pTriggerTab!=0 ){
 72779  72839         int op = pParse->eTriggerOp;
................................................................................
 77063  77123     }else{
 77064  77124       sqlite3ExplainPush(pOut);
 77065  77125       for(i=0; i<pList->nExpr; i++){
 77066  77126         sqlite3ExplainPrintf(pOut, "item[%d] = ", i);
 77067  77127         sqlite3ExplainPush(pOut);
 77068  77128         sqlite3ExplainExpr(pOut, pList->a[i].pExpr);
 77069  77129         sqlite3ExplainPop(pOut);
        77130  +      if( pList->a[i].zName ){
        77131  +        sqlite3ExplainPrintf(pOut, " AS %s", pList->a[i].zName);
        77132  +      }
        77133  +      if( pList->a[i].bSpanIsTab ){
        77134  +        sqlite3ExplainPrintf(pOut, " (%s)", pList->a[i].zSpan);
        77135  +      }
 77070  77136         if( i<pList->nExpr-1 ){
 77071  77137           sqlite3ExplainNL(pOut);
 77072  77138         }
 77073  77139       }
 77074  77140       sqlite3ExplainPop(pOut);
 77075  77141     }
 77076  77142   }
................................................................................
 92737  92803     ** dflt_value: The default value for the column, if any.
 92738  92804     */
 92739  92805     if( sqlite3StrICmp(zLeft, "table_info")==0 && zRight ){
 92740  92806       Table *pTab;
 92741  92807       if( sqlite3ReadSchema(pParse) ) goto pragma_out;
 92742  92808       pTab = sqlite3FindTable(db, zRight, zDb);
 92743  92809       if( pTab ){
 92744         -      int i;
        92810  +      int i, k;
 92745  92811         int nHidden = 0;
 92746  92812         Column *pCol;
        92813  +      Index *pPk;
        92814  +      for(pPk=pTab->pIndex; pPk && pPk->autoIndex!=2; pPk=pPk->pNext){}
 92747  92815         sqlite3VdbeSetNumCols(v, 6);
 92748  92816         pParse->nMem = 6;
 92749  92817         sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", SQLITE_STATIC);
 92750  92818         sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
 92751  92819         sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", SQLITE_STATIC);
 92752  92820         sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC);
 92753  92821         sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC);
................................................................................
 92764  92832              pCol->zType ? pCol->zType : "", 0);
 92765  92833           sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4);
 92766  92834           if( pCol->zDflt ){
 92767  92835             sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pCol->zDflt, 0);
 92768  92836           }else{
 92769  92837             sqlite3VdbeAddOp2(v, OP_Null, 0, 5);
 92770  92838           }
 92771         -        sqlite3VdbeAddOp2(v, OP_Integer,
 92772         -                            (pCol->colFlags&COLFLAG_PRIMKEY)!=0, 6);
        92839  +        if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
        92840  +          k = 0;
        92841  +        }else if( pPk==0 ){
        92842  +          k = 1;
        92843  +        }else{
        92844  +          for(k=1; ALWAYS(k<=pTab->nCol) && pPk->aiColumn[k-1]!=i; k++){}
        92845  +        }
        92846  +        sqlite3VdbeAddOp2(v, OP_Integer, k, 6);
 92773  92847           sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
 92774  92848         }
 92775  92849       }
 92776  92850     }else
 92777  92851   
 92778  92852     if( sqlite3StrICmp(zLeft, "index_info")==0 && zRight ){
 92779  92853       Index *pIdx;
................................................................................
 95754  95828     *pnCol = nCol;
 95755  95829     *paCol = aCol;
 95756  95830   
 95757  95831     for(i=0, pCol=aCol; i<nCol; i++, pCol++){
 95758  95832       /* Get an appropriate name for the column
 95759  95833       */
 95760  95834       p = sqlite3ExprSkipCollate(pEList->a[i].pExpr);
 95761         -    assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
 95762         -               || p->pRight->u.zToken==0 || p->pRight->u.zToken[0]!=0 );
 95763  95835       if( (zName = pEList->a[i].zName)!=0 ){
 95764  95836         /* If the column contains an "AS <name>" phrase, use <name> as the name */
 95765  95837         zName = sqlite3DbStrDup(db, zName);
 95766  95838       }else{
 95767  95839         Expr *pColExpr = p;  /* The expression that is the result column name */
 95768  95840         Table *pTab;         /* Table associated with this expression */
 95769  95841         while( pColExpr->op==TK_DOT ){
................................................................................
 95793  95865       /* Make sure the column name is unique.  If the name is not unique,
 95794  95866       ** append a integer to the name so that it becomes unique.
 95795  95867       */
 95796  95868       nName = sqlite3Strlen30(zName);
 95797  95869       for(j=cnt=0; j<i; j++){
 95798  95870         if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
 95799  95871           char *zNewName;
        95872  +        int k;
        95873  +        for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
        95874  +        if( zName[k]==':' ) nName = k;
 95800  95875           zName[nName] = 0;
 95801  95876           zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt);
 95802  95877           sqlite3DbFree(db, zName);
 95803  95878           zName = zNewName;
 95804  95879           j = -1;
 95805  95880           if( zName==0 ) break;
 95806  95881         }
................................................................................
 97709  97784   static int selectExpander(Walker *pWalker, Select *p){
 97710  97785     Parse *pParse = pWalker->pParse;
 97711  97786     int i, j, k;
 97712  97787     SrcList *pTabList;
 97713  97788     ExprList *pEList;
 97714  97789     struct SrcList_item *pFrom;
 97715  97790     sqlite3 *db = pParse->db;
        97791  +  Expr *pE, *pRight, *pExpr;
 97716  97792   
 97717  97793     if( db->mallocFailed  ){
 97718  97794       return WRC_Abort;
 97719  97795     }
 97720  97796     if( NEVER(p->pSrc==0) || (p->selFlags & SF_Expanded)!=0 ){
 97721  97797       return WRC_Prune;
 97722  97798     }
................................................................................
 97794  97870     ** The following code just has to locate the TK_ALL expressions and expand
 97795  97871     ** each one to the list of all columns in all tables.
 97796  97872     **
 97797  97873     ** The first loop just checks to see if there are any "*" operators
 97798  97874     ** that need expanding.
 97799  97875     */
 97800  97876     for(k=0; k<pEList->nExpr; k++){
 97801         -    Expr *pE = pEList->a[k].pExpr;
        97877  +    pE = pEList->a[k].pExpr;
 97802  97878       if( pE->op==TK_ALL ) break;
 97803  97879       assert( pE->op!=TK_DOT || pE->pRight!=0 );
 97804  97880       assert( pE->op!=TK_DOT || (pE->pLeft!=0 && pE->pLeft->op==TK_ID) );
 97805  97881       if( pE->op==TK_DOT && pE->pRight->op==TK_ALL ) break;
 97806  97882     }
 97807  97883     if( k<pEList->nExpr ){
 97808  97884       /*
................................................................................
 97812  97888       */
 97813  97889       struct ExprList_item *a = pEList->a;
 97814  97890       ExprList *pNew = 0;
 97815  97891       int flags = pParse->db->flags;
 97816  97892       int longNames = (flags & SQLITE_FullColNames)!=0
 97817  97893                         && (flags & SQLITE_ShortColNames)==0;
 97818  97894   
        97895  +    /* When processing FROM-clause subqueries, it is always the case
        97896  +    ** that full_column_names=OFF and short_column_names=ON.  The
        97897  +    ** sqlite3ResultSetOfSelect() routine makes it so. */
        97898  +    assert( (p->selFlags & SF_NestedFrom)==0
        97899  +          || ((flags & SQLITE_FullColNames)==0 &&
        97900  +              (flags & SQLITE_ShortColNames)!=0) );
        97901  +
 97819  97902       for(k=0; k<pEList->nExpr; k++){
 97820         -      Expr *pE = a[k].pExpr;
 97821         -      assert( pE->op!=TK_DOT || pE->pRight!=0 );
 97822         -      if( pE->op!=TK_ALL && (pE->op!=TK_DOT || pE->pRight->op!=TK_ALL) ){
        97903  +      pE = a[k].pExpr;
        97904  +      pRight = pE->pRight;
        97905  +      assert( pE->op!=TK_DOT || pRight!=0 );
        97906  +      if( pE->op!=TK_ALL && (pE->op!=TK_DOT || pRight->op!=TK_ALL) ){
 97823  97907           /* This particular expression does not need to be expanded.
 97824  97908           */
 97825  97909           pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);
 97826  97910           if( pNew ){
 97827  97911             pNew->a[pNew->nExpr-1].zName = a[k].zName;
 97828  97912             pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan;
 97829  97913             a[k].zName = 0;
................................................................................
 97830  97914             a[k].zSpan = 0;
 97831  97915           }
 97832  97916           a[k].pExpr = 0;
 97833  97917         }else{
 97834  97918           /* This expression is a "*" or a "TABLE.*" and needs to be
 97835  97919           ** expanded. */
 97836  97920           int tableSeen = 0;      /* Set to 1 when TABLE matches */
 97837         -        char *zTName;            /* text of name of TABLE */
        97921  +        char *zTName = 0;       /* text of name of TABLE */
 97838  97922           if( pE->op==TK_DOT ){
 97839  97923             assert( pE->pLeft!=0 );
 97840  97924             assert( !ExprHasProperty(pE->pLeft, EP_IntValue) );
 97841  97925             zTName = pE->pLeft->u.zToken;
 97842         -        }else{
 97843         -          zTName = 0;
 97844  97926           }
 97845  97927           for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
 97846  97928             Table *pTab = pFrom->pTab;
        97929  +          Select *pSub = pFrom->pSelect;
 97847  97930             char *zTabName = pFrom->zAlias;
        97931  +          const char *zSchemaName = 0;
        97932  +          int iDb;
 97848  97933             if( zTabName==0 ){
 97849  97934               zTabName = pTab->zName;
 97850  97935             }
 97851  97936             if( db->mallocFailed ) break;
        97937  +          if( pSub==0 || (pSub->selFlags & SF_NestedFrom)==0 ){
        97938  +            pSub = 0;
 97852  97939             if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){
 97853  97940               continue;
 97854  97941             }
 97855         -          tableSeen = 1;
        97942  +            iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
        97943  +            zSchemaName = iDb>=0 ? db->aDb[iDb].zName : "*";
        97944  +          }
 97856  97945             for(j=0; j<pTab->nCol; j++){
 97857         -            Expr *pExpr, *pRight;
 97858  97946               char *zName = pTab->aCol[j].zName;
 97859  97947               char *zColname;  /* The computed column name */
 97860  97948               char *zToFree;   /* Malloced string that needs to be freed */
 97861  97949               Token sColname;  /* Computed column name as a token */
        97950  +
        97951  +            assert( zName );
        97952  +            if( zTName && pSub
        97953  +             && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0
        97954  +            ){
        97955  +              continue;
        97956  +            }
 97862  97957   
 97863  97958               /* If a column is marked as 'hidden' (currently only possible
 97864  97959               ** for virtual tables), do not include it in the expanded
 97865  97960               ** result-set list.
 97866  97961               */
 97867  97962               if( IsHiddenColumn(&pTab->aCol[j]) ){
 97868  97963                 assert(IsVirtual(pTab));
 97869  97964                 continue;
 97870  97965               }
        97966  +            tableSeen = 1;
 97871  97967   
 97872  97968               if( i>0 && zTName==0 ){
 97873  97969                 if( (pFrom->jointype & JT_NATURAL)!=0
 97874  97970                   && tableAndColumnIndex(pTabList, i, zName, 0, 0)
 97875  97971                 ){
 97876  97972                   /* In a NATURAL join, omit the join columns from the 
 97877  97973                   ** table to the right of the join */
................................................................................
 97886  97982               pRight = sqlite3Expr(db, TK_ID, zName);
 97887  97983               zColname = zName;
 97888  97984               zToFree = 0;
 97889  97985               if( longNames || pTabList->nSrc>1 ){
 97890  97986                 Expr *pLeft;
 97891  97987                 pLeft = sqlite3Expr(db, TK_ID, zTabName);
 97892  97988                 pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
        97989  +              if( zSchemaName ){
        97990  +                pLeft = sqlite3Expr(db, TK_ID, zSchemaName);
        97991  +                pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr, 0);
        97992  +              }
 97893  97993                 if( longNames ){
 97894  97994                   zColname = sqlite3MPrintf(db, "%s.%s", zTabName, zName);
 97895  97995                   zToFree = zColname;
 97896  97996                 }
 97897  97997               }else{
 97898  97998                 pExpr = pRight;
 97899  97999               }
 97900  98000               pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);
 97901  98001               sColname.z = zColname;
 97902  98002               sColname.n = sqlite3Strlen30(zColname);
 97903  98003               sqlite3ExprListSetName(pParse, pNew, &sColname, 0);
        98004  +            if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){
        98005  +              struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];
        98006  +              if( pSub ){
        98007  +                pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan);
        98008  +                testcase( pX->zSpan==0 );
        98009  +              }else{
        98010  +                pX->zSpan = sqlite3MPrintf(db, "%s.%s.%s",
        98011  +                                           zSchemaName, zTabName, zColname);
        98012  +                testcase( pX->zSpan==0 );
        98013  +              }
        98014  +              pX->bSpanIsTab = 1;
        98015  +            }
 97904  98016               sqlite3DbFree(db, zToFree);
 97905  98017             }
 97906  98018           }
 97907  98019           if( !tableSeen ){
 97908  98020             if( zTName ){
 97909  98021               sqlite3ErrorMsg(pParse, "no such table: %s", zTName);
 97910  98022             }else{

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      "2012-12-21 16:15:35 ff6857b6ed6a46671006b75157d8cf853a816ef9"
          112  +#define SQLITE_SOURCE_ID      "2013-01-04 19:22:33 8285b15a058811a9a8b452837f52e6a065868115"
   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