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

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

Overview
Comment:Remove obsolete code from select.c, including the "affinity" parameter to the sqlite3Select() module. (CVS 5380)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cbd3c1585b7a8f8042aa1448fe1be87de056c41a
User & Date: drh 2008-07-08 23:40:20
Context
2008-07-09
01:39
Additional test coverage in select.c and expr.c. (CVS 5381) check-in: c6cf0847 user: drh tags: trunk
2008-07-08
23:40
Remove obsolete code from select.c, including the "affinity" parameter to the sqlite3Select() module. (CVS 5380) check-in: cbd3c158 user: drh tags: trunk
22:34
Handle sqlite3_temp_directory on OS/2. (CVS 5379) check-in: 9da0b32c user: pweilbacher tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.489 2008/07/08 22:28:49 shane Exp $
           25  +** $Id: build.c,v 1.490 2008/07/08 23:40:20 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   #include <ctype.h>
    29     29   
    30     30   /*
    31     31   ** This routine is called when a new SQL statement is beginning to
    32     32   ** be parsed.  Initialize the pParse structure as needed.
................................................................................
  1522   1522         SelectDest dest;
  1523   1523         Table *pSelTab;
  1524   1524   
  1525   1525         sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);
  1526   1526         sqlite3VdbeChangeP5(v, 1);
  1527   1527         pParse->nTab = 2;
  1528   1528         sqlite3SelectDestInit(&dest, SRT_Table, 1);
  1529         -      sqlite3Select(pParse, pSelect, &dest, 0, 0, 0, 0);
         1529  +      sqlite3Select(pParse, pSelect, &dest, 0, 0, 0);
  1530   1530         sqlite3VdbeAddOp1(v, OP_Close, 1);
  1531   1531         if( pParse->nErr==0 ){
  1532   1532           pSelTab = sqlite3ResultSetOfSelect(pParse, 0, pSelect);
  1533   1533           if( pSelTab==0 ) return;
  1534   1534           assert( p->aCol==0 );
  1535   1535           p->nCol = pSelTab->nCol;
  1536   1536           p->aCol = pSelTab->aCol;

Changes to src/delete.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** in order to generate code for DELETE FROM statements.
    14     14   **
    15         -** $Id: delete.c,v 1.169 2008/04/28 18:46:43 drh Exp $
           15  +** $Id: delete.c,v 1.170 2008/07/08 23:40:20 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Look up every table that is named in pSrc.  If any table is not found,
    21     21   ** add an error message to pParse->zErrMsg and return NULL.  If all tables
    22     22   ** are found, return a pointer to the last table.
................................................................................
   102    102       SrcList *pFrom;
   103    103       
   104    104       pWhere = sqlite3ExprDup(db, pWhere);
   105    105       pFrom = sqlite3SrcListAppendFromTerm(pParse, 0, 0, 0, 0, pDup, 0, 0);
   106    106       pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
   107    107     }
   108    108     sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);
   109         -  sqlite3Select(pParse, pDup, &dest, 0, 0, 0, 0);
          109  +  sqlite3Select(pParse, pDup, &dest, 0, 0, 0);
   110    110     sqlite3SelectDelete(pDup);
   111    111   }
   112    112   #endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */
   113    113   
   114    114   
   115    115   /*
   116    116   ** Generate code for a DELETE FROM statement.

Changes to src/expr.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.383 2008/07/04 09:41:39 danielk1977 Exp $
           15  +** $Id: expr.c,v 1.384 2008/07/08 23:40:20 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Return the 'affinity' of the expression pExpr if any.
    22     22   **
................................................................................
  1884   1884           */
  1885   1885           SelectDest dest;
  1886   1886           ExprList *pEList;
  1887   1887   
  1888   1888           sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
  1889   1889           dest.affinity = (int)affinity;
  1890   1890           assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
  1891         -        if( sqlite3Select(pParse, pExpr->pSelect, &dest, 0, 0, 0, 0) ){
         1891  +        if( sqlite3Select(pParse, pExpr->pSelect, &dest, 0, 0, 0) ){
  1892   1892             return;
  1893   1893           }
  1894   1894           pEList = pExpr->pSelect->pEList;
  1895   1895           if( pEList && pEList->nExpr>0 ){ 
  1896   1896             keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
  1897   1897                 pEList->a[0].pExpr);
  1898   1898           }
................................................................................
  1965   1965         }else{
  1966   1966           dest.eDest = SRT_Exists;
  1967   1967           sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iParm);
  1968   1968           VdbeComment((v, "Init EXISTS result"));
  1969   1969         }
  1970   1970         sqlite3ExprDelete(pSel->pLimit);
  1971   1971         pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &one);
  1972         -      if( sqlite3Select(pParse, pSel, &dest, 0, 0, 0, 0) ){
         1972  +      if( sqlite3Select(pParse, pSel, &dest, 0, 0, 0) ){
  1973   1973           return;
  1974   1974         }
  1975   1975         pExpr->iColumn = dest.iParm;
  1976   1976         break;
  1977   1977       }
  1978   1978     }
  1979   1979   

Changes to src/insert.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.246 2008/07/08 22:28:49 shane Exp $
           15  +** $Id: insert.c,v 1.247 2008/07/08 23:40:20 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Set P4 of the most recently inserted opcode to a column affinity
    21     21   ** string for index pIdx. A column affinity string has one character
    22     22   ** for each column in the table, according to the affinity of the column:
