/ Check-in [258722b6]
Login

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

Overview
Comment:Fix an issue with the new sqlite3Strlen30() introduced by check-in (6007). Additional casts for compiler warnings. (CVS 6011)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 258722b6178f60eaccef1675aab3edc456d413a5
User & Date: drh 2008-12-10 22:15:00
Context
2008-12-10
22:18
The strlen30 function in tclsqlite.c should be defined regardless of whether or not the amalgamation is used. (CVS 6012) check-in: d8e8c7e5 user: drh tags: trunk
22:15
Fix an issue with the new sqlite3Strlen30() introduced by check-in (6007). Additional casts for compiler warnings. (CVS 6011) check-in: 258722b6 user: drh tags: trunk
21:19
Additional work at eliminating silly compiler warnings. (CVS 6010) check-in: ea01d437 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.513 2008/12/10 21:19:57 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.514 2008/12/10 22:15:00 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   
    26     26   /*
    27     27   ** Macros for troubleshooting.  Normally turned off
    28     28   */
................................................................................
   756    756   
   757    757     rc = read32bits(pPager->jfd, jrnlOff+16, (u32 *)&iPageSize);
   758    758     if( rc==SQLITE_OK 
   759    759      && iPageSize>=512 
   760    760      && iPageSize<=SQLITE_MAX_PAGE_SIZE 
   761    761      && ((iPageSize-1)&iPageSize)==0 
   762    762     ){
   763         -    u16 pagesize = iPageSize;
          763  +    u16 pagesize = (u16)iPageSize;
   764    764       rc = sqlite3PagerSetPagesize(pPager, &pagesize);
   765    765     }
   766    766     if( rc ) return rc;
   767    767   
   768    768     /* Update the assumed sector-size to match the value used by 
   769    769     ** the process that created this journal. If this journal was
   770    770     ** created by a process other than this one, then this routine
................................................................................
  1243   1243       char *zJournal;
  1244   1244       char *zMasterPtr = 0;
  1245   1245       int nMasterPtr = pPager->pVfs->mxPathname+1;
  1246   1246   
  1247   1247       /* Load the entire master journal file into space obtained from
  1248   1248       ** sqlite3_malloc() and pointed to by zMasterJournal. 
  1249   1249       */
  1250         -    zMasterJournal = (char *)sqlite3Malloc(nMasterJournal + nMasterPtr);
         1250  +    zMasterJournal = (char *)sqlite3Malloc((int)nMasterJournal + nMasterPtr);
  1251   1251       if( !zMasterJournal ){
  1252   1252         rc = SQLITE_NOMEM;
  1253   1253         goto delmaster_out;
  1254   1254       }
  1255   1255       zMasterPtr = &zMasterJournal[nMasterJournal];
  1256         -    rc = sqlite3OsRead(pMaster, zMasterJournal, nMasterJournal, 0);
         1256  +    rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);
  1257   1257       if( rc!=SQLITE_OK ) goto delmaster_out;
  1258   1258   
  1259   1259       zJournal = zMasterJournal;
  1260   1260       while( (zJournal-zMasterJournal)<nMasterJournal ){
  1261   1261         int exists;
  1262   1262         rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
  1263   1263         if( rc!=SQLITE_OK ){
................................................................................
  1472   1472       /* If nRec is 0xffffffff, then this journal was created by a process
  1473   1473       ** working in no-sync mode. This means that the rest of the journal
  1474   1474       ** file consists of pages, there are no more journal headers. Compute
  1475   1475       ** the value of nRec based on this assumption.
  1476   1476       */
  1477   1477       if( nRec==0xffffffff ){
  1478   1478         assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) );
  1479         -      nRec = (szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager);
         1479  +      nRec = (int)((szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager));
  1480   1480       }
  1481   1481   
  1482   1482       /* If nRec is 0 and this rollback is of a transaction created by this
  1483   1483       ** process and if this is the final header in the journal, then it means
  1484   1484       ** that this part of the journal was being filled but has not yet been
  1485   1485       ** synced to disk.  Compute the number of pages based on the remaining
  1486   1486       ** size of the file.
  1487   1487       **
  1488   1488       ** The third term of the test was added to fix ticket #2565.
  1489   1489       */
  1490   1490       if( nRec==0 && !isHot &&
  1491   1491           pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){
  1492         -      nRec = (szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager);
         1492  +      nRec = (int)((szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager));
  1493   1493       }
  1494   1494   
  1495   1495       /* If this is the first header read from the journal, truncate the
  1496   1496       ** database file back to its original size.
  1497   1497       */
  1498   1498       if( pPager->journalOff==JOURNAL_HDR_SZ(pPager) ){
  1499   1499         rc = pager_truncate(pPager, mxPg);
................................................................................
  1609   1609     ** everything after that needs to be rolled back, either into the
  1610   1610     ** database, the memory cache, or both.
  1611   1611     **
  1612   1612     ** If it is not zero, then Pager.stmtHdrOff is the offset to the start
  1613   1613     ** of the first journal header written during this statement transaction.
  1614   1614     */
  1615   1615     pPager->journalOff = pPager->stmtJSize;
  1616         -  pPager->cksumInit = pPager->stmtCksum;
         1616  +  pPager->cksumInit = (int)(pPager->stmtCksum & 0xffffffff);
  1617   1617     while( pPager->journalOff < hdrOff ){
  1618   1618       rc = pager_playback_one_page(pPager, pPager->jfd, pPager->journalOff, 1);
  1619   1619       assert( rc!=SQLITE_DONE );
  1620   1620       if( rc!=SQLITE_OK ) goto end_stmt_playback;
  1621   1621     }
  1622   1622   
  1623   1623     while( pPager->journalOff < szJ ){
................................................................................
  1625   1625       u32 dummy;
  1626   1626       rc = readJournalHdr(pPager, szJ, &nJRec, &dummy);
  1627   1627       if( rc!=SQLITE_OK ){
  1628   1628         assert( rc!=SQLITE_DONE );
  1629   1629         goto end_stmt_playback;
  1630   1630       }
  1631   1631       if( nJRec==0 ){
  1632         -      nJRec = (szJ - pPager->journalOff) / (pPager->pageSize+8);
         1632  +      nJRec = (int)((szJ - pPager->journalOff) / (pPager->pageSize+8));
  1633   1633       }
  1634   1634       for(i=nJRec-1; i>=0 && pPager->journalOff < szJ; i--){
  1635   1635         rc = pager_playback_one_page(pPager, pPager->jfd, pPager->journalOff, 1);
  1636   1636         assert( rc!=SQLITE_DONE );
  1637   1637         if( rc!=SQLITE_OK ) goto end_stmt_playback;
  1638   1638       }
  1639   1639     }
................................................................................
  1679   1679   **              point of causing damage to the database during rollback.
  1680   1680   **
  1681   1681   ** Numeric values associated with these states are OFF==1, NORMAL=2,
  1682   1682   ** and FULL=3.
  1683   1683   */
  1684   1684   #ifndef SQLITE_OMIT_PAGER_PRAGMAS
  1685   1685   void sqlite3PagerSetSafetyLevel(Pager *pPager, int level, int bFullFsync){
  1686         -  pPager->noSync =  level==1 || pPager->tempFile;
  1687         -  pPager->fullSync = level==3 && !pPager->tempFile;
         1686  +  pPager->noSync =  (level==1 || pPager->tempFile) ?1:0;
         1687  +  pPager->fullSync = (level==3 && !pPager->tempFile) ?1:0;
  1688   1688     pPager->sync_flags = (bFullFsync?SQLITE_SYNC_FULL:SQLITE_SYNC_NORMAL);
  1689   1689     if( pPager->noSync ) pPager->needSync = 0;
  1690   1690   }
  1691   1691   #endif
  1692   1692   
  1693   1693   /*
  1694   1694   ** The following global variable is incremented whenever the library
................................................................................
  1912   1912       memcpy(pPager->zJournal, pPager->zFilename, nPathname);
  1913   1913       memcpy(&pPager->zJournal[nPathname], "-journal", 9);
  1914   1914     }else{
  1915   1915       pPager->zJournal = 0;
  1916   1916     }
  1917   1917   
  1918   1918     /* pPager->journalOpen = 0; */
  1919         -  pPager->useJournal = useJournal;
  1920         -  pPager->noReadlock = noReadlock && readOnly;
         1919  +  pPager->useJournal = (u8)useJournal;
         1920  +  pPager->noReadlock = (noReadlock && readOnly) ?1:0;
  1921   1921     /* pPager->stmtOpen = 0; */
  1922   1922     /* pPager->stmtInUse = 0; */
  1923   1923     /* pPager->nRef = 0; */
  1924         -  pPager->dbSizeValid = memDb;
         1924  +  pPager->dbSizeValid = (u8)memDb;
  1925   1925     pPager->pageSize = szPageDflt;
  1926   1926     /* pPager->stmtSize = 0; */
  1927   1927     /* pPager->stmtJSize = 0; */
  1928   1928     /* pPager->nPage = 0; */
  1929   1929     pPager->mxPage = 100;
  1930   1930     pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;
  1931   1931     /* pPager->state = PAGER_UNLOCK; */
  1932   1932     assert( pPager->state == (tempFile ? PAGER_EXCLUSIVE : PAGER_UNLOCK) );
  1933   1933     /* pPager->errMask = 0; */
  1934         -  pPager->tempFile = tempFile;
         1934  +  pPager->tempFile = (u8)tempFile;
  1935   1935     assert( tempFile==PAGER_LOCKINGMODE_NORMAL 
  1936   1936             || tempFile==PAGER_LOCKINGMODE_EXCLUSIVE );
  1937   1937     assert( PAGER_LOCKINGMODE_EXCLUSIVE==1 );
  1938         -  pPager->exclusiveMode = tempFile; 
  1939         -  pPager->memDb = memDb;
  1940         -  pPager->readOnly = readOnly;
         1938  +  pPager->exclusiveMode = (u8)tempFile; 
         1939  +  pPager->memDb = (u8)memDb;
         1940  +  pPager->readOnly = (u8)readOnly;
  1941   1941     /* pPager->needSync = 0; */
  1942         -  pPager->noSync = pPager->tempFile || !useJournal;
  1943         -  pPager->fullSync = (pPager->noSync?0:1);
         1942  +  pPager->noSync = (pPager->tempFile || !useJournal) ?1:0;
         1943  +  pPager->fullSync = pPager->noSync ?0:1;
  1944   1944     pPager->sync_flags = SQLITE_SYNC_NORMAL;
  1945   1945     /* pPager->pFirst = 0; */
  1946   1946     /* pPager->pFirstSynced = 0; */
  1947   1947     /* pPager->pLast = 0; */
  1948   1948     pPager->nExtra = nExtra;
  1949   1949     pPager->journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT;
  1950   1950     assert(pPager->fd->pMethods||tempFile);
................................................................................
  2004   2004           pPager->pageSize = pageSize;
  2005   2005           if( !pPager->memDb ) setSectorSize(pPager);
  2006   2006           sqlite3PageFree(pPager->pTmpSpace);
  2007   2007           pPager->pTmpSpace = pNew;
  2008   2008           sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);
  2009   2009         }
  2010   2010       }
  2011         -    *pPageSize = pPager->pageSize;
         2011  +    *pPageSize = (u16)pPager->pageSize;
  2012   2012     }
  2013   2013     return rc;
  2014   2014   }
  2015   2015   
  2016   2016   /*
  2017   2017   ** Return a pointer to the "temporary page" buffer held internally
  2018   2018   ** by the pager.  This is a buffer that is big enough to hold the
................................................................................
  2116   2116       }
  2117   2117       if( n>0 && n<pPager->pageSize ){
  2118   2118         n = 1;
  2119   2119       }else{
  2120   2120         n /= pPager->pageSize;
  2121   2121       }
  2122   2122       if( pPager->state!=PAGER_UNLOCK ){
  2123         -      pPager->dbSize = n;
         2123  +      pPager->dbSize = (int)n;
  2124   2124         pPager->dbSizeValid = 1;
  2125   2125       }
  2126   2126     }
  2127   2127     if( n==(PENDING_BYTE/pPager->pageSize) ){
  2128   2128       n++;
  2129   2129     }
  2130   2130     if( n>pPager->mxPgno ){
  2131         -    pPager->mxPgno = n;
         2131  +    pPager->mxPgno = (Pgno)n;
  2132   2132     }
  2133   2133     if( pnPage ){
  2134         -    *pnPage = n;
         2134  +    *pnPage = (int)n;
  2135   2135     }
  2136   2136     return SQLITE_OK;
  2137   2137   }
  2138   2138   
  2139   2139   /*
  2140   2140   ** Forward declaration
  2141   2141   */
