diff options
author | drh <drh@noemail.net> | 2008-12-10 22:15:00 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-12-10 22:15:00 +0000 |
commit | 4f21c4af30e57d39c5d7873dcab80cb35ee8ab39 (patch) | |
tree | e5e1c7fc51ec575fb5f15af56391ddcc7a7742b0 /src | |
parent | 1bd10f8a0063bcbcb75b99f48e70ae312e145aae (diff) | |
download | sqlite-4f21c4af30e57d39c5d7873dcab80cb35ee8ab39.tar.gz sqlite-4f21c4af30e57d39c5d7873dcab80cb35ee8ab39.zip |
Fix an issue with the new sqlite3Strlen30() introduced by
check-in (6007). Additional casts for compiler warnings. (CVS 6011)
FossilOrigin-Name: 258722b6178f60eaccef1675aab3edc456d413a5
Diffstat (limited to 'src')
-rw-r--r-- | src/pager.c | 50 | ||||
-rw-r--r-- | src/pragma.c | 18 | ||||
-rw-r--r-- | src/select.c | 4 | ||||
-rw-r--r-- | src/shell.c | 48 | ||||
-rw-r--r-- | src/tclsqlite.c | 24 | ||||
-rw-r--r-- | src/update.c | 4 | ||||
-rw-r--r-- | src/util.c | 12 |
7 files changed, 85 insertions, 75 deletions
diff --git a/src/pager.c b/src/pager.c index be35dc922..63d0d1cd5 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.513 2008/12/10 21:19:57 drh Exp $ +** @(#) $Id: pager.c,v 1.514 2008/12/10 22:15:00 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -760,7 +760,7 @@ static int readJournalHdr( && iPageSize<=SQLITE_MAX_PAGE_SIZE && ((iPageSize-1)&iPageSize)==0 ){ - u16 pagesize = iPageSize; + u16 pagesize = (u16)iPageSize; rc = sqlite3PagerSetPagesize(pPager, &pagesize); } if( rc ) return rc; @@ -1247,13 +1247,13 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){ /* Load the entire master journal file into space obtained from ** sqlite3_malloc() and pointed to by zMasterJournal. */ - zMasterJournal = (char *)sqlite3Malloc(nMasterJournal + nMasterPtr); + zMasterJournal = (char *)sqlite3Malloc((int)nMasterJournal + nMasterPtr); if( !zMasterJournal ){ rc = SQLITE_NOMEM; goto delmaster_out; } zMasterPtr = &zMasterJournal[nMasterJournal]; - rc = sqlite3OsRead(pMaster, zMasterJournal, nMasterJournal, 0); + rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0); if( rc!=SQLITE_OK ) goto delmaster_out; zJournal = zMasterJournal; @@ -1476,7 +1476,7 @@ static int pager_playback(Pager *pPager, int isHot){ */ if( nRec==0xffffffff ){ assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) ); - nRec = (szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager); + nRec = (int)((szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager)); } /* If nRec is 0 and this rollback is of a transaction created by this @@ -1489,7 +1489,7 @@ static int pager_playback(Pager *pPager, int isHot){ */ if( nRec==0 && !isHot && pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){ - nRec = (szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager); + nRec = (int)((szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager)); } /* If this is the first header read from the journal, truncate the @@ -1613,7 +1613,7 @@ static int pager_stmt_playback(Pager *pPager){ ** of the first journal header written during this statement transaction. */ pPager->journalOff = pPager->stmtJSize; - pPager->cksumInit = pPager->stmtCksum; + pPager->cksumInit = (int)(pPager->stmtCksum & 0xffffffff); while( pPager->journalOff < hdrOff ){ rc = pager_playback_one_page(pPager, pPager->jfd, pPager->journalOff, 1); assert( rc!=SQLITE_DONE ); @@ -1629,7 +1629,7 @@ static int pager_stmt_playback(Pager *pPager){ goto end_stmt_playback; } if( nJRec==0 ){ - nJRec = (szJ - pPager->journalOff) / (pPager->pageSize+8); + nJRec = (int)((szJ - pPager->journalOff) / (pPager->pageSize+8)); } for(i=nJRec-1; i>=0 && pPager->journalOff < szJ; i--){ rc = pager_playback_one_page(pPager, pPager->jfd, pPager->journalOff, 1); @@ -1683,8 +1683,8 @@ void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){ */ #ifndef SQLITE_OMIT_PAGER_PRAGMAS void sqlite3PagerSetSafetyLevel(Pager *pPager, int level, int bFullFsync){ - pPager->noSync = level==1 || pPager->tempFile; - pPager->fullSync = level==3 && !pPager->tempFile; + pPager->noSync = (level==1 || pPager->tempFile) ?1:0; + pPager->fullSync = (level==3 && !pPager->tempFile) ?1:0; pPager->sync_flags = (bFullFsync?SQLITE_SYNC_FULL:SQLITE_SYNC_NORMAL); if( pPager->noSync ) pPager->needSync = 0; } @@ -1916,12 +1916,12 @@ int sqlite3PagerOpen( } /* pPager->journalOpen = 0; */ - pPager->useJournal = useJournal; - pPager->noReadlock = noReadlock && readOnly; + pPager->useJournal = (u8)useJournal; + pPager->noReadlock = (noReadlock && readOnly) ?1:0; /* pPager->stmtOpen = 0; */ /* pPager->stmtInUse = 0; */ /* pPager->nRef = 0; */ - pPager->dbSizeValid = memDb; + pPager->dbSizeValid = (u8)memDb; pPager->pageSize = szPageDflt; /* pPager->stmtSize = 0; */ /* pPager->stmtJSize = 0; */ @@ -1931,16 +1931,16 @@ int sqlite3PagerOpen( /* pPager->state = PAGER_UNLOCK; */ assert( pPager->state == (tempFile ? PAGER_EXCLUSIVE : PAGER_UNLOCK) ); /* pPager->errMask = 0; */ - pPager->tempFile = tempFile; + pPager->tempFile = (u8)tempFile; assert( tempFile==PAGER_LOCKINGMODE_NORMAL || tempFile==PAGER_LOCKINGMODE_EXCLUSIVE ); assert( PAGER_LOCKINGMODE_EXCLUSIVE==1 ); - pPager->exclusiveMode = tempFile; - pPager->memDb = memDb; - pPager->readOnly = readOnly; + pPager->exclusiveMode = (u8)tempFile; + pPager->memDb = (u8)memDb; + pPager->readOnly = (u8)readOnly; /* pPager->needSync = 0; */ - pPager->noSync = pPager->tempFile || !useJournal; - pPager->fullSync = (pPager->noSync?0:1); + pPager->noSync = (pPager->tempFile || !useJournal) ?1:0; + pPager->fullSync = pPager->noSync ?0:1; pPager->sync_flags = SQLITE_SYNC_NORMAL; /* pPager->pFirst = 0; */ /* pPager->pFirstSynced = 0; */ @@ -2008,7 +2008,7 @@ int sqlite3PagerSetPagesize(Pager *pPager, u16 *pPageSize){ sqlite3PcacheSetPageSize(pPager->pPCache, pageSize); } } - *pPageSize = pPager->pageSize; + *pPageSize = (u16)pPager->pageSize; } return rc; } @@ -2120,7 +2120,7 @@ int sqlite3PagerPagecount(Pager *pPager, int *pnPage){ n /= pPager->pageSize; } if( pPager->state!=PAGER_UNLOCK ){ - pPager->dbSize = n; + pPager->dbSize = (int)n; pPager->dbSizeValid = 1; } } @@ -2128,10 +2128,10 @@ int sqlite3PagerPagecount(Pager *pPager, int *pnPage){ n++; } if( n>pPager->mxPgno ){ - pPager->mxPgno = n; + pPager->mxPgno = (Pgno)n; } if( pnPage ){ - *pnPage = n; + *pnPage = (int)n; } return SQLITE_OK; } @@ -2183,7 +2183,7 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){ rc = sqlite3OsLock(pPager->fd, locktype); }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) ); if( rc==SQLITE_OK ){ - pPager->state = locktype; + pPager->state = (u8)locktype; IOTRACE(("LOCK %p %d\n", pPager, locktype)) } } @@ -2594,7 +2594,7 @@ static int pagerSharedLock(Pager *pPager){ if( pPager->state==PAGER_UNLOCK || isErrorReset ){ sqlite3_vfs *pVfs = pPager->pVfs; - int isHotJournal; + int isHotJournal = 0; assert( !MEMDB ); assert( sqlite3PcacheRefCount(pPager->pPCache)==0 ); if( !pPager->noReadlock ){ diff --git a/src/pragma.c b/src/pragma.c index 9134e6c5d..e891c7849 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.197 2008/12/10 19:26:24 drh Exp $ +** $Id: pragma.c,v 1.198 2008/12/10 22:15:00 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -30,7 +30,7 @@ ** to support legacy SQL code. The safety level used to be boolean ** and older scripts may have used numbers 0 for OFF and 1 for ON. */ -static int getSafetyLevel(const char *z){ +static u8 getSafetyLevel(const char *z){ /* 123456789 123456789 */ static const char zText[] = "onoffalseyestruefull"; static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16}; @@ -52,7 +52,7 @@ static int getSafetyLevel(const char *z){ /* ** Interpret the given string as a boolean value. */ -static int getBoolean(const char *z){ +static u8 getBoolean(const char *z){ return getSafetyLevel(z)&1; } @@ -80,7 +80,7 @@ static int getAutoVacuum(const char *z){ if( 0==sqlite3StrICmp(z, "full") ) return BTREE_AUTOVACUUM_FULL; if( 0==sqlite3StrICmp(z, "incremental") ) return BTREE_AUTOVACUUM_INCR; i = atoi(z); - return ((i>=0&&i<=2)?i:0); + return (u8)((i>=0&&i<=2)?i:0); } #endif /* ifndef SQLITE_OMIT_AUTOVACUUM */ @@ -137,7 +137,7 @@ static int changeTempStorage(Parse *pParse, const char *zStorageType){ if( invalidateTempStorage( pParse ) != SQLITE_OK ){ return SQLITE_ERROR; } - db->temp_store = ts; + db->temp_store = (u8)ts; return SQLITE_OK; } #endif /* SQLITE_PAGER_PRAGMAS */ @@ -435,7 +435,7 @@ void sqlite3Pragma( pPager = sqlite3BtreePager(db->aDb[ii].pBt); sqlite3PagerLockingMode(pPager, eMode); } - db->dfltLockMode = eMode; + db->dfltLockMode = (u8)eMode; } pPager = sqlite3BtreePager(pDb->pBt); eMode = sqlite3PagerLockingMode(pPager, eMode); @@ -495,7 +495,7 @@ void sqlite3Pragma( sqlite3PagerJournalMode(pPager, eMode); } } - db->dfltJournalMode = eMode; + db->dfltJournalMode = (u8)eMode; } pPager = sqlite3BtreePager(pDb->pBt); eMode = sqlite3PagerJournalMode(pPager, eMode); @@ -552,7 +552,7 @@ void sqlite3Pragma( returnSingleInt(pParse, "auto_vacuum", auto_vacuum); }else{ int eAuto = getAutoVacuum(zRight); - db->nextAutovac = eAuto; + db->nextAutovac = (u8)eAuto; if( eAuto>=0 ){ /* Call SetAutoVacuum() to set initialize the internal auto and ** incr-vacuum flags. This is required in case this connection @@ -1063,7 +1063,7 @@ void sqlite3Pragma( /* Do the b-tree integrity checks */ sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1); - sqlite3VdbeChangeP5(v, i); + sqlite3VdbeChangeP5(v, (u8)i); addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName), diff --git a/src/select.c b/src/select.c index ffb4be234..03046de31 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.493 2008/12/10 19:26:24 drh Exp $ +** $Id: select.c,v 1.494 2008/12/10 22:15:00 drh Exp $ */ #include "sqliteInt.h" @@ -2922,7 +2922,7 @@ static int flattenSubquery( ** 2. There is a single expression in the result set, and it is ** either min(x) or max(x), where x is a column reference. */ -static int minMaxQuery(Select *p){ +static u8 minMaxQuery(Select *p){ Expr *pExpr; ExprList *pEList = p->pEList; diff --git a/src/shell.c b/src/shell.c index 3434dd437..04fafcd79 100644 --- a/src/shell.c +++ b/src/shell.c @@ -12,7 +12,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.192 2008/12/10 19:26:24 drh Exp $ +** $Id: shell.c,v 1.193 2008/12/10 22:15:00 drh Exp $ */ #include <stdlib.h> #include <string.h> @@ -366,7 +366,7 @@ static const char *modeDescr[] = { ** Compute a string length that is limited to what can be stored in ** lower 30 bits of a 32-bit signed integer. */ -int sqlite3Strlen30(const char *z){ +static int strlen30(const char *z){ const char *z2 = z; while( *z2 ){ z2++; } return 0x3fffffff & (int)(z2 - z); @@ -487,7 +487,7 @@ static void output_csv(struct callback_data *p, const char *z, int bSep){ fprintf(out,"%s",p->nullvalue); }else{ int i; - int nSep = sqlite3Strlen30(p->separator); + int nSep = strlen30(p->separator); for(i=0; z[i]; i++){ if( needCsvQuote[((unsigned char*)z)[i]] || (z[i]==p->separator[0] && @@ -535,7 +535,7 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){ int w = 5; if( azArg==0 ) break; for(i=0; i<nArg; i++){ - int len = sqlite3Strlen30(azCol[i] ? azCol[i] : ""); + int len = strlen30(azCol[i] ? azCol[i] : ""); if( len>w ) w = len; } if( p->cnt++>0 ) fprintf(p->out,"\n"); @@ -556,9 +556,9 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){ w = 0; } if( w<=0 ){ - w = sqlite3Strlen30(azCol[i] ? azCol[i] : ""); + w = strlen30(azCol[i] ? azCol[i] : ""); if( w<10 ) w = 10; - n = sqlite3Strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue); + n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue); if( w<n ) w = n; } if( i<ArraySize(p->actualWidth) ){ @@ -591,8 +591,8 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){ w = 10; } if( p->mode==MODE_Explain && azArg[i] && - sqlite3Strlen30(azArg[i])>w ){ - w = sqlite3Strlen30(azArg[i]); + strlen30(azArg[i])>w ){ + w = strlen30(azArg[i]); } fprintf(p->out,"%-*.*s%s",w,w, azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " "); @@ -739,8 +739,8 @@ static void set_table_name(struct callback_data *p, const char *zName){ static char *appendText(char *zIn, char const *zAppend, char quote){ int len; int i; - int nAppend = sqlite3Strlen30(zAppend); - int nIn = (zIn?sqlite3Strlen30(zIn):0); + int nAppend = strlen30(zAppend); + int nIn = (zIn?strlen30(zIn):0); len = nAppend+nIn+1; if( quote ){ @@ -907,7 +907,7 @@ static int run_schema_dump_query( rc = sqlite3_exec(p->db, zQuery, dump_callback, p, pzErrMsg); if( rc==SQLITE_CORRUPT ){ char *zQ2; - int len = sqlite3Strlen30(zQuery); + int len = strlen30(zQuery); if( pzErrMsg ) sqlite3_free(*pzErrMsg); zQ2 = malloc( len+100 ); if( zQ2==0 ) return rc; @@ -1081,7 +1081,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ /* Process the input line. */ if( nArg==0 ) return rc; - n = sqlite3Strlen30(azArg[0]); + n = strlen30(azArg[0]); c = azArg[0][0]; if( c=='b' && n>1 && strncmp(azArg[0], "bail", n)==0 && nArg>1 ){ bail_on_error = booleanValue(azArg[1]); @@ -1219,14 +1219,14 @@ static int do_meta_command(char *zLine, struct callback_data *p){ int lineno = 0; /* Line number of input file */ open_db(p); - nSep = sqlite3Strlen30(p->separator); + nSep = strlen30(p->separator); if( nSep==0 ){ fprintf(stderr, "non-null separator required for import\n"); return 0; } zSql = sqlite3_mprintf("SELECT * FROM '%q'", zTable); if( zSql==0 ) return 0; - nByte = sqlite3Strlen30(zSql); + nByte = strlen30(zSql); rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rc ){ @@ -1241,7 +1241,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ zSql = malloc( nByte + 20 + nCol*2 ); if( zSql==0 ) return 0; sqlite3_snprintf(nByte+20, zSql, "INSERT INTO '%q' VALUES(?", zTable); - j = sqlite3Strlen30(zSql); + j = strlen30(zSql); for(i=1; i<nCol; i++){ zSql[j++] = ','; zSql[j++] = '?'; @@ -1374,7 +1374,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ #endif if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg>=2 ){ - int n2 = sqlite3Strlen30(azArg[1]); + int n2 = strlen30(azArg[1]); if( strncmp(azArg[1],"line",n2)==0 || strncmp(azArg[1],"lines",n2)==0 ){ @@ -1532,7 +1532,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ output_c_string(p->out, p->nullvalue); fprintf(p->out, "\n"); fprintf(p->out,"%9.9s: %s\n","output", - sqlite3Strlen30(p->outfile) ? p->outfile : "stdout"); + strlen30(p->outfile) ? p->outfile : "stdout"); fprintf(p->out,"%9.9s: ", "separator"); output_c_string(p->out, p->separator); fprintf(p->out, "\n"); @@ -1581,7 +1581,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ int nPrintCol, nPrintRow; for(i=1; i<=nRow; i++){ if( azResult[i]==0 ) continue; - len = sqlite3Strlen30(azResult[i]); + len = strlen30(azResult[i]); if( len>maxlen ) maxlen = len; } nPrintCol = 80/(maxlen+2); @@ -1728,7 +1728,7 @@ static int process_input(struct callback_data *p, FILE *in){ int i; for(i=0; zLine[i] && isspace((unsigned char)zLine[i]); i++){} if( zLine[i]!=0 ){ - nSql = sqlite3Strlen30(zLine); + nSql = strlen30(zLine); zSql = malloc( nSql+1 ); if( zSql==0 ){ fprintf(stderr, "out of memory\n"); @@ -1738,7 +1738,7 @@ static int process_input(struct callback_data *p, FILE *in){ startline = lineno; } }else{ - int len = sqlite3Strlen30(zLine); + int len = strlen30(zLine); zSql = realloc( zSql, nSql + len + 2 ); if( zSql==0 ){ fprintf(stderr,"%s: out of memory!\n", Argv0); @@ -1825,7 +1825,7 @@ static char *find_home_dir(void){ zDrive = getenv("HOMEDRIVE"); zPath = getenv("HOMEPATH"); if( zDrive && zPath ){ - n = sqlite3Strlen30(zDrive) + sqlite3Strlen30(zPath) + 1; + n = strlen30(zDrive) + strlen30(zPath) + 1; home_dir = malloc( n ); if( home_dir==0 ) return 0; sqlite3_snprintf(n, home_dir, "%s%s", zDrive, zPath); @@ -1838,7 +1838,7 @@ static char *find_home_dir(void){ #endif /* !_WIN32_WCE */ if( home_dir ){ - int n = sqlite3Strlen30(home_dir) + 1; + int n = strlen30(home_dir) + 1; char *z = malloc( n ); if( z ) memcpy(z, home_dir, n); home_dir = z; @@ -1869,7 +1869,7 @@ static void process_sqliterc( #endif return; } - nBuf = sqlite3Strlen30(home_dir) + 16; + nBuf = strlen30(home_dir) + 16; zBuf = malloc( nBuf ); if( zBuf==0 ){ fprintf(stderr,"%s: out of memory!\n", Argv0); @@ -2093,7 +2093,7 @@ int main(int argc, char **argv){ ); zHome = find_home_dir(); if( zHome ){ - nHistory = sqlite3Strlen30(zHome) + 20; + nHistory = strlen30(zHome) + 20; if( (zHistory = malloc(nHistory))!=0 ){ sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome); } diff --git a/src/tclsqlite.c b/src/tclsqlite.c index db31af6d0..b9b349107 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -12,7 +12,7 @@ ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** -** $Id: tclsqlite.c,v 1.229 2008/12/10 19:26:24 drh Exp $ +** $Id: tclsqlite.c,v 1.230 2008/12/10 22:15:00 drh Exp $ */ #include "tcl.h" #include <errno.h> @@ -134,7 +134,7 @@ struct IncrblobChannel { ** Compute a string length that is limited to what can be stored in ** lower 30 bits of a 32-bit signed integer. */ -int sqlite3Strlen30(const char *z){ +static int strlen30(const char *z){ const char *z2 = z; while( *z2 ){ z2++; } return 0x3fffffff & (int)(z2 - z); @@ -397,7 +397,7 @@ static int safeToUseEvalObjv(Tcl_Interp *interp, Tcl_Obj *pCmd){ static SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){ SqlFunc *p, *pNew; int i; - pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + sqlite3Strlen30(zName) + 1 ); + pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + strlen30(zName) + 1 ); pNew->zName = (char*)&pNew[1]; for(i=0; zName[i]; i++){ pNew->zName[i] = tolower(zName[i]); } pNew->zName[i] = 0; @@ -1352,8 +1352,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ zConflict = Tcl_GetStringFromObj(objv[2], 0); zTable = Tcl_GetStringFromObj(objv[3], 0); zFile = Tcl_GetStringFromObj(objv[4], 0); - nSep = sqlite3Strlen30(zSep); - nNull = sqlite3Strlen30(zNull); + nSep = strlen30(zSep); + nNull = strlen30(zNull); if( nSep==0 ){ Tcl_AppendResult(interp,"Error: non-null separator required for copy",0); return TCL_ERROR; @@ -1373,7 +1373,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_AppendResult(interp, "Error: no such table: ", zTable, 0); return TCL_ERROR; } - nByte = sqlite3Strlen30(zSql); + nByte = strlen30(zSql); rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); if( rc ){ @@ -1393,7 +1393,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } sqlite3_snprintf(nByte+50, zSql, "INSERT OR %q INTO '%q' VALUES(?", zConflict, zTable); - j = sqlite3Strlen30(zSql); + j = strlen30(zSql); for(i=1; i<nCol; i++){ zSql[j++] = ','; zSql[j++] = '?'; @@ -1438,7 +1438,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ } if( i+1!=nCol ){ char *zErr; - int nErr = sqlite3Strlen30(zFile) + 200; + int nErr = strlen30(zFile) + 200; zErr = malloc(nErr); if( zErr ){ sqlite3_snprintf(nErr, zErr, @@ -1453,7 +1453,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ for(i=0; i<nCol; i++){ /* check for null data, if so, bind as null */ if( (nNull>0 && strcmp(azCol[i], zNull)==0) - || sqlite3Strlen30(azCol[i])==0 + || strlen30(azCol[i])==0 ){ sqlite3_bind_null(pStmt, i+1); }else{ @@ -1595,7 +1595,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ ** which matches the next sequence of SQL. */ pStmt = 0; - len = sqlite3Strlen30(zSql); + len = strlen30(zSql); for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pPreStmt->pNext){ int n = pPreStmt->nSql; if( len>=n @@ -1848,7 +1848,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ pPreStmt->pStmt = pStmt; pPreStmt->nSql = len; pPreStmt->zSql = sqlite3_sql(pStmt); - assert( sqlite3Strlen30(pPreStmt->zSql)==len ); + assert( strlen30(pPreStmt->zSql)==len ); assert( 0==memcmp(pPreStmt->zSql, zSql, len) ); } @@ -1909,7 +1909,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ int nArg = -1; if( objc==6 ){ const char *z = Tcl_GetString(objv[3]); - int n = sqlite3Strlen30(z); + int n = strlen30(z); if( n>2 && strncmp(z, "-argcount",n)==0 ){ if( Tcl_GetIntFromObj(interp, objv[4], &nArg) ) return TCL_ERROR; if( nArg<0 ){ diff --git a/src/update.c b/src/update.c index ff52524fa..24ad882e4 100644 --- a/src/update.c +++ b/src/update.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** -** $Id: update.c,v 1.189 2008/12/10 18:03:47 drh Exp $ +** $Id: update.c,v 1.190 2008/12/10 22:15:00 drh Exp $ */ #include "sqliteInt.h" @@ -124,7 +124,7 @@ void sqlite3Update( int regOldRowid; /* The old rowid */ int regNewRowid; /* The new rowid */ int regData; /* New data for the row */ - int regRowSet; /* Rowset of rows to be updated */ + int regRowSet = 0; /* Rowset of rows to be updated */ sContext.pParse = 0; db = pParse->db; diff --git a/src/util.c b/src/util.c index 59f1b805a..20be6d728 100644 --- a/src/util.c +++ b/src/util.c @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.244 2008/12/10 21:19:57 drh Exp $ +** $Id: util.c,v 1.245 2008/12/10 22:15:00 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> @@ -51,6 +51,16 @@ int sqlite3IsNaN(double x){ } /* +** Compute a string length that is limited to what can be stored in +** lower 30 bits of a 32-bit signed integer. +*/ +int sqlite3Strlen30(const char *z){ + const char *z2 = z; + while( *z2 ){ z2++; } + return 0x3fffffff & (int)(z2 - z); +} + +/* ** Return the length of a string, except do not allow the string length ** to exceed the SQLITE_LIMIT_LENGTH setting. */ |