................................................................................
   526    526       sqlite3SelectDestInit(&dest, SRT_Coroutine, ++pParse->nMem);
   527    527       addrSelect = sqlite3VdbeCurrentAddr(v)+2;
   528    528       sqlite3VdbeAddOp2(v, OP_Integer, addrSelect-1, dest.iParm);
   529    529       j1 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);
   530    530       VdbeComment((v, "Jump over SELECT coroutine"));
   531    531   
   532    532       /* Resolve the expressions in the SELECT statement and execute it. */
   533         -    rc = sqlite3Select(pParse, pSelect, &dest, 0, 0, 0, 0);
          533  +    rc = sqlite3Select(pParse, pSelect, &dest, 0, 0, 0);
   534    534       if( rc || pParse->nErr || db->mallocFailed ){
   535    535         goto insert_cleanup;
   536    536       }
   537    537       sqlite3VdbeAddOp2(v, OP_Integer, 1, regEof);         /* EOF <- 1 */
   538    538       sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm);   /* yield X */
   539    539       sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_INTERNAL, OE_Abort);
   540    540       VdbeComment((v, "End of SELECT coroutine"));

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.244 2008/06/05 16:47:39 danielk1977 Exp $
           17  +** @(#) $Id: parse.y,v 1.245 2008/07/08 23:40:20 drh Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
   357    357   }
   358    358   %endif  SQLITE_OMIT_VIEW
   359    359   
   360    360   //////////////////////// The SELECT statement /////////////////////////////////
   361    361   //
   362    362   cmd ::= select(X).  {
   363    363     SelectDest dest = {SRT_Callback, 0, 0, 0, 0};
   364         -  sqlite3Select(pParse, X, &dest, 0, 0, 0, 0);
          364  +  sqlite3Select(pParse, X, &dest, 0, 0, 0);
   365    365     sqlite3SelectDelete(X);
   366    366   }
   367    367   
   368    368   %type select {Select*}
   369    369   %destructor select {sqlite3SelectDelete($$);}
   370    370   %type oneselect {Select*}
   371    371   %destructor oneselect {sqlite3SelectDelete($$);}

Changes to src/select.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.450 2008/07/08 19:34:07 drh Exp $
           15  +** $Id: select.c,v 1.451 2008/07/08 23:40:20 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Delete all the content of a Select structure but do not deallocate
    22     22   ** the select structure itself.
................................................................................
   156    156         break;
   157    157       }
   158    158     }
   159    159     if(
   160    160        (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||
   161    161        (jointype & JT_ERROR)!=0
   162    162     ){
   163         -    const char *zSp1 = " ";
   164         -    const char *zSp2 = " ";
   165         -    if( pB==0 ){ zSp1++; }
   166         -    if( pC==0 ){ zSp2++; }
          163  +    const char *zSp = " ";
          164  +    assert( pB!=0 );
          165  +    if( pC==0 ){ zSp++; }
   167    166       sqlite3ErrorMsg(pParse, "unknown or unsupported join type: "
   168         -       "%T%s%T%s%T", pA, zSp1, pB, zSp2, pC);
          167  +       "%T %T%s%T", pA, pB, zSp, pC);
   169    168       jointype = JT_INNER;
   170    169     }else if( jointype & JT_RIGHT ){
   171    170       sqlite3ErrorMsg(pParse, 
   172    171         "RIGHT and FULL OUTER JOINs are not currently supported");
   173    172       jointype = JT_INNER;
   174    173     }
   175    174     return jointype;