................................................................................
  2179   2179     if( pPager->state>=locktype ){
  2180   2180       rc = SQLITE_OK;
  2181   2181     }else{
  2182   2182       do {
  2183   2183         rc = sqlite3OsLock(pPager->fd, locktype);
  2184   2184       }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );
  2185   2185       if( rc==SQLITE_OK ){
  2186         -      pPager->state = locktype;
         2186  +      pPager->state = (u8)locktype;
  2187   2187         IOTRACE(("LOCK %p %d\n", pPager, locktype))
  2188   2188       }
  2189   2189     }
  2190   2190     return rc;
  2191   2191   }
  2192   2192   
  2193   2193   /*
................................................................................
  2590   2590     */
  2591   2591     if( pPager->errCode && pPager->errCode!=SQLITE_FULL ){
  2592   2592       return pPager->errCode;
  2593   2593     }
  2594   2594   
  2595   2595     if( pPager->state==PAGER_UNLOCK || isErrorReset ){
  2596   2596       sqlite3_vfs *pVfs = pPager->pVfs;
  2597         -    int isHotJournal;
         2597  +    int isHotJournal = 0;
  2598   2598       assert( !MEMDB );
  2599   2599       assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );
  2600   2600       if( !pPager->noReadlock ){
  2601   2601         rc = pager_wait_on_lock(pPager, SHARED_LOCK);
  2602   2602         if( rc!=SQLITE_OK ){
  2603   2603           assert( pPager->state==PAGER_UNLOCK );
  2604   2604           return pager_error(pPager, rc);

Changes to src/pragma.c.

     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   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.197 2008/12/10 19:26:24 drh Exp $
           14  +** $Id: pragma.c,v 1.198 2008/12/10 22:15:00 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <ctype.h>
    18     18   
    19     19   /* Ignore this whole file if pragmas are disabled
    20     20   */
    21     21   #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
................................................................................
    26     26   ** unrecognized string argument.
    27     27   **
    28     28   ** Note that the values returned are one less that the values that
    29     29   ** should be passed into sqlite3BtreeSetSafetyLevel().  The is done
    30     30   ** to support legacy SQL code.  The safety level used to be boolean
    31     31   ** and older scripts may have used numbers 0 for OFF and 1 for ON.
    32     32   */
    33         -static int getSafetyLevel(const char *z){
           33  +static u8 getSafetyLevel(const char *z){
    34     34                                /* 123456789 123456789 */
    35     35     static const char zText[] = "onoffalseyestruefull";
    36     36     static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16};
    37     37     static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};
    38     38     static const u8 iValue[] =  {1, 0, 0, 0, 1, 1, 2};
    39     39     int i, n;
    40     40     if( isdigit(*z) ){
................................................................................
    48     48     }
    49     49     return 1;
    50     50   }
    51     51   
    52     52   /*
    53     53   ** Interpret the given string as a boolean value.
    54     54   */
    55         -static int getBoolean(const char *z){
           55  +static u8 getBoolean(const char *z){
    56     56     return getSafetyLevel(z)&1;
    57     57   }
    58     58   
    59     59   /*
    60     60   ** Interpret the given string as a locking mode value.
    61     61   */
    62     62   static int getLockingMode(const char *z){
................................................................................
    76     76   */
    77     77   static int getAutoVacuum(const char *z){
    78     78     int i;
    79     79     if( 0==sqlite3StrICmp(z, "none") ) return BTREE_AUTOVACUUM_NONE;
    80     80     if( 0==sqlite3StrICmp(z, "full") ) return BTREE_AUTOVACUUM_FULL;
    81     81     if( 0==sqlite3StrICmp(z, "incremental") ) return BTREE_AUTOVACUUM_INCR;
    82     82     i = atoi(z);
    83         -  return ((i>=0&&i<=2)?i:0);
           83  +  return (u8)((i>=0&&i<=2)?i:0);
    84     84   }
    85     85   #endif /* ifndef SQLITE_OMIT_AUTOVACUUM */
    86     86   
    87     87   #ifndef SQLITE_OMIT_PAGER_PRAGMAS
    88     88   /*
    89     89   ** Interpret the given string as a temp db location. Return 1 for file
    90     90   ** backed temporary databases, 2 for the Red-Black tree in memory database
................................................................................
   133    133   static int changeTempStorage(Parse *pParse, const char *zStorageType){
   134    134     int ts = getTempStore(zStorageType);
   135    135     sqlite3 *db = pParse->db;
   136    136     if( db->temp_store==ts ) return SQLITE_OK;
   137    137     if( invalidateTempStorage( pParse ) != SQLITE_OK ){
   138    138       return SQLITE_ERROR;
   139    139     }
   140         -  db->temp_store = ts;
          140  +  db->temp_store = (u8)ts;
   141    141     return SQLITE_OK;
   142    142   }
   143    143   #endif /* SQLITE_PAGER_PRAGMAS */
   144    144   
   145    145   /*
   146    146   ** Generate code to return a single integer value.
   147    147   */
................................................................................
   431    431           */
   432    432           int ii;
   433    433           assert(pDb==&db->aDb[0]);
   434    434           for(ii=2; ii<db->nDb; ii++){
   435    435             pPager = sqlite3BtreePager(db->aDb[ii].pBt);
   436    436             sqlite3PagerLockingMode(pPager, eMode);
   437    437           }
   438         -        db->dfltLockMode = eMode;
          438  +        db->dfltLockMode = (u8)eMode;
   439    439         }
   440    440         pPager = sqlite3BtreePager(pDb->pBt);
   441    441         eMode = sqlite3PagerLockingMode(pPager, eMode);
   442    442       }
   443    443   
   444    444       assert(eMode==PAGER_LOCKINGMODE_NORMAL||eMode==PAGER_LOCKINGMODE_EXCLUSIVE);
   445    445       if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){
................................................................................
   491    491           assert(pDb==&db->aDb[0]);
   492    492           for(ii=1; ii<db->nDb; ii++){
   493    493             if( db->aDb[ii].pBt ){
   494    494               pPager = sqlite3BtreePager(db->aDb[ii].pBt);
   495    495               sqlite3PagerJournalMode(pPager, eMode);
   496    496             }
   497    497           }
   498         -        db->dfltJournalMode = eMode;
          498  +        db->dfltJournalMode = (u8)eMode;
   499    499         }
   500    500         pPager = sqlite3BtreePager(pDb->pBt);
   501    501         eMode = sqlite3PagerJournalMode(pPager, eMode);
   502    502       }
   503    503       assert( eMode==PAGER_JOURNALMODE_DELETE
   504    504                 || eMode==PAGER_JOURNALMODE_TRUNCATE
   505    505                 || eMode==PAGER_JOURNALMODE_PERSIST
................................................................................
   548    548       }
   549    549       if( !zRight ){
   550    550         int auto_vacuum = 
   551    551             pBt ? sqlite3BtreeGetAutoVacuum(pBt) : SQLITE_DEFAULT_AUTOVACUUM;
   552    552         returnSingleInt(pParse, "auto_vacuum", auto_vacuum);
   553    553       }else{
   554    554         int eAuto = getAutoVacuum(zRight);
   555         -      db->nextAutovac = eAuto;
          555  +      db->nextAutovac = (u8)eAuto;
   556    556         if( eAuto>=0 ){
   557    557           /* Call SetAutoVacuum() to set initialize the internal auto and
   558    558           ** incr-vacuum flags. This is required in case this connection
   559    559           ** creates the database file. It is important that it is created
   560    560           ** as an auto-vacuum capable db.
   561    561           */
   562    562           int rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
................................................................................
  1059   1059         /* Make sure sufficient number of registers have been allocated */
  1060   1060         if( pParse->nMem < cnt+4 ){
  1061   1061           pParse->nMem = cnt+4;
  1062   1062         }
  1063   1063   
  1064   1064         /* Do the b-tree integrity checks */
  1065   1065         sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);
  1066         -      sqlite3VdbeChangeP5(v, i);
         1066  +      sqlite3VdbeChangeP5(v, (u8)i);
  1067   1067         addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);
  1068   1068         sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
  1069   1069            sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName),
  1070   1070            P4_DYNAMIC);
  1071   1071         sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1);
  1072   1072         sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2);
  1073   1073         sqlite3VdbeAddOp2(v, OP_ResultRow, 2, 1);

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.493 2008/12/10 19:26:24 drh Exp $
           15  +** $Id: select.c,v 1.494 2008/12/10 22:15:00 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.
