/ Check-in [c6bf62e4]
Login

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

Overview
Comment:The sqlite_complete() function should ignore carriage-return characters. (Oops - some unrelated edits also made it into this check-in.) (CVS 942)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c6bf62e41cf44e8ebf740b103204b00e8b826c90
User & Date: drh 2003-04-29 16:20:45
Context
2003-04-29
17:19
Allow the ASC or DESC keyword to appear after a column name in a CREATE INDEX statement. SQLite indices are aways ASC (ascending) regardless of which keyword is used. (CVS 943) check-in: 1a0c5420 user: drh tags: trunk
16:20
The sqlite_complete() function should ignore carriage-return characters. (Oops - some unrelated edits also made it into this check-in.) (CVS 942) check-in: c6bf62e4 user: drh tags: trunk
2003-04-26
13:19
In the test code, make several attempts to convert a pointer to a string and test each attempt to make sure it works before returnning, in order to work around incompatibilities between various systems. Ticket #284. (CVS 941) check-in: 333011ff user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **     PRAGMA
    25     25   **
    26         -** $Id: build.c,v 1.149 2003/04/22 20:30:38 drh Exp $
           26  +** $Id: build.c,v 1.150 2003/04/29 16:20:45 drh Exp $
    27     27   */
    28     28   #include "sqliteInt.h"
    29     29   #include <ctype.h>
    30     30   
    31     31   /*
    32     32   ** This routine is called when a new SQL statement is beginning to
    33     33   ** be parsed.  Check to see if the schema for the database needs
................................................................................
  1972   1972       if( *pz==0 ){
  1973   1973         sqliteSrcListDelete(pList);
  1974   1974         return 0;
  1975   1975       }else{
  1976   1976         sqliteDequote(*pz);
  1977   1977       }
  1978   1978     }
         1979  +  pList->a[pList->nSrc].iCursor = -1;
  1979   1980     pList->nSrc++;
  1980   1981     return pList;
  1981   1982   }
         1983  +
         1984  +/*
         1985  +** Assign cursors to all tables in a SrcList
         1986  +*/
         1987  +void sqliteSrcListAssignCursors(Parse *pParse, SrcList *pList){
         1988  +  int i;
         1989  +  for(i=0; i<pList->nSrc; i++){
         1990  +    if( pList->a[i].iCursor<0 ){
         1991  +      pList->a[i].iCursor = ++pParse->nTab;
         1992  +    }
         1993  +  }
         1994  +}
  1982   1995   
  1983   1996   /*
  1984   1997   ** Add an alias to the last identifier on the given identifier list.
  1985   1998   */
  1986   1999   void sqliteSrcListAddAlias(SrcList *pList, Token *pToken){
  1987   2000     if( pList && pList->nSrc>0 ){
  1988   2001       int i = pList->nSrc - 1;

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.128 2003/04/26 02:31:54 drh Exp $
           17  +** $Id: main.c,v 1.129 2003/04/29 16:20:46 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** A pointer to this structure is used to communicate information
................................................................................
   570    570         case ';': {
   571    571           isComplete = 1;
   572    572           seenText = 1;
   573    573           seenCreate = 0;
   574    574           break;
   575    575         }
   576    576         case ' ':
          577  +      case '\r':
   577    578         case '\t':
   578    579         case '\n':
   579    580         case '\f': {
   580    581           break;
   581    582         }
   582    583         case '[': {
   583    584           isComplete = 0;

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.134 2003/04/24 01:45:04 drh Exp $
           15  +** $Id: select.c,v 1.135 2003/04/29 16:20:46 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Allocate a new Select structure and return a pointer to that
    22     22   ** structure.
................................................................................
   855    855     return pTab;
   856    856   }
   857    857   
   858    858   /*
   859    859   ** For the given SELECT statement, do three things.
   860    860   **
   861    861   **    (1)  Fill in the pTabList->a[].pTab fields in the SrcList that 
   862         -**         defines the set of tables that should be scanned. 
          862  +**         defines the set of tables that should be scanned.  For views,
          863  +**         fill pTabList->a[].pSelect with a copy of the SELECT statement
          864  +**         that implements the view.  A copy is made of the view's SELECT
          865  +**         statement so that we can freely modify or delete that statement
          866  +**         without worrying about messing up the presistent representation
          867  +**         of the view.
   863    868   **
   864    869   **    (2)  Add terms to the WHERE clause to accomodate the NATURAL keyword
   865    870   **         on joins and the ON and USING clause of joins.
   866    871   **
   867    872   **    (3)  Scan the list of columns in the result set (pEList) looking
   868    873   **         for instances of the "*" operator or the TABLE.* operator.
   869    874   **         If found, expand each "*" to be every column in every table
................................................................................
   913    918         /* An ordinary table or view name in the FROM clause */
   914    919         pTabList->a[i].pTab = pTab = 
   915    920           sqliteLocateTable(pParse,pTabList->a[i].zName,pTabList->a[i].zDatabase);
   916    921         if( pTab==0 ){
   917    922           return 1;
   918    923         }
   919    924         if( pTab->pSelect ){
          925  +        /* We reach here if the named table is a really a view */
   920    926           if( sqliteViewGetColumnNames(pParse, pTab) ){
   921    927             return 1;
   922    928           }
   923         -        sqliteSelectDelete(pTabList->a[i].pSelect);
   924         -        pTabList->a[i].pSelect = sqliteSelectDup(pTab->pSelect);
          929  +        /* If pTabList->a[i].pSelect!=0 it means we are dealing with a
          930  +        ** view within a view.  The SELECT structure has already been
          931  +        ** copied by the outer view so we can skip the copy step here
          932  +        ** in the inner view.
          933  +        */
          934  +        if( pTabList->a[i].pSelect==0 ){
          935  +          pTabList->a[i].pSelect = sqliteSelectDup(pTab->pSelect);
          936  +        }
   925    937         }
   926    938       }
   927    939     }
   928    940   
   929    941     /* Process NATURAL keywords, and ON and USING clauses of joins.
   930    942     */
   931    943     if( sqliteProcessJoin(pParse, p) ) return 1;