................................................................................
   527    526     ExprList *pEList,       /* List of values being extracted */
   528    527     int srcTab,             /* Pull data from this table */
   529    528     int nColumn,            /* Number of columns in the source table */
   530    529     ExprList *pOrderBy,     /* If not NULL, sort results using this key */
   531    530     int distinct,           /* If >=0, make sure results are distinct */
   532    531     SelectDest *pDest,      /* How to dispose of the results */
   533    532     int iContinue,          /* Jump here to continue with next row */
   534         -  int iBreak,             /* Jump here to break out of the inner loop */
   535         -  char *aff               /* affinity string if eDest is SRT_Union */
          533  +  int iBreak              /* Jump here to break out of the inner loop */
   536    534   ){
   537    535     Vdbe *v = pParse->pVdbe;
   538    536     int i;
   539    537     int hasDistinct;        /* True if the DISTINCT keyword is present */
   540    538     int regResult;              /* Start of memory holding result set */
   541    539     int eDest = pDest->eDest;   /* How to dispose of results */
   542    540     int iParm = pDest->iParm;   /* First argument to disposal method */
................................................................................
   605    603       ** table iParm.
   606    604       */
   607    605   #ifndef SQLITE_OMIT_COMPOUND_SELECT
   608    606       case SRT_Union: {
   609    607         int r1;
   610    608         r1 = sqlite3GetTempReg(pParse);
   611    609         sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1);
   612         -      if( aff ){
   613         -        sqlite3VdbeChangeP4(v, -1, aff, P4_STATIC);
   614         -      }
   615    610         sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);
   616    611         sqlite3ReleaseTempReg(pParse, r1);
   617    612         break;
   618    613       }
   619    614   
   620    615       /* Construct a record from the query result, but instead of
   621    616       ** saving that record, use it as a key to delete elements from
................................................................................
   845    840         for(i=0; i<nColumn; i++){
   846    841           assert( regRow!=pDest->iMem+i );
   847    842           sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest->iMem+i);
   848    843         }
   849    844         if( eDest==SRT_Callback ){
   850    845           sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iMem, nColumn);
   851    846           sqlite3ExprCacheAffinityChange(pParse, pDest->iMem, nColumn);
   852         -      }else if( eDest==SRT_Coroutine ){
          847  +      }else{
   853    848           sqlite3VdbeAddOp1(v, OP_Yield, pDest->iParm);
   854    849         }
   855    850         break;
   856    851       }
   857    852       default: {
   858    853         /* Do nothing */
   859    854         break;
   860    855       }
   861    856     }
   862    857     sqlite3ReleaseTempReg(pParse, regRow);
   863    858     sqlite3ReleaseTempReg(pParse, regRowid);
   864    859   
   865         -  /* Jump to the end of the loop when the LIMIT is reached
          860  +  /* LIMIT has been implemented by the pushOntoSorter() routine.
   866    861     */
   867         -  if( p->iLimit ){
   868         -    sqlite3VdbeAddOp2(v, OP_AddImm, p->iLimit, -1);
   869         -    sqlite3VdbeAddOp2(v, OP_IfZero, p->iLimit, brk);
   870         -  }
          862  +  assert( p->iLimit==0 );
   871    863   
   872    864     /* The bottom of the loop
   873    865     */
   874    866     sqlite3VdbeResolveLabel(v, cont);
   875    867     sqlite3VdbeAddOp2(v, OP_Next, iTab, addr);
   876    868     sqlite3VdbeResolveLabel(v, brk);
   877    869     if( eDest==SRT_Callback || eDest==SRT_Coroutine ){
................................................................................
  1821   1813         addr1 = sqlite3VdbeAddOp1(v, OP_IfPos, iLimit);
  1822   1814         sqlite3VdbeAddOp2(v, OP_Integer, -1, iOffset+1);
  1823   1815         sqlite3VdbeJumpHere(v, addr1);
  1824   1816       }
  1825   1817     }
  1826   1818   }
  1827   1819   
  1828         -/*
  1829         -** Allocate a virtual index to use for sorting.
  1830         -*/
  1831         -static void createSortingIndex(Parse *pParse, Select *p, ExprList *pOrderBy){
  1832         -  if( pOrderBy ){
  1833         -    int addr;
  1834         -    assert( pOrderBy->iECursor==0 );
  1835         -    pOrderBy->iECursor = pParse->nTab++;
  1836         -    addr = sqlite3VdbeAddOp2(pParse->pVdbe, OP_OpenEphemeral,
  1837         -                            pOrderBy->iECursor, pOrderBy->nExpr+1);
  1838         -    assert( p->addrOpenEphm[2] == -1 );
  1839         -    p->addrOpenEphm[2] = addr;
  1840         -  }
  1841         -}
  1842         -
  1843   1820   #ifndef SQLITE_OMIT_COMPOUND_SELECT
  1844   1821   /*
  1845   1822   ** Return the appropriate collating sequence for the iCol-th column of
  1846   1823   ** the result set for the compound-select statement "p".  Return NULL if
  1847   1824   ** the column has no default collating sequence.
  1848   1825   **
  1849   1826   ** The collating sequence for the compound select is taken from the
................................................................................
  1863   1840   }
  1864   1841   #endif /* SQLITE_OMIT_COMPOUND_SELECT */
  1865   1842   
  1866   1843   /* Forward reference */
  1867   1844   static int multiSelectOrderBy(
  1868   1845     Parse *pParse,        /* Parsing context */
  1869   1846     Select *p,            /* The right-most of SELECTs to be coded */
  1870         -  SelectDest *pDest,    /* What to do with query results */
  1871         -  char *aff             /* If eDest is SRT_Union, the affinity string */
         1847  +  SelectDest *pDest     /* What to do with query results */
  1872   1848   );
  1873   1849   
  1874   1850   
  1875   1851   #ifndef SQLITE_OMIT_COMPOUND_SELECT
  1876   1852   /*
  1877   1853   ** This routine is called to process a compound query form from
  1878   1854   ** two or more separate queries using UNION, UNION ALL, EXCEPT, or
................................................................................
  1903   1879   **
  1904   1880   ** Notice that because of the way SQLite parses compound SELECTs, the
  1905   1881   ** individual selects always group from left to right.
  1906   1882   */
  1907   1883   static int multiSelect(
  1908   1884     Parse *pParse,        /* Parsing context */
  1909   1885     Select *p,            /* The right-most of SELECTs to be coded */
  1910         -  SelectDest *pDest,    /* What to do with query results */
  1911         -  char *aff             /* If eDest is SRT_Union, the affinity string */
         1886  +  SelectDest *pDest     /* What to do with query results */
  1912   1887   ){
  1913   1888     int rc = SQLITE_OK;   /* Success code from a subroutine */
  1914   1889     Select *pPrior;       /* Another SELECT immediately to our left */
  1915   1890     Vdbe *v;              /* Generate code to this VDBE */
  1916   1891     int nCol;             /* Number of columns in the result set */
  1917         -  ExprList *pOrderBy;   /* The ORDER BY clause on p */
  1918   1892     int aSetP2[2];        /* Set P2 value of these op to number of columns */
  1919   1893     int nSetP2 = 0;       /* Number of slots in aSetP2[] used */
  1920   1894     SelectDest dest;      /* Alternative data destination */
  1921   1895     Select *pDelete = 0;  /* Chain of simple selects to delete */
  1922   1896   
  1923   1897     /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs.  Only
  1924   1898     ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
................................................................................
  1967   1941     if( p->pEList->nExpr!=pPrior->pEList->nExpr ){
  1968   1942       sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
  1969   1943         " do not have the same number of result columns", selectOpName(p->op));
  1970   1944       rc = 1;
  1971   1945       goto multi_select_end;
  1972   1946     }
  1973   1947   
  1974         -#if 1
         1948  +  /* Compound SELECTs that have an ORDER BY clause are handled separately.
         1949  +  */
  1975   1950     if( p->pOrderBy ){
  1976         -    return multiSelectOrderBy(pParse, p, pDest, aff);
         1951  +    return multiSelectOrderBy(pParse, p, pDest);
  1977   1952     }
  1978         -#endif
  1979   1953   
  1980   1954     /* Generate code for the left and right SELECT statements.
  1981   1955     */
  1982         -  pOrderBy = p->pOrderBy;
  1983   1956     switch( p->op ){
  1984   1957       case TK_ALL: {
  1985         -      if( pOrderBy==0 ){
  1986         -        int addr = 0;
  1987         -        assert( !pPrior->pLimit );
  1988         -        pPrior->pLimit = p->pLimit;
  1989         -        pPrior->pOffset = p->pOffset;
  1990         -        rc = sqlite3Select(pParse, pPrior, &dest, 0, 0, 0, aff);
  1991         -        p->pLimit = 0;
  1992         -        p->pOffset = 0;
  1993         -        if( rc ){
  1994         -          goto multi_select_end;
  1995         -        }
  1996         -        p->pPrior = 0;
  1997         -        p->iLimit = pPrior->iLimit;
  1998         -        p->iOffset = pPrior->iOffset;
  1999         -        if( p->iLimit ){
  2000         -          addr = sqlite3VdbeAddOp1(v, OP_IfZero, p->iLimit);
  2001         -          VdbeComment((v, "Jump ahead if LIMIT reached"));
  2002         -        }
  2003         -        rc = sqlite3Select(pParse, p, &dest, 0, 0, 0, aff);
  2004         -        pDelete = p->pPrior;
  2005         -        p->pPrior = pPrior;
  2006         -        if( rc ){
  2007         -          goto multi_select_end;
  2008         -        }
  2009         -        if( addr ){
  2010         -          sqlite3VdbeJumpHere(v, addr);
  2011         -        }
  2012         -        break;
  2013         -      }
  2014         -      /* For UNION ALL ... ORDER BY fall through to the next case */
         1958  +      int addr = 0;
         1959  +      assert( !pPrior->pLimit );
         1960  +      pPrior->pLimit = p->pLimit;
         1961  +      pPrior->pOffset = p->pOffset;
         1962  +      rc = sqlite3Select(pParse, pPrior, &dest, 0, 0, 0);
         1963  +      p->pLimit = 0;
         1964  +      p->pOffset = 0;
         1965  +      if( rc ){
         1966  +        goto multi_select_end;
         1967  +      }
         1968  +      p->pPrior = 0;
         1969  +      p->iLimit = pPrior->iLimit;
         1970  +      p->iOffset = pPrior->iOffset;
         1971  +      if( p->iLimit ){
         1972  +        addr = sqlite3VdbeAddOp1(v, OP_IfZero, p->iLimit);
         1973  +        VdbeComment((v, "Jump ahead if LIMIT reached"));
         1974  +      }
         1975  +      rc = sqlite3Select(pParse, p, &dest, 0, 0, 0);
         1976  +      pDelete = p->pPrior;
         1977  +      p->pPrior = pPrior;
         1978  +      if( rc ){
         1979  +        goto multi_select_end;
         1980  +      }
         1981  +      if( addr ){
         1982  +        sqlite3VdbeJumpHere(v, addr);
         1983  +      }
         1984  +      break;
  2015   1985       }
  2016   1986       case TK_EXCEPT:
  2017   1987       case TK_UNION: {
  2018   1988         int unionTab;    /* Cursor number of the temporary table holding result */
  2019   1989         int op = 0;      /* One of the SRT_ operations to apply to self */
  2020   1990         int priorOp;     /* The SRT_ operation to apply to prior selects */
  2021   1991         Expr *pLimit, *pOffset; /* Saved values of p->nLimit and p->nOffset */
  2022   1992         int addr;
  2023   1993         SelectDest uniondest;
  2024   1994   
  2025   1995         priorOp = p->op==TK_ALL ? SRT_Table : SRT_Union;
  2026         -      if( dest.eDest==priorOp && pOrderBy==0 && !p->pLimit && !p->pOffset ){
         1996  +      if( dest.eDest==priorOp && !p->pLimit && !p->pOffset ){
  2027   1997           /* We can reuse a temporary table generated by a SELECT to our
  2028   1998           ** right.
  2029   1999           */
  2030   2000           unionTab = dest.iParm;
  2031   2001         }else{
  2032   2002           /* We will need to create our own temporary table to hold the
  2033   2003           ** intermediate results.
................................................................................
  2042   2012             assert( nSetP2<sizeof(aSetP2)/sizeof(aSetP2[0]) );
  2043   2013             aSetP2[nSetP2++] = addr;
  2044   2014           }else{
  2045   2015             assert( p->addrOpenEphm[0] == -1 );
  2046   2016             p->addrOpenEphm[0] = addr;
  2047   2017             p->pRightmost->usesEphm = 1;
  2048   2018           }
  2049         -        createSortingIndex(pParse, p, pOrderBy);
  2050   2019           assert( p->pEList );
  2051   2020         }
  2052   2021   
  2053   2022         /* Code the SELECT statements to our left
  2054   2023         */
  2055   2024         assert( !pPrior->pOrderBy );
  2056   2025         sqlite3SelectDestInit(&uniondest, priorOp, unionTab);
  2057         -      rc = sqlite3Select(pParse, pPrior, &uniondest, 0, 0, 0, aff);
         2026  +      rc = sqlite3Select(pParse, pPrior, &uniondest, 0, 0, 0);
  2058   2027         if( rc ){
  2059   2028           goto multi_select_end;
  2060   2029         }
  2061   2030   
  2062   2031         /* Code the current SELECT statement
  2063   2032         */
  2064   2033         switch( p->op ){
  2065   2034            case TK_EXCEPT:  op = SRT_Except;   break;
  2066   2035            case TK_UNION:   op = SRT_Union;    break;
  2067   2036            case TK_ALL:     op = SRT_Table;    break;
  2068   2037         }
  2069   2038         p->pPrior = 0;
  2070         -      p->pOrderBy = 0;
  2071         -      p->disallowOrderBy = pOrderBy!=0;
         2039  +      p->disallowOrderBy = 0;
  2072   2040         pLimit = p->pLimit;
  2073   2041         p->pLimit = 0;
  2074   2042         pOffset = p->pOffset;
  2075   2043         p->pOffset = 0;
  2076   2044         uniondest.eDest = op;
  2077         -      rc = sqlite3Select(pParse, p, &uniondest, 0, 0, 0, aff);
         2045  +      rc = sqlite3Select(pParse, p, &uniondest, 0, 0, 0);
  2078   2046         /* Query flattening in sqlite3Select() might refill p->pOrderBy.
  2079   2047         ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */
  2080   2048         sqlite3ExprListDelete(p->pOrderBy);
  2081   2049         pDelete = p->pPrior;
  2082   2050         p->pPrior = pPrior;
  2083         -      p->pOrderBy = pOrderBy;
         2051  +      p->pOrderBy = 0;
  2084   2052         sqlite3ExprDelete(p->pLimit);
  2085   2053         p->pLimit = pLimit;
  2086   2054         p->pOffset = pOffset;
  2087   2055         p->iLimit = 0;
  2088   2056         p->iOffset = 0;
  2089   2057         if( rc ){
  2090   2058           goto multi_select_end;
................................................................................
  2104   2072           }
  2105   2073           iBreak = sqlite3VdbeMakeLabel(v);
  2106   2074           iCont = sqlite3VdbeMakeLabel(v);
  2107   2075           computeLimitRegisters(pParse, p, iBreak);
  2108   2076           sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak);
  2109   2077           iStart = sqlite3VdbeCurrentAddr(v);
  2110   2078           selectInnerLoop(pParse, p, p->pEList, unionTab, p->pEList->nExpr,
  2111         -                        pOrderBy, -1, &dest, iCont, iBreak, 0);
         2079  +                        0, -1, &dest, iCont, iBreak);
  2112   2080           sqlite3VdbeResolveLabel(v, iCont);
  2113   2081           sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart);
  2114   2082           sqlite3VdbeResolveLabel(v, iBreak);
  2115   2083           sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);
  2116   2084         }
  2117   2085         break;
  2118   2086       }