................................................................................
  2918   2918   ** a min()/max() query if:
  2919   2919   **
  2920   2920   **   1. There is a single object in the FROM clause.
  2921   2921   **
  2922   2922   **   2. There is a single expression in the result set, and it is
  2923   2923   **      either min(x) or max(x), where x is a column reference.
  2924   2924   */
  2925         -static int minMaxQuery(Select *p){
         2925  +static u8 minMaxQuery(Select *p){
  2926   2926     Expr *pExpr;
  2927   2927     ExprList *pEList = p->pEList;
  2928   2928   
  2929   2929     if( pEList->nExpr!=1 ) return WHERE_ORDERBY_NORMAL;
  2930   2930     pExpr = pEList->a[0].pExpr;
  2931   2931     pEList = pExpr->pList;
  2932   2932     if( pExpr->op!=TK_AGG_FUNCTION || pEList==0 || pEList->nExpr!=1 ) return 0;

Changes to src/shell.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 code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.192 2008/12/10 19:26:24 drh Exp $
           15  +** $Id: shell.c,v 1.193 2008/12/10 22:15:00 drh Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include <assert.h>
    21     21   #include "sqlite3.h"
    22     22   #include <ctype.h>
................................................................................
   362    362   */
   363    363   #define ArraySize(X)  (int)(sizeof(X)/sizeof(X[0]))
   364    364   
   365    365   /*
   366    366   ** Compute a string length that is limited to what can be stored in
   367    367   ** lower 30 bits of a 32-bit signed integer.
   368    368   */
   369         -int sqlite3Strlen30(const char *z){
          369  +static int strlen30(const char *z){
   370    370     const char *z2 = z;
   371    371     while( *z2 ){ z2++; }
   372    372     return 0x3fffffff & (int)(z2 - z);
   373    373   }
   374    374   
   375    375   /*
   376    376   ** Output the given string as a quoted string using SQL quoting conventions.
................................................................................
   483    483   */
   484    484   static void output_csv(struct callback_data *p, const char *z, int bSep){
   485    485     FILE *out = p->out;
   486    486     if( z==0 ){
   487    487       fprintf(out,"%s",p->nullvalue);
   488    488     }else{
   489    489       int i;
   490         -    int nSep = sqlite3Strlen30(p->separator);
          490  +    int nSep = strlen30(p->separator);
   491    491       for(i=0; z[i]; i++){
   492    492         if( needCsvQuote[((unsigned char*)z)[i]] 
   493    493            || (z[i]==p->separator[0] && 
   494    494                (nSep==1 || memcmp(z, p->separator, nSep)==0)) ){
   495    495           i = 0;
   496    496           break;
   497    497         }
................................................................................
   531    531     int i;
   532    532     struct callback_data *p = (struct callback_data*)pArg;
   533    533     switch( p->mode ){
   534    534       case MODE_Line: {
   535    535         int w = 5;
   536    536         if( azArg==0 ) break;
   537    537         for(i=0; i<nArg; i++){
   538         -        int len = sqlite3Strlen30(azCol[i] ? azCol[i] : "");
          538  +        int len = strlen30(azCol[i] ? azCol[i] : "");
   539    539           if( len>w ) w = len;
   540    540         }
   541    541         if( p->cnt++>0 ) fprintf(p->out,"\n");
   542    542         for(i=0; i<nArg; i++){
   543    543           fprintf(p->out,"%*s = %s\n", w, azCol[i],
   544    544                   azArg[i] ? azArg[i] : p->nullvalue);
   545    545         }
................................................................................
   552    552             int w, n;
   553    553             if( i<ArraySize(p->colWidth) ){
   554    554               w = p->colWidth[i];
   555    555             }else{
   556    556               w = 0;
   557    557             }
   558    558             if( w<=0 ){
   559         -            w = sqlite3Strlen30(azCol[i] ? azCol[i] : "");
          559  +            w = strlen30(azCol[i] ? azCol[i] : "");
   560    560               if( w<10 ) w = 10;
   561         -            n = sqlite3Strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);
          561  +            n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);
   562    562               if( w<n ) w = n;
   563    563             }
   564    564             if( i<ArraySize(p->actualWidth) ){
   565    565               p->actualWidth[i] = w;
   566    566             }
   567    567             if( p->showHeader ){
   568    568               fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": "  ");
................................................................................
   587    587           int w;
   588    588           if( i<ArraySize(p->actualWidth) ){
   589    589              w = p->actualWidth[i];
   590    590           }else{
   591    591              w = 10;
   592    592           }
   593    593           if( p->mode==MODE_Explain && azArg[i] && 
   594         -           sqlite3Strlen30(azArg[i])>w ){
   595         -          w = sqlite3Strlen30(azArg[i]);
          594  +           strlen30(azArg[i])>w ){
          595  +          w = strlen30(azArg[i]);
   596    596           }
   597    597           fprintf(p->out,"%-*.*s%s",w,w,
   598    598               azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": "  ");
   599    599         }
   600    600         break;
   601    601       }
   602    602       case MODE_Semi:
................................................................................
   735    735   **
   736    736   ** If the third argument, quote, is not '\0', then it is used as a 
   737    737   ** quote character for zAppend.
   738    738   */
   739    739   static char *appendText(char *zIn, char const *zAppend, char quote){
   740    740     int len;
   741    741     int i;
   742         -  int nAppend = sqlite3Strlen30(zAppend);
   743         -  int nIn = (zIn?sqlite3Strlen30(zIn):0);
          742  +  int nAppend = strlen30(zAppend);
          743  +  int nIn = (zIn?strlen30(zIn):0);
   744    744   
   745    745     len = nAppend+nIn+1;
   746    746     if( quote ){
   747    747       len += 2;
   748    748       for(i=0; i<nAppend; i++){
   749    749         if( zAppend[i]==quote ) len++;
   750    750       }
................................................................................
   903    903     const char *zQuery,
   904    904     char **pzErrMsg
   905    905   ){
   906    906     int rc;
   907    907     rc = sqlite3_exec(p->db, zQuery, dump_callback, p, pzErrMsg);
   908    908     if( rc==SQLITE_CORRUPT ){
   909    909       char *zQ2;
   910         -    int len = sqlite3Strlen30(zQuery);
          910  +    int len = strlen30(zQuery);
   911    911       if( pzErrMsg ) sqlite3_free(*pzErrMsg);
   912    912       zQ2 = malloc( len+100 );
   913    913       if( zQ2==0 ) return rc;
   914    914       sqlite3_snprintf(sizeof(zQ2), zQ2, "%s ORDER BY rowid DESC", zQuery);
   915    915       rc = sqlite3_exec(p->db, zQ2, dump_callback, p, pzErrMsg);
   916    916       free(zQ2);
   917    917     }
................................................................................
  1077   1077         resolve_backslashes(azArg[nArg-1]);
  1078   1078       }
  1079   1079     }
  1080   1080   
  1081   1081     /* Process the input line.
  1082   1082     */
  1083   1083     if( nArg==0 ) return rc;
  1084         -  n = sqlite3Strlen30(azArg[0]);
         1084  +  n = strlen30(azArg[0]);
  1085   1085     c = azArg[0][0];
  1086   1086     if( c=='b' && n>1 && strncmp(azArg[0], "bail", n)==0 && nArg>1 ){
  1087   1087       bail_on_error = booleanValue(azArg[1]);
  1088   1088     }else
  1089   1089   
  1090   1090     if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 ){
  1091   1091       struct callback_data data;
................................................................................
  1215   1215       char *zLine;                /* A single line of input from the file */
  1216   1216       char **azCol;               /* zLine[] broken up into columns */
  1217   1217       char *zCommit;              /* How to commit changes */   
  1218   1218       FILE *in;                   /* The input file */
  1219   1219       int lineno = 0;             /* Line number of input file */
  1220   1220   
  1221   1221       open_db(p);
  1222         -    nSep = sqlite3Strlen30(p->separator);
         1222  +    nSep = strlen30(p->separator);
  1223   1223       if( nSep==0 ){
  1224   1224         fprintf(stderr, "non-null separator required for import\n");
  1225   1225         return 0;
  1226   1226       }
  1227   1227       zSql = sqlite3_mprintf("SELECT * FROM '%q'", zTable);
  1228   1228       if( zSql==0 ) return 0;
  1229         -    nByte = sqlite3Strlen30(zSql);
         1229  +    nByte = strlen30(zSql);
  1230   1230       rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
  1231   1231       sqlite3_free(zSql);
  1232   1232       if( rc ){
  1233   1233         fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
  1234   1234         nCol = 0;
  1235   1235         rc = 1;
  1236   1236       }else{
................................................................................
  1237   1237         nCol = sqlite3_column_count(pStmt);
  1238   1238       }
  1239   1239       sqlite3_finalize(pStmt);
  1240   1240       if( nCol==0 ) return 0;
  1241   1241       zSql = malloc( nByte + 20 + nCol*2 );
  1242   1242       if( zSql==0 ) return 0;
  1243   1243       sqlite3_snprintf(nByte+20, zSql, "INSERT INTO '%q' VALUES(?", zTable);
  1244         -    j = sqlite3Strlen30(zSql);
         1244  +    j = strlen30(zSql);
  1245   1245       for(i=1; i<nCol; i++){
  1246   1246         zSql[j++] = ',';
  1247   1247         zSql[j++] = '?';
  1248   1248       }
  1249   1249       zSql[j++] = ')';
  1250   1250       zSql[j] = 0;
  1251   1251       rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
................................................................................
  1370   1370         sqlite3_free(zErrMsg);
  1371   1371         rc = 1;
  1372   1372       }
  1373   1373     }else
  1374   1374   #endif
  1375   1375   
  1376   1376     if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg>=2 ){
  1377         -    int n2 = sqlite3Strlen30(azArg[1]);
         1377  +    int n2 = strlen30(azArg[1]);
  1378   1378       if( strncmp(azArg[1],"line",n2)==0
  1379   1379           ||
  1380   1380           strncmp(azArg[1],"lines",n2)==0 ){
  1381   1381         p->mode = MODE_Line;
  1382   1382       }else if( strncmp(azArg[1],"column",n2)==0
  1383   1383                 ||
  1384   1384                 strncmp(azArg[1],"columns",n2)==0 ){
................................................................................
  1528   1528       fprintf(p->out,"%9.9s: %s\n","explain", p->explainPrev.valid ? "on" :"off");
  1529   1529       fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off");
  1530   1530       fprintf(p->out,"%9.9s: %s\n","mode", modeDescr[p->mode]);
  1531   1531       fprintf(p->out,"%9.9s: ", "nullvalue");
  1532   1532         output_c_string(p->out, p->nullvalue);
  1533   1533         fprintf(p->out, "\n");
  1534   1534       fprintf(p->out,"%9.9s: %s\n","output",
  1535         -            sqlite3Strlen30(p->outfile) ? p->outfile : "stdout");
         1535  +            strlen30(p->outfile) ? p->outfile : "stdout");
  1536   1536       fprintf(p->out,"%9.9s: ", "separator");
  1537   1537         output_c_string(p->out, p->separator);
  1538   1538         fprintf(p->out, "\n");
  1539   1539       fprintf(p->out,"%9.9s: ","width");
  1540   1540       for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {
  1541   1541         fprintf(p->out,"%d ",p->colWidth[i]);
  1542   1542       }
................................................................................
  1577   1577       }
  1578   1578       if( rc==SQLITE_OK ){
  1579   1579         int len, maxlen = 0;
  1580   1580         int i, j;
  1581   1581         int nPrintCol, nPrintRow;
  1582   1582         for(i=1; i<=nRow; i++){
  1583   1583           if( azResult[i]==0 ) continue;
  1584         -        len = sqlite3Strlen30(azResult[i]);
         1584  +        len = strlen30(azResult[i]);
  1585   1585           if( len>maxlen ) maxlen = len;
  1586   1586         }
  1587   1587         nPrintCol = 80/(maxlen+2);
  1588   1588         if( nPrintCol<1 ) nPrintCol = 1;
  1589   1589         nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
  1590   1590         for(i=0; i<nPrintRow; i++){
  1591   1591           for(j=i+1; j<=nRow; j+=nPrintRow){
................................................................................
  1724   1724         memcpy(zLine,";",2);
  1725   1725       }
  1726   1726       nSqlPrior = nSql;
  1727   1727       if( zSql==0 ){
  1728   1728         int i;
  1729   1729         for(i=0; zLine[i] && isspace((unsigned char)zLine[i]); i++){}
  1730   1730         if( zLine[i]!=0 ){
  1731         -        nSql = sqlite3Strlen30(zLine);
         1731  +        nSql = strlen30(zLine);
  1732   1732           zSql = malloc( nSql+1 );
  1733   1733           if( zSql==0 ){
  1734   1734             fprintf(stderr, "out of memory\n");
  1735   1735             exit(1);
  1736   1736           }
  1737   1737           memcpy(zSql, zLine, nSql+1);
  1738   1738           startline = lineno;
  1739   1739         }
  1740   1740       }else{
  1741         -      int len = sqlite3Strlen30(zLine);
         1741  +      int len = strlen30(zLine);
  1742   1742         zSql = realloc( zSql, nSql + len + 2 );
  1743   1743         if( zSql==0 ){
  1744   1744           fprintf(stderr,"%s: out of memory!\n", Argv0);
  1745   1745           exit(1);
  1746   1746         }
  1747   1747         zSql[nSql++] = '\n';
  1748   1748         memcpy(&zSql[nSql], zLine, len+1);
................................................................................
  1821   1821   #if defined(_WIN32) || defined(WIN32) || defined(__OS2__)
  1822   1822     if (!home_dir) {
  1823   1823       char *zDrive, *zPath;
  1824   1824       int n;
  1825   1825       zDrive = getenv("HOMEDRIVE");
  1826   1826       zPath = getenv("HOMEPATH");
  1827   1827       if( zDrive && zPath ){
  1828         -      n = sqlite3Strlen30(zDrive) + sqlite3Strlen30(zPath) + 1;
         1828  +      n = strlen30(zDrive) + strlen30(zPath) + 1;
  1829   1829         home_dir = malloc( n );
  1830   1830         if( home_dir==0 ) return 0;
  1831   1831         sqlite3_snprintf(n, home_dir, "%s%s", zDrive, zPath);
  1832   1832         return home_dir;
  1833   1833       }
  1834   1834       home_dir = "c:\\";
  1835   1835     }
  1836   1836   #endif
  1837   1837   
  1838   1838   #endif /* !_WIN32_WCE */
  1839   1839   
  1840   1840     if( home_dir ){
  1841         -    int n = sqlite3Strlen30(home_dir) + 1;
         1841  +    int n = strlen30(home_dir) + 1;
  1842   1842       char *z = malloc( n );
  1843   1843       if( z ) memcpy(z, home_dir, n);
  1844   1844       home_dir = z;
  1845   1845     }
  1846   1846   
  1847   1847     return home_dir;
  1848   1848   }
................................................................................
  1865   1865       home_dir = find_home_dir();
  1866   1866       if( home_dir==0 ){
  1867   1867   #if !defined(__RTP__) && !defined(_WRS_KERNEL)
  1868   1868         fprintf(stderr,"%s: cannot locate your home directory!\n", Argv0);
  1869   1869   #endif
  1870   1870         return;
  1871   1871       }
  1872         -    nBuf = sqlite3Strlen30(home_dir) + 16;
         1872  +    nBuf = strlen30(home_dir) + 16;
  1873   1873       zBuf = malloc( nBuf );
  1874   1874       if( zBuf==0 ){
  1875   1875         fprintf(stderr,"%s: out of memory!\n", Argv0);
  1876   1876         exit(1);
  1877   1877       }
  1878   1878       sqlite3_snprintf(nBuf, zBuf,"%s/.sqliterc",home_dir);
  1879   1879       free(home_dir);
................................................................................
  2089   2089           "SQLite version %s\n"
  2090   2090           "Enter \".help\" for instructions\n"
  2091   2091           "Enter SQL statements terminated with a \";\"\n",
  2092   2092           sqlite3_libversion()
  2093   2093         );
  2094   2094         zHome = find_home_dir();
  2095   2095         if( zHome ){
  2096         -        nHistory = sqlite3Strlen30(zHome) + 20;
         2096  +        nHistory = strlen30(zHome) + 20;
  2097   2097           if( (zHistory = malloc(nHistory))!=0 ){
  2098   2098             sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
  2099   2099           }
  2100   2100         }
  2101   2101   #if defined(HAVE_READLINE) && HAVE_READLINE==1
  2102   2102         if( zHistory ) read_history(zHistory);
  2103   2103   #endif

Changes to src/tclsqlite.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   ** A TCL Interface to SQLite.  Append this file to sqlite3.c and
    13     13   ** compile the whole thing to build a TCL-enabled version of SQLite.
    14     14   **
    15         -** $Id: tclsqlite.c,v 1.229 2008/12/10 19:26:24 drh Exp $
           15  +** $Id: tclsqlite.c,v 1.230 2008/12/10 22:15:00 drh Exp $
    16     16   */
    17     17   #include "tcl.h"
    18     18   #include <errno.h>
    19     19   
    20     20   /*
    21     21   ** Some additional include files are needed if this file is not
    22     22   ** appended to the amalgamation.
................................................................................
   130    130   };
   131    131   
   132    132   #ifndef SQLITE_AMALGAMATION
   133    133   /*
   134    134   ** Compute a string length that is limited to what can be stored in
   135    135   ** lower 30 bits of a 32-bit signed integer.
   136    136   */
   137         -int sqlite3Strlen30(const char *z){
          137  +static int strlen30(const char *z){
   138    138     const char *z2 = z;
   139    139     while( *z2 ){ z2++; }
   140    140     return 0x3fffffff & (int)(z2 - z);
   141    141   }
   142    142   #endif
   143    143   
   144    144   
................................................................................
   393    393   ** Find an SqlFunc structure with the given name.  Or create a new
   394    394   ** one if an existing one cannot be found.  Return a pointer to the
   395    395   ** structure.
   396    396   */
   397    397   static SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){
   398    398     SqlFunc *p, *pNew;
   399    399     int i;
   400         -  pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + sqlite3Strlen30(zName) + 1 );
          400  +  pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + strlen30(zName) + 1 );
   401    401     pNew->zName = (char*)&pNew[1];
   402    402     for(i=0; zName[i]; i++){ pNew->zName[i] = tolower(zName[i]); }
   403    403     pNew->zName[i] = 0;
   404    404     for(p=pDb->pFunc; p; p=p->pNext){ 
   405    405       if( strcmp(p->zName, pNew->zName)==0 ){
   406    406         Tcl_Free((char*)pNew);
   407    407         return p;
................................................................................
  1348   1348         zNull = Tcl_GetStringFromObj(objv[6], 0);
  1349   1349       }else{
  1350   1350         zNull = "";
  1351   1351       }
  1352   1352       zConflict = Tcl_GetStringFromObj(objv[2], 0);
  1353   1353       zTable = Tcl_GetStringFromObj(objv[3], 0);
  1354   1354       zFile = Tcl_GetStringFromObj(objv[4], 0);
  1355         -    nSep = sqlite3Strlen30(zSep);
  1356         -    nNull = sqlite3Strlen30(zNull);
         1355  +    nSep = strlen30(zSep);
         1356  +    nNull = strlen30(zNull);
  1357   1357       if( nSep==0 ){
  1358   1358         Tcl_AppendResult(interp,"Error: non-null separator required for copy",0);
  1359   1359         return TCL_ERROR;
  1360   1360       }
  1361   1361       if(strcmp(zConflict, "rollback") != 0 &&
  1362   1362          strcmp(zConflict, "abort"   ) != 0 &&
  1363   1363          strcmp(zConflict, "fail"    ) != 0 &&
................................................................................
  1369   1369         return TCL_ERROR;
  1370   1370       }
  1371   1371       zSql = sqlite3_mprintf("SELECT * FROM '%q'", zTable);
  1372   1372       if( zSql==0 ){
  1373   1373         Tcl_AppendResult(interp, "Error: no such table: ", zTable, 0);
  1374   1374         return TCL_ERROR;
  1375   1375       }
  1376         -    nByte = sqlite3Strlen30(zSql);
         1376  +    nByte = strlen30(zSql);
  1377   1377       rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0);
  1378   1378       sqlite3_free(zSql);
  1379   1379       if( rc ){
  1380   1380         Tcl_AppendResult(interp, "Error: ", sqlite3_errmsg(pDb->db), 0);
  1381   1381         nCol = 0;
  1382   1382       }else{
  1383   1383         nCol = sqlite3_column_count(pStmt);
................................................................................
  1389   1389       zSql = malloc( nByte + 50 + nCol*2 );
  1390   1390       if( zSql==0 ) {
  1391   1391         Tcl_AppendResult(interp, "Error: can't malloc()", 0);
  1392   1392         return TCL_ERROR;
  1393   1393       }
  1394   1394       sqlite3_snprintf(nByte+50, zSql, "INSERT OR %q INTO '%q' VALUES(?",
  1395   1395            zConflict, zTable);
  1396         -    j = sqlite3Strlen30(zSql);
         1396  +    j = strlen30(zSql);
  1397   1397       for(i=1; i<nCol; i++){
  1398   1398         zSql[j++] = ',';
  1399   1399         zSql[j++] = '?';
  1400   1400       }
  1401   1401       zSql[j++] = ')';
  1402   1402       zSql[j] = 0;
  1403   1403       rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0);
................................................................................
  1434   1434               azCol[i] = &z[nSep];
  1435   1435               z += nSep-1;
  1436   1436             }
  1437   1437           }
  1438   1438         }
  1439   1439         if( i+1!=nCol ){
  1440   1440           char *zErr;
  1441         -        int nErr = sqlite3Strlen30(zFile) + 200;
         1441  +        int nErr = strlen30(zFile) + 200;
  1442   1442           zErr = malloc(nErr);
  1443   1443           if( zErr ){
  1444   1444             sqlite3_snprintf(nErr, zErr,
  1445   1445                "Error: %s line %d: expected %d columns of data but found %d",
  1446   1446                zFile, lineno, nCol, i+1);
  1447   1447             Tcl_AppendResult(interp, zErr, 0);
  1448   1448             free(zErr);
................................................................................
  1449   1449           }
  1450   1450           zCommit = "ROLLBACK";
  1451   1451           break;
  1452   1452         }
  1453   1453         for(i=0; i<nCol; i++){
  1454   1454           /* check for null data, if so, bind as null */
  1455   1455           if( (nNull>0 && strcmp(azCol[i], zNull)==0)
  1456         -          || sqlite3Strlen30(azCol[i])==0 
         1456  +          || strlen30(azCol[i])==0 
  1457   1457           ){
  1458   1458             sqlite3_bind_null(pStmt, i+1);
  1459   1459           }else{
  1460   1460             sqlite3_bind_text(pStmt, i+1, azCol[i], -1, SQLITE_STATIC);
  1461   1461           }
  1462   1462         }
  1463   1463         sqlite3_step(pStmt);