................................................................................
  1628   1640     if( (pSub->isDistinct || pSub->nLimit>=0) &&  (pSrc->nSrc>1 || isAgg) ){
  1629   1641        return 0;
  1630   1642     }
  1631   1643     if( (p->isDistinct || p->nLimit>=0) && subqueryIsAgg ) return 0;
  1632   1644     if( p->pOrderBy && pSub->pOrderBy ) return 0;
  1633   1645   
  1634   1646     /* If we reach this point, it means flattening is permitted for the
  1635         -  ** i-th entry of the FROM clause in the outer query.
         1647  +  ** iFrom-th entry of the FROM clause in the outer query.
  1636   1648     */
  1637   1649     iParent = p->base + iFrom;
  1638   1650     iSub = pSub->base;
  1639   1651     substExprList(p->pEList, iParent, pSub->pEList, iSub);
  1640   1652     pList = p->pEList;
  1641   1653     for(i=0; i<pList->nExpr; i++){
  1642   1654       Expr *pExpr;

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.181 2003/04/25 17:52:11 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.182 2003/04/29 16:20:46 drh Exp $
    15     15   */
    16     16   #include "config.h"
    17     17   #include "sqlite.h"
    18     18   #include "hash.h"
    19     19   #include "vdbe.h"
    20     20   #include "parse.h"
    21     21   #include "btree.h"
................................................................................
   665    665     struct SrcList_item {
   666    666       char *zDatabase;  /* Name of database holding this table */
   667    667       char *zName;      /* Name of the table */
   668    668       char *zAlias;     /* The "B" part of a "A AS B" phrase.  zName is the "A" */
   669    669       Table *pTab;      /* An SQL table corresponding to zName */
   670    670       Select *pSelect;  /* A SELECT statement used in place of a table name */
   671    671       int jointype;     /* Type of join between this table and the next */
          672  +    int iCursor;      /* The VDBE cursor number used to access this table */
   672    673       Expr *pOn;        /* The ON clause of a join */
   673    674       IdList *pUsing;   /* The USING clause of a join */
   674    675     } a[1];             /* One entry for each identifier on the list */
   675    676   };
   676    677   
   677    678   /*
   678    679   ** Permitted values of the SrcList.a.jointype field