................................................................................
  2130   2098         */
  2131   2099         tab1 = pParse->nTab++;
  2132   2100         tab2 = pParse->nTab++;
  2133   2101         if( processCompoundOrderBy(pParse, p, tab1) ){
  2134   2102           rc = 1;
  2135   2103           goto multi_select_end;
  2136   2104         }
  2137         -      createSortingIndex(pParse, p, pOrderBy);
  2138   2105   
  2139   2106         addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);
  2140   2107         assert( p->addrOpenEphm[0] == -1 );
  2141   2108         p->addrOpenEphm[0] = addr;
  2142   2109         p->pRightmost->usesEphm = 1;
  2143   2110         assert( p->pEList );
  2144   2111   
  2145   2112         /* Code the SELECTs to our left into temporary table "tab1".
  2146   2113         */
  2147   2114         sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);
  2148         -      rc = sqlite3Select(pParse, pPrior, &intersectdest, 0, 0, 0, aff);
         2115  +      rc = sqlite3Select(pParse, pPrior, &intersectdest, 0, 0, 0);
  2149   2116         if( rc ){
  2150   2117           goto multi_select_end;
  2151   2118         }
  2152   2119   
  2153   2120         /* Code the current SELECT into temporary table "tab2"
  2154   2121         */
  2155   2122         addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