................................................................................
  1591   1591         Tcl_Obj **apColName = 0;   /* Array of column names */
  1592   1592         int len;                   /* String length of zSql */
  1593   1593     
  1594   1594         /* Try to find a SQL statement that has already been compiled and
  1595   1595         ** which matches the next sequence of SQL.
  1596   1596         */
  1597   1597         pStmt = 0;
  1598         -      len = sqlite3Strlen30(zSql);
         1598  +      len = strlen30(zSql);
  1599   1599         for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pPreStmt->pNext){
  1600   1600           int n = pPreStmt->nSql;
  1601   1601           if( len>=n 
  1602   1602               && memcmp(pPreStmt->zSql, zSql, n)==0
  1603   1603               && (zSql[n]==0 || zSql[n-1]==';')
  1604   1604           ){
  1605   1605             pStmt = pPreStmt->pStmt;
................................................................................
  1844   1844           if( pPreStmt==0 ){
  1845   1845             len = zLeft - zSql;
  1846   1846             pPreStmt = (SqlPreparedStmt*)Tcl_Alloc( sizeof(*pPreStmt) );
  1847   1847             if( pPreStmt==0 ) return TCL_ERROR;
  1848   1848             pPreStmt->pStmt = pStmt;
  1849   1849             pPreStmt->nSql = len;
  1850   1850             pPreStmt->zSql = sqlite3_sql(pStmt);
  1851         -          assert( sqlite3Strlen30(pPreStmt->zSql)==len );
         1851  +          assert( strlen30(pPreStmt->zSql)==len );
  1852   1852             assert( 0==memcmp(pPreStmt->zSql, zSql, len) );
  1853   1853           }
  1854   1854   
  1855   1855           /* Add the prepared statement to the beginning of the cache list
  1856   1856           */
  1857   1857           pPreStmt->pNext = pDb->stmtList;
  1858   1858           pPreStmt->pPrev = 0;
................................................................................
  1905   1905     case DB_FUNCTION: {
  1906   1906       SqlFunc *pFunc;
  1907   1907       Tcl_Obj *pScript;
  1908   1908       char *zName;
  1909   1909       int nArg = -1;
  1910   1910       if( objc==6 ){
  1911   1911         const char *z = Tcl_GetString(objv[3]);
  1912         -      int n = sqlite3Strlen30(z);
         1912  +      int n = strlen30(z);
  1913   1913         if( n>2 && strncmp(z, "-argcount",n)==0 ){
  1914   1914           if( Tcl_GetIntFromObj(interp, objv[4], &nArg) ) return TCL_ERROR;
  1915   1915           if( nArg<0 ){
  1916   1916             Tcl_AppendResult(interp, "number of arguments must be non-negative",
  1917   1917                              (char*)0);
  1918   1918             return TCL_ERROR;
  1919   1919           }

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.189 2008/12/10 18:03:47 drh Exp $
           15  +** $Id: update.c,v 1.190 2008/12/10 22:15:00 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 */
................................................................................
   120    120     int oldIdx      = -1;  /* index of trigger "old" temp table       */
   121    121   
   122    122     /* Register Allocations */
   123    123     int regRowCount = 0;   /* A count of rows changed */
   124    124     int regOldRowid;       /* The old rowid */
   125    125     int regNewRowid;       /* The new rowid */
   126    126     int regData;           /* New data for the row */
   127         -  int regRowSet;         /* Rowset of rows to be updated */
          127  +  int regRowSet = 0;     /* Rowset of rows to be updated */
   128    128   
   129    129     sContext.pParse = 0;
   130    130     db = pParse->db;
   131    131     if( pParse->nErr || db->mallocFailed ){
   132    132       goto update_cleanup;
   133    133     }
   134    134     assert( pTabList->nSrc==1 );

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.244 2008/12/10 21:19:57 drh Exp $
           17  +** $Id: util.c,v 1.245 2008/12/10 22:15:00 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdarg.h>
    21     21   #include <ctype.h>
    22     22   
    23     23   
    24     24   /*
................................................................................
    45     45   #ifdef __FAST_MATH__
    46     46   # error SQLite will not work correctly with the -ffast-math option of GCC.
    47     47   #endif
    48     48     volatile double y = x;
    49     49     volatile double z = y;
    50     50     return y!=z;
    51     51   }
           52  +
           53  +/*
           54  +** Compute a string length that is limited to what can be stored in
           55  +** lower 30 bits of a 32-bit signed integer.
           56  +*/
           57  +int sqlite3Strlen30(const char *z){
           58  +  const char *z2 = z;
           59  +  while( *z2 ){ z2++; }
           60  +  return 0x3fffffff & (int)(z2 - z);
           61  +}
    52     62   
    53     63   /*
    54     64   ** Return the length of a string, except do not allow the string length
    55     65   ** to exceed the SQLITE_LIMIT_LENGTH setting.
    56     66   */
    57     67   int sqlite3Strlen(sqlite3 *db, const char *z){
    58     68     const char *z2 = z;