................................................................................
  2157   2124         p->addrOpenEphm[1] = addr;
  2158   2125         p->pPrior = 0;
  2159   2126         pLimit = p->pLimit;
  2160   2127         p->pLimit = 0;
  2161   2128         pOffset = p->pOffset;
  2162   2129         p->pOffset = 0;
  2163   2130         intersectdest.iParm = tab2;
  2164         -      rc = sqlite3Select(pParse, p, &intersectdest, 0, 0, 0, aff);
         2131  +      rc = sqlite3Select(pParse, p, &intersectdest, 0, 0, 0);
  2165   2132         pDelete = p->pPrior;
  2166   2133         p->pPrior = pPrior;
  2167   2134         sqlite3ExprDelete(p->pLimit);
  2168   2135         p->pLimit = pLimit;
  2169   2136         p->pOffset = pOffset;
  2170   2137         if( rc ){
  2171   2138           goto multi_select_end;
................................................................................
  2185   2152         computeLimitRegisters(pParse, p, iBreak);
  2186   2153         sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak);
  2187   2154         r1 = sqlite3GetTempReg(pParse);
  2188   2155         iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1);
  2189   2156         sqlite3VdbeAddOp3(v, OP_NotFound, tab2, iCont, r1);
  2190   2157         sqlite3ReleaseTempReg(pParse, r1);
  2191   2158         selectInnerLoop(pParse, p, p->pEList, tab1, p->pEList->nExpr,
  2192         -                      pOrderBy, -1, &dest, iCont, iBreak, 0);
         2159  +                      0, -1, &dest, iCont, iBreak);
  2193   2160         sqlite3VdbeResolveLabel(v, iCont);
  2194   2161         sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart);
  2195   2162         sqlite3VdbeResolveLabel(v, iBreak);
  2196   2163         sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);
  2197   2164         sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);
  2198   2165         break;
  2199   2166       }
................................................................................
  2202   2169     /* Set the number of columns in temporary tables
  2203   2170     */
  2204   2171     nCol = p->pEList->nExpr;
  2205   2172     while( nSetP2 ){
  2206   2173       sqlite3VdbeChangeP2(v, aSetP2[--nSetP2], nCol);
  2207   2174     }
  2208   2175   
  2209         -  /* Compute collating sequences used by either the ORDER BY clause or
  2210         -  ** by any temporary tables needed to implement the compound select.
  2211         -  ** Attach the KeyInfo structure to all temporary tables.  Invoke the
  2212         -  ** ORDER BY processing if there is an ORDER BY clause.
         2176  +  /* Compute collating sequences used by 
         2177  +  ** temporary tables needed to implement the compound select.
         2178  +  ** Attach the KeyInfo structure to all temporary tables.
  2213   2179     **
  2214   2180     ** This section is run by the right-most SELECT statement only.
  2215   2181     ** SELECT statements to the left always skip this part.  The right-most
  2216   2182     ** SELECT might also skip this part if it has no ORDER BY clause and
  2217   2183     ** no temp tables are required.
  2218   2184     */
  2219         -  if( pOrderBy || p->usesEphm ){
         2185  +  if( p->usesEphm ){
  2220   2186       int i;                        /* Loop counter */
  2221   2187       KeyInfo *pKeyInfo;            /* Collating sequence for the result set */
  2222   2188       Select *pLoop;                /* For looping through SELECT statements */
  2223         -    int nKeyCol;                  /* Number of entries in pKeyInfo->aCol[] */
  2224   2189       CollSeq **apColl;             /* For looping through pKeyInfo->aColl[] */
  2225         -    CollSeq **aCopy;              /* A copy of pKeyInfo->aColl[] */
  2226   2190   
  2227   2191       assert( p->pRightmost==p );
  2228         -    nKeyCol = nCol + (pOrderBy ? pOrderBy->nExpr : 0);
  2229   2192       pKeyInfo = sqlite3DbMallocZero(pParse->db,
  2230         -                       sizeof(*pKeyInfo)+nKeyCol*(sizeof(CollSeq*) + 1));
         2193  +                       sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));
  2231   2194       if( !pKeyInfo ){
  2232   2195         rc = SQLITE_NOMEM;
  2233   2196         goto multi_select_end;
  2234   2197       }
  2235   2198   
  2236   2199       pKeyInfo->enc = ENC(pParse->db);
  2237   2200       pKeyInfo->nField = nCol;
................................................................................
  2253   2216             break;
  2254   2217           }
  2255   2218           sqlite3VdbeChangeP2(v, addr, nCol);
  2256   2219           sqlite3VdbeChangeP4(v, addr, (char*)pKeyInfo, P4_KEYINFO);
  2257   2220           pLoop->addrOpenEphm[i] = -1;
  2258   2221         }
  2259   2222       }
  2260         -
  2261         -    if( pOrderBy ){
  2262         -      struct ExprList_item *pOTerm = pOrderBy->a;
  2263         -      int nOrderByExpr = pOrderBy->nExpr;
  2264         -      int addr;
  2265         -      u8 *pSortOrder;
  2266         -
  2267         -      /* Reuse the same pKeyInfo for the ORDER BY as was used above for
  2268         -      ** the compound select statements.  Except we have to change out the
  2269         -      ** pKeyInfo->aColl[] values.  Some of the aColl[] values will be
  2270         -      ** reused when constructing the pKeyInfo for the ORDER BY, so make
  2271         -      ** a copy.  Sufficient space to hold both the nCol entries for
  2272         -      ** the compound select and the nOrderbyExpr entries for the ORDER BY
  2273         -      ** was allocated above.  But we need to move the compound select
  2274         -      ** entries out of the way before constructing the ORDER BY entries.
  2275         -      ** Move the compound select entries into aCopy[] where they can be
  2276         -      ** accessed and reused when constructing the ORDER BY entries.
  2277         -      ** Because nCol might be greater than or less than nOrderByExpr
  2278         -      ** we have to use memmove() when doing the copy.
  2279         -      */
  2280         -      aCopy = &pKeyInfo->aColl[nOrderByExpr];
  2281         -      pSortOrder = pKeyInfo->aSortOrder = (u8*)&aCopy[nCol];
  2282         -      memmove(aCopy, pKeyInfo->aColl, nCol*sizeof(CollSeq*));
  2283         -
  2284         -      apColl = pKeyInfo->aColl;
  2285         -      for(i=0; i<nOrderByExpr; i++, pOTerm++, apColl++, pSortOrder++){
  2286         -        Expr *pExpr = pOTerm->pExpr;
  2287         -        if( (pExpr->flags & EP_ExpCollate) ){
  2288         -          assert( pExpr->pColl!=0 );
  2289         -          *apColl = pExpr->pColl;
  2290         -        }else{
  2291         -          *apColl = aCopy[pExpr->iColumn];
  2292         -        }
  2293         -        *pSortOrder = pOTerm->sortOrder;
  2294         -      }
  2295         -      assert( p->pRightmost==p );
  2296         -      assert( p->addrOpenEphm[2]>=0 );
  2297         -      addr = p->addrOpenEphm[2];
  2298         -      sqlite3VdbeChangeP2(v, addr, p->pOrderBy->nExpr+2);
  2299         -      pKeyInfo->nField = nOrderByExpr;
  2300         -      sqlite3VdbeChangeP4(v, addr, (char*)pKeyInfo, P4_KEYINFO_HANDOFF);
  2301         -      pKeyInfo = 0;
  2302         -      generateSortTail(pParse, p, v, p->pEList->nExpr, &dest);
  2303         -    }
  2304         -
  2305   2223       sqlite3_free(pKeyInfo);
  2306   2224     }
  2307   2225   
  2308   2226   multi_select_end:
  2309   2227     pDest->iMem = dest.iMem;
  2310   2228     pDest->nMem = dest.nMem;
  2311   2229     sqlite3SelectDelete(pDelete);
................................................................................
  2554   2472   ** actually called using Gosub and they do not Return.  EofA and EofB loop
  2555   2473   ** until all data is exhausted then jump to the "end" labe.  AltB, AeqB,
  2556   2474   ** and AgtB jump to either L2 or to one of EofA or EofB.
  2557   2475   */
  2558   2476   static int multiSelectOrderBy(
  2559   2477     Parse *pParse,        /* Parsing context */
  2560   2478     Select *p,            /* The right-most of SELECTs to be coded */
  2561         -  SelectDest *pDest,    /* What to do with query results */
  2562         -  char *aff             /* If eDest is SRT_Union, the affinity string */
         2479  +  SelectDest *pDest     /* What to do with query results */
  2563   2480   ){
  2564   2481     int i, j;             /* Loop counters */
  2565   2482     Select *pPrior;       /* Another SELECT immediately to our left */
  2566   2483     Vdbe *v;              /* Generate code to this VDBE */
  2567   2484     SelectDest destA;     /* Destination for coroutine A */
  2568   2485     SelectDest destB;     /* Destination for coroutine B */
  2569   2486     int regAddrA;         /* Address register for select-A coroutine */
................................................................................
  2754   2671   
  2755   2672   
  2756   2673     /* Generate a coroutine to evaluate the SELECT statement to the
  2757   2674     ** left of the compound operator - the "A" select.
  2758   2675     */
  2759   2676     VdbeNoopComment((v, "Begin coroutine for left SELECT"));
  2760   2677     pPrior->iLimit = regLimitA;
  2761         -  sqlite3Select(pParse, pPrior, &destA, 0, 0, 0, 0);
         2678  +  sqlite3Select(pParse, pPrior, &destA, 0, 0, 0);
  2762   2679     sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofA);
  2763   2680     sqlite3VdbeAddOp1(v, OP_Yield, regAddrA);
  2764   2681     VdbeNoopComment((v, "End coroutine for left SELECT"));
  2765   2682   
  2766   2683     /* Generate a coroutine to evaluate the SELECT statement on 
  2767   2684     ** the right - the "B" select
  2768   2685     */
  2769   2686     addrSelectB = sqlite3VdbeCurrentAddr(v);
  2770   2687     VdbeNoopComment((v, "Begin coroutine for right SELECT"));
  2771   2688     savedLimit = p->iLimit;
  2772   2689     savedOffset = p->iOffset;
  2773   2690     p->iLimit = regLimitB;
  2774   2691     p->iOffset = 0;  
  2775         -  sqlite3Select(pParse, p, &destB, 0, 0, 0, 0);
         2692  +  sqlite3Select(pParse, p, &destB, 0, 0, 0);
  2776   2693     p->iLimit = savedLimit;
  2777   2694     p->iOffset = savedOffset;
  2778   2695     sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofB);
  2779   2696     sqlite3VdbeAddOp1(v, OP_Yield, regAddrB);
  2780   2697     VdbeNoopComment((v, "End coroutine for right SELECT"));
  2781   2698   
  2782   2699     /* Generate a subroutine that outputs the current row of the A
................................................................................
  3727   3644   */
  3728   3645   int sqlite3Select(
  3729   3646     Parse *pParse,         /* The parser context */
  3730   3647     Select *p,             /* The SELECT statement being coded. */
  3731   3648     SelectDest *pDest,     /* What to do with the query results */
  3732   3649     Select *pParent,       /* Another SELECT for which this is a sub-query */
  3733   3650     int parentTab,         /* Index in pParent->pSrc of this query */
  3734         -  int *pParentAgg,       /* True if pParent uses aggregate functions */
  3735         -  char *aff              /* If eDest is SRT_Union, the affinity string */
         3651  +  int *pParentAgg        /* True if pParent uses aggregate functions */
  3736   3652   ){
  3737   3653     int i, j;              /* Loop counters */
  3738   3654     WhereInfo *pWInfo;     /* Return from sqlite3WhereBegin() */
  3739   3655     Vdbe *v;               /* The virtual machine under construction */
  3740   3656     int isAgg;             /* True for select lists like "count(*)" */
  3741   3657     ExprList *pEList;      /* List of columns to extract. */
  3742   3658     SrcList *pTabList;     /* List of tables to select from */
................................................................................
  3835   3751       if( flattenSubquery(pParse, p, i, isAgg, isAggSub) ){
  3836   3752         if( isAggSub ){
  3837   3753           p->isAgg = isAgg = 1;
  3838   3754         }
  3839   3755         i = -1;
  3840   3756       }else{
  3841   3757         sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
  3842         -      sqlite3Select(pParse, pSub, &dest, p, i, &isAgg, 0);
         3758  +      sqlite3Select(pParse, pSub, &dest, p, i, &isAgg);
  3843   3759       }
  3844   3760       if( pParse->nErr || db->mallocFailed ){
  3845   3761         goto select_end;
  3846   3762       }
  3847   3763       pParse->nHeight -= sqlite3SelectExprHeight(p);
  3848   3764       pTabList = p->pSrc;
  3849   3765       if( !IgnorableOrderby(pDest) ){
................................................................................
  3872   3788         }
  3873   3789         mxSelect = db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT];
  3874   3790         if( mxSelect && cnt>mxSelect ){
  3875   3791           sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
  3876   3792           return 1;
  3877   3793         }
  3878   3794       }
  3879         -    return multiSelect(pParse, p, pDest, aff);
         3795  +    return multiSelect(pParse, p, pDest);
  3880   3796     }
  3881   3797   #endif
  3882   3798   
  3883   3799     /* If writing to memory or generating a set
  3884   3800     ** only a single column may be output.
  3885   3801     */
  3886   3802   #ifndef SQLITE_OMIT_SUBQUERY
................................................................................
  3959   3875         p->addrOpenEphm[2] = -1;
  3960   3876       }
  3961   3877   
  3962   3878       /* Use the standard inner loop
  3963   3879       */
  3964   3880       assert(!isDistinct);
  3965   3881       selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, -1, pDest,
  3966         -                    pWInfo->iContinue, pWInfo->iBreak, aff);
         3882  +                    pWInfo->iContinue, pWInfo->iBreak);
  3967   3883   
  3968   3884       /* End the database scan loop.
  3969   3885       */
  3970   3886       sqlite3WhereEnd(pWInfo);
  3971   3887     }else{
  3972   3888       /* This is the processing for aggregate queries */
  3973   3889       NameContext sNC;    /* Name context for processing aggregate information */
................................................................................
  4069   3985         sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
  4070   3986         finalizeAggFunctions(pParse, &sAggInfo);
  4071   3987         if( pHaving ){
  4072   3988           sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);
  4073   3989         }
  4074   3990         selectInnerLoop(pParse, p, p->pEList, 0, 0, pOrderBy,
  4075   3991                         distinct, pDest,
  4076         -                      addrOutputRow+1, addrSetAbort, aff);
         3992  +                      addrOutputRow+1, addrSetAbort);
  4077   3993         sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);
  4078   3994         VdbeComment((v, "end groupby result generator"));
  4079   3995   
  4080   3996         /* Generate a subroutine that will reset the group-by accumulator
  4081   3997         */
  4082   3998         addrReset = sqlite3VdbeCurrentAddr(v);
  4083   3999         regReset = ++pParse->nMem;
................................................................................
  4264   4180         sqlite3WhereEnd(pWInfo);
  4265   4181         finalizeAggFunctions(pParse, &sAggInfo);
  4266   4182         pOrderBy = 0;
  4267   4183         if( pHaving ){
  4268   4184           sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL);
  4269   4185         }
  4270   4186         selectInnerLoop(pParse, p, p->pEList, 0, 0, 0, -1, 
  4271         -                      pDest, addrEnd, addrEnd, aff);
         4187  +                      pDest, addrEnd, addrEnd);
  4272   4188   
  4273   4189         sqlite3ExprListDelete(pDel);
  4274   4190       }
  4275   4191       sqlite3VdbeResolveLabel(v, addrEnd);
  4276   4192       
  4277   4193     } /* endif aggregate query */
  4278   4194   

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.737 2008/07/08 22:28:49 shane Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.738 2008/07/08 23:40:20 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Include the configuration header output by 'configure' if we're using the
    21     21   ** autoconf-based build
................................................................................
  1918   1918   void sqlite3SrcListShiftJoinType(SrcList*);
  1919   1919   void sqlite3SrcListAssignCursors(Parse*, SrcList*);
  1920   1920   void sqlite3IdListDelete(IdList*);
  1921   1921   void sqlite3SrcListDelete(SrcList*);
  1922   1922   void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,
  1923   1923                           Token*, int, int);
  1924   1924   void sqlite3DropIndex(Parse*, SrcList*, int);
  1925         -int sqlite3Select(Parse*, Select*, SelectDest*, Select*, int, int*, char *aff);
         1925  +int sqlite3Select(Parse*, Select*, SelectDest*, Select*, int, int*);
  1926   1926   Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
  1927   1927                            Expr*,ExprList*,int,Expr*,Expr*);
  1928   1928   void sqlite3SelectDelete(Select*);
  1929   1929   Table *sqlite3SrcListLookup(Parse*, SrcList*);
  1930   1930   int sqlite3IsReadOnly(Parse*, Table*, int);
  1931   1931   void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
  1932   1932   void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);

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.30 2008/06/26 10:54:12 danielk1977 Exp $
           19  +** $Id: test_config.c,v 1.31 2008/07/08 23:40:20 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>
................................................................................
    60     60   
    61     61   #ifdef SQLITE_DISABLE_LFS
    62     62     Tcl_SetVar2(interp, "sqlite_options", "lfs", "0", TCL_GLOBAL_ONLY);
    63     63   #else
    64     64     Tcl_SetVar2(interp, "sqlite_options", "lfs", "1", TCL_GLOBAL_ONLY);
    65     65   #endif
    66     66   
    67         -#ifdef SQLITE_MEMDEBUG
           67  +#if 1 /* def SQLITE_MEMDEBUG */
    68     68     Tcl_SetVar2(interp, "sqlite_options", "memdebug", "1", TCL_GLOBAL_ONLY);
    69     69   #else
    70     70     Tcl_SetVar2(interp, "sqlite_options", "memdebug", "0", TCL_GLOBAL_ONLY);
    71     71   #endif
    72     72   
    73     73   #ifdef SQLITE_ENABLE_MEMSYS3
    74     74     Tcl_SetVar2(interp, "sqlite_options", "mem3", "1", TCL_GLOBAL_ONLY);

Changes to src/trigger.c.

     6      6   **    May you do good and not evil.
     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   **
    12     12   **
    13         -** $Id: trigger.c,v 1.126 2008/05/16 04:51:55 danielk1977 Exp $
           13  +** $Id: trigger.c,v 1.127 2008/07/08 23:40:20 drh Exp $
    14     14   */
    15     15   #include "sqliteInt.h"
    16     16   
    17     17   #ifndef SQLITE_OMIT_TRIGGER
    18     18   /*
    19     19   ** Delete a linked list of TriggerStep structures.
    20     20   */
................................................................................
   676    676         case TK_SELECT: {
   677    677           Select *ss = sqlite3SelectDup(db, pTriggerStep->pSelect);
   678    678           if( ss ){
   679    679             SelectDest dest;
   680    680   
   681    681             sqlite3SelectDestInit(&dest, SRT_Discard, 0);
   682    682             sqlite3SelectResolve(pParse, ss, 0);
   683         -          sqlite3Select(pParse, ss, &dest, 0, 0, 0, 0);
          683  +          sqlite3Select(pParse, ss, &dest, 0, 0, 0);
   684    684             sqlite3SelectDelete(ss);
   685    685           }
   686    686           break;
   687    687         }
   688    688         case TK_UPDATE: {
   689    689           SrcList *pSrc;
   690    690           pSrc = targetSrcList(pParse, pTriggerStep);

Changes to src/update.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle UPDATE statements.
    14     14   **
    15         -** $Id: update.c,v 1.178 2008/04/28 18:46:43 drh Exp $
           15  +** $Id: update.c,v 1.179 2008/07/08 23:40:20 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   #ifndef SQLITE_OMIT_VIRTUALTABLE
    20     20   /* Forward declaration */
    21     21   static void updateVirtualTable(
    22     22     Parse *pParse,       /* The parsing context */
................................................................................
   645    645     assert( v );
   646    646     ephemTab = pParse->nTab++;
   647    647     sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0));
   648    648   
   649    649     /* fill the ephemeral table 
   650    650     */
   651    651     sqlite3SelectDestInit(&dest, SRT_Table, ephemTab);
   652         -  sqlite3Select(pParse, pSelect, &dest, 0, 0, 0, 0);
          652  +  sqlite3Select(pParse, pSelect, &dest, 0, 0, 0);
   653    653   
   654    654     /* Generate code to scan the ephemeral table and call VUpdate. */
   655    655     iReg = ++pParse->nMem;
   656    656     pParse->nMem += pTab->nCol+1;
   657    657     sqlite3VdbeAddOp2(v, OP_Rewind, ephemTab, 0);
   658    658     addr = sqlite3VdbeCurrentAddr(v);
   659    659     sqlite3VdbeAddOp3(v, OP_Column,  ephemTab, 0, iReg);

Changes to test/join.test.

     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.
    12     12   #
    13     13   # This file implements tests for joins, including outer joins.
    14     14   #
    15         -# $Id: join.test,v 1.22 2006/06/20 11:01:09 danielk1977 Exp $
           15  +# $Id: join.test,v 1.23 2008/07/08 23:40:20 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   do_test join-1.1 {
    21     21     execsql {
    22     22       CREATE TABLE t1(a,b,c);
................................................................................
   229    229     }
   230    230   } {1 {a NATURAL join may not have an ON or USING clause}}
   231    231   do_test join-3.3 {
   232    232     catchsql {
   233    233       SELECT * FROM t1 JOIN t2 ON t1.a=t2.b USING(b);
   234    234     }
   235    235   } {1 {cannot have both ON and USING clauses in the same join}}
   236         -do_test join-3.4 {
          236  +do_test join-3.4.1 {
   237    237     catchsql {
   238    238       SELECT * FROM t1 JOIN t2 USING(a);
   239    239     }
   240    240   } {1 {cannot join using column a - column not present in both tables}}
          241  +do_test join-3.4.2 {
          242  +  catchsql {
          243  +    SELECT * FROM t1 JOIN t2 USING(d);
          244  +  }
          245  +} {1 {cannot join using column d - column not present in both tables}}
   241    246   do_test join-3.5 {
   242    247     catchsql {
   243    248       SELECT * FROM t1 USING(a);
   244    249     }
   245    250   } {0 {1 2 3 2 3 4 3 4 5}}
   246    251   do_test join-3.6 {
   247    252     catchsql {
................................................................................
   249    254     }
   250    255   } {1 {no such column: t3.a}}
   251    256   do_test join-3.7 {
   252    257     catchsql {
   253    258       SELECT * FROM t1 INNER OUTER JOIN t2;
   254    259     }
   255    260   } {1 {unknown or unsupported join type: INNER OUTER}}
   256         -do_test join-3.7 {
          261  +do_test join-3.8 {
          262  +  catchsql {
          263  +    SELECT * FROM t1 INNER OUTER CROSS JOIN t2;
          264  +  }
          265  +} {1 {unknown or unsupported join type: INNER OUTER CROSS}}
          266  +do_test join-3.9 {
          267  +  catchsql {
          268  +    SELECT * FROM t1 OUTER NATURAL INNER JOIN t2;
          269  +  }
          270  +} {1 {unknown or unsupported join type: OUTER NATURAL INNER}}
          271  +do_test join-3.10 {
   257    272     catchsql {
   258    273       SELECT * FROM t1 LEFT BOGUS JOIN t2;
   259    274     }
   260    275   } {1 {unknown or unsupported join type: LEFT BOGUS}}
          276  +do_test join-3.11 {
          277  +  catchsql {
          278  +    SELECT * FROM t1 INNER BOGUS CROSS JOIN t2;
          279  +  }
          280  +} {1 {unknown or unsupported join type: INNER BOGUS CROSS}}
          281  +do_test join-3.12 {
          282  +  catchsql {
          283  +    SELECT * FROM t1 NATURAL AWK SED JOIN t2;
          284  +  }
          285  +} {1 {unknown or unsupported join type: NATURAL AWK SED}}
   261    286   
   262    287   do_test join-4.1 {
   263    288     execsql {
   264    289       BEGIN;
   265    290       CREATE TABLE t5(a INTEGER PRIMARY KEY);
   266    291       CREATE TABLE t6(a INTEGER);
   267    292       INSERT INTO t6 VALUES(NULL);