From d8e454e19ac21660a134c7167c0e5787111c7504 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 4 Oct 2011 11:22:59 +0000 Subject: [PATCH 01/51] Add experimental 'content' option to FTS4. FossilOrigin-Name: 1d27ea741f61c624e18bdc6a3b1c2d8574a64ddc --- ext/fts3/fts3.c | 251 +++++++++++++++++++++------ ext/fts3/fts3Int.h | 2 + ext/fts3/fts3_snippet.c | 4 +- ext/fts3/fts3_write.c | 142 ++++++++++++++-- manifest | 26 +-- manifest.uuid | 2 +- test/fts4content.test | 366 ++++++++++++++++++++++++++++++++++++++++ test/permutations.test | 3 +- 8 files changed, 709 insertions(+), 87 deletions(-) create mode 100644 test/fts4content.test diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 29e071a50f..c188945b28 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -468,6 +468,7 @@ static int fts3DisconnectMethod(sqlite3_vtab *pVtab){ sqlite3_free(p->zSegmentsTbl); sqlite3_free(p->zReadExprlist); sqlite3_free(p->zWriteExprlist); + sqlite3_free(p->zContentTbl); /* Invoke the tokenizer destructor to free the tokenizer. */ p->pTokenizer->pModule->xDestroy(p->pTokenizer); @@ -507,16 +508,19 @@ static void fts3DbExec( ** The xDestroy() virtual table method. */ static int fts3DestroyMethod(sqlite3_vtab *pVtab){ - int rc = SQLITE_OK; /* Return code */ Fts3Table *p = (Fts3Table *)pVtab; - sqlite3 *db = p->db; + int rc = SQLITE_OK; /* Return code */ + const char *zDb = p->zDb; /* Name of database (e.g. "main", "temp") */ + sqlite3 *db = p->db; /* Database handle */ /* Drop the shadow tables */ - fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", p->zDb, p->zName); - fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", p->zDb,p->zName); - fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", p->zDb, p->zName); - fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", p->zDb, p->zName); - fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", p->zDb, p->zName); + if( p->zContentTbl==0 ){ + fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName); + } + fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName); + fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName); + fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName); + fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName); /* If everything has worked, invoke fts3DisconnectMethod() to free the ** memory associated with the Fts3Table structure and return SQLITE_OK. @@ -578,23 +582,27 @@ static void fts3DeclareVtab(int *pRc, Fts3Table *p){ static int fts3CreateTables(Fts3Table *p){ int rc = SQLITE_OK; /* Return code */ int i; /* Iterator variable */ - char *zContentCols; /* Columns of %_content table */ sqlite3 *db = p->db; /* The database connection */ - /* Create a list of user columns for the content table */ - zContentCols = sqlite3_mprintf("docid INTEGER PRIMARY KEY"); - for(i=0; zContentCols && inColumn; i++){ - char *z = p->azColumn[i]; - zContentCols = sqlite3_mprintf("%z, 'c%d%q'", zContentCols, i, z); - } - if( zContentCols==0 ) rc = SQLITE_NOMEM; + if( p->zContentTbl==0 ){ + char *zContentCols; /* Columns of %_content table */ + + /* Create a list of user columns for the content table */ + zContentCols = sqlite3_mprintf("docid INTEGER PRIMARY KEY"); + for(i=0; zContentCols && inColumn; i++){ + char *z = p->azColumn[i]; + zContentCols = sqlite3_mprintf("%z, 'c%d%q'", zContentCols, i, z); + } + if( zContentCols==0 ) rc = SQLITE_NOMEM; + + /* Create the content table */ + fts3DbExec(&rc, db, + "CREATE TABLE %Q.'%q_content'(%s)", + p->zDb, p->zName, zContentCols + ); + sqlite3_free(zContentCols); + } - /* Create the content table */ - fts3DbExec(&rc, db, - "CREATE TABLE %Q.'%q_content'(%s)", - p->zDb, p->zName, zContentCols - ); - sqlite3_free(zContentCols); /* Create other tables */ fts3DbExec(&rc, db, "CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);", @@ -745,8 +753,8 @@ static char *fts3QuoteId(char const *zInput){ } /* -** Return a list of comma separated SQL expressions that could be used -** in a SELECT statement such as the following: +** Return a list of comma separated SQL expressions and a FROM clause that +** could be used in a SELECT statement such as the following: ** ** SELECT FROM %_content AS x ... ** @@ -757,7 +765,7 @@ static char *fts3QuoteId(char const *zInput){ ** table has the three user-defined columns "a", "b", and "c", the following ** string is returned: ** -** "docid, unzip(x.'a'), unzip(x.'b'), unzip(x.'c')" +** "docid, unzip(x.'a'), unzip(x.'b'), unzip(x.'c') FROM %_content AS x" ** ** The pointer returned points to a buffer allocated by sqlite3_malloc(). It ** is the responsibility of the caller to eventually free it. @@ -773,16 +781,28 @@ static char *fts3ReadExprList(Fts3Table *p, const char *zFunc, int *pRc){ char *zFunction; int i; - if( !zFunc ){ - zFunction = ""; + if( p->zContentTbl==0 ){ + if( !zFunc ){ + zFunction = ""; + }else{ + zFree = zFunction = fts3QuoteId(zFunc); + } + fts3Appendf(pRc, &zRet, "docid"); + for(i=0; inColumn; i++){ + fts3Appendf(pRc, &zRet, ",%s(x.'c%d%q')", zFunction, i, p->azColumn[i]); + } + sqlite3_free(zFree); }else{ - zFree = zFunction = fts3QuoteId(zFunc); + fts3Appendf(pRc, &zRet, "rowid"); + for(i=0; inColumn; i++){ + fts3Appendf(pRc, &zRet, ", x.'%q'", p->azColumn[i]); + } } - fts3Appendf(pRc, &zRet, "docid"); - for(i=0; inColumn; i++){ - fts3Appendf(pRc, &zRet, ",%s(x.'c%d%q')", zFunction, i, p->azColumn[i]); - } - sqlite3_free(zFree); + fts3Appendf(pRc, &zRet, "FROM '%q'.'%q%s' AS x", + p->zDb, + (p->zContentTbl ? p->zContentTbl : p->zName), + (p->zContentTbl ? "" : "_content") + ); return zRet; } @@ -906,6 +926,91 @@ static int fts3PrefixParameter( return SQLITE_OK; } +/* +** This function is called when initializing an FTS4 table that uses the +** content=xxx option. It determines the number of and names of the columns +** of the new FTS4 table. +** +** The third argument passed to this function is the value passed to the +** config=xxx option (i.e. "xxx"). This function queries the database for +** a table of that name. If found, the output variables are populated +** as follows: +** +** *pnCol: Set to the number of columns table xxx has, +** +** *pnStr: Set to the total amount of space required to store a copy +** of each columns name, including the nul-terminator. +** +** *pazCol: Set to point to an array of *pnCol strings. Each string is +** the name of the corresponding column in table xxx. The array +** and its contents are allocated using a single allocation. It +** is the responsibility of the caller to free this allocation +** by eventually passing the *pazCol value to sqlite3_free(). +** +** If the table cannot be found, an error code is returned and the output +** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is +** returned (and the output variables are undefined). +*/ +static int fts3ContentColumns( + sqlite3 *db, /* Database handle */ + const char *zDb, /* Name of db (i.e. "main", "temp" etc.) */ + const char *zTbl, /* Name of content table */ + const char ***pazCol, /* OUT: Malloc'd array of column names */ + int *pnCol, /* OUT: Size of array *pazCol */ + int *pnStr /* OUT: Bytes of string content */ +){ + int rc = SQLITE_OK; /* Return code */ + char *zSql; /* "SELECT *" statement on zTbl */ + sqlite3_stmt *pStmt = 0; /* Compiled version of zSql */ + + zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", zDb, zTbl); + if( !zSql ){ + rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); + } + sqlite3_free(zSql); + + if( rc==SQLITE_OK ){ + const char **azCol; /* Output array */ + int nStr = 0; /* Size of all column names (incl. 0x00) */ + int nCol; /* Number of table columns */ + int i; /* Used to iterate through columns */ + + /* Loop through the returned columns. Set nStr to the number of bytes of + ** space required to store a copy of each column name, including the + ** nul-terminator byte. */ + nCol = sqlite3_column_count(pStmt); + for(i=0; i MATCHINFO */ - { "prefix", 6, 0 }, /* 1 -> PREFIX */ - { "compress", 8, 0 }, /* 2 -> COMPRESS */ - { "uncompress", 10, 0 }, /* 3 -> UNCOMPRESS */ - { "order", 5, 0 } /* 4 -> ORDER */ + { "matchinfo", 9 }, /* 0 -> MATCHINFO */ + { "prefix", 6 }, /* 1 -> PREFIX */ + { "compress", 8 }, /* 2 -> COMPRESS */ + { "uncompress", 10 }, /* 3 -> UNCOMPRESS */ + { "order", 5 }, /* 4 -> ORDER */ + { "content", 7 } /* 5 -> CONTENT */ }; int iOpt; @@ -1052,6 +1158,12 @@ static int fts3InitVtab( } bDescIdx = (zVal[0]=='d' || zVal[0]=='D'); break; + + case 5: /* CONTENT */ + sqlite3_free(zUncompress); + zContent = zVal; + zVal = 0; + break; } } sqlite3_free(zVal); @@ -1064,6 +1176,27 @@ static int fts3InitVtab( aCol[nCol++] = z; } } + + /* If a content=xxx option was specified, the following: + ** + ** 1. Ignore any compress= and uncompress= options. + ** + ** 2. Ignore any column names that were specified as part of the + ** the CREATE VIRTUAL TABLE statement. + ** + ** 3. Determine the actual column names to use for the FTS table + ** based on the columns of the content= table. + */ + if( rc==SQLITE_OK && zContent ){ + sqlite3_free(aCol); + sqlite3_free(zCompress); + sqlite3_free(zUncompress); + zCompress = 0; + zUncompress = 0; + aCol = 0; + rc = fts3ContentColumns(db, argv[1], zContent, &aCol, &nCol, &nString); + assert( rc!=SQLITE_OK || nCol>0 ); + } if( rc!=SQLITE_OK ) goto fts3_init_out; if( nCol==0 ){ @@ -1108,6 +1241,8 @@ static int fts3InitVtab( p->bHasDocsize = (isFts4 && bNoDocsize==0); p->bHasStat = isFts4; p->bDescIdx = bDescIdx; + p->zContentTbl = zContent; + zContent = 0; TESTONLY( p->inTransaction = -1 ); TESTONLY( p->mxSavepoint = -1 ); @@ -1169,6 +1304,7 @@ fts3_init_out: sqlite3_free(aIndex); sqlite3_free(zCompress); sqlite3_free(zUncompress); + sqlite3_free(zContent); sqlite3_free((void *)aCol); if( rc!=SQLITE_OK ){ if( p ){ @@ -1334,11 +1470,16 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ }else{ int rc = sqlite3_reset(pCsr->pStmt); if( rc==SQLITE_OK ){ - /* If no row was found and no error has occured, then the %_content - ** table is missing a row that is present in the full-text index. - ** The data structures are corrupt. - */ - rc = SQLITE_CORRUPT_VTAB; + Fts3Table *p = (Fts3Table *)pCsr->base.pVtab; + if( p->zContentTbl==0 ){ + /* If no row was found and no error has occured, then the %_content + ** table is missing a row that is present in the full-text index. + ** The data structures are corrupt. + */ + rc = SQLITE_CORRUPT_VTAB; + }else{ + return SQLITE_OK; + } } pCsr->isEof = 1; if( pContext ){ @@ -2713,12 +2854,13 @@ static int fts3FilterMethod( ** row by docid. */ if( idxNum==FTS3_FULLSCAN_SEARCH ){ - const char *zSort = (pCsr->bDesc ? "DESC" : "ASC"); - const char *zTmpl = "SELECT %s FROM %Q.'%q_content' AS x ORDER BY docid %s"; - zSql = sqlite3_mprintf(zTmpl, p->zReadExprlist, p->zDb, p->zName, zSort); + const char *zTmpl = "SELECT %s ORDER BY rowid %s"; + zSql = sqlite3_mprintf(zTmpl, + p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC") + ); }else{ - const char *zTmpl = "SELECT %s FROM %Q.'%q_content' AS x WHERE docid = ?"; - zSql = sqlite3_mprintf(zTmpl, p->zReadExprlist, p->zDb, p->zName); + const char *zTmpl = "SELECT %s WHERE rowid = ?"; + zSql = sqlite3_mprintf(zTmpl, p->zReadExprlist); } if( !zSql ) return SQLITE_NOMEM; rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); @@ -2781,7 +2923,7 @@ static int fts3ColumnMethod( sqlite3_result_blob(pContext, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT); }else{ rc = fts3CursorSeek(0, pCsr); - if( rc==SQLITE_OK ){ + if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)>(iCol+1) ){ sqlite3_result_value(pContext, sqlite3_column_value(pCsr->pStmt, iCol+1)); } } @@ -3079,10 +3221,13 @@ static int fts3RenameMethod( return rc; } - fts3DbExec(&rc, db, - "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", - p->zDb, p->zName, zName - ); + if( p->zContentTbl==0 ){ + fts3DbExec(&rc, db, + "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", + p->zDb, p->zName, zName + ); + } + if( p->bHasDocsize ){ fts3DbExec(&rc, db, "ALTER TABLE %Q.'%q_docsize' RENAME TO '%q_docsize';", diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index ed8043adf6..b4f26fc7a5 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -184,6 +184,7 @@ struct Fts3Table { int nColumn; /* number of named columns in virtual table */ char **azColumn; /* column names. malloced */ sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */ + char *zContentTbl; /* content=xxx option, or NULL */ /* Precompiled statements used by the implementation. Each of these ** statements is run and reset within a single virtual table API call. @@ -245,6 +246,7 @@ struct Fts3Cursor { i16 eSearch; /* Search strategy (see below) */ u8 isEof; /* True if at End Of Results */ u8 isRequireSeek; /* True if must seek pStmt to %_content row */ + u8 isNullRow; /* True for a row of NULLs */ sqlite3_stmt *pStmt; /* Prepared statement in use by the cursor */ Fts3Expr *pExpr; /* Parsed MATCH query string */ int nPhrase; /* Number of matchable phrases in query */ diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index b569eb131b..13d0ca3551 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -1409,7 +1409,7 @@ void sqlite3Fts3Offsets( if( !pTerm ){ /* All offsets for this column have been gathered. */ - break; + rc = SQLITE_DONE; }else{ assert( iCurrent<=iMinPos ); if( 0==(0xFE&*pTerm->pList) ){ @@ -1426,7 +1426,7 @@ void sqlite3Fts3Offsets( "%d %d %d %d ", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart ); rc = fts3StringAppend(&res, aBuffer, -1); - }else if( rc==SQLITE_DONE ){ + }else if( rc==SQLITE_DONE && pTab->zContentTbl==0 ){ rc = SQLITE_CORRUPT_VTAB; } } diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 36f2249e12..46a1ead2d8 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -256,7 +256,7 @@ static int fts3SqlStmt( /* 4 */ "DELETE FROM %Q.'%q_segdir'", /* 5 */ "DELETE FROM %Q.'%q_docsize'", /* 6 */ "DELETE FROM %Q.'%q_stat'", -/* 7 */ "SELECT %s FROM %Q.'%q_content' AS x WHERE rowid=?", +/* 7 */ "SELECT %s WHERE rowid=?", /* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1", /* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)", /* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)", @@ -298,7 +298,7 @@ static int fts3SqlStmt( if( eStmt==SQL_CONTENT_INSERT ){ zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist); }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){ - zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist, p->zDb, p->zName); + zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist); }else{ zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName); } @@ -780,6 +780,18 @@ static int fts3InsertData( int rc; /* Return code */ sqlite3_stmt *pContentInsert; /* INSERT INTO %_content VALUES(...) */ + if( p->zContentTbl ){ + sqlite3_value *pRowid = apVal[p->nColumn+3]; + if( sqlite3_value_type(pRowid)==SQLITE_NULL ){ + pRowid = apVal[1]; + } + if( sqlite3_value_type(pRowid)!=SQLITE_INTEGER ){ + return SQLITE_CONSTRAINT; + } + *piDocid = sqlite3_value_int64(pRowid); + return SQLITE_OK; + } + /* Locate the statement handle used to insert data into the %_content ** table. The SQL for this statement is: ** @@ -830,14 +842,16 @@ static int fts3InsertData( ** Remove all data from the FTS3 table. Clear the hash table containing ** pending terms. */ -static int fts3DeleteAll(Fts3Table *p){ +static int fts3DeleteAll(Fts3Table *p, int bContent){ int rc = SQLITE_OK; /* Return code */ /* Discard the contents of the pending-terms hash table. */ sqlite3Fts3PendingTermsClear(p); - /* Delete everything from the %_content, %_segments and %_segdir tables. */ - fts3SqlExec(&rc, p, SQL_DELETE_ALL_CONTENT, 0); + /* Delete everything from the shadow tables. Except, leave %_content as + ** is if bContent is false. */ + assert( p->zContentTbl==0 || bContent==0 ); + if( bContent ) fts3SqlExec(&rc, p, SQL_DELETE_ALL_CONTENT, 0); fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGMENTS, 0); fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGDIR, 0); if( p->bHasDocsize ){ @@ -2125,12 +2139,18 @@ static void fts3SegWriterFree(SegmentWriter *pWriter){ static int fts3IsEmpty(Fts3Table *p, sqlite3_value *pRowid, int *pisEmpty){ sqlite3_stmt *pStmt; int rc; - rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, &pRowid); - if( rc==SQLITE_OK ){ - if( SQLITE_ROW==sqlite3_step(pStmt) ){ - *pisEmpty = sqlite3_column_int(pStmt, 0); + if( p->zContentTbl ){ + /* If using the content=xxx option, assume the table is never empty */ + *pisEmpty = 0; + rc = SQLITE_OK; + }else{ + rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, &pRowid); + if( rc==SQLITE_OK ){ + if( SQLITE_ROW==sqlite3_step(pStmt) ){ + *pisEmpty = sqlite3_column_int(pStmt, 0); + } + rc = sqlite3_reset(pStmt); } - rc = sqlite3_reset(pStmt); } return rc; } @@ -2787,9 +2807,9 @@ static void fts3DecodeIntArray( ** a blob of varints. */ static void fts3InsertDocsize( - int *pRC, /* Result code */ - Fts3Table *p, /* Table into which to insert */ - u32 *aSz /* Sizes of each column */ + int *pRC, /* Result code */ + Fts3Table *p, /* Table into which to insert */ + u32 *aSz /* Sizes of each column, in tokens */ ){ char *pBlob; /* The BLOB encoding of the document size */ int nBlob; /* Number of bytes in the BLOB */ @@ -2911,6 +2931,84 @@ static int fts3DoOptimize(Fts3Table *p, int bReturnDone){ return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc; } +/* +** This function is called when the user executes the following statement: +** +** INSERT INTO () VALUES('rebuild'); +** +** The entire FTS index is discarded and rebuilt. If the table is one +** created using the content=xxx option, then the new index is based on +** the current contents of the xxx table. Otherwise, it is rebuilt based +** on the contents of the %_content table. +*/ +static int fts3DoRebuild(Fts3Table *p){ + int rc; /* Return Code */ + + rc = fts3DeleteAll(p, 0); + if( rc==SQLITE_OK ){ + u32 *aSz = 0; + u32 *aSzIns; + u32 *aSzDel; + sqlite3_stmt *pStmt = 0; + int nEntry = 0; + + /* Compose and prepare an SQL statement to loop through the content table */ + char *zSql = sqlite3_mprintf("SELECT %s" , p->zReadExprlist); + if( !zSql ){ + rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + } + + if( rc==SQLITE_OK ){ + int nByte = sizeof(u32) * (p->nColumn+1)*3; + aSz = (u32 *)sqlite3_malloc(nByte); + if( aSz==0 ){ + rc = SQLITE_NOMEM; + }else{ + memset(aSz, 0, nByte); + aSzIns = &aSz[p->nColumn+1]; + aSzDel = &aSzIns[p->nColumn+1]; + } + } + + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ + int iCol; + rc = fts3PendingTermsDocid(p, sqlite3_column_int64(pStmt, 0)); + aSz[p->nColumn] = 0; + for(iCol=0; rc==SQLITE_OK && iColnColumn; iCol++){ + const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1); + rc = fts3PendingTermsAdd(p, z, iCol, &aSz[iCol]); + aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1); + } + if( p->bHasDocsize ){ + fts3InsertDocsize(&rc, p, aSz); + } + if( rc!=SQLITE_OK ){ + sqlite3_finalize(pStmt); + pStmt = 0; + }else{ + nEntry++; + for(iCol=0; iCol<=p->nColumn; iCol++){ + aSzIns[iCol] += aSz[iCol]; + } + } + } + if( p->bHasStat ){ + fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry); + } + sqlite3_free(aSz); + + if( pStmt ){ + assert( rc==SQLITE_OK ); + rc = sqlite3_finalize(pStmt); + } + } + + return rc; +} + /* ** Handle a 'special' INSERT of the form: ** @@ -2928,6 +3026,8 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ return SQLITE_NOMEM; }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){ rc = fts3DoOptimize(p, 0); + }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){ + rc = fts3DoRebuild(p); #ifdef SQLITE_TEST }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ p->nNodeSize = atoi(&zVal[9]); @@ -3099,14 +3199,18 @@ static int fts3DeleteByRowid( /* Deleting this row means the whole table is empty. In this case ** delete the contents of all three tables and throw away any ** data in the pendingTerms hash table. */ - rc = fts3DeleteAll(p); + rc = fts3DeleteAll(p, 1); *pnDoc = *pnDoc - 1; }else{ sqlite3_int64 iRemove = sqlite3_value_int64(pRowid); rc = fts3PendingTermsDocid(p, iRemove); fts3DeleteTerms(&rc, p, pRowid, aSzDel); - fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid); - if( sqlite3_changes(p->db) ) *pnDoc = *pnDoc - 1; + if( p->zContentTbl==0 ){ + fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid); + if( sqlite3_changes(p->db) ) *pnDoc = *pnDoc - 1; + }else{ + *pnDoc = *pnDoc - 1; + } if( p->bHasDocsize ){ fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid); } @@ -3167,7 +3271,7 @@ int sqlite3Fts3UpdateMethod( ** detect the conflict and return SQLITE_CONSTRAINT before beginning to ** modify the database file. */ - if( nArg>1 ){ + if( nArg>1 && p->zContentTbl==0 ){ /* Find the value object that holds the new rowid value. */ sqlite3_value *pNewRowid = apVal[3+p->nColumn]; if( sqlite3_value_type(pNewRowid)==SQLITE_NULL ){ @@ -3219,7 +3323,9 @@ int sqlite3Fts3UpdateMethod( if( nArg>1 && rc==SQLITE_OK ){ if( bInsertDone==0 ){ rc = fts3InsertData(p, apVal, pRowid); - if( rc==SQLITE_CONSTRAINT ) rc = SQLITE_CORRUPT_VTAB; + if( rc==SQLITE_CONSTRAINT && p->zContentTbl==0 ){ + rc = SQLITE_CORRUPT_VTAB; + } } if( rc==SQLITE_OK && (!isRemove || *pRowid!=iRemove) ){ rc = fts3PendingTermsDocid(p, *pRowid); diff --git a/manifest b/manifest index 916f02c341..6ca44ed83d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sMSVC\smakefile\sto\sallow\stargets\sto\sbe\sbuilt\swith\ssupport\sfor\sICU. -D 2011-10-02T05:23:16.470 +C Add\sexperimental\s'content'\soption\sto\sFTS4. +D 2011-10-04T11:22:59.677 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,22 +62,22 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 195e4da669741c1f097434ec48c0ba5739193af9 +F ext/fts3/fts3.c 626fcf477e531b470f06aae3d427abcda2d5d31c F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 30063fdd0bc433b5db1532e3a363cb0f2f7e8eb3 +F ext/fts3/fts3Int.h a335d671d42ca07528a93c5b830e48e0205b26bc F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 F ext/fts3/fts3_expr.c 23791de01b3a5d313d76e02befd2601d4096bc2b F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa F ext/fts3/fts3_porter.c 8d946908f4812c005d3d33fcbe78418b1f4eb70c -F ext/fts3/fts3_snippet.c 58b2ba2b934c1e2a2f6ac857d7f3c7e1a14b4532 +F ext/fts3/fts3_snippet.c 8838a1de5f7df3a559596870caaa4a9895248998 F ext/fts3/fts3_term.c a5457992723455a58804cb75c8cbd8978db5c2ef F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c 194829c8fd024a448fc899e5ff02a8ed06595529 +F ext/fts3/fts3_write.c 9e14eb54310345b441d7a8c83bc3ae474230bea6 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -486,6 +486,7 @@ F test/fts3shared.test 8bb266521d7c5495c0ae522bb4d376ad5387d4a2 F test/fts3snippet.test 8e956051221a34c7daeb504f023cb54d5fa5a8b2 F test/fts3sort.test 9a5176c9317bb545ec5f144d62e6fedb4da6c66e F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68 +F test/fts4content.test fbafb7160eef1560b6a254b1ad5631acccd388a1 F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a @@ -620,7 +621,7 @@ F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806 F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 -F test/permutations.test ad17319066a90e2db71823c3ff104795ffc71b31 +F test/permutations.test 7b1c4cb40af3712e42364c82390ace0df207b5e0 F test/pragma.test c8108e01da04f16e67e5754e610bc62c1b993f6c F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea @@ -965,7 +966,10 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P 9ddfe1e41300413bc9af7e5ce0ec9d1daf9136b1 -R 03863d4dd01ba5995289085115b33375 -U mistachkin -Z 7dfdbd4e337132033acb3bc17ce78d60 +P eb5da5e1dbe9c198095036827318fb381441cbd0 +R 7991a3071fb34636c7b5ed4b010ad95a +T *branch * fts4-content +T *sym-fts4-content * +T -sym-trunk * +U dan +Z 48ff718a3615a321d5bc0764cb014ed4 diff --git a/manifest.uuid b/manifest.uuid index c4bc7f0c61..be6a47c58b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb5da5e1dbe9c198095036827318fb381441cbd0 \ No newline at end of file +1d27ea741f61c624e18bdc6a3b1c2d8574a64ddc \ No newline at end of file diff --git a/test/fts4content.test b/test/fts4content.test new file mode 100644 index 0000000000..6ac5a6806a --- /dev/null +++ b/test/fts4content.test @@ -0,0 +1,366 @@ +# 2011 October 03 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# This file implements regression tests for SQLite library. The +# focus of this script is testing the content=xxx FTS4 option. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix fts4content + +# If SQLITE_ENABLE_FTS3 is defined, omit this file. +ifcapable !fts3 { + finish_test + return +} + +do_execsql_test 1.1 { + CREATE TABLE t1(a, b, c); + INSERT INTO t1 VALUES('w x', 'x y', 'y z'); + CREATE VIRTUAL TABLE ft1 USING fts4(content=t1); +} + +do_execsql_test 1.2 { + PRAGMA table_info(ft1); +} { + 0 a {} 0 {} 0 + 1 b {} 0 {} 0 + 2 c {} 0 {} 0 +} + +do_execsql_test 1.3 { SELECT *, rowid FROM ft1 } {{w x} {x y} {y z} 1} +do_execsql_test 1.4 { SELECT a, c FROM ft1 WHERE rowid=1 } {{w x} {y z}} + +do_execsql_test 1.5 { INSERT INTO ft1(ft1) VALUES('rebuild') } {} +do_execsql_test 1.6 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'x' } {1} +do_execsql_test 1.7 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'a' } {} + +#------------------------------------------------------------------------- +# The following block of tests - 2.* - test that a content=xxx FTS table +# can be queried. Also tested are cases where rows identified in the FTS +# are missing from the content table, and cases where the index is +# inconsistent with the content table. +# +do_execsql_test 2.0 { + CREATE TABLE t2(x); + INSERT INTO t2 VALUES('O S W W F U C R Q I C N P Z Y Y E Y Y E'); -- 1 + INSERT INTO t2 VALUES('Y X U V L B E H Y J C Y A I A P V F V K'); -- 2 + INSERT INTO t2 VALUES('P W I N J H I I N I F B K D U Q B Z S F'); -- 3 + INSERT INTO t2 VALUES('N R O R H J R H G M D I U U B O M P A U'); -- 4 + INSERT INTO t2 VALUES('Y O V O G T P N G T N F I V B U M J M G'); -- 5 + INSERT INTO t2 VALUES('J O B N K N E C H Z R K J O U G M K L S'); -- 6 + INSERT INTO t2 VALUES('S Z S R I Q U A P W R X H K C Z U L S P'); -- 7 + INSERT INTO t2 VALUES('J C H N R C K R V N M O F Z M Z A I H W'); -- 8 + INSERT INTO t2 VALUES('O Y G I S J U U W O D Z F J K N R P R L'); -- 9 + INSERT INTO t2 VALUES('B G L K U R U P V X Z I H V R W C Q A S'); -- 10 + INSERT INTO t2 VALUES('T F T J F F Y V F W N X K Q A Y L X W G'); -- 11 + INSERT INTO t2 VALUES('C J U H B Q X L C M M Y E G V F W V Z C'); -- 12 + INSERT INTO t2 VALUES('B W L T F S G X D P H N G M R I O A X I'); -- 13 + INSERT INTO t2 VALUES('N G Y O K Q K Z N M H U J E D H U W R K'); -- 14 + INSERT INTO t2 VALUES('U D T R U Y F J D S J X E H Q G V A S Z'); -- 15 + INSERT INTO t2 VALUES('M I W P J S H R J D Q I C G P C T P H R'); -- 16 + INSERT INTO t2 VALUES('J M N I S L X Q C A B F C B Y D H V R J'); -- 17 + INSERT INTO t2 VALUES('F V Z W J Q L P X Y E W B U Q N H X K T'); -- 18 + INSERT INTO t2 VALUES('R F S R Y O F Q E I E G H C B H R X Y N'); -- 19 + INSERT INTO t2 VALUES('U Q Q Q T E P D M F X P J G H X C Q D L'); -- 20 +} + +do_execsql_test 2.1 { + CREATE VIRTUAL TABLE ft2 USING fts4(content=t2); + INSERT INTO ft2(ft2) VALUES('rebuild'); + + -- Modify the backing table a bit: Row 17 is missing and the contents + -- of row 20 do not match the FTS index contents. + DELETE FROM t2 WHERE rowid = 17; + UPDATE t2 SET x = 'a b c d e f g h i j' WHERE rowid = 20; +} + +foreach {tn match rowidlist} { + 1 {S} {1 3 6 7 9 10 13 15 16 17 19} + 2 {"S R"} {7 19} + 3 {"N K N"} {6} + 4 {"Q Q"} {20} + 5 {"B Y D"} {17} +} { + do_execsql_test 2.2.1.$tn { + SELECT rowid FROM ft2 WHERE ft2 MATCH $match + } $rowidlist + + do_execsql_test 2.2.2.$tn { + SELECT docid FROM ft2 WHERE ft2 MATCH $match + } $rowidlist +} + +foreach {tn match result} { + 1 {"N K N"} {{J O B N K N E C H Z R K J O U G M K L S}} + 2 {"Q Q"} {{a b c d e f g h i j}} + 3 {"B Y D"} {{}} +} { + do_execsql_test 2.3.$tn { + SELECT * FROM ft2 WHERE ft2 MATCH $match + } $result +} + +foreach {tn match result} { + 1 {"N K N"} {{..O B [N] [K] [N] E..}} + 2 {"B Y D"} {{}} + 3 {"Q Q"} {{a [b] [c] [d] e f..}} +} { + do_execsql_test 2.4.$tn { + SELECT snippet(ft2, '[', ']', '..', -1, 6) FROM ft2 WHERE ft2 MATCH $match + } $result +} + +foreach {tn match result} { + 1 {"N K N"} {{0 0 6 1 0 1 8 1 0 2 10 1}} + 2 {"B Y D"} {{}} + 3 {"Q Q"} {{0 0 2 1 0 0 4 1 0 1 4 1 0 1 6 1}} + 4 {"Q D L"} {{}} +} { + do_execsql_test 2.5.$tn { + SELECT offsets(ft2) FROM ft2 WHERE ft2 MATCH $match + } $result +} + +#------------------------------------------------------------------------- +# The following block of tests - 3.* - test that the FTS index can be +# modified by writing to the table. But that this has no effect on the +# content table. +# + +do_execsql_test 3.1 { + CREATE TABLE t3(x, y); + CREATE VIRTUAL TABLE ft3 USING fts4(content=t3); +} + +do_catchsql_test 3.1.1 { + INSERT INTO ft3 VALUES('a b c', 'd e f'); +} {1 {constraint failed}} +do_execsql_test 3.1.2 { + INSERT INTO ft3(docid, x, y) VALUES(21, 'a b c', 'd e f'); + SELECT rowid FROM ft3 WHERE ft3 MATCH '"a b c"'; +} {21} +do_execsql_test 3.1.3 { SELECT * FROM t3 } {} + +# This DELETE does not work, since there is no row in [t3] to base the +# DELETE on. So the SELECT on [ft3] still returns rowid 21. +do_execsql_test 3.1.4 { + DELETE FROM ft3; + SELECT rowid FROM ft3 WHERE ft3 MATCH '"a b c"'; +} {21} + +# If the row is added to [t3] before the DELETE on [ft3], it works. +do_execsql_test 3.1.5 { + INSERT INTO t3(rowid, x, y) VALUES(21, 'a b c', 'd e f'); + DELETE FROM ft3; + SELECT rowid FROM ft3 WHERE ft3 MATCH '"a b c"'; +} {} +do_execsql_test 3.1.6 { SELECT rowid FROM t3 } {21} + +do_execsql_test 3.2.1 { + INSERT INTO ft3(rowid, x, y) VALUES(0, 'R T M S M', 'A F O K H'); + INSERT INTO ft3(rowid, x, y) VALUES(1, 'C Z J O X', 'U S Q D K'); + INSERT INTO ft3(rowid, x, y) VALUES(2, 'N G H P O', 'N O P O C'); + INSERT INTO ft3(rowid, x, y) VALUES(3, 'V H S D R', 'K N G E C'); + INSERT INTO ft3(rowid, x, y) VALUES(4, 'J T R V U', 'U X S L C'); + INSERT INTO ft3(rowid, x, y) VALUES(5, 'N A Y N G', 'X D G P Y'); + INSERT INTO ft3(rowid, x, y) VALUES(6, 'I Q I S P', 'D R O Q B'); + INSERT INTO ft3(rowid, x, y) VALUES(7, 'T K T Z J', 'B W D G O'); + INSERT INTO ft3(rowid, x, y) VALUES(8, 'Y K F X T', 'D F G V G'); + INSERT INTO ft3(rowid, x, y) VALUES(9, 'E L E T L', 'P W N F Z'); + INSERT INTO ft3(rowid, x, y) VALUES(10, 'O G J G X', 'G J F E P'); + INSERT INTO ft3(rowid, x, y) VALUES(11, 'O L N N Z', 'K E Z F D'); + INSERT INTO ft3(rowid, x, y) VALUES(12, 'R Z M R J', 'X G I M Z'); + INSERT INTO ft3(rowid, x, y) VALUES(13, 'L X N N X', 'R R N S T'); + INSERT INTO ft3(rowid, x, y) VALUES(14, 'F L B J H', 'K W F L C'); + INSERT INTO ft3(rowid, x, y) VALUES(15, 'P E B M V', 'E A A B U'); + INSERT INTO ft3(rowid, x, y) VALUES(16, 'V E C F P', 'L U T V K'); + INSERT INTO ft3(rowid, x, y) VALUES(17, 'T N O Z N', 'T P Q X N'); + INSERT INTO ft3(rowid, x, y) VALUES(18, 'V W U W R', 'H O A A V'); + INSERT INTO ft3(rowid, x, y) VALUES(19, 'A H N L F', 'I G H B O'); +} + +foreach {tn match rowidlist} { + 1 "N A" {5 19} + 2 "x:O" {1 2 10 11 17} + 3 "y:O" {0 2 6 7 18 19} +} { + set res [list] + foreach rowid $rowidlist { lappend res $rowid {} {} } + + do_execsql_test 3.2.2.$tn { + SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match + } $res + do_execsql_test 3.2.3.$tn { + SELECT docid, * FROM ft3 WHERE ft3 MATCH $match + } $res +} + +do_execsql_test 3.3.1 { + INSERT INTO t3(rowid, x, y) VALUES(0, 'R T M S M', 'A F O K H'); + INSERT INTO t3(rowid, x, y) VALUES(1, 'C Z J O X', 'U S Q D K'); + INSERT INTO t3(rowid, x, y) VALUES(2, 'N G H P O', 'N O P O C'); + INSERT INTO t3(rowid, x, y) VALUES(3, 'V H S D R', 'K N G E C'); + INSERT INTO t3(rowid, x, y) VALUES(4, 'J T R V U', 'U X S L C'); + INSERT INTO t3(rowid, x, y) VALUES(5, 'N A Y N G', 'X D G P Y'); + UPDATE ft3 SET x = y, y = x; + DELETE FROM t3; +} + +foreach {tn match rowidlist} { + 1 "N A" {5 19} + 2 "x:O" {0 2 10 11 17} + 3 "y:O" {1 2 6 7 18 19} +} { + set res [list] + foreach rowid $rowidlist { lappend res $rowid {} {} } + + do_execsql_test 3.3.2.$tn { + SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match + } $res + do_execsql_test 3.3.3.$tn { + SELECT docid, * FROM ft3 WHERE ft3 MATCH $match + } $res +} + +do_execsql_test 3.3.1 { + INSERT INTO t3(rowid, x, y) VALUES(15, 'P E B M V', 'E A A B U'); + INSERT INTO t3(rowid, x, y) VALUES(16, 'V E C F P', 'L U T V K'); + INSERT INTO t3(rowid, x, y) VALUES(17, 'T N O Z N', 'T P Q X N'); + INSERT INTO t3(rowid, x, y) VALUES(18, 'V W U W R', 'H O A A V'); + INSERT INTO t3(rowid, x, y) VALUES(19, 'A H N L F', 'I G H B O'); + DELETE FROM ft3; +} + +foreach {tn match rowidlist} { + 1 "N A" {5} + 2 "x:O" {0 2 10 11} + 3 "y:O" {1 2 6 7} +} { + set res [list] + foreach rowid $rowidlist { lappend res $rowid {} {} } + + do_execsql_test 3.3.2.$tn { + SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match + } $res + do_execsql_test 3.3.3.$tn { + SELECT docid, * FROM ft3 WHERE ft3 MATCH $match + } $res +} + + +#------------------------------------------------------------------------- +# Test cases 4.* test the 'rebuild' command. On content=xxx and regular +# FTS tables. +# +do_execsql_test 4.0 { + CREATE TABLE t4(x); + CREATE VIRTUAL TABLE ft4 USING fts4(content=t4); + CREATE VIRTUAL TABLE ft4x USING fts4(x); +} + +do_execsql_test 4.1.1 { + INSERT INTO ft4x(ft4x) VALUES('rebuild'); + INSERT INTO ft4(ft4) VALUES('rebuild'); +} {} +do_execsql_test 4.1.2 { + SELECT id, quote(value) FROM ft4_stat +} {0 X'000000'} +do_execsql_test 4.1.3 { + SELECT id, quote(value) FROM ft4x_stat +} {0 X'000000'} + +do_execsql_test 4.2.1 { + INSERT INTO ft4x VALUES('M G M F T'); + INSERT INTO ft4x VALUES('Z Q C A U'); + INSERT INTO ft4x VALUES('N L L V'); + INSERT INTO ft4x VALUES('T F D X D'); + INSERT INTO ft4x VALUES('Z H I S D'); + + SELECT id, quote(value) FROM ft4x_stat +} {0 X'05182B'} + +do_execsql_test 4.2.2 { + INSERT INTO ft4(rowid, x) SELECT rowid, * FROM ft4x; + SELECT id, quote(value) FROM ft4_stat +} {0 X'05182B'} + +do_execsql_test 4.2.3 { + SELECT docid, quote(size) FROM ft4_docsize +} {1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'} + +do_execsql_test 4.2.4 { + INSERT INTO ft4x(ft4x) VALUES('rebuild'); + SELECT id, quote(value) FROM ft4x_stat; + SELECT docid, quote(size) FROM ft4x_docsize +} {0 X'05182B' 1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'} + +do_execsql_test 4.2.5 { + INSERT INTO ft4(ft4) VALUES('rebuild'); + SELECT id, quote(value) FROM ft4_stat; + SELECT docid, quote(size) FROM ft4_docsize +} {0 X'000000'} + +do_execsql_test 4.2.6 { + INSERT INTO t4(rowid, x) SELECT rowid, x FROM ft4x; + INSERT INTO ft4(ft4) VALUES('rebuild'); + SELECT id, quote(value) FROM ft4_stat; + SELECT docid, quote(size) FROM ft4_docsize +} {0 X'05182B' 1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'} + + +#------------------------------------------------------------------------- +# Test cases 5.* test that the following commands do not create/move or +# delete a %_content table when used with a content=xxx FTS table. +# +do_execsql_test 5.1.1 { + CREATE TABLE t5(a, b, c, d); + CREATE VIRTUAL TABLE ft5 USING fts4(content=t5); + SELECT name FROM sqlite_master WHERE name LIKE '%t5%'; +} { + t5 ft5 ft5_segments ft5_segdir + sqlite_autoindex_ft5_segdir_1 ft5_docsize ft5_stat +} +do_execsql_test 5.1.2 { + ALTER TABLE ft5 RENAME TO ft6; + SELECT name FROM sqlite_master WHERE name LIKE '%t5%'; +} { + t5 +} +do_execsql_test 5.1.3 { + SELECT name FROM sqlite_master WHERE name LIKE '%t6%'; +} { + ft6 ft6_segments ft6_segdir + sqlite_autoindex_ft6_segdir_1 ft6_docsize ft6_stat +} +do_execsql_test 5.1.4 { + INSERT INTO t5 VALUES('a', 'b', 'c', 'd'); + INSERT INTO ft6(ft6) VALUES('rebuild'); + SELECT rowid FROM ft6 WHERE ft6 MATCH 'b'; +} {1} +do_execsql_test 5.1.5 { + DROP TABLE ft6; + SELECT * FROM t5; +} {a b c d} +do_execsql_test 5.1.6 { + SELECT name FROM sqlite_master WHERE name LIKE '%t6%'; +} { +} +do_execsql_test 5.1.7 { + CREATE VIRTUAL TABLE ft5 USING fts4(content=t5); + CREATE TABLE t5_content(a, b); + DROP TABLE ft5; + SELECT name FROM sqlite_master WHERE name LIKE '%t5%'; +} { + t5 t5_content +} + +finish_test diff --git a/test/permutations.test b/test/permutations.test index c911e6f062..9ae881ba23 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -180,10 +180,9 @@ test_suite "fts3" -prefix "" -description { fts3defer.test fts3defer2.test fts3e.test fts3expr.test fts3expr2.test fts3near.test fts3query.test fts3shared.test fts3snippet.test fts3sort.test - fts3fault.test fts3malloc.test fts3matchinfo.test - fts3aux1.test fts3comp1.test fts3auto.test + fts4aa.test fts4content.test } From cc5b81464a4ea31d8a3357f10514bded304ab211 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 4 Oct 2011 16:37:35 +0000 Subject: [PATCH 02/51] Add tests to check that modifying the schema of an FTS content table does not cause a crash in the FTS module. Also disable the deferred token optimization for content=xxx FTS tables. FossilOrigin-Name: be86c7061b68f403730bf63ea1f7dc0d9ceb0a3b --- ext/fts3/fts3.c | 9 +++++ ext/fts3/fts3Int.h | 3 +- manifest | 21 +++++------ manifest.uuid | 2 +- test/fts4content.test | 85 ++++++++++++++++++++++++++++++++++++++++++ test/permutations.test | 2 + 6 files changed, 107 insertions(+), 15 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index c188945b28..c6b356f51f 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4048,6 +4048,15 @@ static int fts3EvalSelectDeferred( int nMinEst = 0; /* The minimum count for any phrase so far. */ int nLoad4 = 1; /* (Phrases that will be loaded)^4. */ + /* Tokens are never deferred for FTS tables created using the content=xxx + ** option. The reason being that it is not guaranteed that the content + ** table actually contains the same data as the index. To prevent this from + ** causing any problems, the deferred token optimization is completely + ** disabled for content=xxx tables. */ + if( pTab->zContentTbl ){ + return SQLITE_OK; + } + /* Count the tokens in this AND/NEAR cluster. If none of the doclists ** associated with the tokens spill onto overflow pages, or if there is ** only 1 token, exit early. No tokens to defer in this case. */ diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index b4f26fc7a5..552d73d764 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -225,7 +225,7 @@ struct Fts3Table { int nPendingData; /* Current bytes of pending data */ sqlite_int64 iPrevDocid; /* Docid of most recently inserted document */ -#if defined(SQLITE_DEBUG) +#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) /* State variables used for validating that the transaction control ** methods of the virtual table are called at appropriate times. These ** values do not contribution to the FTS computation; they are used for @@ -246,7 +246,6 @@ struct Fts3Cursor { i16 eSearch; /* Search strategy (see below) */ u8 isEof; /* True if at End Of Results */ u8 isRequireSeek; /* True if must seek pStmt to %_content row */ - u8 isNullRow; /* True for a row of NULLs */ sqlite3_stmt *pStmt; /* Prepared statement in use by the cursor */ Fts3Expr *pExpr; /* Parsed MATCH query string */ int nPhrase; /* Number of matchable phrases in query */ diff --git a/manifest b/manifest index 6ca44ed83d..9881895908 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sexperimental\s'content'\soption\sto\sFTS4. -D 2011-10-04T11:22:59.677 +C Add\stests\sto\scheck\sthat\smodifying\sthe\sschema\sof\san\sFTS\scontent\stable\sdoes\snot\scause\sa\scrash\sin\sthe\sFTS\smodule.\sAlso\sdisable\sthe\sdeferred\stoken\soptimization\sfor\scontent=xxx\sFTS\stables. +D 2011-10-04T16:37:35.422 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,9 +62,9 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 626fcf477e531b470f06aae3d427abcda2d5d31c +F ext/fts3/fts3.c df149056426597b32b2b8488eefbc755258f55d7 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h a335d671d42ca07528a93c5b830e48e0205b26bc +F ext/fts3/fts3Int.h 06f442ce096e6254432a6b16a56b6fe7b24bd372 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 F ext/fts3/fts3_expr.c 23791de01b3a5d313d76e02befd2601d4096bc2b F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 @@ -486,7 +486,7 @@ F test/fts3shared.test 8bb266521d7c5495c0ae522bb4d376ad5387d4a2 F test/fts3snippet.test 8e956051221a34c7daeb504f023cb54d5fa5a8b2 F test/fts3sort.test 9a5176c9317bb545ec5f144d62e6fedb4da6c66e F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68 -F test/fts4content.test fbafb7160eef1560b6a254b1ad5631acccd388a1 +F test/fts4content.test 5c226c7c666e250c175bcbdfbdd4be3f275c73ba F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a @@ -621,7 +621,7 @@ F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806 F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 -F test/permutations.test 7b1c4cb40af3712e42364c82390ace0df207b5e0 +F test/permutations.test d850b5000a13baf042d5a20eb747079477dad45e F test/pragma.test c8108e01da04f16e67e5754e610bc62c1b993f6c F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea @@ -966,10 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P eb5da5e1dbe9c198095036827318fb381441cbd0 -R 7991a3071fb34636c7b5ed4b010ad95a -T *branch * fts4-content -T *sym-fts4-content * -T -sym-trunk * +P 1d27ea741f61c624e18bdc6a3b1c2d8574a64ddc +R da82d432e1ef8526b881f10f91640d66 U dan -Z 48ff718a3615a321d5bc0764cb014ed4 +Z d642325dd5adee7274f24ac6f8449504 diff --git a/manifest.uuid b/manifest.uuid index be6a47c58b..18907d6d6b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1d27ea741f61c624e18bdc6a3b1c2d8574a64ddc \ No newline at end of file +be86c7061b68f403730bf63ea1f7dc0d9ceb0a3b \ No newline at end of file diff --git a/test/fts4content.test b/test/fts4content.test index 6ac5a6806a..7925ed218d 100644 --- a/test/fts4content.test +++ b/test/fts4content.test @@ -22,6 +22,24 @@ ifcapable !fts3 { return } +#------------------------------------------------------------------------- +# Test organization: +# +# 1.* - Warm-body tests. +# +# 2.* - Querying a content=xxx FTS table. +# +# 3.* - Writing to a content=xxx FTS table. +# +# 4.* - The "INSERT INTO fts(fts) VALUES('rebuild')" command. +# +# 5.* - Check that CREATE TABLE, DROP TABLE and ALTER TABLE correctly +# ignore any %_content table when used with the content=xxx option. +# +# 6.* - Test the effects of messing with the schema of table xxx after +# creating a content=xxx FTS index. +# + do_execsql_test 1.1 { CREATE TABLE t1(a, b, c); INSERT INTO t1 VALUES('w x', 'x y', 'y z'); @@ -363,4 +381,71 @@ do_execsql_test 5.1.7 { t5 t5_content } +#------------------------------------------------------------------------- +# Test cases 6.* test +# +do_catchsql_test 6.1.1 { + CREATE VIRTUAL TABLE ft7 USING fts4(content=t7); +} {1 {vtable constructor failed: ft7}} + +do_execsql_test 6.2.1 { + CREATE TABLE t7(one, two); + CREATE VIRTUAL TABLE ft7 USING fts4(content=t7); + INSERT INTO t7 VALUES('A B', 'B A'); + INSERT INTO t7 VALUES('C D', 'A A'); + SELECT * FROM ft7; +} { + {A B} {B A} {C D} {A A} +} + +do_catchsql_test 6.2.2 { + DROP TABLE t7; + SELECT * FROM ft7; +} {1 {SQL logic error or missing database}} + +db close +sqlite3 db test.db +do_execsql_test 6.2.3 { + SELECT name FROM sqlite_master WHERE name LIKE '%t7%' +} { + ft7 ft7_segments ft7_segdir sqlite_autoindex_ft7_segdir_1 + ft7_docsize ft7_stat +} +do_catchsql_test 6.2.4 { + SELECT * FROM ft7; +} {1 {vtable constructor failed: ft7}} +do_execsql_test 6.2.5 { + CREATE TABLE t7(x, y); + INSERT INTO t7 VALUES('A B', 'B A'); + INSERT INTO t7 VALUES('C D', 'A A'); + SELECT * FROM ft7; +} { + {A B} {B A} {C D} {A A} +} + +do_execsql_test 6.2.6 { + INSERT INTO ft7(ft7) VALUES('rebuild'); + SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"'; +} {2} + +do_execsql_test 6.2.7 { + DROP TABLE t7; + CREATE TABLE t7(x); +} +do_catchsql_test 6.2.8 { + SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"'; +} {1 {SQL logic error or missing database}} +do_catchsql_test 6.2.9 { + SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"'; +} {1 {SQL logic error or missing database}} + +db close +sqlite3 db test.db +do_catchsql_test 6.2.10 { + SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"'; +} {0 2} +do_catchsql_test 6.2.11 { + SELECT rowid, * FROM ft7 WHERE ft7 MATCH '"A A"'; +} {0 {2 {}}} + finish_test diff --git a/test/permutations.test b/test/permutations.test index 9ae881ba23..14330d0cc1 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -183,6 +183,8 @@ test_suite "fts3" -prefix "" -description { fts3fault.test fts3malloc.test fts3matchinfo.test fts3aux1.test fts3comp1.test fts3auto.test fts4aa.test fts4content.test + fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test + fts3corrupt2.test } From 49fc336438e8bfca1427cbf1fe386259a111259b Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 4 Oct 2011 19:41:50 +0000 Subject: [PATCH 03/51] Improve test coverage of fts3.c. FossilOrigin-Name: 0f439944ab49a5691615bc170fdcf652055573df --- ext/fts3/fts3.c | 40 +++++++++++++++++++++------------------- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- test/fts3ao.test | 3 +++ test/fts3fault2.test | 23 +++++++++++++++++++++++ test/fts3malloc.test | 1 + test/fts3matchinfo.test | 16 ++++++++++++++++ test/fts3prefix.test | 10 ++++++++++ test/fts3sort.test | 5 +++++ 9 files changed, 92 insertions(+), 32 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index c6b356f51f..624221f979 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1151,7 +1151,7 @@ static int fts3InitVtab( case 4: /* ORDER */ if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3)) - && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 3)) + && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4)) ){ *pzErr = sqlite3_mprintf("unrecognized order: %s", zVal); rc = SQLITE_ERROR; @@ -1159,7 +1159,8 @@ static int fts3InitVtab( bDescIdx = (zVal[0]=='d' || zVal[0]=='D'); break; - case 5: /* CONTENT */ + default: /* CONTENT */ + assert( iOpt==5 ); sqlite3_free(zUncompress); zContent = zVal; zVal = 0; @@ -1928,7 +1929,7 @@ static int fts3PoslistPhraseMerge( char **pp1, /* IN/OUT: Left input list */ char **pp2 /* IN/OUT: Right input list */ ){ - char *p = (pp ? *pp : 0); + char *p = *pp; char *p1 = *pp1; char *p2 = *pp2; int iCol1 = 0; @@ -1954,7 +1955,7 @@ static int fts3PoslistPhraseMerge( sqlite3_int64 iPos1 = 0; sqlite3_int64 iPos2 = 0; - if( pp && iCol1 ){ + if( iCol1 ){ *p++ = POS_COLUMN; p += sqlite3Fts3PutVarint(p, iCol1); } @@ -1969,13 +1970,6 @@ static int fts3PoslistPhraseMerge( || (isExact==0 && iPos2>iPos1 && iPos2<=iPos1+nToken) ){ sqlite3_int64 iSave; - if( !pp ){ - fts3PoslistCopy(0, &p2); - fts3PoslistCopy(0, &p1); - *pp1 = p1; - *pp2 = p2; - return 1; - } iSave = isSaveLeft ? iPos1 : iPos2; fts3PutDeltaVarint(&p, &iPrev, iSave+2); iPrev -= 2; pSave = 0; @@ -2027,7 +2021,7 @@ static int fts3PoslistPhraseMerge( fts3PoslistCopy(0, &p1); *pp1 = p1; *pp2 = p2; - if( !pp || *pp==p ){ + if( *pp==p ){ return 0; } *p++ = 0x00; @@ -3216,10 +3210,14 @@ static int fts3RenameMethod( sqlite3 *db = p->db; /* Database connection */ int rc; /* Return Code */ + /* As it happens, the pending terms table is always empty here. This is + ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction + ** always opens a savepoint transaction. And the xSavepoint() method + ** flushes the pending terms table. But leave the (no-op) call to + ** PendingTermsFlush() in in case that changes. + */ + assert( p->nPendingData==0 ); rc = sqlite3Fts3PendingTermsFlush(p); - if( rc!=SQLITE_OK ){ - return rc; - } if( p->zContentTbl==0 ){ fts3DbExec(&rc, db, @@ -3586,21 +3584,20 @@ static int fts3EvalPhraseLoad( */ static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){ int iToken; /* Used to iterate through phrase tokens */ - int rc = SQLITE_OK; /* Return code */ char *aPoslist = 0; /* Position list for deferred tokens */ int nPoslist = 0; /* Number of bytes in aPoslist */ int iPrev = -1; /* Token number of previous deferred token */ assert( pPhrase->doclist.bFreeList==0 ); - for(iToken=0; rc==SQLITE_OK && iTokennToken; iToken++){ + for(iToken=0; iTokennToken; iToken++){ Fts3PhraseToken *pToken = &pPhrase->aToken[iToken]; Fts3DeferredToken *pDeferred = pToken->pDeferred; if( pDeferred ){ char *pList; int nList; - rc = sqlite3Fts3DeferredTokenList(pDeferred, &pList, &nList); + int rc = sqlite3Fts3DeferredTokenList(pDeferred, &pList, &nList); if( rc!=SQLITE_OK ) return rc; if( pList==0 ){ @@ -3930,7 +3927,7 @@ static void fts3EvalTokenCosts( Fts3Expr ***ppOr, /* Write new OR root to *(*ppOr)++ */ int *pRc /* IN/OUT: Error code */ ){ - if( *pRc==SQLITE_OK && pExpr ){ + if( *pRc==SQLITE_OK ){ if( pExpr->eType==FTSQUERY_PHRASE ){ Fts3Phrase *pPhrase = pExpr->pPhrase; int i; @@ -3944,6 +3941,11 @@ static void fts3EvalTokenCosts( *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl); } }else if( pExpr->eType!=FTSQUERY_NOT ){ + assert( pExpr->eType==FTSQUERY_OR + || pExpr->eType==FTSQUERY_AND + || pExpr->eType==FTSQUERY_NEAR + ); + assert( pExpr->pLeft && pExpr->pRight ); if( pExpr->eType==FTSQUERY_OR ){ pRoot = pExpr->pLeft; **ppOr = pRoot; diff --git a/manifest b/manifest index 9881895908..e1d1bbee86 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sto\scheck\sthat\smodifying\sthe\sschema\sof\san\sFTS\scontent\stable\sdoes\snot\scause\sa\scrash\sin\sthe\sFTS\smodule.\sAlso\sdisable\sthe\sdeferred\stoken\soptimization\sfor\scontent=xxx\sFTS\stables. -D 2011-10-04T16:37:35.422 +C Improve\stest\scoverage\sof\sfts3.c. +D 2011-10-04T19:41:50.550 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c df149056426597b32b2b8488eefbc755258f55d7 +F ext/fts3/fts3.c 6d6f3d331ed785d2e68608443eff66448ea95354 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 06f442ce096e6254432a6b16a56b6fe7b24bd372 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -457,7 +457,7 @@ F test/fts3ak.test bd14deafe9d1586e8e9bf032411026ac4f8c925d F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8 F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18 -F test/fts3ao.test 60a15590d3c8578e943e4a149524b16b9bc1be92 +F test/fts3ao.test e7b80272efcced57d1d087a9da5c690dd7c21fd9 F test/fts3atoken.test 402ef2f7c2fb4b3d4fa0587df6441c1447e799b3 F test/fts3auto.test c1a30b37002b7c764a96937fbc71065b73d69494 F test/fts3aux1.test 0b02743955d56fc0d4d66236a26177bd1b726de0 @@ -475,16 +475,16 @@ F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 -F test/fts3fault2.test dc96203af6ba31ce20163fc35460e1556e8edf4d -F test/fts3malloc.test 9c8cc3f885bb4dfc66d0460c52f68f45e4710d1b -F test/fts3matchinfo.test 08a82d18cc08abb28aec41d412b4c2ef25ba6a5f +F test/fts3fault2.test 253f9b336043ab7d0393d1b97a9f4ed21190331a +F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be +F test/fts3matchinfo.test 6507fe1c342e542300d65ea637d4110eccf894e6 F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 -F test/fts3prefix.test 36246609111ec1683f7ea5ed27666ce2cefb5676 +F test/fts3prefix.test b36d4f00b128a51e7b386cc013a874246d9d7dc1 F test/fts3query.test ef79d31fdb355d094baec1c1b24b60439a1fb8a2 F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 8bb266521d7c5495c0ae522bb4d376ad5387d4a2 F test/fts3snippet.test 8e956051221a34c7daeb504f023cb54d5fa5a8b2 -F test/fts3sort.test 9a5176c9317bb545ec5f144d62e6fedb4da6c66e +F test/fts3sort.test 95be0b19d7e41c44b29014f13ea8bddd495fd659 F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68 F test/fts4content.test 5c226c7c666e250c175bcbdfbdd4be3f275c73ba F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P 1d27ea741f61c624e18bdc6a3b1c2d8574a64ddc -R da82d432e1ef8526b881f10f91640d66 +P be86c7061b68f403730bf63ea1f7dc0d9ceb0a3b +R 5a9454f18e2824c0a4b3f3725eccae4e U dan -Z d642325dd5adee7274f24ac6f8449504 +Z e08086009c7ea460be359636e4d09cb8 diff --git a/manifest.uuid b/manifest.uuid index 18907d6d6b..2e94e1ac7c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -be86c7061b68f403730bf63ea1f7dc0d9ceb0a3b \ No newline at end of file +0f439944ab49a5691615bc170fdcf652055573df \ No newline at end of file diff --git a/test/fts3ao.test b/test/fts3ao.test index 0b6fcd3d19..786667a7f3 100644 --- a/test/fts3ao.test +++ b/test/fts3ao.test @@ -200,6 +200,9 @@ do_test fts3ao-4.7 { SELECT * FROM t5; } } {{the quick brown fox} {jumped over the} {lazy dog}} +do_execsql_test fts3ao-4.8 { + SELECT snippet(t5, '[', ']') FROM t5 WHERE t5 MATCH 'the' +} {{[the] quick brown fox} {jumped over [the]}} # Test that it is possible to rename an FTS4 table. Renaming an FTS4 table # involves renaming the extra %_docsize and %_stat tables. diff --git a/test/fts3fault2.test b/test/fts3fault2.test index fb877737f4..c24c52fe95 100644 --- a/test/fts3fault2.test +++ b/test/fts3fault2.test @@ -82,4 +82,27 @@ do_faultsim_test 2.1 -prep { faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 1 1 c 0 1 1 x * 1 1 x 1 1 1 y * 1 1 y 1 1 1 z * 1 1 z 1 1 1}} } +do_faultsim_test 3.0 -faults oom* -prep { + faultsim_delete_and_reopen + db eval { CREATE TABLE 'xx yy'(a, b); } +} -body { + execsql { + CREATE VIRTUAL TABLE tt USING fts4(content="xx yy"); + } +} -test { + faultsim_test_result {0 {}} +} + +do_faultsim_test 3.1 -faults oom* -prep { + faultsim_delete_and_reopen + db func zip zip + db func unzip unzip +} -body { + execsql { + CREATE VIRTUAL TABLE tt USING fts4(compress=zip, uncompress=unzip); + } +} -test { + faultsim_test_result {0 {}} +} + finish_test diff --git a/test/fts3malloc.test b/test/fts3malloc.test index 932ea098d0..7eeee7fe0d 100644 --- a/test/fts3malloc.test +++ b/test/fts3malloc.test @@ -294,6 +294,7 @@ do_write_test fts3_malloc-5.1 ft_content { do_test fts3_malloc-5.2 { execsql { CREATE VIRTUAL TABLE ft8 USING fts3(x, tokenize porter) } } {} + do_write_test fts3_malloc-5.3 ft_content { INSERT INTO ft8 VALUES('short alongertoken reallyquitealotlongerimeanit andthistokenisjustsolongthatonemightbeforgivenforimaginingthatitwasmerelyacontrivedexampleandnotarealtoken') } diff --git a/test/fts3matchinfo.test b/test/fts3matchinfo.test index 40366b6aef..0e8885804f 100644 --- a/test/fts3matchinfo.test +++ b/test/fts3matchinfo.test @@ -19,6 +19,7 @@ source $testdir/tester.tcl ifcapable !fts3 { finish_test ; return } set testprefix fts3matchinfo +set sqlite_fts3_enable_parentheses 0 proc mit {blob} { set scan(littleEndian) i* @@ -57,6 +58,9 @@ do_catchsql_test 2.0 { do_catchsql_test 2.1 { CREATE VIRTUAL TABLE x2 USING fts4(mtchinfo=fts3); } {1 {unrecognized parameter: mtchinfo=fts3}} +do_catchsql_test 2.2 { + CREATE VIRTUAL TABLE x2 USING fts4(matchinfo=fts5); +} {1 {unrecognized matchinfo: fts5}} # Check that with fts3, the "=" character is permitted in column definitions. # @@ -224,6 +228,18 @@ do_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'} { s {{2 0} {0 2}} } do_matchinfo_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} } do_matchinfo_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} } do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'} { s {{1 0} {0 1}} } +do_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} { + x { + {0 1 1 1 1 1 0 0 0 0 0 0} + {1 1 1 0 1 1 0 0 0 0 0 0} + } +} +do_matchinfo_test 4.1.8 t4 {t4 MATCH 'f -abcd'} { + x { + {0 1 1 1 1 1} + {1 1 1 0 1 1} + } +} do_execsql_test 4.2.0 { CREATE VIRTUAL TABLE t5 USING fts4; diff --git a/test/fts3prefix.test b/test/fts3prefix.test index f5e31f3208..e7c197da9d 100644 --- a/test/fts3prefix.test +++ b/test/fts3prefix.test @@ -200,4 +200,14 @@ do_execsql_test 4.6 { SELECT * FROM t3 WHERE t3 MATCH 'one*' } {{one two three}} +#------------------------------------------------------------------------- +# Syntax tests. +# +do_catchsql_test 5.1 { + CREATE VIRTUAL TABLE t4 USING fts4(prefix="abc"); +} {1 {error parsing prefix parameter: abc}} +do_catchsql_test 5.2 { + CREATE VIRTUAL TABLE t4 USING fts4(prefix=""); +} {0 {}} + finish_test diff --git a/test/fts3sort.test b/test/fts3sort.test index ccdc203442..be7560432b 100644 --- a/test/fts3sort.test +++ b/test/fts3sort.test @@ -138,6 +138,8 @@ foreach {tn param res} { 3 "order=dec" {1 {unrecognized order: dec}} 4 "order=xxx, order=asc" {1 {unrecognized order: xxx}} 5 "order=desc, order=asc" {0 {}} + 6 "order=xxxx, order=asc" {1 {unrecognized order: xxxx}} + 7 "order=desk" {1 {unrecognized order: desk}} } { execsql { DROP TABLE IF EXISTS t1 } do_catchsql_test 2.1.$tn " @@ -157,6 +159,9 @@ do_execsql_test 2.2 { do_execsql_test 2.3 { SELECT docid FROM t2 WHERE t2 MATCH 'aa'; } {3 1} +do_execsql_test 2.4 { + SELECT docid FROM t2 WHERE t2 MATCH 'aa' ORDER BY content; +} {1 3} #------------------------------------------------------------------------- # Test that ticket [56be976859] has been fixed. From 8361b189c9c28f2fecdd329ccd897be819a78159 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Oct 2011 06:07:00 +0000 Subject: [PATCH 04/51] Fix a problem with IO error handling in the rebuild-index code. FossilOrigin-Name: c6ba81fcad32192674bd510e607f787adc1f7038 --- ext/fts3/fts3_write.c | 6 ++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts3fault2.test | 26 ++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 46a1ead2d8..591f31f081 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -3001,8 +3001,10 @@ static int fts3DoRebuild(Fts3Table *p){ sqlite3_free(aSz); if( pStmt ){ - assert( rc==SQLITE_OK ); - rc = sqlite3_finalize(pStmt); + int rc2 = sqlite3_finalize(pStmt); + if( rc==SQLITE_OK ){ + rc = rc2; + } } } diff --git a/manifest b/manifest index e1d1bbee86..b582707f76 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\stest\scoverage\sof\sfts3.c. -D 2011-10-04T19:41:50.550 +C Fix\sa\sproblem\swith\sIO\serror\shandling\sin\sthe\srebuild-index\scode. +D 2011-10-05T06:07:00.875 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -77,7 +77,7 @@ F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c 9e14eb54310345b441d7a8c83bc3ae474230bea6 +F ext/fts3/fts3_write.c 16fba93fc840f15421ebf1a783a8c3395700bbf9 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -475,7 +475,7 @@ F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 -F test/fts3fault2.test 253f9b336043ab7d0393d1b97a9f4ed21190331a +F test/fts3fault2.test b62a2bc843c20414405f80e5eeb78e39bc68fe53 F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be F test/fts3matchinfo.test 6507fe1c342e542300d65ea637d4110eccf894e6 F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P be86c7061b68f403730bf63ea1f7dc0d9ceb0a3b -R 5a9454f18e2824c0a4b3f3725eccae4e +P 0f439944ab49a5691615bc170fdcf652055573df +R 29197ea13db81f2ba07fe324b03117e5 U dan -Z e08086009c7ea460be359636e4d09cb8 +Z a28913360f741831433fc7b43c93a8a9 diff --git a/manifest.uuid b/manifest.uuid index 2e94e1ac7c..5039f9295e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f439944ab49a5691615bc170fdcf652055573df \ No newline at end of file +c6ba81fcad32192674bd510e607f787adc1f7038 \ No newline at end of file diff --git a/test/fts3fault2.test b/test/fts3fault2.test index c24c52fe95..0178ed27cc 100644 --- a/test/fts3fault2.test +++ b/test/fts3fault2.test @@ -105,4 +105,30 @@ do_faultsim_test 3.1 -faults oom* -prep { faultsim_test_result {0 {}} } +do_test 4.0 { + faultsim_delete_and_reopen + execsql { + CREATE VIRTUAL TABLE ft USING fts4(a, b); + INSERT INTO ft VALUES('U U T C O', 'F N D E S'); + INSERT INTO ft VALUES('P H X G B', 'I D M R U'); + INSERT INTO ft VALUES('P P X D M', 'Y V N T C'); + INSERT INTO ft VALUES('Z L Q O W', 'D F U N Q'); + INSERT INTO ft VALUES('A J D U P', 'C H M Q E'); + INSERT INTO ft VALUES('P S A O H', 'S Z C W D'); + INSERT INTO ft VALUES('T B N L W', 'C A K T I'); + INSERT INTO ft VALUES('K E Z L O', 'L L Y C E'); + INSERT INTO ft VALUES('C R E S V', 'Q V F W P'); + INSERT INTO ft VALUES('S K H G W', 'R W Q F G'); + } + faultsim_save_and_close +} {} +do_faultsim_test 4.1 -prep { + faultsim_restore_and_reopen + db eval {SELECT * FROM sqlite_master} +} -body { + execsql { INSERT INTO ft(ft) VALUES('rebuild') } +} -test { + faultsim_test_result {0 {}} +} + finish_test From deb9473250318fd3f361d59178df39129d6bd810 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 5 Oct 2011 15:11:30 +0000 Subject: [PATCH 05/51] Change FTS4 so that if both the content=xxx option and column names are specified, the virtual table assumes that the named columns correspond to columns of table xxx. FossilOrigin-Name: 289ee43179369fce2fde50870d72c445e184e896 --- ext/fts3/fts3.c | 105 +++++++++++++++++++++++++----------------- ext/fts3/fts3_write.c | 17 +++++-- manifest | 16 +++---- manifest.uuid | 2 +- test/fts4content.test | 45 ++++++++++++++---- 5 files changed, 121 insertions(+), 64 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 624221f979..6fa06907bf 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1182,20 +1182,19 @@ static int fts3InitVtab( ** ** 1. Ignore any compress= and uncompress= options. ** - ** 2. Ignore any column names that were specified as part of the - ** the CREATE VIRTUAL TABLE statement. - ** - ** 3. Determine the actual column names to use for the FTS table - ** based on the columns of the content= table. + ** 2. If no column names were specified as part of the CREATE VIRTUAL + ** TABLE statement, use all columns from the content table. */ if( rc==SQLITE_OK && zContent ){ - sqlite3_free(aCol); sqlite3_free(zCompress); sqlite3_free(zUncompress); zCompress = 0; zUncompress = 0; - aCol = 0; - rc = fts3ContentColumns(db, argv[1], zContent, &aCol, &nCol, &nString); + if( nCol==0 ){ + sqlite3_free(aCol); + aCol = 0; + rc = fts3ContentColumns(db, argv[1], zContent, &aCol, &nCol, &nString); + } assert( rc!=SQLITE_OK || nCol>0 ); } if( rc!=SQLITE_OK ) goto fts3_init_out; @@ -1457,40 +1456,64 @@ static int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){ return SQLITE_OK; } +/* +** If pCsr->pStmt has not been prepared (i.e. if pCsr->pStmt==0), then +** compose and prepare an SQL statement of the form: +** +** "SELECT FROM %_content WHERE rowid = ?" +** +** (or the equivalent for a content=xxx table) and set pCsr->pStmt to +** it. If an error occurs, return an SQLite error code. +** +** Otherwise, set *ppStmt to point to pCsr->pStmt and return SQLITE_OK. +*/ +static int fts3CursorSeekStmt(Fts3Cursor *pCsr, sqlite3_stmt **ppStmt){ + int rc = SQLITE_OK; + if( pCsr->pStmt==0 ){ + Fts3Table *p = (Fts3Table *)pCsr->base.pVtab; + char *zSql; + zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist); + if( !zSql ) return SQLITE_NOMEM; + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); + sqlite3_free(zSql); + } + *ppStmt = pCsr->pStmt; + return rc; +} + /* ** Position the pCsr->pStmt statement so that it is on the row ** of the %_content table that contains the last match. Return ** SQLITE_OK on success. */ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ + int rc = SQLITE_OK; if( pCsr->isRequireSeek ){ - sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId); - pCsr->isRequireSeek = 0; - if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ - return SQLITE_OK; - }else{ - int rc = sqlite3_reset(pCsr->pStmt); - if( rc==SQLITE_OK ){ - Fts3Table *p = (Fts3Table *)pCsr->base.pVtab; - if( p->zContentTbl==0 ){ + sqlite3_stmt *pStmt = 0; + + rc = fts3CursorSeekStmt(pCsr, &pStmt); + if( rc==SQLITE_OK ){ + sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId); + pCsr->isRequireSeek = 0; + if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ + return SQLITE_OK; + }else{ + rc = sqlite3_reset(pCsr->pStmt); + if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){ /* If no row was found and no error has occured, then the %_content ** table is missing a row that is present in the full-text index. - ** The data structures are corrupt. - */ + ** The data structures are corrupt. */ rc = SQLITE_CORRUPT_VTAB; - }else{ - return SQLITE_OK; + pCsr->isEof = 1; } } - pCsr->isEof = 1; - if( pContext ){ - sqlite3_result_error_code(pContext, rc); - } - return rc; } - }else{ - return SQLITE_OK; } + + if( rc!=SQLITE_OK && pContext ){ + sqlite3_result_error_code(pContext, rc); + } + return rc; } /* @@ -2848,24 +2871,24 @@ static int fts3FilterMethod( ** row by docid. */ if( idxNum==FTS3_FULLSCAN_SEARCH ){ - const char *zTmpl = "SELECT %s ORDER BY rowid %s"; - zSql = sqlite3_mprintf(zTmpl, + zSql = sqlite3_mprintf( + "SELECT %s ORDER BY rowid %s", p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC") ); - }else{ - const char *zTmpl = "SELECT %s WHERE rowid = ?"; - zSql = sqlite3_mprintf(zTmpl, p->zReadExprlist); + if( zSql ){ + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); + sqlite3_free(zSql); + }else{ + rc = SQLITE_NOMEM; + } + }else if( idxNum==FTS3_DOCID_SEARCH ){ + rc = fts3CursorSeekStmt(pCsr, &pCsr->pStmt); + if( rc==SQLITE_OK ){ + rc = sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]); + } } - if( !zSql ) return SQLITE_NOMEM; - rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); - sqlite3_free(zSql); if( rc!=SQLITE_OK ) return rc; - if( idxNum==FTS3_DOCID_SEARCH ){ - rc = sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]); - if( rc!=SQLITE_OK ) return rc; - } - return fts3NextMethod(pCursor); } diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 591f31f081..47bed0dd5e 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -409,17 +409,24 @@ static void fts3SqlExec( ** not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. It can ** still happen if the user reads data directly from the %_segments or ** %_segdir tables instead of going through FTS3 though. +** +** This reasoning does not apply to a content=xxx table. */ int sqlite3Fts3ReadLock(Fts3Table *p){ int rc; /* Return code */ sqlite3_stmt *pStmt; /* Statement used to obtain lock */ - rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pStmt, 0); - if( rc==SQLITE_OK ){ - sqlite3_bind_null(pStmt, 1); - sqlite3_step(pStmt); - rc = sqlite3_reset(pStmt); + if( p->zContentTbl==0 ){ + rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pStmt, 0); + if( rc==SQLITE_OK ){ + sqlite3_bind_null(pStmt, 1); + sqlite3_step(pStmt); + rc = sqlite3_reset(pStmt); + } + }else{ + rc = SQLITE_OK; } + return rc; } diff --git a/manifest b/manifest index b582707f76..0c36a83a5c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sIO\serror\shandling\sin\sthe\srebuild-index\scode. -D 2011-10-05T06:07:00.875 +C Change\sFTS4\sso\sthat\sif\sboth\sthe\scontent=xxx\soption\sand\scolumn\snames\sare\sspecified,\sthe\svirtual\stable\sassumes\sthat\sthe\snamed\scolumns\scorrespond\sto\scolumns\sof\stable\sxxx. +D 2011-10-05T15:11:30.760 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 6d6f3d331ed785d2e68608443eff66448ea95354 +F ext/fts3/fts3.c f2ed0ae669534e0c9c8ba95b60b6c137544e7e49 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 06f442ce096e6254432a6b16a56b6fe7b24bd372 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -77,7 +77,7 @@ F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c 16fba93fc840f15421ebf1a783a8c3395700bbf9 +F ext/fts3/fts3_write.c 06520aa8a0a32a7bed08b29a9004fde1cb7f0318 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -486,7 +486,7 @@ F test/fts3shared.test 8bb266521d7c5495c0ae522bb4d376ad5387d4a2 F test/fts3snippet.test 8e956051221a34c7daeb504f023cb54d5fa5a8b2 F test/fts3sort.test 95be0b19d7e41c44b29014f13ea8bddd495fd659 F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68 -F test/fts4content.test 5c226c7c666e250c175bcbdfbdd4be3f275c73ba +F test/fts4content.test c5f531ecfc3d446b90032cae212549dbbb18dd78 F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P 0f439944ab49a5691615bc170fdcf652055573df -R 29197ea13db81f2ba07fe324b03117e5 +P c6ba81fcad32192674bd510e607f787adc1f7038 +R 0217fe49810be9d8f9417ba3c648ab3e U dan -Z a28913360f741831433fc7b43c93a8a9 +Z 1eb4f36513f7844867f45162778888e7 diff --git a/manifest.uuid b/manifest.uuid index 5039f9295e..b8efcec3d4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c6ba81fcad32192674bd510e607f787adc1f7038 \ No newline at end of file +289ee43179369fce2fde50870d72c445e184e896 \ No newline at end of file diff --git a/test/fts4content.test b/test/fts4content.test index 7925ed218d..8295d91d61 100644 --- a/test/fts4content.test +++ b/test/fts4content.test @@ -40,13 +40,13 @@ ifcapable !fts3 { # creating a content=xxx FTS index. # -do_execsql_test 1.1 { +do_execsql_test 1.1.1 { CREATE TABLE t1(a, b, c); INSERT INTO t1 VALUES('w x', 'x y', 'y z'); CREATE VIRTUAL TABLE ft1 USING fts4(content=t1); } -do_execsql_test 1.2 { +do_execsql_test 1.1.2 { PRAGMA table_info(ft1); } { 0 a {} 0 {} 0 @@ -54,12 +54,23 @@ do_execsql_test 1.2 { 2 c {} 0 {} 0 } -do_execsql_test 1.3 { SELECT *, rowid FROM ft1 } {{w x} {x y} {y z} 1} -do_execsql_test 1.4 { SELECT a, c FROM ft1 WHERE rowid=1 } {{w x} {y z}} +do_execsql_test 1.1.3 { SELECT *, rowid FROM ft1 } {{w x} {x y} {y z} 1} +do_execsql_test 1.1.4 { SELECT a, c FROM ft1 WHERE rowid=1 } {{w x} {y z}} -do_execsql_test 1.5 { INSERT INTO ft1(ft1) VALUES('rebuild') } {} -do_execsql_test 1.6 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'x' } {1} -do_execsql_test 1.7 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'a' } {} +do_execsql_test 1.1.5 { INSERT INTO ft1(ft1) VALUES('rebuild') } {} +do_execsql_test 1.1.6 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'x' } {1} +do_execsql_test 1.1.7 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'a' } {} + +do_execsql_test 1.2.1 { + DROP TABLE ft1; + CREATE VIRTUAL TABLE ft1 USING fts4(content=t1, b); + PRAGMA table_info(ft1); +} { + 0 b {} 0 {} 0 +} +do_execsql_test 1.2.2 { + SELECT *, rowid FROM ft1 +} {{x y} 1} #------------------------------------------------------------------------- # The following block of tests - 2.* - test that a content=xxx FTS table @@ -433,10 +444,10 @@ do_execsql_test 6.2.7 { CREATE TABLE t7(x); } do_catchsql_test 6.2.8 { - SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"'; + SELECT * FROM ft7 WHERE ft7 MATCH '"A A"'; } {1 {SQL logic error or missing database}} do_catchsql_test 6.2.9 { - SELECT rowid FROM ft7 WHERE ft7 MATCH '"A A"'; + SELECT * FROM ft7 WHERE ft7 MATCH '"A A"'; } {1 {SQL logic error or missing database}} db close @@ -448,4 +459,20 @@ do_catchsql_test 6.2.11 { SELECT rowid, * FROM ft7 WHERE ft7 MATCH '"A A"'; } {0 {2 {}}} +#------------------------------------------------------------------------- +# Test cases 7.* +# +do_execsql_test 7.1.1 { + CREATE VIRTUAL TABLE ft8 USING fts4(content=nosuchtable, x); + INSERT INTO ft8(docid, x) VALUES(13, 'U O N X G'); + INSERT INTO ft8(docid, x) VALUES(14, 'C J J U B'); + INSERT INTO ft8(docid, x) VALUES(15, 'N J Y G X'); + INSERT INTO ft8(docid, x) VALUES(16, 'R Y D O R'); + INSERT INTO ft8(docid, x) VALUES(17, 'I Y T Q O'); +} + +do_execsql_test 7.1.2 { + SELECT docid FROM ft8 WHERE ft8 MATCH 'N'; +} {13 15} + finish_test From 59eedf7925f06e8373b226e50e95e1b802034a7b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 11 Oct 2011 17:54:54 +0000 Subject: [PATCH 06/51] Remove all precision and width limits from formatting fields in the sqlite3_mprintf() family of functions. Malloc for space as necessary. The prevents a stack overflow on very large numbers using %f. FossilOrigin-Name: 1f843fb383583ee7ef51c13b8a820744e450101a --- manifest | 14 +++++------ manifest.uuid | 2 +- src/printf.c | 62 +++++++++++++++++++++++++----------------------- test/printf.test | 2 +- 4 files changed, 41 insertions(+), 39 deletions(-) diff --git a/manifest b/manifest index 79c4572a2b..f38e0e3be4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\srequirements\smarks\sassociate\swith\sSTAT3. -D 2011-10-11T12:39:19.194 +C Remove\sall\sprecision\sand\swidth\slimits\sfrom\sformatting\sfields\sin\sthe\nsqlite3_mprintf()\sfamily\sof\sfunctions.\sMalloc\sfor\sspace\sas\snecessary.\nThe\sprevents\sa\sstack\soverflow\son\svery\slarge\snumbers\susing\s%f. +D 2011-10-11T17:54:54.587 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 24f5e85a78514584b46190260ba7ab0a66312197 F src/pragma.c 68d7db4fc9de8bcfae94c1d43120531ec252b9c0 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 -F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1 +F src/printf.c 1cd24df913bafc0cb69dc7ae68af85cc480925aa F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 @@ -624,7 +624,7 @@ F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/permutations.test ad17319066a90e2db71823c3ff104795ffc71b31 F test/pragma.test c8108e01da04f16e67e5754e610bc62c1b993f6c F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 -F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea +F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P e5169f9a5b7e20b8adaf6ebb7868a64e44fd7321 -R fa1bfea306973bc99ccb0d80c9355cfe +P 9325c1a8c413dfbf0381190d8347f0a446ae5f5b +R e5d1b1fb843cbf71cdab9d042be23020 U drh -Z 7aa6c1f7c4e6214ddb2d3b34feac8ca1 +Z 4feb18f759ff84be86477c96fb244530 diff --git a/manifest.uuid b/manifest.uuid index 076bf3c8fd..4c5accd9f0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9325c1a8c413dfbf0381190d8347f0a446ae5f5b \ No newline at end of file +1f843fb383583ee7ef51c13b8a820744e450101a \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 2a3dd81d7d..2f6945577b 100644 --- a/src/printf.c +++ b/src/printf.c @@ -190,11 +190,7 @@ static void appendSpace(StrAccum *pAccum, int N){ ** SQLITE_PRINT_BUF_SIZE to be less than 350. */ #ifndef SQLITE_PRINT_BUF_SIZE -# if defined(SQLITE_SMALL_STACK) -# define SQLITE_PRINT_BUF_SIZE 50 -# else -# define SQLITE_PRINT_BUF_SIZE 350 -# endif +# define SQLITE_PRINT_BUF_SIZE 70 #endif #define etBUFSIZE SQLITE_PRINT_BUF_SIZE /* Size of the output buffer */ @@ -250,6 +246,8 @@ void sqlite3VXPrintf( LONGDOUBLE_TYPE realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char buf[etBUFSIZE]; /* Conversion buffer */ + char *zOut; /* Rendering buffer */ + int nOut; /* Size of the rendering buffer */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ etByte xtype = 0; /* Conversion paradigm */ char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ @@ -258,7 +256,6 @@ void sqlite3VXPrintf( double rounder; /* Used for rounding floating point values */ etByte flag_dp; /* True if decimal point should be shown */ etByte flag_rtz; /* True if trailing zeros should be removed */ - etByte flag_exp; /* True to force display of the exponent */ int nsd; /* Number of significant digits returned */ #endif @@ -307,9 +304,6 @@ void sqlite3VXPrintf( c = *++fmt; } } - if( width > etBUFSIZE-10 ){ - width = etBUFSIZE-10; - } /* Get the precision */ if( c=='.' ){ precision = 0; @@ -356,12 +350,6 @@ void sqlite3VXPrintf( } zExtra = 0; - - /* Limit the precision to prevent overflowing buf[] during conversion */ - if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){ - precision = etBUFSIZE-40; - } - /* ** At this point, variables are initialized as follows: ** @@ -426,16 +414,26 @@ void sqlite3VXPrintf( if( flag_zeropad && precisionmallocFailed = 1; + return; + } + } + bufpt = &zOut[nOut-1]; if( xtype==etORDINAL ){ static const char zOrd[] = "thstndrd"; int x = (int)(longvalue % 10); if( x>=4 || (longvalue/10)%10==1 ){ x = 0; } - buf[etBUFSIZE-3] = zOrd[x*2]; - buf[etBUFSIZE-2] = zOrd[x*2+1]; - bufpt -= 2; + *(--bufpt) = zOrd[x*2+1]; + *(--bufpt) = zOrd[x*2]; } { register const char *cset; /* Use registers for speed */ @@ -447,7 +445,7 @@ void sqlite3VXPrintf( longvalue = longvalue/base; }while( longvalue>0 ); } - length = (int)(&buf[etBUFSIZE-1]-bufpt); + length = (int)(&zOut[nOut-1]-bufpt); for(idx=precision-length; idx>0; idx--){ *(--bufpt) = '0'; /* Zero pad */ } @@ -458,7 +456,7 @@ void sqlite3VXPrintf( pre = &aPrefix[infop->prefix]; for(; (x=(*pre))!=0; pre++) *(--bufpt) = x; } - length = (int)(&buf[etBUFSIZE-1]-bufpt); + length = (int)(&zOut[nOut-1]-bufpt); break; case etFLOAT: case etEXP: @@ -468,7 +466,6 @@ void sqlite3VXPrintf( length = 0; #else if( precision<0 ) precision = 6; /* Set default precision */ - if( precision>etBUFSIZE/2-10 ) precision = etBUFSIZE/2-10; if( realvalue<0.0 ){ realvalue = -realvalue; prefix = '-'; @@ -516,7 +513,6 @@ void sqlite3VXPrintf( ** If the field type is etGENERIC, then convert to either etEXP ** or etFLOAT, as appropriate. */ - flag_exp = xtype==etEXP; if( xtype!=etFLOAT ){ realvalue += rounder; if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; } @@ -537,6 +533,14 @@ void sqlite3VXPrintf( }else{ e2 = exp; } + if( e2+precision+width > etBUFSIZE - 15 ){ + bufpt = zExtra = sqlite3Malloc( e2+precision+width+15 ); + if( bufpt==0 ){ + pAccum->mallocFailed = 1; + return; + } + } + zOut = bufpt; nsd = 0; flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2; /* The sign in front of the number */ @@ -568,7 +572,7 @@ void sqlite3VXPrintf( /* Remove trailing zeros and the "." if no digits follow the "." */ if( flag_rtz && flag_dp ){ while( bufpt[-1]=='0' ) *(--bufpt) = 0; - assert( bufpt>buf ); + assert( bufpt>zOut ); if( bufpt[-1]=='.' ){ if( flag_altform2 ){ *(bufpt++) = '0'; @@ -578,7 +582,7 @@ void sqlite3VXPrintf( } } /* Add the "eNNN" suffix */ - if( flag_exp || xtype==etEXP ){ + if( xtype==etEXP ){ *(bufpt++) = aDigits[infop->charset]; if( exp<0 ){ *(bufpt++) = '-'; exp = -exp; @@ -597,8 +601,8 @@ void sqlite3VXPrintf( /* The converted number is in buf[] and zero terminated. Output it. ** Note that the number is in the usual order, not reversed as with ** integer conversions. */ - length = (int)(bufpt-buf); - bufpt = buf; + length = (int)(bufpt-zOut); + bufpt = zOut; /* Special case: Add leading zeros if the flag_zeropad flag is ** set and we are not left justified */ @@ -736,9 +740,7 @@ void sqlite3VXPrintf( appendSpace(pAccum, nspace); } } - if( zExtra ){ - sqlite3_free(zExtra); - } + sqlite3_free(zExtra); }/* End for loop over the format string */ } /* End of function */ diff --git a/test/printf.test b/test/printf.test index 100ce96b12..73222720ab 100644 --- a/test/printf.test +++ b/test/printf.test @@ -3547,7 +3547,7 @@ do_test printf-4.16 { do_test printf-5.1 { set x [sqlite3_mprintf_str {%d %d %100000s} 0 0 {Hello}] string length $x -} {344} +} {100004} do_test printf-5.2 { sqlite3_mprintf_str {%d %d (%-10.10s) %} -9 -10 {HelloHelloHello} } {-9 -10 (HelloHello) %} From 3ec4a0c1a5bd314d2bb97f741e9ff49a1811ea5f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 11 Oct 2011 18:18:54 +0000 Subject: [PATCH 07/51] Change the behavior of the readonly_shm=1 query parameter so that it never attempts to open the -shm file read/write. FossilOrigin-Name: f1364004836078378e4005ab3eb9c0a04e3d4ce7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 17 ++++++++--------- test/walro.test | 6 +++--- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index f38e0e3be4..152af8299b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sall\sprecision\sand\swidth\slimits\sfrom\sformatting\sfields\sin\sthe\nsqlite3_mprintf()\sfamily\sof\sfunctions.\sMalloc\sfor\sspace\sas\snecessary.\nThe\sprevents\sa\sstack\soverflow\son\svery\slarge\snumbers\susing\s%f. -D 2011-10-11T17:54:54.587 +C Change\sthe\sbehavior\sof\sthe\sreadonly_shm=1\squery\sparameter\sso\sthat\sit\snever\nattempts\sto\sopen\sthe\s-shm\sfile\sread/write. +D 2011-10-11T18:18:54.704 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os.c 3b3f69c34be7f998f5ea6bd46a2fe8a2b7fa8f70 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 9da63854b702e0855ce13711a80d8bdcc5b69549 +F src/os_unix.c b14e8b40e28d983a908249442e1e0273a1ecb64e F src/os_win.c fbe47c7fdc9a846a772bbf98719c328becad5f8a F src/pager.c 8a6ac3e0d9694412076e2273e3c81e9c4e08758f F src/pager.h dbcaa791e8b6c3a6b77c168c5c27deec289fb176 @@ -905,7 +905,7 @@ F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 F test/walpersist.test fd40d33765b2693f721c90c66d97f99757559006 -F test/walro.test 412d0809300b94ba142440e94d6a30eabf2220b7 +F test/walro.test e6bb27762c9f22601cbb8bff6e0acfd124e74b63 F test/walshared.test 6dda2293880c300baf5d791c307f653094585761 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a F test/walthread.test a2ed5270eb695284d4ad27d252517bdc3317ee2a @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 9325c1a8c413dfbf0381190d8347f0a446ae5f5b -R e5d1b1fb843cbf71cdab9d042be23020 +P 1f843fb383583ee7ef51c13b8a820744e450101a +R 87c5e36e725d4b46722e677165962480 U drh -Z 4feb18f759ff84be86477c96fb244530 +Z 87c8aa4ca9cebc791402bbaa3b6f9b8a diff --git a/manifest.uuid b/manifest.uuid index 4c5accd9f0..c27b8b842a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f843fb383583ee7ef51c13b8a820744e450101a \ No newline at end of file +f1364004836078378e4005ab3eb9c0a04e3d4ce7 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index a23a76234b..6e87a4bfdf 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3854,16 +3854,15 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ } if( pInode->bProcessLock==0 ){ - pShmNode->h = robust_open(zShmFilename, O_RDWR|O_CREAT, - (sStat.st_mode & 0777)); + const char *zRO; + int openFlags = O_RDWR | O_CREAT; + zRO = sqlite3_uri_parameter(pDbFd->zPath, "readonly_shm"); + if( zRO && sqlite3GetBoolean(zRO) ){ + openFlags = O_RDONLY; + pShmNode->isReadonly = 1; + } + pShmNode->h = robust_open(zShmFilename, openFlags, (sStat.st_mode&0777)); if( pShmNode->h<0 ){ - const char *zRO; - zRO = sqlite3_uri_parameter(pDbFd->zPath, "readonly_shm"); - if( zRO && sqlite3GetBoolean(zRO) ){ - pShmNode->h = robust_open(zShmFilename, O_RDONLY, - (sStat.st_mode & 0777)); - pShmNode->isReadonly = 1; - } if( pShmNode->h<0 ){ rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShmFilename); goto shm_open_err; diff --git a/test/walro.test b/test/walro.test index a8c489a792..3ae7d53cd9 100644 --- a/test/walro.test +++ b/test/walro.test @@ -143,7 +143,7 @@ do_multiclient_test tn { } {1 {unable to open database file}} # Also test that if the -shm file can be opened for read/write access, - # it is, even if readonly_shm=1 is present in the URI. + # it is not if readonly_shm=1 is present in the URI. do_test 1.3.2.1 { code1 { db close } code2 { db2 close } @@ -151,8 +151,8 @@ do_multiclient_test tn { } {0} do_test 1.3.2.2 { code1 { sqlite3 db file:test.db?readonly_shm=1 } - sql1 { SELECT * FROM t1 } - } {a b c d e f g h i j k l} + csql1 { SELECT * FROM sqlite_master } + } {1 {unable to open database file}} do_test 1.3.2.3 { code1 { db close } close [open test.db-shm w] From 338ec3e18e198efc72678cd325db736665dc06e4 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 11 Oct 2011 20:14:41 +0000 Subject: [PATCH 08/51] Add a couple of asserts trying to make the operation of sqlite3SelectNew() clearer. FossilOrigin-Name: b21b1c7bc490b193da8d8a277489eb875a507e30 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/select.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 152af8299b..dd50da4e64 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sbehavior\sof\sthe\sreadonly_shm=1\squery\sparameter\sso\sthat\sit\snever\nattempts\sto\sopen\sthe\s-shm\sfile\sread/write. -D 2011-10-11T18:18:54.704 +C Add\sa\scouple\sof\sasserts\strying\sto\smake\sthe\soperation\sof\s\nsqlite3SelectNew()\sclearer. +D 2011-10-11T20:14:41.773 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/printf.c 1cd24df913bafc0cb69dc7ae68af85cc480925aa F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 -F src/select.c d9b7d20b0365f80761846f00ef3638d4b33eeaf2 +F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f F src/shell.c e8fe1251aee84baa2fb232ce83d938de25aa650f F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 1f843fb383583ee7ef51c13b8a820744e450101a -R 87c5e36e725d4b46722e677165962480 +P f1364004836078378e4005ab3eb9c0a04e3d4ce7 +R 3342cb35f3dfdd7fe1a8faa40e73a95e U drh -Z 87c8aa4ca9cebc791402bbaa3b6f9b8a +Z ff666d79c8aac1b8165f8cc9911a51c1 diff --git a/manifest.uuid b/manifest.uuid index c27b8b842a..b659a6ea86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f1364004836078378e4005ab3eb9c0a04e3d4ce7 \ No newline at end of file +b21b1c7bc490b193da8d8a277489eb875a507e30 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 89c6b251c3..cf9a00a8d8 100644 --- a/src/select.c +++ b/src/select.c @@ -65,6 +65,7 @@ Select *sqlite3SelectNew( pNew = sqlite3DbMallocZero(db, sizeof(*pNew) ); assert( db->mallocFailed || !pOffset || pLimit ); /* OFFSET implies LIMIT */ if( pNew==0 ){ + assert( db->mallocFailed ); pNew = &standin; memset(pNew, 0, sizeof(*pNew)); } @@ -92,6 +93,7 @@ Select *sqlite3SelectNew( }else{ assert( pNew->pSrc!=0 || pParse->nErr>0 ); } + assert( pNew!=&standin ); return pNew; } From f0693c8928161e7db8426e0e6d07de28b7e9b0ff Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 11 Oct 2011 20:41:54 +0000 Subject: [PATCH 09/51] Put in code to defend against signed/unsigned character problems in the command-line shell. FossilOrigin-Name: b94a80a832777f0e639f6a81fcfe169bf970a8c0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 37 +++++++++++++++++++++---------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index dd50da4e64..5fe5a99230 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\scouple\sof\sasserts\strying\sto\smake\sthe\soperation\sof\s\nsqlite3SelectNew()\sclearer. -D 2011-10-11T20:14:41.773 +C Put\sin\scode\sto\sdefend\sagainst\ssigned/unsigned\scharacter\sproblems\nin\sthe\scommand-line\sshell. +D 2011-10-11T20:41:54.810 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f -F src/shell.c e8fe1251aee84baa2fb232ce83d938de25aa650f +F src/shell.c a07ce148dc665e4283edf878d0fb52fed2018408 F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 2f66bf068131f0e499dd5e0abea3f68cd6b27b2d @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P f1364004836078378e4005ab3eb9c0a04e3d4ce7 -R 3342cb35f3dfdd7fe1a8faa40e73a95e +P b21b1c7bc490b193da8d8a277489eb875a507e30 +R 7c8d9511406d6fc0a6ea749b1b39d02c U drh -Z ff666d79c8aac1b8165f8cc9911a51c1 +Z 1652abdbfcdbd0d6697e8d56e8019c87 diff --git a/manifest.uuid b/manifest.uuid index b659a6ea86..781d1198a0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b21b1c7bc490b193da8d8a277489eb875a507e30 \ No newline at end of file +b94a80a832777f0e639f6a81fcfe169bf970a8c0 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 48933bc790..15a7b779e3 100644 --- a/src/shell.c +++ b/src/shell.c @@ -74,6 +74,11 @@ extern int isatty(); /* True if the timer is enabled */ static int enableTimer = 0; +/* ctype macros that work with signed characters */ +#define IsSpace(X) isspace((unsigned char)X) +#define IsDigit(X) isdigit((unsigned char)X) +#define ToLower(X) (char)tolower((unsigned char)X) + #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) && !defined(__RTP__) && !defined(_WRS_KERNEL) #include #include @@ -265,23 +270,23 @@ static void iotracePrintf(const char *zFormat, ...){ */ static int isNumber(const char *z, int *realnum){ if( *z=='-' || *z=='+' ) z++; - if( !isdigit(*z) ){ + if( !IsDigit(*z) ){ return 0; } z++; if( realnum ) *realnum = 0; - while( isdigit(*z) ){ z++; } + while( IsDigit(*z) ){ z++; } if( *z=='.' ){ z++; - if( !isdigit(*z) ) return 0; - while( isdigit(*z) ){ z++; } + if( !IsDigit(*z) ) return 0; + while( IsDigit(*z) ){ z++; } if( realnum ) *realnum = 1; } if( *z=='e' || *z=='E' ){ z++; if( *z=='+' || *z=='-' ) z++; - if( !isdigit(*z) ) return 0; - while( isdigit(*z) ){ z++; } + if( !IsDigit(*z) ) return 0; + while( IsDigit(*z) ){ z++; } if( realnum ) *realnum = 1; } return *z==0; @@ -1090,7 +1095,7 @@ static int shell_exec( if( !pStmt ){ /* this happens for a comment or white-space */ zSql = zLeftover; - while( isspace(zSql[0]) ) zSql++; + while( IsSpace(zSql[0]) ) zSql++; continue; } @@ -1170,7 +1175,7 @@ static int shell_exec( rc = sqlite3_finalize(pStmt); if( rc==SQLITE_OK ){ zSql = zLeftover; - while( isspace(zSql[0]) ) zSql++; + while( IsSpace(zSql[0]) ) zSql++; }else if( pzErrMsg ){ *pzErrMsg = save_err_msg(db); } @@ -1441,7 +1446,7 @@ static int booleanValue(char *zArg){ int val = atoi(zArg); int j; for(j=0; zArg[j]; j++){ - zArg[j] = (char)tolower(zArg[j]); + zArg[j] = ToLower(zArg[j]); } if( strcmp(zArg,"on")==0 ){ val = 1; @@ -1467,7 +1472,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ /* Parse the input line into tokens. */ while( zLine[i] && nArg1 ){ int i; - for(i=0; azArg[1][i]; i++) azArg[1][i] = (char)tolower(azArg[1][i]); + for(i=0; azArg[1][i]; i++) azArg[1][i] = ToLower(azArg[1][i]); if( strcmp(azArg[1],"sqlite_master")==0 ){ char *new_argv[2], *new_colv[2]; new_argv[0] = "CREATE TABLE sqlite_master (\n" @@ -2344,7 +2349,7 @@ static int _contains_semicolon(const char *z, int N){ */ static int _all_whitespace(const char *z){ for(; *z; z++){ - if( isspace(*(unsigned char*)z) ) continue; + if( IsSpace(z[0]) ) continue; if( *z=='/' && z[1]=='*' ){ z += 2; while( *z && (*z!='*' || z[1]!='/') ){ z++; } @@ -2369,11 +2374,11 @@ static int _all_whitespace(const char *z){ ** as is the Oracle "/". */ static int _is_command_terminator(const char *zLine){ - while( isspace(*(unsigned char*)zLine) ){ zLine++; }; + while( IsSpace(zLine[0]) ){ zLine++; }; if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ){ return 1; /* Oracle */ } - if( tolower(zLine[0])=='g' && tolower(zLine[1])=='o' + if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o' && _all_whitespace(&zLine[2]) ){ return 1; /* SQL Server */ } @@ -2443,7 +2448,7 @@ static int process_input(struct callback_data *p, FILE *in){ nSqlPrior = nSql; if( zSql==0 ){ int i; - for(i=0; zLine[i] && isspace((unsigned char)zLine[i]); i++){} + for(i=0; zLine[i] && IsSpace(zLine[i]); i++){} if( zLine[i]!=0 ){ nSql = strlen30(zLine); zSql = malloc( nSql+3 ); From 8a575d9aa9b8da6c375c069a026236ddbb33fa8d Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 12 Oct 2011 17:00:28 +0000 Subject: [PATCH 10/51] Clarify a comment and fix a code formatting issue in btree.c. FossilOrigin-Name: 4f1a558d0013fbf3fe00bdf5883e61a1f3779831 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 5fe5a99230..e28ce9ccbe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Put\sin\scode\sto\sdefend\sagainst\ssigned/unsigned\scharacter\sproblems\nin\sthe\scommand-line\sshell. -D 2011-10-11T20:41:54.810 +C Clarify\sa\scomment\sand\sfix\sa\scode\sformatting\sissue\sin\sbtree.c. +D 2011-10-12T17:00:28.920 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 4fd4440c8f81339d8eb8e5d2df54b68d79e94f2f F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c b53e009bccb4cfcbcde074f586f0c1c6712a0e12 +F src/btree.c 74da2e088722edfef79f1d182934bbe6a436c0fc F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 F src/build.c 119937b0ae1ff4dcec8fdea53771acc95bafca51 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P b21b1c7bc490b193da8d8a277489eb875a507e30 -R 7c8d9511406d6fc0a6ea749b1b39d02c +P b94a80a832777f0e639f6a81fcfe169bf970a8c0 +R 95fde01c6f40604b21834caf64be98db U drh -Z 1652abdbfcdbd0d6697e8d56e8019c87 +Z 389b1315be168f08d6aa9a5e7d0d3d85 diff --git a/manifest.uuid b/manifest.uuid index 781d1198a0..0ffa2c80e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b94a80a832777f0e639f6a81fcfe169bf970a8c0 \ No newline at end of file +4f1a558d0013fbf3fe00bdf5883e61a1f3779831 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 72d61cc268..f1a67cab94 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5995,13 +5995,15 @@ static int balance_nonroot( ** four bytes of the divider cell. So the pointer is safe to use ** later on. ** - ** Unless SQLite is compiled in secure-delete mode. In this case, + ** But not if we are in secure-delete mode. In secure-delete mode, ** the dropCell() routine will overwrite the entire cell with zeroes. ** In this case, temporarily copy the cell into the aOvflSpace[] ** buffer. It will be copied out again as soon as the aSpace[] buffer ** is allocated. */ if( pBt->secureDelete ){ - int iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData); + int iOff; + + iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData); if( (iOff+szNew[i])>(int)pBt->usableSize ){ rc = SQLITE_CORRUPT_BKPT; memset(apOld, 0, (i+1)*sizeof(MemPage*)); From ed1fddf462a33572c4edc476ca2b4c8aab4eb6dd Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 12 Oct 2011 18:52:59 +0000 Subject: [PATCH 11/51] Clean up obsolete comments in printf.c. FossilOrigin-Name: 97ef4f5013731fa3a0f72451b7e8c9aec5523104 --- manifest | 12 ++++---- manifest.uuid | 2 +- src/printf.c | 84 +++++++-------------------------------------------- 3 files changed, 18 insertions(+), 80 deletions(-) diff --git a/manifest b/manifest index e28ce9ccbe..b43a2cefb9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarify\sa\scomment\sand\sfix\sa\scode\sformatting\sissue\sin\sbtree.c. -D 2011-10-12T17:00:28.920 +C Clean\sup\sobsolete\scomments\sin\sprintf.c. +D 2011-10-12T18:52:59.595 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 24f5e85a78514584b46190260ba7ab0a66312197 F src/pragma.c 68d7db4fc9de8bcfae94c1d43120531ec252b9c0 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 -F src/printf.c 1cd24df913bafc0cb69dc7ae68af85cc480925aa +F src/printf.c c6ec4b345655a90691fd69de46bfd10f263b1aaf F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P b94a80a832777f0e639f6a81fcfe169bf970a8c0 -R 95fde01c6f40604b21834caf64be98db +P 4f1a558d0013fbf3fe00bdf5883e61a1f3779831 +R 3b4749da52d09d736fe4f908b2fe6beb U drh -Z 389b1315be168f08d6aa9a5e7d0d3d85 +Z 30471bd3e45c0db38d5307794f8fd877 diff --git a/manifest.uuid b/manifest.uuid index 0ffa2c80e6..487057834a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f1a558d0013fbf3fe00bdf5883e61a1f3779831 \ No newline at end of file +97ef4f5013731fa3a0f72451b7e8c9aec5523104 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 2f6945577b..1303e17edf 100644 --- a/src/printf.c +++ b/src/printf.c @@ -7,48 +7,10 @@ ** ************************************************************************** ** -** The following modules is an enhanced replacement for the "printf" subroutines -** found in the standard C library. The following enhancements are -** supported: -** -** + Additional functions. The standard set of "printf" functions -** includes printf, fprintf, sprintf, vprintf, vfprintf, and -** vsprintf. This module adds the following: -** -** * snprintf -- Works like sprintf, but has an extra argument -** which is the size of the buffer written to. -** -** * mprintf -- Similar to sprintf. Writes output to memory -** obtained from malloc. -** -** * xprintf -- Calls a function to dispose of output. -** -** * nprintf -- No output, but returns the number of characters -** that would have been output by printf. -** -** * A v- version (ex: vsnprintf) of every function is also -** supplied. -** -** + A few extensions to the formatting notation are supported: -** -** * The "=" flag (similar to "-") causes the output to be -** be centered in the appropriately sized field. -** -** * The %b field outputs an integer in binary notation. -** -** * The %c field now accepts a precision. The character output -** is repeated by the number of times the precision specifies. -** -** * The %' field works like %c, but takes as its character the -** next character of the format string, instead of the next -** argument. For example, printf("%.78'-") prints 78 minus -** signs, the same as printf("%.78c",'-'). -** -** + When compiled using GCC on a SPARC, this version of printf is -** faster than the library printf for SUN OS 4.1. -** -** + All functions are fully reentrant. -** +** This file contains code for a set of "printf"-like routines. These +** routines format strings much like the printf() from the standard C +** library, though the implementation here has enhancements to support +** SQLlite. */ #include "sqliteInt.h" @@ -187,7 +149,7 @@ static void appendSpace(StrAccum *pAccum, int N){ /* ** On machines with a small stack size, you can redefine the -** SQLITE_PRINT_BUF_SIZE to be less than 350. +** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired. */ #ifndef SQLITE_PRINT_BUF_SIZE # define SQLITE_PRINT_BUF_SIZE 70 @@ -195,31 +157,7 @@ static void appendSpace(StrAccum *pAccum, int N){ #define etBUFSIZE SQLITE_PRINT_BUF_SIZE /* Size of the output buffer */ /* -** The root program. All variations call this core. -** -** INPUTS: -** func This is a pointer to a function taking three arguments -** 1. A pointer to anything. Same as the "arg" parameter. -** 2. A pointer to the list of characters to be output -** (Note, this list is NOT null terminated.) -** 3. An integer number of characters to be output. -** (Note: This number might be zero.) -** -** arg This is the pointer to anything which will be passed as the -** first argument to "func". Use it for whatever you like. -** -** fmt This is the format string, as in the usual print. -** -** ap This is a pointer to a list of arguments. Same as in -** vfprint. -** -** OUTPUTS: -** The return value is the total number of characters sent to -** the function "func". Returns -1 on a error. -** -** Note that the order in which automatic variables are declared below -** seems to make a big difference in determining how fast this beast -** will run. +** Render a string given by "fmt" into the StrAccum object. */ void sqlite3VXPrintf( StrAccum *pAccum, /* Accumulate results here */ @@ -242,22 +180,22 @@ void sqlite3VXPrintf( etByte flag_long; /* True if "l" flag is present */ etByte flag_longlong; /* True if the "ll" flag is present */ etByte done; /* Loop termination flag */ + etByte xtype = 0; /* Conversion paradigm */ + char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ sqlite_uint64 longvalue; /* Value for integer types */ LONGDOUBLE_TYPE realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ - char buf[etBUFSIZE]; /* Conversion buffer */ char *zOut; /* Rendering buffer */ int nOut; /* Size of the rendering buffer */ - char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ - etByte xtype = 0; /* Conversion paradigm */ - char *zExtra; /* Extra memory used for etTCLESCAPE conversions */ + char *zExtra; /* Malloced memory used by some conversion */ #ifndef SQLITE_OMIT_FLOATING_POINT int exp, e2; /* exponent of real numbers */ + int nsd; /* Number of significant digits returned */ double rounder; /* Used for rounding floating point values */ etByte flag_dp; /* True if decimal point should be shown */ etByte flag_rtz; /* True if trailing zeros should be removed */ - int nsd; /* Number of significant digits returned */ #endif + char buf[etBUFSIZE]; /* Conversion buffer */ length = 0; bufpt = 0; From c3c8dac7419ee34dfcd31e60c30d86a8ea195199 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 12 Oct 2011 19:04:07 +0000 Subject: [PATCH 12/51] Suppress a compiler warning that occurs with SQLITE_OMIT_VIRTUALTABLE. FossilOrigin-Name: 6bedb49d68f2960a6fc4701d02e177789abf9099 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b43a2cefb9..0ed4f83f33 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clean\sup\sobsolete\scomments\sin\sprintf.c. -D 2011-10-12T18:52:59.595 +C Suppress\sa\scompiler\swarning\sthat\soccurs\swith\sSQLITE_OMIT_VIRTUALTABLE. +D 2011-10-12T19:04:07.402 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -183,7 +183,7 @@ F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f F src/shell.c a07ce148dc665e4283edf878d0fb52fed2018408 F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 -F src/sqliteInt.h 2f66bf068131f0e499dd5e0abea3f68cd6b27b2d +F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4f1a558d0013fbf3fe00bdf5883e61a1f3779831 -R 3b4749da52d09d736fe4f908b2fe6beb +P 97ef4f5013731fa3a0f72451b7e8c9aec5523104 +R aa347fcaa7b1b78f72c141e6103db8e0 U drh -Z 30471bd3e45c0db38d5307794f8fd877 +Z 4df9a6a5c072d98e4f59e9f8ded1b3be diff --git a/manifest.uuid b/manifest.uuid index 487057834a..b64d7d9f8e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -97ef4f5013731fa3a0f72451b7e8c9aec5523104 \ No newline at end of file +6bedb49d68f2960a6fc4701d02e177789abf9099 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 2a54e4593a..ed1a8d17da 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3095,6 +3095,7 @@ void sqlite3AutoLoadExtensions(sqlite3*); # define sqlite3VtabUnlock(X) # define sqlite3VtabUnlockList(X) # define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK +# define sqlite3GetVTable(X,Y) ((VTable*)0) #else void sqlite3VtabClear(sqlite3 *db, Table*); int sqlite3VtabSync(sqlite3 *db, char **); @@ -3104,6 +3105,7 @@ void sqlite3AutoLoadExtensions(sqlite3*); void sqlite3VtabUnlock(VTable *); void sqlite3VtabUnlockList(sqlite3*); int sqlite3VtabSavepoint(sqlite3 *, int, int); + VTable *sqlite3GetVTable(sqlite3*, Table*); # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) #endif void sqlite3VtabMakeWritable(Parse*,Table*); @@ -3123,7 +3125,6 @@ int sqlite3Reprepare(Vdbe*); void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*); CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *); int sqlite3TempInMemory(const sqlite3*); -VTable *sqlite3GetVTable(sqlite3*, Table*); const char *sqlite3JournalModename(int); int sqlite3Checkpoint(sqlite3*, int, int, int*, int*); int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); From 3170225f197cbd15a9ecadb7ed9631445b2b74c0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 12 Oct 2011 23:13:43 +0000 Subject: [PATCH 13/51] The date/time functions return NULL if the xCurrentTime or xCurrentTimeInt64 VFS methods fail. Ticket [0b803bff856c644c] FossilOrigin-Name: c96651dd6ceadd51c9e1f4d942177d3c128c47b4 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/date.c | 49 ++++++++++++++++++++++++++----------------------- src/os_unix.c | 18 ++++++++++++------ src/os_win.c | 7 ++++--- 5 files changed, 51 insertions(+), 41 deletions(-) diff --git a/manifest b/manifest index 0ed4f83f33..d2b56aa51e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Suppress\sa\scompiler\swarning\sthat\soccurs\swith\sSQLITE_OMIT_VIRTUALTABLE. -D 2011-10-12T19:04:07.402 +C The\sdate/time\sfunctions\sreturn\sNULL\sif\sthe\sxCurrentTime\sor\nxCurrentTimeInt64\sVFS\smethods\sfail.\nTicket\s[0b803bff856c644c] +D 2011-10-12T23:13:43.648 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -131,7 +131,7 @@ F src/build.c 119937b0ae1ff4dcec8fdea53771acc95bafca51 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 829f3261d3db48e3d87891bc887208734734c2e4 -F src/date.c a3c6842bad7ae632281811de112a8ba63ff08ab3 +F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c ff68e5ef23aee08c0ff528f699a19397ed8bbed8 F src/expr.c f4dcaeb8252c4b16fcdc245660f70ed366bc6cdd F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -165,8 +165,8 @@ F src/os.c 3b3f69c34be7f998f5ea6bd46a2fe8a2b7fa8f70 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c b14e8b40e28d983a908249442e1e0273a1ecb64e -F src/os_win.c fbe47c7fdc9a846a772bbf98719c328becad5f8a +F src/os_unix.c 7f8031b5b3aee1b9e066e2ea8f83e02775debcb4 +F src/os_win.c 58c1cef8a167275d5238bdfb3c455e53e3146354 F src/pager.c 8a6ac3e0d9694412076e2273e3c81e9c4e08758f F src/pager.h dbcaa791e8b6c3a6b77c168c5c27deec289fb176 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 97ef4f5013731fa3a0f72451b7e8c9aec5523104 -R aa347fcaa7b1b78f72c141e6103db8e0 +P 6bedb49d68f2960a6fc4701d02e177789abf9099 +R f6f2282ee33c9438c6a443681fa52486 U drh -Z 4df9a6a5c072d98e4f59e9f8ded1b3be +Z e1a02e86d35f387f95f1d1ceb1084f34 diff --git a/manifest.uuid b/manifest.uuid index b64d7d9f8e..34b3f1b149 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6bedb49d68f2960a6fc4701d02e177789abf9099 \ No newline at end of file +c96651dd6ceadd51c9e1f4d942177d3c128c47b4 \ No newline at end of file diff --git a/src/date.c b/src/date.c index f9411ea5b3..758dd7c89b 100644 --- a/src/date.c +++ b/src/date.c @@ -289,12 +289,18 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){ } /* -** Set the time to the current time reported by the VFS +** Set the time to the current time reported by the VFS. +** +** Return the number of errors. */ -static void setDateTimeToCurrent(sqlite3_context *context, DateTime *p){ +static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){ sqlite3 *db = sqlite3_context_db_handle(context); - sqlite3OsCurrentTimeInt64(db->pVfs, &p->iJD); - p->validJD = 1; + if( sqlite3OsCurrentTimeInt64(db->pVfs, &p->iJD)==SQLITE_OK ){ + p->validJD = 1; + return 0; + }else{ + return 1; + } } /* @@ -324,8 +330,7 @@ static int parseDateOrTime( }else if( parseHhMmSs(zDate, p)==0 ){ return 0; }else if( sqlite3StrICmp(zDate,"now")==0){ - setDateTimeToCurrent(context, p); - return 0; + return setDateTimeToCurrent(context, p); }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){ p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5); p->validJD = 1; @@ -752,8 +757,9 @@ static int isDate( int eType; memset(p, 0, sizeof(*p)); if( argc==0 ){ - setDateTimeToCurrent(context, p); - }else if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT + return setDateTimeToCurrent(context, p); + } + if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT || eType==SQLITE_INTEGER ){ p->iJD = (sqlite3_int64)(sqlite3_value_double(argv[0])*86400000.0 + 0.5); p->validJD = 1; @@ -1065,31 +1071,28 @@ static void currentTimeFunc( char *zFormat = (char *)sqlite3_user_data(context); sqlite3 *db; sqlite3_int64 iT; + struct tm *pTm; + struct tm sNow; char zBuf[20]; UNUSED_PARAMETER(argc); UNUSED_PARAMETER(argv); db = sqlite3_context_db_handle(context); - sqlite3OsCurrentTimeInt64(db->pVfs, &iT); + if( sqlite3OsCurrentTimeInt64(db->pVfs, &iT) ) return; t = iT/1000 - 10000*(sqlite3_int64)21086676; #ifdef HAVE_GMTIME_R - { - struct tm sNow; - gmtime_r(&t, &sNow); - strftime(zBuf, 20, zFormat, &sNow); - } + pTm = gmtime_r(&t, &sNow); #else - { - struct tm *pTm; - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); - pTm = gmtime(&t); - strftime(zBuf, 20, zFormat, pTm); - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); - } + sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); + pTm = gmtime(&t); + if( pTm ) memcpy(&sNow, pTm, sizeof(sNow)); + sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); #endif - - sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); + if( pTm ){ + strftime(zBuf, 20, zFormat, &sNow); + sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); + } } #endif diff --git a/src/os_unix.c b/src/os_unix.c index 6e87a4bfdf..7e0a7e8406 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5428,10 +5428,12 @@ int sqlite3_current_time = 0; /* Fake system time in seconds since 1970. */ ** epoch of noon in Greenwich on November 24, 4714 B.C according to the ** proleptic Gregorian calendar. ** -** On success, return 0. Return 1 if the time and date cannot be found. +** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date +** cannot be found. */ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000; + int rc = SQLITE_OK; #if defined(NO_GETTOD) time_t t; time(&t); @@ -5442,8 +5444,11 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000; #else struct timeval sNow; - gettimeofday(&sNow, 0); - *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000; + if( gettimeofday(&sNow, 0)==0 ){ + *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000; + }else{ + rc = SQLITE_ERROR; + } #endif #ifdef SQLITE_TEST @@ -5452,7 +5457,7 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ } #endif UNUSED_PARAMETER(NotUsed); - return 0; + return rc; } /* @@ -5462,10 +5467,11 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ */ static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){ sqlite3_int64 i; + int rc; UNUSED_PARAMETER(NotUsed); - unixCurrentTimeInt64(0, &i); + rc = unixCurrentTimeInt64(0, &i); *prNow = i/86400000.0; - return 0; + return rc; } /* diff --git a/src/os_win.c b/src/os_win.c index b68b036701..ef70522a03 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3066,7 +3066,8 @@ int sqlite3_current_time = 0; /* Fake system time in seconds since 1970. */ ** epoch of noon in Greenwich on November 24, 4714 B.C according to the ** proleptic Gregorian calendar. ** -** On success, return 0. Return 1 if the time and date cannot be found. +** On success, return SQLITE_OK. Return SQLITE_ERROR if the time and date +** cannot be found. */ static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ /* FILETIME structure is a 64-bit value representing the number of @@ -3086,7 +3087,7 @@ static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ GetSystemTime(&time); /* if SystemTimeToFileTime() fails, it returns zero. */ if (!SystemTimeToFileTime(&time,&ft)){ - return 1; + return SQLITE_ERROR; } #else GetSystemTimeAsFileTime( &ft ); @@ -3102,7 +3103,7 @@ static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ } #endif UNUSED_PARAMETER(pVfs); - return 0; + return SQLITE_OK; } /* From cb5e4dbf4e617f3e039fb9f8c45c35d27f35f39a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 12 Oct 2011 23:49:49 +0000 Subject: [PATCH 14/51] The sqlite3_overload_function() interface returns an error if it is unable to create the overload function. Ticket [20f9d4fbbff3a3] FossilOrigin-Name: d5b6b374c5225d21c386fb3d6507d3938296e759 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index d2b56aa51e..f186ae5990 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sdate/time\sfunctions\sreturn\sNULL\sif\sthe\sxCurrentTime\sor\nxCurrentTimeInt64\sVFS\smethods\sfail.\nTicket\s[0b803bff856c644c] -D 2011-10-12T23:13:43.648 +C The\ssqlite3_overload_function()\sinterface\sreturns\san\serror\sif\sit\sis\sunable\nto\screate\sthe\soverload\sfunction.\s\sTicket\s[20f9d4fbbff3a3] +D 2011-10-12T23:49:49.486 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -146,7 +146,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 99a161b27a499fc8ad40745b7b1900a26f0a5f51 -F src/main.c 43664b68a0b0f8fe9edc7d987b42cb8e26298468 +F src/main.c ae03daa1adf657aac69f18bb13f6a0763494b502 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 6bedb49d68f2960a6fc4701d02e177789abf9099 -R f6f2282ee33c9438c6a443681fa52486 +P c96651dd6ceadd51c9e1f4d942177d3c128c47b4 +R ea04b607dc034a923513c6e21f4d7206 U drh -Z e1a02e86d35f387f95f1d1ceb1084f34 +Z 3ca712cf2f818c92184b1f1b656548d2 diff --git a/manifest.uuid b/manifest.uuid index 34b3f1b149..fb4983fb5f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c96651dd6ceadd51c9e1f4d942177d3c128c47b4 \ No newline at end of file +d5b6b374c5225d21c386fb3d6507d3938296e759 \ No newline at end of file diff --git a/src/main.c b/src/main.c index efdb2076bf..51596c1de1 100644 --- a/src/main.c +++ b/src/main.c @@ -1214,13 +1214,13 @@ int sqlite3_overload_function( int nArg ){ int nName = sqlite3Strlen30(zName); - int rc; + int rc = SQLITE_OK; sqlite3_mutex_enter(db->mutex); if( sqlite3FindFunction(db, zName, nName, nArg, SQLITE_UTF8, 0)==0 ){ - sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8, - 0, sqlite3InvalidFunction, 0, 0, 0); + rc = sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8, + 0, sqlite3InvalidFunction, 0, 0, 0); } - rc = sqlite3ApiExit(db, SQLITE_OK); + rc = sqlite3ApiExit(db, rc); sqlite3_mutex_leave(db->mutex); return rc; } From 52dbea883f1fcd6a60590d1705a89c607f678edd Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 00:11:36 +0000 Subject: [PATCH 15/51] Be sure to allocate plenty of space for error messages coming out of sqlite3_load_extension(), so that filenames and procedure names are not truncated. Ticket [7d32c69b50f89d] FossilOrigin-Name: af8bcdd951c31f69966942d67833da30f6b121bf --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/loadext.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f186ae5990..c6bfc81c4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3_overload_function()\sinterface\sreturns\san\serror\sif\sit\sis\sunable\nto\screate\sthe\soverload\sfunction.\s\sTicket\s[20f9d4fbbff3a3] -D 2011-10-12T23:49:49.486 +C Be\ssure\sto\sallocate\splenty\sof\sspace\sfor\serror\smessages\scoming\sout\sof\nsqlite3_load_extension(),\sso\sthat\sfilenames\sand\sprocedure\snames\sare\nnot\struncated.\s\sTicket\s[7d32c69b50f89d] +D 2011-10-13T00:11:36.709 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,7 +145,7 @@ F src/insert.c ca18783512323f74aaf4ee74b46ffd75ec80d031 F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e -F src/loadext.c 99a161b27a499fc8ad40745b7b1900a26f0a5f51 +F src/loadext.c d0d2022a5a07274d408820b978b9e549189d314f F src/main.c ae03daa1adf657aac69f18bb13f6a0763494b502 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c96651dd6ceadd51c9e1f4d942177d3c128c47b4 -R ea04b607dc034a923513c6e21f4d7206 +P d5b6b374c5225d21c386fb3d6507d3938296e759 +R ad241b5f1e2b5a40e8b22e9f2c8bb18c U drh -Z 3ca712cf2f818c92184b1f1b656548d2 +Z 12a1fc6a3955002b8a71d507adebb052 diff --git a/manifest.uuid b/manifest.uuid index fb4983fb5f..a39009f80d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d5b6b374c5225d21c386fb3d6507d3938296e759 \ No newline at end of file +af8bcdd951c31f69966942d67833da30f6b121bf \ No newline at end of file diff --git a/src/loadext.c b/src/loadext.c index 079458d143..e9c97adff3 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -403,7 +403,7 @@ static int sqlite3LoadExtension( int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); char *zErrmsg = 0; void **aHandle; - const int nMsg = 300; + int nMsg = 300 + sqlite3Strlen30(zFile); if( pzErrMsg ) *pzErrMsg = 0; @@ -440,6 +440,7 @@ static int sqlite3LoadExtension( sqlite3OsDlSym(pVfs, handle, zProc); if( xInit==0 ){ if( pzErrMsg ){ + nMsg += sqlite3Strlen30(zProc); *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg); if( zErrmsg ){ sqlite3_snprintf(nMsg, zErrmsg, From 2f464a045bb69c52007765ca7cfc9053b8d5c266 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 00:41:49 +0000 Subject: [PATCH 16/51] If errors are encountered while processing the ".dump" command in the command-line shell, print error messages as comments in the output and ROLLBACK at the end rather than committing. Ticket [ee19e690ec9a5a2] FossilOrigin-Name: 8a8dcd6bd043d82dc04b6ad0614c64d20ace8e5f --- manifest | 12 ++++----- manifest.uuid | 2 +- src/shell.c | 67 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/manifest b/manifest index c6bfc81c4c..290c14947b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Be\ssure\sto\sallocate\splenty\sof\sspace\sfor\serror\smessages\scoming\sout\sof\nsqlite3_load_extension(),\sso\sthat\sfilenames\sand\sprocedure\snames\sare\nnot\struncated.\s\sTicket\s[7d32c69b50f89d] -D 2011-10-13T00:11:36.709 +C If\serrors\sare\sencountered\swhile\sprocessing\sthe\s".dump"\scommand\sin\sthe\ncommand-line\sshell,\sprint\serror\smessages\sas\scomments\sin\sthe\soutput\sand\nROLLBACK\sat\sthe\send\srather\sthan\scommitting.\nTicket\s[ee19e690ec9a5a2] +D 2011-10-13T00:41:49.789 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f -F src/shell.c a07ce148dc665e4283edf878d0fb52fed2018408 +F src/shell.c bef48bc4fa2e42535aee14c1e0ca34b0a43f27e4 F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P d5b6b374c5225d21c386fb3d6507d3938296e759 -R ad241b5f1e2b5a40e8b22e9f2c8bb18c +P af8bcdd951c31f69966942d67833da30f6b121bf +R cf954ca8f3097f02bf28c5ed04310c31 U drh -Z 12a1fc6a3955002b8a71d507adebb052 +Z bdd04747fa59c02e0592ff23948f0dfa diff --git a/manifest.uuid b/manifest.uuid index a39009f80d..b6bae86418 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af8bcdd951c31f69966942d67833da30f6b121bf \ No newline at end of file +8a8dcd6bd043d82dc04b6ad0614c64d20ace8e5f \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 15a7b779e3..e8aa3fdb7a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -407,6 +407,7 @@ struct callback_data { int statsOn; /* True to display memory stats before each finalize */ int cnt; /* Number of records displayed so far */ FILE *out; /* Write results here */ + int nErr; /* Number of errors seen */ int mode; /* An output mode setting */ int writableSchema; /* True if PRAGMA writable_schema=ON */ int showHeader; /* True to show column names in List or Column mode */ @@ -932,27 +933,33 @@ static char *appendText(char *zIn, char const *zAppend, char quote){ ** querying the SQLITE_MASTER table. */ static int run_table_dump_query( - FILE *out, /* Send output here */ - sqlite3 *db, /* Database to query */ - const char *zSelect, /* SELECT statement to extract content */ - const char *zFirstRow /* Print before first row, if not NULL */ + struct callback_data *p, /* Query context */ + const char *zSelect, /* SELECT statement to extract content */ + const char *zFirstRow /* Print before first row, if not NULL */ ){ sqlite3_stmt *pSelect; int rc; - rc = sqlite3_prepare(db, zSelect, -1, &pSelect, 0); + rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0); if( rc!=SQLITE_OK || !pSelect ){ + fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); + p->nErr++; return rc; } rc = sqlite3_step(pSelect); while( rc==SQLITE_ROW ){ if( zFirstRow ){ - fprintf(out, "%s", zFirstRow); + fprintf(p->out, "%s", zFirstRow); zFirstRow = 0; } - fprintf(out, "%s;\n", sqlite3_column_text(pSelect, 0)); + fprintf(p->out, "%s;\n", sqlite3_column_text(pSelect, 0)); rc = sqlite3_step(pSelect); } - return sqlite3_finalize(pSelect); + rc = sqlite3_finalize(pSelect); + if( rc!=SQLITE_OK ){ + fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); + p->nErr++; + } + return rc; } /* @@ -1278,10 +1285,10 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ zSelect = appendText(zSelect, "|| ')' FROM ", 0); zSelect = appendText(zSelect, zTable, '"'); - rc = run_table_dump_query(p->out, p->db, zSelect, zPrepStmt); + rc = run_table_dump_query(p, zSelect, zPrepStmt); if( rc==SQLITE_CORRUPT ){ zSelect = appendText(zSelect, " ORDER BY rowid DESC", 0); - rc = run_table_dump_query(p->out, p->db, zSelect, 0); + run_table_dump_query(p, zSelect, 0); } if( zSelect ) free(zSelect); } @@ -1297,19 +1304,30 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ */ static int run_schema_dump_query( struct callback_data *p, - const char *zQuery, - char **pzErrMsg + const char *zQuery ){ int rc; - rc = sqlite3_exec(p->db, zQuery, dump_callback, p, pzErrMsg); + char *zErr = 0; + rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr); if( rc==SQLITE_CORRUPT ){ char *zQ2; int len = strlen30(zQuery); - if( pzErrMsg ) sqlite3_free(*pzErrMsg); + fprintf(p->out, "/****** CORRUPTION ERROR *******/\n"); + if( zErr ){ + fprintf(p->out, "/****** %s ******/\n", zErr); + sqlite3_free(zErr); + zErr = 0; + } zQ2 = malloc( len+100 ); if( zQ2==0 ) return rc; sqlite3_snprintf(sizeof(zQ2), zQ2, "%s ORDER BY rowid DESC", zQuery); - rc = sqlite3_exec(p->db, zQ2, dump_callback, p, pzErrMsg); + rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr); + if( rc ){ + fprintf(p->out, "/****** ERROR: %s ******/\n", zErr); + }else{ + rc = SQLITE_CORRUPT; + } + sqlite3_free(zErr); free(zQ2); } return rc; @@ -1555,7 +1573,6 @@ static int do_meta_command(char *zLine, struct callback_data *p){ }else if( c=='d' && strncmp(azArg[0], "dump", n)==0 && nArg<3 ){ - char *zErrMsg = 0; open_db(p); /* When playing back a "dump", the content might appear in an order ** which causes immediate foreign key constraints to be violated. @@ -1564,16 +1581,17 @@ static int do_meta_command(char *zLine, struct callback_data *p){ fprintf(p->out, "BEGIN TRANSACTION;\n"); p->writableSchema = 0; sqlite3_exec(p->db, "PRAGMA writable_schema=ON", 0, 0, 0); + p->nErr = 0; if( nArg==1 ){ run_schema_dump_query(p, "SELECT name, type, sql FROM sqlite_master " - "WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'", 0 + "WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'" ); run_schema_dump_query(p, "SELECT name, type, sql FROM sqlite_master " - "WHERE name=='sqlite_sequence'", 0 + "WHERE name=='sqlite_sequence'" ); - run_table_dump_query(p->out, p->db, + run_table_dump_query(p, "SELECT sql FROM sqlite_master " "WHERE sql NOT NULL AND type IN ('index','trigger','view')", 0 ); @@ -1584,8 +1602,8 @@ static int do_meta_command(char *zLine, struct callback_data *p){ run_schema_dump_query(p, "SELECT name, type, sql FROM sqlite_master " "WHERE tbl_name LIKE shellstatic() AND type=='table'" - " AND sql NOT NULL", 0); - run_table_dump_query(p->out, p->db, + " AND sql NOT NULL"); + run_table_dump_query(p, "SELECT sql FROM sqlite_master " "WHERE sql NOT NULL" " AND type IN ('index','trigger','view')" @@ -1599,12 +1617,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ p->writableSchema = 0; } sqlite3_exec(p->db, "PRAGMA writable_schema=OFF", 0, 0, 0); - if( zErrMsg ){ - fprintf(stderr,"Error: %s\n", zErrMsg); - sqlite3_free(zErrMsg); - }else{ - fprintf(p->out, "COMMIT;\n"); - } + fprintf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); }else if( c=='e' && strncmp(azArg[0], "echo", n)==0 && nArg>1 && nArg<3 ){ From b87a6663152f57f65d1afa907b5739dfe6d4658e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 01:01:14 +0000 Subject: [PATCH 17/51] Fix a harmless compiler warning introduced into os_unix.c by one of the recent changes. FossilOrigin-Name: 4bf4d5ebfbf5d157a8bf3a3817e2ce350f25af0e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 290c14947b..c9af67b067 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\serrors\sare\sencountered\swhile\sprocessing\sthe\s".dump"\scommand\sin\sthe\ncommand-line\sshell,\sprint\serror\smessages\sas\scomments\sin\sthe\soutput\sand\nROLLBACK\sat\sthe\send\srather\sthan\scommitting.\nTicket\s[ee19e690ec9a5a2] -D 2011-10-13T00:41:49.789 +C Fix\sa\sharmless\scompiler\swarning\sintroduced\sinto\sos_unix.c\sby\sone\sof\sthe\s\nrecent\schanges. +D 2011-10-13T01:01:14.183 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os.c 3b3f69c34be7f998f5ea6bd46a2fe8a2b7fa8f70 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 7f8031b5b3aee1b9e066e2ea8f83e02775debcb4 +F src/os_unix.c d42ad1c4cb8360825639a64c44bc63672ace8916 F src/os_win.c 58c1cef8a167275d5238bdfb3c455e53e3146354 F src/pager.c 8a6ac3e0d9694412076e2273e3c81e9c4e08758f F src/pager.h dbcaa791e8b6c3a6b77c168c5c27deec289fb176 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P af8bcdd951c31f69966942d67833da30f6b121bf -R cf954ca8f3097f02bf28c5ed04310c31 +P 8a8dcd6bd043d82dc04b6ad0614c64d20ace8e5f +R 427d2c24706186abc37fd5c28f6e528a U drh -Z bdd04747fa59c02e0592ff23948f0dfa +Z 31d3119f9b55f979f35bd3ee2d4fe1ba diff --git a/manifest.uuid b/manifest.uuid index b6bae86418..2d0f866d9f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8a8dcd6bd043d82dc04b6ad0614c64d20ace8e5f \ No newline at end of file +4bf4d5ebfbf5d157a8bf3a3817e2ce350f25af0e \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 7e0a7e8406..e0025229fd 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5466,7 +5466,7 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){ ** return 0. Return 1 if the time and date cannot be found. */ static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){ - sqlite3_int64 i; + sqlite3_int64 i = 0; int rc; UNUSED_PARAMETER(NotUsed); rc = unixCurrentTimeInt64(0, &i); From 58c803b7f06f74ad7f7303fb36fe480d64ed86b7 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 13:34:04 +0000 Subject: [PATCH 18/51] Do the ".dump" command inside of a transaction to prevent other processes from modifying the database while the dump is underway. Ticket [2466653295e65] FossilOrigin-Name: 1c00d5454c85dfddb6c628c3742b4ddeaad6423a --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index c9af67b067..cea56f1741 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sintroduced\sinto\sos_unix.c\sby\sone\sof\sthe\s\nrecent\schanges. -D 2011-10-13T01:01:14.183 +C Do\sthe\s".dump"\scommand\sinside\sof\sa\stransaction\sto\sprevent\sother\sprocesses\nfrom\smodifying\sthe\sdatabase\swhile\sthe\sdump\sis\sunderway.\nTicket\s[2466653295e65] +D 2011-10-13T13:34:04.111 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f -F src/shell.c bef48bc4fa2e42535aee14c1e0ca34b0a43f27e4 +F src/shell.c 2a44834246f0b55fe4673cda749fa0efe4d078e2 F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8a8dcd6bd043d82dc04b6ad0614c64d20ace8e5f -R 427d2c24706186abc37fd5c28f6e528a +P 4bf4d5ebfbf5d157a8bf3a3817e2ce350f25af0e +R c828aecf4dc802851bfe4e4621a41639 U drh -Z 31d3119f9b55f979f35bd3ee2d4fe1ba +Z 1d222bf3e883f519ea46d7f751e5c97d diff --git a/manifest.uuid b/manifest.uuid index 2d0f866d9f..dd97cc88b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4bf4d5ebfbf5d157a8bf3a3817e2ce350f25af0e \ No newline at end of file +1c00d5454c85dfddb6c628c3742b4ddeaad6423a \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index e8aa3fdb7a..db9295c6ef 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1580,7 +1580,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ fprintf(p->out, "PRAGMA foreign_keys=OFF;\n"); fprintf(p->out, "BEGIN TRANSACTION;\n"); p->writableSchema = 0; - sqlite3_exec(p->db, "PRAGMA writable_schema=ON", 0, 0, 0); + sqlite3_exec(p->db, "BEGIN; PRAGMA writable_schema=ON", 0, 0, 0); p->nErr = 0; if( nArg==1 ){ run_schema_dump_query(p, @@ -1613,7 +1613,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ } } if( p->writableSchema ){ - fprintf(p->out, "PRAGMA writable_schema=OFF;\n"); + fprintf(p->out, "PRAGMA writable_schema=OFF; COMMIT;\n"); p->writableSchema = 0; } sqlite3_exec(p->db, "PRAGMA writable_schema=OFF", 0, 0, 0); From 134c4ff6983f746e87836b27a981c3d8effd5a55 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 14:05:32 +0000 Subject: [PATCH 19/51] Make sure all non-API functions in os_win.c have file scope. Ticket [35c54c874987] FossilOrigin-Name: 17e4fde5c541f1bba723386938b6123b2431bffc --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index cea56f1741..c92b136d8a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\sthe\s".dump"\scommand\sinside\sof\sa\stransaction\sto\sprevent\sother\sprocesses\nfrom\smodifying\sthe\sdatabase\swhile\sthe\sdump\sis\sunderway.\nTicket\s[2466653295e65] -D 2011-10-13T13:34:04.111 +C Make\ssure\sall\snon-API\sfunctions\sin\sos_win.c\shave\sfile\sscope.\nTicket\s[35c54c874987] +D 2011-10-13T14:05:32.038 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -166,7 +166,7 @@ F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c d42ad1c4cb8360825639a64c44bc63672ace8916 -F src/os_win.c 58c1cef8a167275d5238bdfb3c455e53e3146354 +F src/os_win.c 49d418916428a59d773f39993db0ecde56ab4c37 F src/pager.c 8a6ac3e0d9694412076e2273e3c81e9c4e08758f F src/pager.h dbcaa791e8b6c3a6b77c168c5c27deec289fb176 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4bf4d5ebfbf5d157a8bf3a3817e2ce350f25af0e -R c828aecf4dc802851bfe4e4621a41639 +P 1c00d5454c85dfddb6c628c3742b4ddeaad6423a +R 62079adc2aa04b6b18d74fffb6482754 U drh -Z 1d222bf3e883f519ea46d7f751e5c97d +Z a52af7b3a4f3b4ce4a34929a0d76fe19 diff --git a/manifest.uuid b/manifest.uuid index dd97cc88b9..b9cc217f67 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1c00d5454c85dfddb6c628c3742b4ddeaad6423a \ No newline at end of file +17e4fde5c541f1bba723386938b6123b2431bffc \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index ef70522a03..4518030483 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2981,7 +2981,7 @@ static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){ UNUSED_PARAMETER(pVfs); getLastErrorMsg(nBuf, zBufOut); } -void (*winDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol))(void){ +static void (*winDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol))(void){ UNUSED_PARAMETER(pVfs); #if SQLITE_OS_WINCE /* The GetProcAddressA() routine is only available on wince. */ @@ -2992,7 +2992,7 @@ void (*winDlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol))(void){ return (void(*)(void))GetProcAddress((HANDLE)pHandle, zSymbol); #endif } -void winDlClose(sqlite3_vfs *pVfs, void *pHandle){ +static void winDlClose(sqlite3_vfs *pVfs, void *pHandle){ UNUSED_PARAMETER(pVfs); FreeLibrary((HANDLE)pHandle); } @@ -3111,7 +3111,7 @@ static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ ** current time and date as a Julian Day number into *prNow and ** return 0. Return 1 if the time and date cannot be found. */ -int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){ +static int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){ int rc; sqlite3_int64 i; rc = winCurrentTimeInt64(pVfs, &i); From beaba6282b25d1742eb309a2e55159b188899ce0 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 14:18:51 +0000 Subject: [PATCH 20/51] Adjust the symbols.sh script for STAT3. Add the symbols-mingw.sh script for testing on windows with MinGW. FossilOrigin-Name: c41d1d4652b8c7608322e9360c30f06965fd0942 --- manifest | 13 +++++++------ manifest.uuid | 2 +- tool/symbols-mingw.sh | 33 +++++++++++++++++++++++++++++++++ tool/symbols.sh | 6 +++--- 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 tool/symbols-mingw.sh diff --git a/manifest b/manifest index c92b136d8a..0e37b2a722 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sall\snon-API\sfunctions\sin\sos_win.c\shave\sfile\sscope.\nTicket\s[35c54c874987] -D 2011-10-13T14:05:32.038 +C Adjust\sthe\ssymbols.sh\sscript\sfor\sSTAT3.\s\sAdd\sthe\ssymbols-mingw.sh\sscript\sfor\ntesting\son\swindows\swith\sMinGW. +D 2011-10-13T14:18:51.846 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -962,11 +962,12 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c -F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 +F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d +F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 1c00d5454c85dfddb6c628c3742b4ddeaad6423a -R 62079adc2aa04b6b18d74fffb6482754 +P 17e4fde5c541f1bba723386938b6123b2431bffc +R 486400a177be812669a333a82555c1f5 U drh -Z a52af7b3a4f3b4ce4a34929a0d76fe19 +Z f27e2c68607b57fc251f5ab7e7102c22 diff --git a/manifest.uuid b/manifest.uuid index b9cc217f67..e7ccaae909 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -17e4fde5c541f1bba723386938b6123b2431bffc \ No newline at end of file +c41d1d4652b8c7608322e9360c30f06965fd0942 \ No newline at end of file diff --git a/tool/symbols-mingw.sh b/tool/symbols-mingw.sh new file mode 100644 index 0000000000..bf93eec7c6 --- /dev/null +++ b/tool/symbols-mingw.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Run this script in a directory that contains a valid SQLite makefile in +# order to verify that unintentionally exported symbols. +# +make sqlite3.c + +echo '****** Exported symbols from a build including RTREE && FTS4 ******' +gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ + -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ + -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ + -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ + sqlite3.c +nm sqlite3.o | grep " [TD] " + +echo '****** Surplus symbols from a build including RTREE & FTS4 ******' +nm sqlite3.o | grep " [TD] " | grep -v " .*sqlite3_" + +echo '****** Dependencies of the core. No extensions. No OS interface *******' +gcc -c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ + -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ + -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ + -DSQLITE_OS_OTHER -DSQLITE_THREADSAFE=0 \ + sqlite3.c +nm sqlite3.o | grep " U " + +echo '****** Dependencies including RTREE & FTS4 *******' +gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ + -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ + -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ + -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ + sqlite3.c +nm sqlite3.o | grep " U " diff --git a/tool/symbols.sh b/tool/symbols.sh index 74b1243e6e..befffce5c4 100644 --- a/tool/symbols.sh +++ b/tool/symbols.sh @@ -7,7 +7,7 @@ make sqlite3.c echo '****** Exported symbols from a build including RTREE, FTS4 & ICU ******' gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ - -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 \ + -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ -DSQLITE_ENABLE_ICU \ @@ -18,7 +18,7 @@ echo '****** Surplus symbols from a build including RTREE, FTS4 & ICU ******' nm sqlite3.o | grep ' [TD] ' | grep -v ' .*sqlite3_' echo '****** Dependencies of the core. No extensions. No OS interface *******' -gcc -c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 \ +gcc -c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ -DSQLITE_OS_OTHER -DSQLITE_THREADSAFE=0 \ @@ -27,7 +27,7 @@ nm sqlite3.o | grep ' U ' | sort -k 3 echo '****** Dependencies including RTREE & FTS4 *******' gcc -c -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \ - -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 \ + -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT3 \ -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_UNLOCK_NOTIFY \ -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_ATOMIC_WRITE \ sqlite3.c From 5d16a9a6c62eb37fb229f783ae8f0c6a857e6827 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 14:41:22 +0000 Subject: [PATCH 21/51] Make sure the page_count and quick_check pragmas work properly even when their names are capitalized. Fixes a problem reported on the mailing list. FossilOrigin-Name: 150592b4b4d86372e70332d4f69e41a04c4c54c3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pragma.c | 4 ++-- test/pragma.test | 12 ++++++++++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 0e37b2a722..a48ef4b30d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\ssymbols.sh\sscript\sfor\sSTAT3.\s\sAdd\sthe\ssymbols-mingw.sh\sscript\sfor\ntesting\son\swindows\swith\sMinGW. -D 2011-10-13T14:18:51.846 +C Make\ssure\sthe\spage_count\sand\squick_check\spragmas\swork\sproperly\seven\swhen\ntheir\snames\sare\scapitalized.\s\sFixes\sa\sproblem\sreported\son\sthe\smailing\slist. +D 2011-10-13T14:41:22.110 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,7 +173,7 @@ F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 49e718c095810c6b3334e3a6d89970aceaddefce F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 24f5e85a78514584b46190260ba7ab0a66312197 -F src/pragma.c 68d7db4fc9de8bcfae94c1d43120531ec252b9c0 +F src/pragma.c 0a11a7b543b455ab28e0c881b346fb569eefd2d3 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 F src/printf.c c6ec4b345655a90691fd69de46bfd10f263b1aaf F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -622,7 +622,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/permutations.test ad17319066a90e2db71823c3ff104795ffc71b31 -F test/pragma.test c8108e01da04f16e67e5754e610bc62c1b993f6c +F test/pragma.test 1ea0c85be853135bb7468e6eed48ee12b04794d4 F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 @@ -967,7 +967,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 17e4fde5c541f1bba723386938b6123b2431bffc -R 486400a177be812669a333a82555c1f5 +P c41d1d4652b8c7608322e9360c30f06965fd0942 +R c197aad45ade73dffa326e7c03277cd6 U drh -Z f27e2c68607b57fc251f5ab7e7102c22 +Z 7e96464fa3894ea180db838f3653f8b1 diff --git a/manifest.uuid b/manifest.uuid index e7ccaae909..f95cc22607 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c41d1d4652b8c7608322e9360c30f06965fd0942 \ No newline at end of file +150592b4b4d86372e70332d4f69e41a04c4c54c3 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 11345078ad..4e01948eec 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -467,7 +467,7 @@ void sqlite3Pragma( if( sqlite3ReadSchema(pParse) ) goto pragma_out; sqlite3CodeVerifySchema(pParse, iDb); iReg = ++pParse->nMem; - if( zLeft[0]=='p' ){ + if( (zLeft[0]&0xf)==0 ){ sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg); }else{ sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi(zRight)); @@ -1080,7 +1080,7 @@ void sqlite3Pragma( { OP_ResultRow, 3, 1, 0}, }; - int isQuick = (zLeft[0]=='q'); + int isQuick = ((zLeft[0]&0xf)==1); /* Initialize the VDBE program */ if( sqlite3ReadSchema(pParse) ) goto pragma_out; diff --git a/test/pragma.test b/test/pragma.test index d2a756f61a..0cad25a37d 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -329,6 +329,9 @@ ifcapable attach { do_test pragma-3.8.1 { execsql {PRAGMA quick_check} } {ok} + do_test pragma-3.8.2 { + execsql {PRAGMA QUICK_CHECK} + } {ok} do_test pragma-3.9 { execsql { ATTACH 'testerr.db' AS t2; @@ -1219,6 +1222,9 @@ ifcapable pager_pragmas { PRAGMA page_count; } } {2} + do_test pragma-14.2uc { + execsql {pragma PAGE_COUNT} + } {2} do_test pragma-14.3 { execsql { @@ -1227,6 +1233,9 @@ ifcapable pager_pragmas { PRAGMA page_count; } } {3} + do_test pragma-14.3uc { + execsql {pragma PAGE_COUNT} + } {3} do_test pragma-14.4 { set page_size [db one {pragma page_size}] @@ -1256,6 +1265,9 @@ ifcapable pager_pragmas { PRAGMA aux.page_count; } } {5} + do_test pragma-14.6uc { + execsql {pragma AUX.PAGE_COUNT} + } {5} } # Test that the value set using the cache_size pragma is not reset when the From 6b93c9ae24e599fa949beab0356d919dce14374e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 15:35:52 +0000 Subject: [PATCH 22/51] Make sure the query optimizer for aggregate queries knows that expressions (x='a') and (x='A') are different. Ticket [fa7bf5ec94801e7e] FossilOrigin-Name: e43da426e66e6b63d5ed9610a6308aba0089313b --- manifest | 13 +++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- test/tkt-fa7bf5ec.test | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 test/tkt-fa7bf5ec.test diff --git a/manifest b/manifest index a48ef4b30d..5b66702538 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\spage_count\sand\squick_check\spragmas\swork\sproperly\seven\swhen\ntheir\snames\sare\scapitalized.\s\sFixes\sa\sproblem\sreported\son\sthe\smailing\slist. -D 2011-10-13T14:41:22.110 +C Make\ssure\sthe\squery\soptimizer\sfor\saggregate\squeries\sknows\sthat\sexpressions\n(x='a')\sand\s(x='A')\sare\sdifferent.\s\sTicket\s[fa7bf5ec94801e7e] +D 2011-10-13T15:35:52.354 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 829f3261d3db48e3d87891bc887208734734c2e4 F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c ff68e5ef23aee08c0ff528f699a19397ed8bbed8 -F src/expr.c f4dcaeb8252c4b16fcdc245660f70ed366bc6cdd +F src/expr.c 1a7970a0c5c72a76c6929896ac109f04e194619b F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 9f00ea98f6b360d477b5a78b5b59a1fbde82431c F src/func.c 59bb046d7e3df1ab512ac339ccb0a6f996a17cb7 @@ -749,6 +749,7 @@ F test/tkt-f3e5abed55.test 669bb076f2ac573c7398ce00f40cd0ca502043a9 F test/tkt-f777251dc7a.test 6f24c053bc5cdb7e1e19be9a72c8887cf41d5e87 F test/tkt-f7b4edec.test d998a08ff2b18b7f62edce8e3044317c45efe6c7 F test/tkt-f973c7ac31.test 1da0ed15ec2c7749fb5ce2828cd69d07153ad9f4 +F test/tkt-fa7bf5ec.test 9102dfea58aa371d78969da735f9392c57e2e035 F test/tkt-fc62af4523.test 72825d3febdedcd5593a27989fc05accdbfc2bb4 F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00 F test/tkt1443.test bacc311da5c96a227bf8c167e77a30c99f8e8368 @@ -967,7 +968,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c41d1d4652b8c7608322e9360c30f06965fd0942 -R c197aad45ade73dffa326e7c03277cd6 +P 150592b4b4d86372e70332d4f69e41a04c4c54c3 +R 323134b1e783ca1be165bf0fb4b4559e U drh -Z 7e96464fa3894ea180db838f3653f8b1 +Z de56e6160107aa87c1184b3bbf78f940 diff --git a/manifest.uuid b/manifest.uuid index f95cc22607..26b91e11b4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -150592b4b4d86372e70332d4f69e41a04c4c54c3 \ No newline at end of file +e43da426e66e6b63d5ed9610a6308aba0089313b \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index d024528d7c..3e144612c9 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3453,7 +3453,7 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB){ } }else if( pA->op!=TK_COLUMN && pA->u.zToken ){ if( ExprHasProperty(pB, EP_IntValue) || NEVER(pB->u.zToken==0) ) return 2; - if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ){ + if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ return 2; } } diff --git a/test/tkt-fa7bf5ec.test b/test/tkt-fa7bf5ec.test new file mode 100644 index 0000000000..34f12b9677 --- /dev/null +++ b/test/tkt-fa7bf5ec.test @@ -0,0 +1,39 @@ +# 2011 October 13 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. Specifically, +# it tests that ticket [fa7bf5ec94801e7e2030e41eefe5d9dd96eaacfd] has +# been resolved. +# +# The problem described by this ticket was that the sqlite3ExprCompare() +# function was saying that expressions (x='a') and (x='A') were identical +# because it was using sqlite3StrICmp() instead of strcmp() to compare string +# literals. That was causing the query optimizer for aggregate queries to +# believe that both count() operations were identical, and thus only +# computing the first count() and making a copy of the result for the +# second count(). +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_test tkt-fa7bf5ec-1 { + execsql { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES ('a'); + INSERT INTO t1 VALUES ('A'); + INSERT INTO t1 VALUES ('A'); + SELECT count(CASE WHEN x='a' THEN 1 END), + count(CASE WHEN x='A' THEN 1 END) + FROM t1; + } +} {1 2} + +finish_test From 36f7dd3f0bece64a1d0f94e128a80271eeaaff12 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 16:02:17 +0000 Subject: [PATCH 23/51] Enable large-file support for fopen() and friends in the command-line shell. Ticket [92af7da36b6fbd] FossilOrigin-Name: eeeba4f0d2207ec26c60a405e2705e5d40022dbb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 11 +++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 5b66702538..42d8db8180 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\squery\soptimizer\sfor\saggregate\squeries\sknows\sthat\sexpressions\n(x='a')\sand\s(x='A')\sare\sdifferent.\s\sTicket\s[fa7bf5ec94801e7e] -D 2011-10-13T15:35:52.354 +C Enable\slarge-file\ssupport\sfor\sfopen()\sand\sfriends\sin\sthe\scommand-line\sshell.\nTicket\s[92af7da36b6fbd] +D 2011-10-13T16:02:17.114 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f -F src/shell.c 2a44834246f0b55fe4673cda749fa0efe4d078e2 +F src/shell.c faba48cc0e93cc5cf3ed807a1301397198656ba1 F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 @@ -968,7 +968,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 150592b4b4d86372e70332d4f69e41a04c4c54c3 -R 323134b1e783ca1be165bf0fb4b4559e +P e43da426e66e6b63d5ed9610a6308aba0089313b +R 2f8c91247f2bf8554514af942b180667 U drh -Z de56e6160107aa87c1184b3bbf78f940 +Z b6deee099df43353152ea0c675f27bf5 diff --git a/manifest.uuid b/manifest.uuid index 26b91e11b4..4e72dd21c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e43da426e66e6b63d5ed9610a6308aba0089313b \ No newline at end of file +eeeba4f0d2207ec26c60a405e2705e5d40022dbb \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index db9295c6ef..1b58bd2756 100644 --- a/src/shell.c +++ b/src/shell.c @@ -17,6 +17,17 @@ #define _CRT_SECURE_NO_WARNINGS #endif +/* +** Enable large-file support for fopen() and friends on unix. +*/ +#ifndef SQLITE_DISABLE_LFS +# define _LARGE_FILE 1 +# ifndef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 +# endif +# define _LARGEFILE_SOURCE 1 +#endif + #include #include #include From 56197954dd9ccb8d59181a9f045e8a4cdfdbce39 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 16:30:13 +0000 Subject: [PATCH 24/51] Change the command-line shell to do the ".dump" inside of a SAVEPOINT rather than a transaction, since this allows it to be run from within a transaction. FossilOrigin-Name: 6df7343b4c3de9ad8221180dc959dbbdf54733c7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 42d8db8180..a6989cff49 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enable\slarge-file\ssupport\sfor\sfopen()\sand\sfriends\sin\sthe\scommand-line\sshell.\nTicket\s[92af7da36b6fbd] -D 2011-10-13T16:02:17.114 +C Change\sthe\scommand-line\sshell\sto\sdo\sthe\s".dump"\sinside\sof\sa\sSAVEPOINT\nrather\sthan\sa\stransaction,\ssince\sthis\sallows\sit\sto\sbe\srun\sfrom\swithin\na\stransaction. +D 2011-10-13T16:30:13.341 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f -F src/shell.c faba48cc0e93cc5cf3ed807a1301397198656ba1 +F src/shell.c 2a1dc64d3090b2df52c7f14193412158dc270092 F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 @@ -968,7 +968,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P e43da426e66e6b63d5ed9610a6308aba0089313b -R 2f8c91247f2bf8554514af942b180667 +P eeeba4f0d2207ec26c60a405e2705e5d40022dbb +R ed7e565f0211c4c1131b905cec35ce7f U drh -Z b6deee099df43353152ea0c675f27bf5 +Z 07e4e2747d51a87b1cc6214a4bd49bcf diff --git a/manifest.uuid b/manifest.uuid index 4e72dd21c8..b02554be0e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eeeba4f0d2207ec26c60a405e2705e5d40022dbb \ No newline at end of file +6df7343b4c3de9ad8221180dc959dbbdf54733c7 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 1b58bd2756..915438e6c2 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1591,7 +1591,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ fprintf(p->out, "PRAGMA foreign_keys=OFF;\n"); fprintf(p->out, "BEGIN TRANSACTION;\n"); p->writableSchema = 0; - sqlite3_exec(p->db, "BEGIN; PRAGMA writable_schema=ON", 0, 0, 0); + sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0); p->nErr = 0; if( nArg==1 ){ run_schema_dump_query(p, @@ -1624,10 +1624,11 @@ static int do_meta_command(char *zLine, struct callback_data *p){ } } if( p->writableSchema ){ - fprintf(p->out, "PRAGMA writable_schema=OFF; COMMIT;\n"); + fprintf(p->out, "PRAGMA writable_schema=OFF;\n"); p->writableSchema = 0; } - sqlite3_exec(p->db, "PRAGMA writable_schema=OFF", 0, 0, 0); + sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0); + sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0); fprintf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n"); }else From b2acc3b145fff44a28b5660204343f21a3c4dc14 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 16:36:29 +0000 Subject: [PATCH 25/51] Provide a complete prototype for isatty() in the command-line shell sources. FossilOrigin-Name: 8bf13b036a77af9984f8f3d3a93da589fafd773f --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index a6989cff49..aab1650124 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\scommand-line\sshell\sto\sdo\sthe\s".dump"\sinside\sof\sa\sSAVEPOINT\nrather\sthan\sa\stransaction,\ssince\sthis\sallows\sit\sto\sbe\srun\sfrom\swithin\na\stransaction. -D 2011-10-13T16:30:13.341 +C Provide\sa\scomplete\sprototype\sfor\sisatty()\sin\sthe\scommand-line\sshell\ssources. +D 2011-10-13T16:36:29.833 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f -F src/shell.c 2a1dc64d3090b2df52c7f14193412158dc270092 +F src/shell.c e30e20107fda14260640191a51aa527d8f209671 F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 @@ -968,7 +968,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P eeeba4f0d2207ec26c60a405e2705e5d40022dbb -R ed7e565f0211c4c1131b905cec35ce7f +P 6df7343b4c3de9ad8221180dc959dbbdf54733c7 +R b36f1c5467f7a7b4c968bdd000819e3b U drh -Z 07e4e2747d51a87b1cc6214a4bd49bcf +Z 3bfa4da8f402717f393283aeaaadc9a9 diff --git a/manifest.uuid b/manifest.uuid index b02554be0e..e873052123 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6df7343b4c3de9ad8221180dc959dbbdf54733c7 \ No newline at end of file +8bf13b036a77af9984f8f3d3a93da589fafd773f \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 915438e6c2..58a48db123 100644 --- a/src/shell.c +++ b/src/shell.c @@ -71,7 +71,7 @@ #else /* Make sure isatty() has a prototype. */ -extern int isatty(); +extern int isatty(int); #endif #if defined(_WIN32_WCE) From c522731b88c6c32989e3bc3c7a9f2a1f9437941a Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 17:09:01 +0000 Subject: [PATCH 26/51] An improved fix for the page_count and quick_check problem previously patched at [150592b4b4d8637] FossilOrigin-Name: c3cb7f4fad725d5fa4d5acd9da63fc4538ce8e13 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/pragma.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index aab1650124..fc7425da2c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Provide\sa\scomplete\sprototype\sfor\sisatty()\sin\sthe\scommand-line\sshell\ssources. -D 2011-10-13T16:36:29.833 +C An\simproved\sfix\sfor\sthe\spage_count\sand\squick_check\sproblem\spreviously\npatched\sat\s[150592b4b4d8637] +D 2011-10-13T17:09:01.247 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -173,7 +173,7 @@ F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 49e718c095810c6b3334e3a6d89970aceaddefce F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 24f5e85a78514584b46190260ba7ab0a66312197 -F src/pragma.c 0a11a7b543b455ab28e0c881b346fb569eefd2d3 +F src/pragma.c da8ef96b3eec351e81e0061c39810e548bcc96d7 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 F src/printf.c c6ec4b345655a90691fd69de46bfd10f263b1aaf F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -968,7 +968,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 6df7343b4c3de9ad8221180dc959dbbdf54733c7 -R b36f1c5467f7a7b4c968bdd000819e3b +P 8bf13b036a77af9984f8f3d3a93da589fafd773f +R 2d14ac4e9551c84e90407929f7ce1d30 U drh -Z 3bfa4da8f402717f393283aeaaadc9a9 +Z 0f1ef2a0c533d691837cc1c484eedc14 diff --git a/manifest.uuid b/manifest.uuid index e873052123..b18b5e4606 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8bf13b036a77af9984f8f3d3a93da589fafd773f \ No newline at end of file +c3cb7f4fad725d5fa4d5acd9da63fc4538ce8e13 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 4e01948eec..13a973347b 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -467,7 +467,7 @@ void sqlite3Pragma( if( sqlite3ReadSchema(pParse) ) goto pragma_out; sqlite3CodeVerifySchema(pParse, iDb); iReg = ++pParse->nMem; - if( (zLeft[0]&0xf)==0 ){ + if( sqlite3Tolower(zLeft[0])=='p' ){ sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg); }else{ sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi(zRight)); @@ -1080,7 +1080,7 @@ void sqlite3Pragma( { OP_ResultRow, 3, 1, 0}, }; - int isQuick = ((zLeft[0]&0xf)==1); + int isQuick = (sqlite3Tolower(zLeft[0])=='q'); /* Initialize the VDBE program */ if( sqlite3ReadSchema(pParse) ) goto pragma_out; From 8dab211632ad34bbfbf809eac10a3883e1c12601 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 13 Oct 2011 17:16:45 +0000 Subject: [PATCH 27/51] Handle updating the only row of an FTS table correctly. Fix for [9fd058691]. FossilOrigin-Name: 7e24645be2fe0ffe092212e7bcfa5b4500305811 --- ext/fts3/fts3.c | 17 +++++++++--- ext/fts3/fts3Int.h | 7 +++++ ext/fts3/fts3_snippet.c | 4 +-- ext/fts3/fts3_write.c | 13 +++++---- manifest | 21 ++++++++------- manifest.uuid | 2 +- test/fts-9fd058691.test | 59 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 99 insertions(+), 24 deletions(-) create mode 100644 test/fts-9fd058691.test diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 29e071a50f..b3780b8349 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1338,7 +1338,7 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ ** table is missing a row that is present in the full-text index. ** The data structures are corrupt. */ - rc = SQLITE_CORRUPT_VTAB; + rc = FTS_CORRUPT_VTAB; } pCsr->isEof = 1; if( pContext ){ @@ -1398,7 +1398,7 @@ static int fts3ScanInteriorNode( zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); if( zCsr>zEnd ){ - return SQLITE_CORRUPT_VTAB; + return FTS_CORRUPT_VTAB; } while( zCsrzEnd ){ - rc = SQLITE_CORRUPT_VTAB; + rc = FTS_CORRUPT_VTAB; goto finish_scan; } if( nPrefix+nSuffix>nAlloc ){ @@ -3859,7 +3859,7 @@ static int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){ } if( nDoc==0 || nByte==0 ){ sqlite3_reset(pStmt); - return SQLITE_CORRUPT_VTAB; + return FTS_CORRUPT_VTAB; } pCsr->nDoc = nDoc; @@ -4826,6 +4826,15 @@ void sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *pPhrase){ } } +/* +** Return SQLITE_CORRUPT_VTAB. +*/ +#ifdef SQLITE_DEBUG +int sqlite3Fts3Corrupt(){ + return SQLITE_CORRUPT_VTAB; +} +#endif + #if !SQLITE_CORE /* ** Initialize API pointer table, if required. diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index ed8043adf6..f210aa4569 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -157,6 +157,13 @@ typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */ #endif /* SQLITE_AMALGAMATION */ +#ifdef SQLITE_DEBUG +int sqlite3Fts3Corrupt(void); +# define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt() +#else +# define FTS_CORRUPT_VTAB SQLITE_CORRUPT_VTAB +#endif + typedef struct Fts3Table Fts3Table; typedef struct Fts3Cursor Fts3Cursor; typedef struct Fts3Expr Fts3Expr; diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index b569eb131b..3bb47a04ad 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -848,7 +848,7 @@ static int fts3MatchinfoSelectDoctotal( a = sqlite3_column_blob(pStmt, 0); a += sqlite3Fts3GetVarint(a, &nDoc); - if( nDoc==0 ) return SQLITE_CORRUPT_VTAB; + if( nDoc==0 ) return FTS_CORRUPT_VTAB; *pnDoc = (u32)nDoc; if( paLen ) *paLen = a; @@ -1427,7 +1427,7 @@ void sqlite3Fts3Offsets( ); rc = fts3StringAppend(&res, aBuffer, -1); }else if( rc==SQLITE_DONE ){ - rc = SQLITE_CORRUPT_VTAB; + rc = FTS_CORRUPT_VTAB; } } } diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 36f2249e12..471feeec9f 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -341,7 +341,7 @@ static int fts3SelectDocsize( rc = sqlite3_step(pStmt); if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){ rc = sqlite3_reset(pStmt); - if( rc==SQLITE_OK ) rc = SQLITE_CORRUPT_VTAB; + if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB; pStmt = 0; }else{ rc = SQLITE_OK; @@ -1145,7 +1145,7 @@ static int fts3SegReaderNext( if( nPrefix<0 || nSuffix<=0 || &pNext[nSuffix]>&pReader->aNode[pReader->nNode] ){ - return SQLITE_CORRUPT_VTAB; + return FTS_CORRUPT_VTAB; } if( nPrefix+nSuffix>pReader->nTermAlloc ){ @@ -1175,7 +1175,7 @@ static int fts3SegReaderNext( if( &pReader->aDoclist[pReader->nDoclist]>&pReader->aNode[pReader->nNode] || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1]) ){ - return SQLITE_CORRUPT_VTAB; + return FTS_CORRUPT_VTAB; } return SQLITE_OK; } @@ -3129,7 +3129,6 @@ int sqlite3Fts3UpdateMethod( Fts3Table *p = (Fts3Table *)pVtab; int rc = SQLITE_OK; /* Return Code */ int isRemove = 0; /* True for an UPDATE or DELETE */ - sqlite3_int64 iRemove = 0; /* Rowid removed by UPDATE or DELETE */ u32 *aSzIns = 0; /* Sizes of inserted documents */ u32 *aSzDel; /* Sizes of deleted documents */ int nChng = 0; /* Net change in number of documents */ @@ -3212,19 +3211,19 @@ int sqlite3Fts3UpdateMethod( assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER ); rc = fts3DeleteByRowid(p, apVal[0], &nChng, aSzDel); isRemove = 1; - iRemove = sqlite3_value_int64(apVal[0]); } /* If this is an INSERT or UPDATE operation, insert the new record. */ if( nArg>1 && rc==SQLITE_OK ){ if( bInsertDone==0 ){ rc = fts3InsertData(p, apVal, pRowid); - if( rc==SQLITE_CONSTRAINT ) rc = SQLITE_CORRUPT_VTAB; + if( rc==SQLITE_CONSTRAINT ) rc = FTS_CORRUPT_VTAB; } - if( rc==SQLITE_OK && (!isRemove || *pRowid!=iRemove) ){ + if( rc==SQLITE_OK && (!isRemove || *pRowid!=p->iPrevDocid ) ){ rc = fts3PendingTermsDocid(p, *pRowid); } if( rc==SQLITE_OK ){ + assert( p->iPrevDocid==*pRowid ); rc = fts3InsertTerms(p, apVal, aSzIns); } if( p->bHasDocsize ){ diff --git a/manifest b/manifest index fc7425da2c..a6cd78f5fa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\simproved\sfix\sfor\sthe\spage_count\sand\squick_check\sproblem\spreviously\npatched\sat\s[150592b4b4d8637] -D 2011-10-13T17:09:01.247 +C Handle\supdating\sthe\sonly\srow\sof\san\sFTS\stable\scorrectly.\sFix\sfor\s[9fd058691]. +D 2011-10-13T17:16:45.272 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,22 +62,22 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 195e4da669741c1f097434ec48c0ba5739193af9 +F ext/fts3/fts3.c 0ace6b45d62338b35f095c7e7d1851965e477e4e F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 30063fdd0bc433b5db1532e3a363cb0f2f7e8eb3 +F ext/fts3/fts3Int.h 59c5a9475fed5d76c70a4763103b3c8e60424a68 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 F ext/fts3/fts3_expr.c 23791de01b3a5d313d76e02befd2601d4096bc2b F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa F ext/fts3/fts3_porter.c 8d946908f4812c005d3d33fcbe78418b1f4eb70c -F ext/fts3/fts3_snippet.c 58b2ba2b934c1e2a2f6ac857d7f3c7e1a14b4532 +F ext/fts3/fts3_snippet.c 19a906f8ed73ad8b670dfc271ceae7b3338c157e F ext/fts3/fts3_term.c a5457992723455a58804cb75c8cbd8978db5c2ef F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c 194829c8fd024a448fc899e5ff02a8ed06595529 +F ext/fts3/fts3_write.c ffe13acc3867ea6b0fc8b9cfbf904bfae64eac84 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -408,6 +408,7 @@ F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e F test/fkey4.test c6c8f9f9be885f95c85c7bceb26f243ad906fd49 F test/fkey_malloc.test a5ede29bd2f6e56dea78c3d43fb86dd696c068c8 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb +F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c F test/fts1a.test 46090311f85da51bb33bd5ce84f7948359c6d8d7 F test/fts1b.test 5d8a01aefbecc8b7442b36c94c05eb7a845462d5 F test/fts1c.test 85a525ce7428907469b4cce13d5563ce542ce64c @@ -968,7 +969,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8bf13b036a77af9984f8f3d3a93da589fafd773f -R 2d14ac4e9551c84e90407929f7ce1d30 -U drh -Z 0f1ef2a0c533d691837cc1c484eedc14 +P c3cb7f4fad725d5fa4d5acd9da63fc4538ce8e13 +R ec95a62db79b84d7111fda3a8be06ca9 +U dan +Z 25dbdd79336e5688c7ffd1d8a10e1ab3 diff --git a/manifest.uuid b/manifest.uuid index b18b5e4606..49e0787bce 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c3cb7f4fad725d5fa4d5acd9da63fc4538ce8e13 \ No newline at end of file +7e24645be2fe0ffe092212e7bcfa5b4500305811 \ No newline at end of file diff --git a/test/fts-9fd058691.test b/test/fts-9fd058691.test new file mode 100644 index 0000000000..b228482d46 --- /dev/null +++ b/test/fts-9fd058691.test @@ -0,0 +1,59 @@ +# 2011 October 13 +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# This file implements regression tests for the FTS SQLite module. +# +# This file implements tests to verify that ticket [9fd058691] has been +# fixed. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# If SQLITE_ENABLE_FTS3 is defined, omit this file. +ifcapable !fts3 { + finish_test + return +} + +set ::testprefix fts3-9fd058691 + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE fts USING fts3( tags TEXT); + INSERT INTO fts (tags) VALUES ('tag1'); + SELECT * FROM fts WHERE tags MATCH 'tag1'; +} {tag1} + +do_test 1.1 { + db close + sqlite3 db test.db + execsql { + UPDATE fts SET tags = 'tag1' WHERE rowid = 1; + SELECT * FROM fts WHERE tags MATCH 'tag1'; + } +} {tag1} + +db close +forcedelete test.db +sqlite3 db test.db + +do_execsql_test 2.0 { + CREATE VIRTUAL TABLE fts USING fts3(tags TEXT); + INSERT INTO fts (docid, tags) VALUES (1, 'tag1'); + INSERT INTO fts (docid, tags) VALUES (2, NULL); + INSERT INTO fts (docid, tags) VALUES (3, 'three'); +} {} + +do_test 2.1 { + execsql { + UPDATE fts SET tags = 'two' WHERE rowid = 2; + SELECT * FROM fts WHERE tags MATCH 'two'; + } +} {two} + +finish_test From df901d34e55ca1bff5d7bf10f67bcde51d7c7aae Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 18:00:11 +0000 Subject: [PATCH 28/51] Simplifications to the upper() and lower() SQL functions. Updates to documentation on sqlite3_bind_text() and sqlite3_result_text() to make it clear that users should not try to create strings with embedded NULs and that if they do the result of expression on those strings is undefined. Ticket [57c971fc74524a] FossilOrigin-Name: 9984cc20ca70b7fb39c0b99580a1317a7b0c9c85 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/func.c | 16 +++++++--------- src/sqlite.h.in | 17 +++++++++++++++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index a6cd78f5fa..df81adf9cf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Handle\supdating\sthe\sonly\srow\sof\san\sFTS\stable\scorrectly.\sFix\sfor\s[9fd058691]. -D 2011-10-13T17:16:45.272 +C Simplifications\sto\sthe\supper()\sand\slower()\sSQL\sfunctions.\nUpdates\sto\sdocumentation\son\ssqlite3_bind_text()\sand\ssqlite3_result_text()\nto\smake\sit\sclear\sthat\susers\sshould\snot\stry\sto\screate\sstrings\swith\nembedded\sNULs\sand\sthat\sif\sthey\sdo\sthe\sresult\sof\sexpression\son\sthose\sstrings\nis\sundefined.\s\sTicket\s[57c971fc74524a] +D 2011-10-13T18:00:11.063 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -136,7 +136,7 @@ F src/delete.c ff68e5ef23aee08c0ff528f699a19397ed8bbed8 F src/expr.c 1a7970a0c5c72a76c6929896ac109f04e194619b F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 9f00ea98f6b360d477b5a78b5b59a1fbde82431c -F src/func.c 59bb046d7e3df1ab512ac339ccb0a6f996a17cb7 +F src/func.c 6261ce00aad9c63cd5b4219249b05683979060e9 F src/global.c e230227de13601714b29f9363028514aada5ae2f F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -181,7 +181,7 @@ F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f F src/shell.c e30e20107fda14260640191a51aa527d8f209671 -F src/sqlite.h.in 821027573c481e45ba276b078a3ae9ebaeb9bb92 +F src/sqlite.h.in 5ec7488ef4c124ae905286600a9f2d64250aebb1 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -969,7 +969,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P c3cb7f4fad725d5fa4d5acd9da63fc4538ce8e13 -R ec95a62db79b84d7111fda3a8be06ca9 -U dan -Z 25dbdd79336e5688c7ffd1d8a10e1ab3 +P 7e24645be2fe0ffe092212e7bcfa5b4500305811 +R 70d5d750704aa84a6b8318ba5f4ea9e5 +U drh +Z 36fd6a9db851f3c203fcf94c8d8271d9 diff --git a/manifest.uuid b/manifest.uuid index 49e0787bce..a38544dbc3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7e24645be2fe0ffe092212e7bcfa5b4500305811 \ No newline at end of file +9984cc20ca70b7fb39c0b99580a1317a7b0c9c85 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 16de6bbbdf..3a1879ca69 100644 --- a/src/func.c +++ b/src/func.c @@ -332,16 +332,15 @@ static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ if( z2 ){ z1 = contextMalloc(context, ((i64)n)+1); if( z1 ){ - memcpy(z1, z2, n+1); - for(i=0; z1[i]; i++){ - z1[i] = (char)sqlite3Toupper(z1[i]); + for(i=0; iincluding -** the nul-terminator bytes. +** the nul-terminator bytes as this saves SQLite from having to +** make a copy of the input string. ** ** ^If pzTail is not NULL then *pzTail is made to point to the first byte ** past the end of the first SQL statement in zSql. These routines only @@ -3020,6 +3021,13 @@ typedef struct sqlite3_context sqlite3_context; ** number of bytes in the value, not the number of characters.)^ ** ^If the fourth parameter is negative, the length of the string is ** the number of bytes up to the first zero terminator. +** If a non-negative fourth parameter is provided to sqlite3_bind_text() +** or sqlite3_bind_text16() then that parameter must be the byte offset +** where the NUL terminator would occur assuming the string were NUL +** terminated. If any NUL characters occur at byte offsets less than +** the value of the fourth parameter then the resulting string value will +** contain embedded NULs. The result of expressions involving strings +** with embedded NULs is undefined. ** ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or @@ -4038,7 +4046,12 @@ typedef void (*sqlite3_destructor_type)(void*); ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is non-negative, then as many bytes (not characters) of the text ** pointed to by the 2nd parameter are taken as the application-defined -** function result. +** function result. If the 3rd parameter is non-negative, then it +** must be the byte offset into the string where the NUL terminator would +** appear if the string where NUL terminated. If any NUL characters occur +** in the string at a byte offset that is less than the value of the 3rd +** parameter, then the resulting string will contain embedded NULs and the +** result of expressions operating on strings with embedded NULs is undefined. ** ^If the 4th parameter to the sqlite3_result_text* interfaces ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that ** function as the destructor on the text or BLOB result when it has From 0edb7acd3c2dcd913e5cecce8475aed8ff0850bf Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 13 Oct 2011 18:08:04 +0000 Subject: [PATCH 29/51] Change the makefile to delete both plain and ".exe" variants of build tools. Ticket [92bd6eaf04e117] FossilOrigin-Name: 19536a382815c2ff4cb23625984b4ca92e5e17ee --- main.mk | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/main.mk b/main.mk index 2668b854e1..2b8f47a00c 100644 --- a/main.mk +++ b/main.mk @@ -594,7 +594,8 @@ install: sqlite3 libsqlite3.a sqlite3.h clean: rm -f *.o sqlite3 sqlite3.exe libsqlite3.a sqlite3.h opcodes.* - rm -f lemon lempar.c parse.* sqlite*.tar.gz mkkeywordhash keywordhash.h + rm -f lemon lemon.exe lempar.c parse.* sqlite*.tar.gz + rm -f mkkeywordhash mkkeywordhash.exe keywordhash.h rm -f $(PUBLISH) rm -f *.da *.bb *.bbg gmon.out rm -rf tsrc target_source diff --git a/manifest b/manifest index df81adf9cf..28902fa9d5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\supper()\sand\slower()\sSQL\sfunctions.\nUpdates\sto\sdocumentation\son\ssqlite3_bind_text()\sand\ssqlite3_result_text()\nto\smake\sit\sclear\sthat\susers\sshould\snot\stry\sto\screate\sstrings\swith\nembedded\sNULs\sand\sthat\sif\sthey\sdo\sthe\sresult\sof\sexpression\son\sthose\sstrings\nis\sundefined.\s\sTicket\s[57c971fc74524a] -D 2011-10-13T18:00:11.063 +C Change\sthe\smakefile\sto\sdelete\sboth\splain\sand\s".exe"\svariants\sof\sbuild\stools.\nTicket\s[92bd6eaf04e117] +D 2011-10-13T18:08:04.720 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -104,7 +104,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk aa43670ca62ce7a3f4d80a5f8980c9a9ad076903 +F main.mk 0eb7d4edf00e3bb1e312766ec2edccd015703eec F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -969,7 +969,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 7e24645be2fe0ffe092212e7bcfa5b4500305811 -R 70d5d750704aa84a6b8318ba5f4ea9e5 +P 9984cc20ca70b7fb39c0b99580a1317a7b0c9c85 +R 6c94372987ab796e3d8be832b30cc3a8 U drh -Z 36fd6a9db851f3c203fcf94c8d8271d9 +Z e987d3a4cc3057dbc92acbbf64cbac34 diff --git a/manifest.uuid b/manifest.uuid index a38544dbc3..fea4ea80c7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9984cc20ca70b7fb39c0b99580a1317a7b0c9c85 \ No newline at end of file +19536a382815c2ff4cb23625984b4ca92e5e17ee \ No newline at end of file From b07028f71cd96b48a81474c6f1eea9596eb41cc7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 14 Oct 2011 21:49:18 +0000 Subject: [PATCH 30/51] Add assert() statements and eliminate needless variable assignments in order to get the clang scan-build utility to report zero problems against the SQLite core. Clang's static analysis did find one real problem - but it was in the command-line shell, not in the SQLite core. FossilOrigin-Name: 60fee9574b0125705787e33c16f116cf188c8323 --- manifest | 42 +++++++++++++++++++++--------------------- manifest.uuid | 2 +- src/btree.c | 6 ++++-- src/build.c | 24 +++++++++++++----------- src/expr.c | 17 +++++++++++++---- src/fkey.c | 1 + src/main.c | 1 + src/os_unix.c | 21 ++++++--------------- src/pager.c | 2 +- src/printf.c | 5 +++-- src/select.c | 5 ++++- src/shell.c | 16 +++++++--------- src/tclsqlite.c | 22 ++++++++++++---------- src/update.c | 2 ++ src/vdbe.c | 8 ++++---- src/vdbeaux.c | 31 +++++++++++++++---------------- src/wal.c | 2 +- src/where.c | 3 ++- 18 files changed, 111 insertions(+), 99 deletions(-) diff --git a/manifest b/manifest index 28902fa9d5..a0b4acc9b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\smakefile\sto\sdelete\sboth\splain\sand\s".exe"\svariants\sof\sbuild\stools.\nTicket\s[92bd6eaf04e117] -D 2011-10-13T18:08:04.720 +C Add\sassert()\sstatements\sand\seliminate\sneedless\svariable\sassignments\sin\sorder\nto\sget\sthe\sclang\sscan-build\sutility\sto\sreport\szero\sproblems\sagainst\sthe\nSQLite\score.\s\sClang's\sstatic\sanalysis\sdid\sfind\sone\sreal\sproblem\s-\sbut\sit\swas\nin\sthe\scommand-line\sshell,\snot\sin\sthe\sSQLite\score. +D 2011-10-14T21:49:18.517 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,18 +124,18 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 4fd4440c8f81339d8eb8e5d2df54b68d79e94f2f F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 74da2e088722edfef79f1d182934bbe6a436c0fc +F src/btree.c 4918e848d92212005057e42a2e45b7219e4bb630 F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 -F src/build.c 119937b0ae1ff4dcec8fdea53771acc95bafca51 +F src/build.c ae152efb9c2d6615b14adb7a5f2c51483d4d55df F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 829f3261d3db48e3d87891bc887208734734c2e4 F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c ff68e5ef23aee08c0ff528f699a19397ed8bbed8 -F src/expr.c 1a7970a0c5c72a76c6929896ac109f04e194619b +F src/expr.c fbf116f90cabc917ae50bba24a73a0b55519a0c8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c 9f00ea98f6b360d477b5a78b5b59a1fbde82431c +F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 F src/func.c 6261ce00aad9c63cd5b4219249b05683979060e9 F src/global.c e230227de13601714b29f9363028514aada5ae2f F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af @@ -146,7 +146,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c d0d2022a5a07274d408820b978b9e549189d314f -F src/main.c ae03daa1adf657aac69f18bb13f6a0763494b502 +F src/main.c 82863f47e8ec76dbce21eb92699cd4720b0f45e7 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -165,9 +165,9 @@ F src/os.c 3b3f69c34be7f998f5ea6bd46a2fe8a2b7fa8f70 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c d42ad1c4cb8360825639a64c44bc63672ace8916 +F src/os_unix.c 951ac5260895f1311432ff3ecd5384bbe22f9f4f F src/os_win.c 49d418916428a59d773f39993db0ecde56ab4c37 -F src/pager.c 8a6ac3e0d9694412076e2273e3c81e9c4e08758f +F src/pager.c 60c80db526d39286b913c824cf8303d34ab17a89 F src/pager.h dbcaa791e8b6c3a6b77c168c5c27deec289fb176 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 49e718c095810c6b3334e3a6d89970aceaddefce @@ -175,19 +175,19 @@ F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c 24f5e85a78514584b46190260ba7ab0a66312197 F src/pragma.c da8ef96b3eec351e81e0061c39810e548bcc96d7 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 -F src/printf.c c6ec4b345655a90691fd69de46bfd10f263b1aaf +F src/printf.c 03104cbff6959ff45df69dc9060ba6212f60a869 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 -F src/select.c 94b375306bfb4590fdfd76581ae663f57e94808f -F src/shell.c e30e20107fda14260640191a51aa527d8f209671 +F src/select.c 80f3ac44a8514b1d107b80f5df4a424ae059d2b6 +F src/shell.c f0ab793261ab045a0b8c47fa2707e8a894d2898f F src/sqlite.h.in 5ec7488ef4c124ae905286600a9f2d64250aebb1 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e -F src/tclsqlite.c 20578e66dda94b4d4db3d4478644a4dd9c6084a6 +F src/tclsqlite.c de581e2e71f5e7f98366156afad83b4742ac6fe0 F src/test1.c 0f41b7c67719207a5de24b009e172c4dcf189827 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 124ff9735fb6bb7d41de180d6bac90e7b1509432 @@ -234,24 +234,24 @@ F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c c819d9f72168a035d545a5bdafe9b085b20df705 F src/trigger.c 1cfb80e2290ef66ea89cb4e821caae65a02c0d56 -F src/update.c 74a6cfb34e9732c1e2a86278b229913b4b51eeec +F src/update.c 25e046a8f69d5e557aabde2000487b8545509d8d F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 F src/util.c 06302ffd2b80408d4f6c7af71f7090e0cf8d8ff7 F src/vacuum.c 0c0ba2242355c6048d65e2b333abe0f7c06348fa -F src/vdbe.c 60340bfb23f456ea0791cb28262a887363773371 +F src/vdbe.c 75e626a6e6aefbd35b25ccab8bff533a65354638 F src/vdbe.h f0725ee997db869ecae5bb70a71612aabeca7755 F src/vdbeInt.h 693d6ac6810298fc6b4c503cfbe3f99a240f40af F src/vdbeapi.c 11dc47987abacb76ad016dcf5abc0dc422482a98 -F src/vdbeaux.c b4d509749502554e67ed14268928e4cc038b8efb +F src/vdbeaux.c 5bd4886b444051b779eb4a2e27e46a5deb65c0fd F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c 2fc78b3e0fabcc1eaa23cd79dd2e30e6dcfe1e56 F src/vdbesort.c 468d43c057063e54da4f1988b38b4f46d60e7790 F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582 -F src/wal.c 3154756177d6219e233d84291d5b05f4e06ff5e9 +F src/wal.c 9658df8d404b82e6b2d40fd05944463214e2d935 F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 12939ac49f5122eb11b5ca4c35b2fdd8eaae9833 +F src/where.c 0db7e2db5128c9e8aec225fd229cf56773a4ef5a F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 @@ -969,7 +969,7 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 9984cc20ca70b7fb39c0b99580a1317a7b0c9c85 -R 6c94372987ab796e3d8be832b30cc3a8 +P 19536a382815c2ff4cb23625984b4ca92e5e17ee +R 58341c3af5b5e017b2de4c1d1c18c025 U drh -Z e987d3a4cc3057dbc92acbbf64cbac34 +Z df8323ed17eddd9599c36e3ee7e4fb6f diff --git a/manifest.uuid b/manifest.uuid index fea4ea80c7..c499c05537 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19536a382815c2ff4cb23625984b4ca92e5e17ee \ No newline at end of file +60fee9574b0125705787e33c16f116cf188c8323 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index f1a67cab94..6c724d0fa3 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4585,7 +4585,6 @@ int sqlite3BtreeMovetoUnpacked( if( c==0 ){ if( pPage->intKey && !pPage->leaf ){ lwr = idx; - upr = lwr - 1; break; }else{ *pRes = 0; @@ -4603,7 +4602,7 @@ int sqlite3BtreeMovetoUnpacked( } pCur->aiIdx[pCur->iPage] = (u16)(idx = (lwr+upr)/2); } - assert( lwr==upr+1 ); + assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); assert( pPage->isInit ); if( pPage->leaf ){ chldPg = 0; @@ -4868,6 +4867,8 @@ static int allocateBtreePage( pTrunk = 0; goto end_allocate_page; } + assert( pTrunk!=0 ); + assert( pTrunk->aData!=0 ); k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */ if( k==0 && !searchList ){ @@ -6423,6 +6424,7 @@ static int balance_nonroot( /* Cell i is the cell immediately following the last cell on old ** sibling page j. If the siblings are not leaf pages of an ** intkey b-tree, then cell i was a divider cell. */ + assert( j+1 < ArraySize(apCopy) ); pOld = apCopy[++j]; iNextOld = i + !leafData + pOld->nCell + pOld->nOverflow; if( pOld->nOverflow ){ diff --git a/src/build.c b/src/build.c index d7f08e4966..050643d183 100644 --- a/src/build.c +++ b/src/build.c @@ -2342,13 +2342,15 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){ Table *pTab = pIndex->pTable; /* The table that is indexed */ int iTab = pParse->nTab++; /* Btree cursor used for pTab */ int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */ - int iSorter = iTab; /* Cursor opened by OpenSorter (if in use) */ + int iSorter; /* Cursor opened by OpenSorter (if in use) */ int addr1; /* Address of top of loop */ int addr2; /* Address to jump to for next iteration */ int tnum; /* Root page of index */ Vdbe *v; /* Generate code into this virtual machine */ KeyInfo *pKey; /* KeyInfo for index */ +#ifdef SQLITE_OMIT_MERGE_SORT int regIdxKey; /* Registers containing the index key */ +#endif int regRecord; /* Register holding assemblied index record */ sqlite3 *db = pParse->db; /* The database connection */ int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema); @@ -2382,17 +2384,18 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){ /* Open the sorter cursor if we are to use one. */ iSorter = pParse->nTab++; sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO); +#else + iSorter = iTab; #endif /* Open the table. Loop through all rows of the table, inserting index ** records into the sorter. */ sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); - addr2 = addr1 + 1; regRecord = sqlite3GetTempReg(pParse); - regIdxKey = sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); #ifndef SQLITE_OMIT_MERGE_SORT + sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord); sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); sqlite3VdbeJumpHere(v, addr1); @@ -2412,6 +2415,8 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){ sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1); sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); #else + regIdxKey = sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); + addr2 = addr1 + 1; if( pIndex->onError!=OE_None ){ const int regRowid = regIdxKey + pIndex->nColumn; const int j2 = sqlite3VdbeCurrentAddr(v) + 2; @@ -2509,6 +2514,7 @@ Index *sqlite3CreateIndex( assert( pName1 && pName2 ); iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName); if( iDb<0 ) goto exit_create_index; + assert( pName && pName->z ); #ifndef SQLITE_OMIT_TEMPDB /* If the index name was unqualified, check if the the table @@ -2536,6 +2542,7 @@ Index *sqlite3CreateIndex( assert( db->aDb[iDb].pSchema==pTab->pSchema ); }else{ assert( pName==0 ); + assert( pStart==0 ); pTab = pParse->pNewTable; if( !pTab ) goto exit_create_index; iDb = sqlite3SchemaToIndex(db, pTab->pSchema); @@ -2578,6 +2585,7 @@ Index *sqlite3CreateIndex( if( pName ){ zName = sqlite3NameFromToken(db, pName); if( zName==0 ) goto exit_create_index; + assert( pName->z!=0 ); if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto exit_create_index; } @@ -3433,13 +3441,10 @@ void sqlite3BeginTransaction(Parse *pParse, int type){ ** Commit a transaction */ void sqlite3CommitTransaction(Parse *pParse){ - sqlite3 *db; Vdbe *v; assert( pParse!=0 ); - db = pParse->db; - assert( db!=0 ); -/* if( db->aDb[0].pBt==0 ) return; */ + assert( pParse->db!=0 ); if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ){ return; } @@ -3453,13 +3458,10 @@ void sqlite3CommitTransaction(Parse *pParse){ ** Rollback a transaction */ void sqlite3RollbackTransaction(Parse *pParse){ - sqlite3 *db; Vdbe *v; assert( pParse!=0 ); - db = pParse->db; - assert( db!=0 ); -/* if( db->aDb[0].pBt==0 ) return; */ + assert( pParse->db!=0 ); if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ){ return; } diff --git a/src/expr.c b/src/expr.c index 3e144612c9..d506173771 100644 --- a/src/expr.c +++ b/src/expr.c @@ -403,7 +403,8 @@ Expr *sqlite3ExprAlloc( }else{ int c; pNew->u.zToken = (char*)&pNew[1]; - memcpy(pNew->u.zToken, pToken->z, pToken->n); + assert( pToken->z!=0 || pToken->n==0 ); + if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n); pNew->u.zToken[pToken->n] = 0; if( dequote && nExtra>=3 && ((c = pToken->z[0])=='\'' || c=='"' || c=='[' || c=='`') ){ @@ -1442,11 +1443,19 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){ p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0); if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){ sqlite3 *db = pParse->db; /* Database connection */ - Expr *pExpr = p->pEList->a[0].pExpr; /* Expression */ - int iCol = pExpr->iColumn; /* Index of column */ Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */ - Table *pTab = p->pSrc->a[0].pTab; /* Table . */ + Table *pTab; /* Table
. */ + Expr *pExpr; /* Expression */ + int iCol; /* Index of column */ int iDb; /* Database idx for pTab */ + + assert( p ); /* Because of isCandidateForInOpt(p) */ + assert( p->pEList!=0 ); /* Because of isCandidateForInOpt(p) */ + assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */ + assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */ + pTab = p->pSrc->a[0].pTab; + pExpr = p->pEList->a[0].pExpr; + iCol = pExpr->iColumn; /* Code an OP_VerifyCookie and OP_TableLock for
. */ iDb = sqlite3SchemaToIndex(db, pTab->pSchema); diff --git a/src/fkey.c b/src/fkey.c index f0a9fb6ba1..82e4cdc471 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -1124,6 +1124,7 @@ static Trigger *fkActionTrigger( fkTriggerDelete(db, pTrigger); return 0; } + assert( pStep!=0 ); switch( action ){ case OE_Restrict: diff --git a/src/main.c b/src/main.c index 51596c1de1..b18217d34a 100644 --- a/src/main.c +++ b/src/main.c @@ -2282,6 +2282,7 @@ opendb_out: sqlite3_mutex_leave(db->mutex); } rc = sqlite3_errcode(db); + assert( db!=0 || rc==SQLITE_NOMEM ); if( rc==SQLITE_NOMEM ){ sqlite3_close(db); db = 0; diff --git a/src/os_unix.c b/src/os_unix.c index e0025229fd..0236bf7ccb 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1363,14 +1363,14 @@ static int unixLock(sqlite3_file *id, int eFileLock){ */ int rc = SQLITE_OK; unixFile *pFile = (unixFile*)id; - unixInodeInfo *pInode = pFile->pInode; + unixInodeInfo *pInode; struct flock lock; int tErrno = 0; assert( pFile ); OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h, azFileLock(eFileLock), azFileLock(pFile->eFileLock), - azFileLock(pInode->eFileLock), pInode->nShared , getpid())); + azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared , getpid())); /* If there is already a lock of this type or more restrictive on the ** unixFile, do nothing. Don't use the end_lock: exit path, as @@ -1574,7 +1574,6 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){ unixInodeInfo *pInode; struct flock lock; int rc = SQLITE_OK; - int h; assert( pFile ); OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock, @@ -1586,14 +1585,10 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){ return SQLITE_OK; } unixEnterMutex(); - h = pFile->h; pInode = pFile->pInode; assert( pInode->nShared!=0 ); if( pFile->eFileLock>SHARED_LOCK ){ assert( pInode->eFileLock==pFile->eFileLock ); - SimulateIOErrorBenign(1); - SimulateIOError( h=(-1) ) - SimulateIOErrorBenign(0); #ifndef NDEBUG /* When reducing a lock such that other processes can start @@ -1604,11 +1599,6 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){ ** the file has changed and hence might not know to flush their ** cache. The use of a stale cache can lead to database corruption. */ -#if 0 - assert( pFile->inNormalWrite==0 - || pFile->dbUpdate==0 - || pFile->transCntrChng==1 ); -#endif pFile->inNormalWrite = 0; #endif @@ -1710,9 +1700,6 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){ lock.l_type = F_UNLCK; lock.l_whence = SEEK_SET; lock.l_start = lock.l_len = 0L; - SimulateIOErrorBenign(1); - SimulateIOError( h=(-1) ) - SimulateIOErrorBenign(0); if( unixFileLock(pFile, &lock)==0 ){ pInode->eFileLock = NO_LOCK; }else{ @@ -4548,6 +4535,9 @@ static int fillInUnixFile( assert( zFilename==0 || zFilename[0]=='/' ); #endif + /* No locking occurs in temporary files */ + assert( zFilename!=0 || noLock ); + OSTRACE(("OPEN %-3d %s\n", h, zFilename)); pNew->h = h; pNew->zPath = zFilename; @@ -4649,6 +4639,7 @@ static int fillInUnixFile( */ char *zLockFile; int nFilename; + assert( zFilename!=0 ); nFilename = (int)strlen(zFilename) + 6; zLockFile = (char *)sqlite3_malloc(nFilename); if( zLockFile==0 ){ diff --git a/src/pager.c b/src/pager.c index 99a3ebd4c3..421a7094f1 100644 --- a/src/pager.c +++ b/src/pager.c @@ -2703,7 +2703,6 @@ static int pager_playback(Pager *pPager, int isHot){ rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0); if( rc!=SQLITE_OK ){ if( rc==SQLITE_DONE ){ - rc = SQLITE_OK; pPager->journalOff = szJ; break; }else if( rc==SQLITE_IOERR_SHORT_READ ){ @@ -2965,6 +2964,7 @@ static int pagerWalFrames( #endif assert( pPager->pWal ); + assert( pList ); #ifdef SQLITE_DEBUG /* Verify that the page list is in accending order */ for(p=pList; p && p->pDirty; p=p->pDirty){ diff --git a/src/printf.c b/src/printf.c index 1303e17edf..0babee5141 100644 --- a/src/printf.c +++ b/src/printf.c @@ -197,7 +197,6 @@ void sqlite3VXPrintf( #endif char buf[etBUFSIZE]; /* Conversion buffer */ - length = 0; bufpt = 0; for(; (c=(*fmt))!=0; ++fmt){ if( c!='%' ){ @@ -692,6 +691,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ testcase(p->mallocFailed); return; } + assert( p->zText!=0 || p->nChar==0 ); if( N<0 ){ N = sqlite3Strlen30(z); } @@ -723,7 +723,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ zNew = sqlite3_realloc(zOld, p->nAlloc); } if( zNew ){ - if( zOld==0 ) memcpy(zNew, p->zText, p->nChar); + if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; }else{ p->mallocFailed = 1; @@ -732,6 +732,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ } } } + assert( p->zText ); memcpy(&p->zText[p->nChar], z, N); p->nChar += N; } diff --git a/src/select.c b/src/select.c index cf9a00a8d8..571a77822b 100644 --- a/src/select.c +++ b/src/select.c @@ -1272,7 +1272,10 @@ static int selectColumnsFromExprList( }else{ Expr *pColExpr = p; /* The expression that is the result column name */ Table *pTab; /* Table associated with this expression */ - while( pColExpr->op==TK_DOT ) pColExpr = pColExpr->pRight; + while( pColExpr->op==TK_DOT ){ + pColExpr = pColExpr->pRight; + assert( pColExpr!=0 ); + } if( pColExpr->op==TK_COLUMN && ALWAYS(pColExpr->pTab!=0) ){ /* For columns use the column name name */ int iCol = pColExpr->iColumn; diff --git a/src/shell.c b/src/shell.c index 58a48db123..07623e52a0 100644 --- a/src/shell.c +++ b/src/shell.c @@ -338,7 +338,6 @@ static char *local_getline(char *zPrompt, FILE *in){ char *zLine; int nLine; int n; - int eol; if( zPrompt && *zPrompt ){ printf("%s",zPrompt); @@ -348,8 +347,7 @@ static char *local_getline(char *zPrompt, FILE *in){ zLine = malloc( nLine ); if( zLine==0 ) return 0; n = 0; - eol = 0; - while( !eol ){ + while( 1 ){ if( n+100>nLine ){ nLine = nLine*2 + 100; zLine = realloc(zLine, nLine); @@ -361,7 +359,6 @@ static char *local_getline(char *zPrompt, FILE *in){ return 0; } zLine[n] = 0; - eol = 1; break; } while( zLine[n] ){ n++; } @@ -369,7 +366,7 @@ static char *local_getline(char *zPrompt, FILE *in){ n--; if( n>0 && zLine[n-1]=='\r' ) n--; zLine[n] = 0; - eol = 1; + break; } } zLine = realloc( zLine, n+1 ); @@ -1097,6 +1094,7 @@ static int shell_exec( ){ sqlite3_stmt *pStmt = NULL; /* Statement to execute. */ int rc = SQLITE_OK; /* Return Code */ + int rc2; const char *zLeftover; /* Tail of unprocessed SQL */ if( pzErrMsg ){ @@ -1190,7 +1188,8 @@ static int shell_exec( /* Finalize the statement just executed. If this fails, save a ** copy of the error message. Otherwise, set zSql to point to the ** next statement to execute. */ - rc = sqlite3_finalize(pStmt); + rc2 = sqlite3_finalize(pStmt); + if( rc!=SQLITE_NOMEM ) rc = rc2; if( rc==SQLITE_OK ){ zSql = zLeftover; while( IsSpace(zSql[0]) ) zSql++; @@ -1762,7 +1761,6 @@ static int do_meta_command(char *zLine, struct callback_data *p){ zCommit = "COMMIT"; while( (zLine = local_getline(0, in))!=0 ){ char *z; - i = 0; lineno++; azCol[0] = zLine; for(i=0, z=zLine; *z && *z!='\n' && *z!='\r'; z++){ @@ -2237,7 +2235,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ if( testctrl<0 ){ testctrl = aCtrl[i].ctrlCode; }else{ - fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[i]); + fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]); testctrl = -1; break; } @@ -2745,6 +2743,7 @@ int main(int argc, char **argv){ }else if( strcmp(argv[i],"-batch")==0 ){ stdin_is_interactive = 0; }else if( strcmp(argv[i],"-heap")==0 ){ +#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) int j, c; const char *zSize; sqlite3_int64 szHeap; @@ -2757,7 +2756,6 @@ int main(int argc, char **argv){ if( c=='G' ){ szHeap *= 1000000000; break; } } if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000; -#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); #endif #ifdef SQLITE_ENABLE_VFSTRACE diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 35dd0ad8ae..c8f0fbd31b 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -919,7 +919,7 @@ static int auth_callback( Tcl_DStringAppendElement(&str, zArg4 ? zArg4 : ""); rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str)); Tcl_DStringFree(&str); - zReply = Tcl_GetStringResult(pDb->interp); + zReply = rc==TCL_OK ? Tcl_GetStringResult(pDb->interp) : "SQLITE_DENY"; if( strcmp(zReply,"SQLITE_OK")==0 ){ rc = SQLITE_OK; }else if( strcmp(zReply,"SQLITE_DENY")==0 ){ @@ -968,14 +968,12 @@ static char *local_getline(char *zPrompt, FILE *in){ char *zLine; int nLine; int n; - int eol; nLine = 100; zLine = malloc( nLine ); if( zLine==0 ) return 0; n = 0; - eol = 0; - while( !eol ){ + while( 1 ){ if( n+100>nLine ){ nLine = nLine*2 + 100; zLine = realloc(zLine, nLine); @@ -987,14 +985,13 @@ static char *local_getline(char *zPrompt, FILE *in){ return 0; } zLine[n] = 0; - eol = 1; break; } while( zLine[n] ){ n++; } if( n>0 && zLine[n-1]=='\n' ){ n--; zLine[n] = 0; - eol = 1; + break; } } zLine = realloc( zLine, n+1 ); @@ -2121,7 +2118,6 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ zCommit = "COMMIT"; while( (zLine = local_getline(0, in))!=0 ){ char *z; - i = 0; lineno++; azCol[0] = zLine; for(i=0, z=zLine; *z; z++){ @@ -2550,14 +2546,16 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ ** Change the encryption key on the currently open database. */ case DB_REKEY: { +#ifdef SQLITE_HAS_CODEC int nKey; void *pKey; +#endif if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "KEY"); return TCL_ERROR; } - pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey); #ifdef SQLITE_HAS_CODEC + pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey); rc = sqlite3_rekey(pDb->db, pKey, nKey); if( rc ){ Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0); @@ -2920,8 +2918,6 @@ static int DbObjCmdAdaptor( */ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *p; - void *pKey = 0; - int nKey = 0; const char *zArg; char *zErrMsg; int i; @@ -2929,6 +2925,10 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ const char *zVfs = 0; int flags; Tcl_DString translatedFilename; +#ifdef SQLITE_HAS_CODEC + void *pKey = 0; + int nKey = 0; +#endif /* In normal use, each TCL interpreter runs in a single thread. So ** by default, we can turn of mutexing on SQLite database connections. @@ -2960,7 +2960,9 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ for(i=3; i+1pIndex; pIdx; pIdx=pIdx->pNext, i++){ + assert( aRegIdx ); if( openAll || aRegIdx[i]>0 ){ KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur+i+1, pIdx->tnum, iDb, @@ -529,6 +530,7 @@ void sqlite3Update( /* Close all tables */ for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ + assert( aRegIdx ); if( openAll || aRegIdx[i]>0 ){ sqlite3VdbeAddOp2(v, OP_Close, iCur+i+1, 0); } diff --git a/src/vdbe.c b/src/vdbe.c index 4f7fd6bbeb..91e25bafc1 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2178,7 +2178,7 @@ case OP_Column: { zRec = (char*)pC->aRow; }else if( pC->isIndex ){ assert( sqlite3BtreeCursorIsValid(pCrsr) ); - rc = sqlite3BtreeKeySize(pCrsr, &payloadSize64); + VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &payloadSize64); assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */ /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the ** payload size, so it is impossible for payloadSize64 to be @@ -2187,7 +2187,7 @@ case OP_Column: { payloadSize = (u32)payloadSize64; }else{ assert( sqlite3BtreeCursorIsValid(pCrsr) ); - rc = sqlite3BtreeDataSize(pCrsr, &payloadSize); + VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &payloadSize); assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ } }else if( ALWAYS(pC->pseudoTableReg>0) ){ @@ -4191,14 +4191,14 @@ case OP_RowData: { if( pC->isIndex ){ assert( !pC->isTable ); - rc = sqlite3BtreeKeySize(pCrsr, &n64); + VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &n64); assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */ if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){ goto too_big; } n = (u32)n64; }else{ - rc = sqlite3BtreeDataSize(pCrsr, &n); + VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &n); assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ goto too_big; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 9de4fe04f2..15b28ab90a 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -781,30 +781,29 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ ** makes the code easier to read during debugging. None of this happens ** in a production build. */ -void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){ - va_list ap; - if( !p ) return; +static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){ assert( p->nOp>0 || p->aOp==0 ); assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); if( p->nOp ){ - char **pz = &p->aOp[p->nOp-1].zComment; + assert( p->aOp ); + sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment); + p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap); + } +} +void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){ + va_list ap; + if( p ){ va_start(ap, zFormat); - sqlite3DbFree(p->db, *pz); - *pz = sqlite3VMPrintf(p->db, zFormat, ap); + vdbeVComment(p, zFormat, ap); va_end(ap); } } void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){ va_list ap; - if( !p ) return; - sqlite3VdbeAddOp0(p, OP_Noop); - assert( p->nOp>0 || p->aOp==0 ); - assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); - if( p->nOp ){ - char **pz = &p->aOp[p->nOp-1].zComment; + if( p ){ + sqlite3VdbeAddOp0(p, OP_Noop); va_start(ap, zFormat); - sqlite3DbFree(p->db, *pz); - *pz = sqlite3VMPrintf(p->db, zFormat, ap); + vdbeVComment(p, zFormat, ap); va_end(ap); } } @@ -3064,7 +3063,7 @@ int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){ ** this code can safely assume that nCellKey is 32-bits */ assert( sqlite3BtreeCursorIsValid(pCur) ); - rc = sqlite3BtreeKeySize(pCur, &nCellKey); + VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey); assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey ); @@ -3139,7 +3138,7 @@ int sqlite3VdbeIdxKeyCompare( Mem m; assert( sqlite3BtreeCursorIsValid(pCur) ); - rc = sqlite3BtreeKeySize(pCur, &nCellKey); + VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey); assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ /* nCellKey will always be between 0 and 0xffffffff because of the say ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ diff --git a/src/wal.c b/src/wal.c index 3bc42ffb17..f2b3187147 100644 --- a/src/wal.c +++ b/src/wal.c @@ -2343,7 +2343,7 @@ int sqlite3WalRead( int sz; i64 iOffset; sz = pWal->hdr.szPage; - sz = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); + sz = (sz&0xfe00) + ((sz&0x0001)<<16); testcase( sz<=32768 ); testcase( sz>=65536 ); iOffset = walFrameOffset(iRead, sz) + WAL_FRAME_HDRSIZE; diff --git a/src/where.c b/src/where.c index 3c0244e68d..f962d6f354 100644 --- a/src/where.c +++ b/src/where.c @@ -4896,7 +4896,8 @@ WhereInfo *sqlite3WhereBegin( WHERETRACE(("*** Optimizer selects table %d for loop %d" " with cost=%g and nRow=%g\n", bestJ, pLevel-pWInfo->a, bestPlan.rCost, bestPlan.plan.nRow)); - if( (bestPlan.plan.wsFlags & WHERE_ORDERBY)!=0 ){ + /* The ALWAYS() that follows was added to hush up clang scan-build */ + if( (bestPlan.plan.wsFlags & WHERE_ORDERBY)!=0 && ALWAYS(ppOrderBy) ){ *ppOrderBy = 0; } if( (bestPlan.plan.wsFlags & WHERE_DISTINCT)!=0 ){ From 086e4913b5e0a959c50ee9ab135a22b7a23f479f Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 14 Oct 2011 22:57:03 +0000 Subject: [PATCH 31/51] Fix a few minor and harmless clang warnings in FTS3 and RTREE. FossilOrigin-Name: b3324f6cc27c3bfb32b12eacace2fc731c2dd644 --- ext/fts3/fts3.c | 11 +++++++---- ext/fts3/fts3_expr.c | 8 ++++++-- ext/rtree/rtree.c | 7 +++++-- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index b3780b8349..e66e8fe58b 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -438,7 +438,7 @@ static void fts3GetReverseVarint( sqlite3_int64 *pVal ){ sqlite3_int64 iVal; - char *p = *pp; + char *p; /* Pointer p now points at the first byte past the varint we are ** interested in. So, unless the doclist is corrupt, the 0x80 bit is @@ -839,7 +839,7 @@ static char *fts3WriteExprList(Fts3Table *p, const char *zFunc, int *pRc){ ** This function is used when parsing the "prefix=" FTS4 parameter. */ static int fts3GobbleInt(const char **pp, int *pnOut){ - const char *p = *pp; /* Iterator pointer */ + const char *p; /* Iterator pointer */ int nInt = 0; /* Output value */ for(p=*pp; p[0]>='0' && p[0]<='9'; p++){ @@ -1429,6 +1429,7 @@ static int fts3ScanInteriorNode( } zBuffer = zNew; } + assert( zBuffer ); memcpy(&zBuffer[nPrefix], zCsr, nSuffix); nBuffer = nPrefix + nSuffix; zCsr += nSuffix; @@ -2865,7 +2866,7 @@ static int fts3RollbackMethod(sqlite3_vtab *pVtab){ */ static void fts3ReversePoslist(char *pStart, char **ppPoslist){ char *p = &(*ppPoslist)[-2]; - char c; + char c = 0; while( p>pStart && (c=*p--)==0 ); while( p>pStart && (*p & 0x80) | c ){ @@ -4335,7 +4336,9 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){ aPoslist = pExpr->pRight->pPhrase->doclist.pList; nToken = pExpr->pRight->pPhrase->nToken; for(p=pExpr->pLeft; p && res; p=p->pLeft){ - int nNear = p->pParent->nNear; + int nNear; + assert( p->pParent && p->pParent->pLeft==p ); + nNear = p->pParent->nNear; Fts3Phrase *pPhrase = ( p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase ); diff --git a/ext/fts3/fts3_expr.c b/ext/fts3/fts3_expr.c index 7eb2962d44..6b2b414aab 100644 --- a/ext/fts3/fts3_expr.c +++ b/ext/fts3/fts3_expr.c @@ -302,8 +302,12 @@ static int getNextString( p->pPhrase->nToken = nToken; zBuf = (char *)&p->pPhrase->aToken[nToken]; - memcpy(zBuf, zTemp, nTemp); - sqlite3_free(zTemp); + if( zTemp ){ + memcpy(zBuf, zTemp, nTemp); + sqlite3_free(zTemp); + }else{ + assert( nTemp==0 ); + } for(jj=0; jjpPhrase->nToken; jj++){ p->pPhrase->aToken[jj].z = zBuf; diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 2375069e3e..55385d7fd7 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1268,7 +1268,8 @@ static int rtreeFilter( rc = SQLITE_NOMEM; }else{ memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc); - assert( (idxStr==0 && argc==0) || (int)strlen(idxStr)==argc*2 ); + assert( (idxStr==0 && argc==0) + || (idxStr && (int)strlen(idxStr)==argc*2) ); for(ii=0; iiaConstraint[ii]; p->op = idxStr[ii*2]; @@ -1569,7 +1570,9 @@ static int ChooseLeaf( float fMinGrowth = 0.0; float fMinArea = 0.0; +#if VARIANT_RSTARTREE_CHOOSESUBTREE float fMinOverlap = 0.0; +#endif int nCell = NCELL(pNode); RtreeCell cell; @@ -1616,6 +1619,7 @@ static int ChooseLeaf( || (overlap==fMinOverlap && growth==fMinGrowth && area Date: Sat, 15 Oct 2011 00:16:30 +0000 Subject: [PATCH 32/51] Added the tool/warnings-clang.sh script. Changes so that there are no warnings with either gcc or clang even including FTS4 and RTREE and both with and without SQLITE_THREADSAFE=0. FossilOrigin-Name: 39408702a989f907261c298bf0947f3e68bd10fe --- ext/fts3/fts3.c | 3 ++- ext/rtree/rtree.c | 4 +++- manifest | 33 +++++++++++++++++---------------- manifest.uuid | 2 +- src/backup.c | 4 ++-- src/btree.c | 12 +++++++----- src/lempar.c | 5 ++++- src/main.c | 4 ++-- src/mutex.h | 7 +++++-- src/os.c | 4 ++-- src/os_unix.c | 2 +- src/where.c | 1 - test/tkt3793.test | 18 ++++++++++-------- tool/warnings-clang.sh | 13 +++++++++++++ 14 files changed, 69 insertions(+), 43 deletions(-) create mode 100644 tool/warnings-clang.sh diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index e66e8fe58b..c2047437f0 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4337,9 +4337,10 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){ nToken = pExpr->pRight->pPhrase->nToken; for(p=pExpr->pLeft; p && res; p=p->pLeft){ int nNear; + Fts3Phrase *pPhrase; assert( p->pParent && p->pParent->pLeft==p ); nNear = p->pParent->nNear; - Fts3Phrase *pPhrase = ( + pPhrase = ( p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase ); res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 55385d7fd7..884482ea66 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1572,6 +1572,7 @@ static int ChooseLeaf( float fMinArea = 0.0; #if VARIANT_RSTARTREE_CHOOSESUBTREE float fMinOverlap = 0.0; + float overlap; #endif int nCell = NCELL(pNode); @@ -1604,7 +1605,6 @@ static int ChooseLeaf( int bBest = 0; float growth; float area; - float overlap = 0.0; nodeGetCell(pRtree, pNode, iCell, &cell); growth = cellGrowth(pRtree, &cell, pCell); area = cellArea(pRtree, &cell); @@ -1612,6 +1612,8 @@ static int ChooseLeaf( #if VARIANT_RSTARTREE_CHOOSESUBTREE if( ii==(pRtree->iDepth-1) ){ overlap = cellOverlapEnlargement(pRtree,&cell,pCell,aCell,nCell,iCell); + }else{ + overlap = 0.0; } if( (iCell==0) || (overlappSrcDb->mutex); sqlite3BtreeEnter(p->pSrc); - mutex = p->pSrcDb->mutex; + MUTEX_LOGIC( mutex = p->pSrcDb->mutex; ) if( p->pDestDb ){ sqlite3_mutex_enter(p->pDestDb->mutex); } diff --git a/src/btree.c b/src/btree.c index 6c724d0fa3..d64e172f74 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1766,17 +1766,19 @@ int sqlite3BtreeOpen( if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){ int nFullPathname = pVfs->mxPathname+1; char *zFullPathname = sqlite3Malloc(nFullPathname); - sqlite3_mutex *mutexShared; + MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) p->sharable = 1; if( !zFullPathname ){ sqlite3_free(p); return SQLITE_NOMEM; } sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname); +#if SQLITE_THREADSAFE mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN); sqlite3_mutex_enter(mutexOpen); mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex_enter(mutexShared); +#endif for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){ assert( pBt->nRef>0 ); if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager)) @@ -1882,9 +1884,9 @@ int sqlite3BtreeOpen( /* Add the new BtShared object to the linked list sharable BtShareds. */ if( p->sharable ){ - sqlite3_mutex *mutexShared; + MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) pBt->nRef = 1; - mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);) if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){ pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST); if( pBt->mutex==0 ){ @@ -1966,12 +1968,12 @@ btree_open_out: */ static int removeFromSharingList(BtShared *pBt){ #ifndef SQLITE_OMIT_SHARED_CACHE - sqlite3_mutex *pMaster; + MUTEX_LOGIC( sqlite3_mutex *pMaster; ) BtShared *pList; int removed = 0; assert( sqlite3_mutex_notheld(pBt->mutex) ); - pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) sqlite3_mutex_enter(pMaster); pBt->nRef--; if( pBt->nRef<=0 ){ diff --git a/src/lempar.c b/src/lempar.c index fb52490e4c..cb6025e87b 100644 --- a/src/lempar.c +++ b/src/lempar.c @@ -716,7 +716,9 @@ void Parse( ){ YYMINORTYPE yyminorunion; int yyact; /* The parser action. */ +#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ +#endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif @@ -739,7 +741,9 @@ void Parse( yypParser->yystack[0].major = 0; } yyminorunion.yy0 = yyminor; +#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); +#endif ParseARG_STORE; #ifndef NDEBUG @@ -751,7 +755,6 @@ void Parse( do{ yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyactyyerrcnt--; yymajor = YYNOCODE; diff --git a/src/main.c b/src/main.c index b18217d34a..42bbba5d01 100644 --- a/src/main.c +++ b/src/main.c @@ -106,7 +106,7 @@ char *sqlite3_temp_directory = 0; ** without blocking. */ int sqlite3_initialize(void){ - sqlite3_mutex *pMaster; /* The main static mutex */ + MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ int rc; /* Result code */ #ifdef SQLITE_OMIT_WSD @@ -140,7 +140,7 @@ int sqlite3_initialize(void){ ** malloc subsystem - this implies that the allocation of a static ** mutex must not require support from the malloc subsystem. */ - pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) sqlite3_mutex_enter(pMaster); sqlite3GlobalConfig.isMutexInit = 1; if( !sqlite3GlobalConfig.isMallocInit ){ diff --git a/src/mutex.h b/src/mutex.h index c24f3da4c6..b0e552c7c4 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -60,12 +60,15 @@ */ #define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) #define sqlite3_mutex_free(X) -#define sqlite3_mutex_enter(X) +#define sqlite3_mutex_enter(X) #define sqlite3_mutex_try(X) SQLITE_OK -#define sqlite3_mutex_leave(X) +#define sqlite3_mutex_leave(X) #define sqlite3_mutex_held(X) ((void)(X),1) #define sqlite3_mutex_notheld(X) ((void)(X),1) #define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8) #define sqlite3MutexInit() SQLITE_OK #define sqlite3MutexEnd() +#define MUTEX_LOGIC(X) +#else +#define MUTEX_LOGIC(X) X #endif /* defined(SQLITE_MUTEX_OMIT) */ diff --git a/src/os.c b/src/os.c index 9ca72fa31f..0b13c86e9e 100644 --- a/src/os.c +++ b/src/os.c @@ -297,12 +297,12 @@ static void vfsUnlink(sqlite3_vfs *pVfs){ ** true. */ int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ - sqlite3_mutex *mutex = 0; + MUTEX_LOGIC(sqlite3_mutex *mutex;) #ifndef SQLITE_OMIT_AUTOINIT int rc = sqlite3_initialize(); if( rc ) return rc; #endif - mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) sqlite3_mutex_enter(mutex); vfsUnlink(pVfs); if( makeDflt || vfsList==0 ){ diff --git a/src/os_unix.c b/src/os_unix.c index 0236bf7ccb..2e43eabf17 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -528,7 +528,7 @@ static int unixMutexHeld(void) { #endif -#ifdef SQLITE_DEBUG +#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) /* ** Helper function for printing out trace information from debugging ** binaries. This returns the string represetation of the supplied diff --git a/src/where.c b/src/where.c index f962d6f354..4ea2b3a951 100644 --- a/src/where.c +++ b/src/where.c @@ -2476,7 +2476,6 @@ static int whereKeyStats( if( pVal==0 ) return SQLITE_ERROR; n = pIdx->aiRowEst[0]; aSample = pIdx->aSample; - i = 0; eType = sqlite3_value_type(pVal); if( eType==SQLITE_INTEGER ){ diff --git a/test/tkt3793.test b/test/tkt3793.test index 2b5f2bab39..074aab2df0 100644 --- a/test/tkt3793.test +++ b/test/tkt3793.test @@ -100,16 +100,18 @@ set x 0 # Note: Before the bug was fixed, if [db2] was opened with the "-fullmutex 1" # option, then this test case would cause an assert() to fail. # -set ::busyconnection db1 -db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} { - do_test tkt3793-2.[incr x] { set ::busyconnection } db1 - set ::busyconnection db2 - - db2 eval { SELECT count(*) FROM t2 } - do_test tkt3793-2.[incr x] { set ::busyconnection } db2 +ifcapable threadsafe { set ::busyconnection db1 + db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} { + do_test tkt3793-2.[incr x] { set ::busyconnection } db1 + set ::busyconnection db2 + + db2 eval { SELECT count(*) FROM t2 } + do_test tkt3793-2.[incr x] { set ::busyconnection } db2 + set ::busyconnection db1 + } } - + do_test tkt3793-3 { db1 close db2 close diff --git a/tool/warnings-clang.sh b/tool/warnings-clang.sh new file mode 100644 index 0000000000..51084f31a6 --- /dev/null +++ b/tool/warnings-clang.sh @@ -0,0 +1,13 @@ +#/bin/sh +# +# Run this script in a directory with a working makefile to check for +# compiler warnings in SQLite. +# +rm -f sqlite3.c +make sqlite3.c +echo '************* FTS4 and RTREE ****************' +scan-build gcc -c -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ + -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:' +echo '********** ENABLE_STAT3. THREADSAFE=0 *******' +scan-build gcc -c -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \ + -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:' From 2458a2e742b9cd1c732485656e96364e05130316 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Oct 2011 12:14:26 +0000 Subject: [PATCH 33/51] Performance improvement for ascii to floating-point conversions with very large exponents. FossilOrigin-Name: 59bb999c8ba5e4ee7a4e388fc724b8606136d60c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index abe3a3a7d3..eb75006444 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Added\sthe\stool/warnings-clang.sh\sscript.\s\sChanges\sso\sthat\sthere\sare\sno\nwarnings\swith\seither\sgcc\sor\sclang\seven\sincluding\sFTS4\sand\sRTREE\sand\nboth\swith\sand\swithout\sSQLITE_THREADSAFE=0. -D 2011-10-15T00:16:30.056 +C Performance\simprovement\sfor\sascii\sto\sfloating-point\sconversions\swith\svery\nlarge\sexponents. +D 2011-10-17T12:14:26.646 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -236,7 +236,7 @@ F src/tokenize.c c819d9f72168a035d545a5bdafe9b085b20df705 F src/trigger.c 1cfb80e2290ef66ea89cb4e821caae65a02c0d56 F src/update.c 25e046a8f69d5e557aabde2000487b8545509d8d F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 -F src/util.c 06302ffd2b80408d4f6c7af71f7090e0cf8d8ff7 +F src/util.c a982d7ee3c4aca643b01abc6f742f61fea1e4fa3 F src/vacuum.c 0c0ba2242355c6048d65e2b333abe0f7c06348fa F src/vdbe.c 75e626a6e6aefbd35b25ccab8bff533a65354638 F src/vdbe.h f0725ee997db869ecae5bb70a71612aabeca7755 @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P b3324f6cc27c3bfb32b12eacace2fc731c2dd644 -R fdfdc42f8d308f4430129946a791fabf +P 39408702a989f907261c298bf0947f3e68bd10fe +R 204579a8fff7f7f01b8c865c0b12cfa2 U drh -Z b3da471414a86656d736be9bf8ce9b6c +Z 09bec3cab67bc63e509e3048fd3a5001 diff --git a/manifest.uuid b/manifest.uuid index ebd5525f92..422a541e4d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -39408702a989f907261c298bf0947f3e68bd10fe \ No newline at end of file +59bb999c8ba5e4ee7a4e388fc724b8606136d60c \ No newline at end of file diff --git a/src/util.c b/src/util.c index 67e43b4ba8..f4a6c7d008 100644 --- a/src/util.c +++ b/src/util.c @@ -382,6 +382,12 @@ do_atof_calc: result = s * scale; result *= 1.0e+308; } + }else if( e>=342 ){ + if( esign<0 ){ + result = 0.0*s; + }else{ + result = 1e308*1e308*s; /* Infinity */ + } }else{ /* 1.0e+22 is the largest power of 10 than can be ** represented exactly. */ From 57db4a750951933a45fc17e185e313526017ae9c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Oct 2011 20:41:46 +0000 Subject: [PATCH 34/51] Avoid 32-bit integer overflow when evaluating the exponent of a floating point value during ascii to binary conversion. FossilOrigin-Name: 4becc47eb4d48686faca4f61e93e5f379b227fcc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/util.c | 2 +- test/nan.test | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index eb75006444..106fd60640 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\simprovement\sfor\sascii\sto\sfloating-point\sconversions\swith\svery\nlarge\sexponents. -D 2011-10-17T12:14:26.646 +C Avoid\s32-bit\sinteger\soverflow\swhen\sevaluating\sthe\sexponent\sof\sa\sfloating\spoint\nvalue\sduring\sascii\sto\sbinary\sconversion. +D 2011-10-17T20:41:46.844 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -236,7 +236,7 @@ F src/tokenize.c c819d9f72168a035d545a5bdafe9b085b20df705 F src/trigger.c 1cfb80e2290ef66ea89cb4e821caae65a02c0d56 F src/update.c 25e046a8f69d5e557aabde2000487b8545509d8d F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 -F src/util.c a982d7ee3c4aca643b01abc6f742f61fea1e4fa3 +F src/util.c df83983bd57057df4951516880066b42b7055269 F src/vacuum.c 0c0ba2242355c6048d65e2b333abe0f7c06348fa F src/vdbe.c 75e626a6e6aefbd35b25ccab8bff533a65354638 F src/vdbe.h f0725ee997db869ecae5bb70a71612aabeca7755 @@ -604,7 +604,7 @@ F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054 F test/multiplex.test 9df8bf738b3b97c718fceb3fadb30900ba494418 F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 -F test/nan.test dc212a22b36109fd1ae37154292444ef249c5ec2 +F test/nan.test e9648b9d007c7045242af35e11a984d4b169443a F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf F test/notify2.test 9503e51b9a272a5405c205ad61b7623d5a9ca489 F test/notify3.test a86259abbfb923aa27d30f0fc038c88e5251488a @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 39408702a989f907261c298bf0947f3e68bd10fe -R 204579a8fff7f7f01b8c865c0b12cfa2 +P 59bb999c8ba5e4ee7a4e388fc724b8606136d60c +R 6b0f73ca59012aaddad5825c810302fc U drh -Z 09bec3cab67bc63e509e3048fd3a5001 +Z c15000514b2d7c59bec3a3398b3cbf62 diff --git a/manifest.uuid b/manifest.uuid index 422a541e4d..fda4caea88 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -59bb999c8ba5e4ee7a4e388fc724b8606136d60c \ No newline at end of file +4becc47eb4d48686faca4f61e93e5f379b227fcc \ No newline at end of file diff --git a/src/util.c b/src/util.c index f4a6c7d008..3356417e0c 100644 --- a/src/util.c +++ b/src/util.c @@ -331,7 +331,7 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ } /* copy digits to exponent */ while( z Date: Mon, 17 Oct 2011 23:15:31 +0000 Subject: [PATCH 35/51] Change the OP_JournalMode implementation so that it works even if a substitute sqlite3PagerFilename() that might return NULL is used. FossilOrigin-Name: 491ff5fb2504173d6905e38b8ea35737338aaa84 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 106fd60640..05041e4872 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\s32-bit\sinteger\soverflow\swhen\sevaluating\sthe\sexponent\sof\sa\sfloating\spoint\nvalue\sduring\sascii\sto\sbinary\sconversion. -D 2011-10-17T20:41:46.844 +C Change\sthe\sOP_JournalMode\simplementation\sso\sthat\sit\sworks\seven\sif\sa\nsubstitute\ssqlite3PagerFilename()\sthat\smight\sreturn\sNULL\sis\sused. +D 2011-10-17T23:15:31.767 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -238,7 +238,7 @@ F src/update.c 25e046a8f69d5e557aabde2000487b8545509d8d F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 F src/util.c df83983bd57057df4951516880066b42b7055269 F src/vacuum.c 0c0ba2242355c6048d65e2b333abe0f7c06348fa -F src/vdbe.c 75e626a6e6aefbd35b25ccab8bff533a65354638 +F src/vdbe.c 054e1d52587718605ac482e45cd93e0eae673298 F src/vdbe.h f0725ee997db869ecae5bb70a71612aabeca7755 F src/vdbeInt.h 693d6ac6810298fc6b4c503cfbe3f99a240f40af F src/vdbeapi.c 11dc47987abacb76ad016dcf5abc0dc422482a98 @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 59bb999c8ba5e4ee7a4e388fc724b8606136d60c -R 6b0f73ca59012aaddad5825c810302fc +P 4becc47eb4d48686faca4f61e93e5f379b227fcc +R 39fd2a2cf30de71b2b3450062d311602 U drh -Z c15000514b2d7c59bec3a3398b3cbf62 +Z 7b2456baf32ad39dc2142b8f75916654 diff --git a/manifest.uuid b/manifest.uuid index fda4caea88..5d7b80b5e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4becc47eb4d48686faca4f61e93e5f379b227fcc \ No newline at end of file +491ff5fb2504173d6905e38b8ea35737338aaa84 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 91e25bafc1..7dcdf4621b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -5467,7 +5467,7 @@ case OP_JournalMode: { /* out2-prerelease */ ** in temporary storage or if the VFS does not support shared memory */ if( eNew==PAGER_JOURNALMODE_WAL - && (zFilename[0]==0 /* Temp file */ + && (sqlite3Strlen30(zFilename)==0 /* Temp file */ || !sqlite3PagerWalSupported(pPager)) /* No shared-memory support */ ){ eNew = eOld; From 42495cd46fb4c41b29306e5f61ae259ab3758225 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 18 Oct 2011 12:44:04 +0000 Subject: [PATCH 36/51] Fix a floating-point exception that can occur when an FTS4 query contains a large number of tokens connected by AND or NEAR operators. FossilOrigin-Name: 3126754c72351c724be29d75a194bfc3e7b67205 --- ext/fts3/fts3.c | 6 +++++- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/fts3defer.test | 28 ++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index c2047437f0..754f3b5cb7 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3966,7 +3966,11 @@ static int fts3EvalSelectDeferred( fts3SegReaderCursorFree(pToken->pSegcsr); pToken->pSegcsr = 0; }else{ - nLoad4 = nLoad4*4; + /* Set nLoad4 to the value of (4^nOther) for the next iteration of the + ** for-loop. Except, limit the value to 2^24 to prevent it from + ** overflowing the 32-bit integer it is stored in. */ + if( ii<12 ) nLoad4 = nLoad4*4; + if( ii==0 || pTC->pPhrase->nToken>1 ){ /* Either this is the cheapest token in the entire query, or it is ** part of a multi-token phrase. Either way, the entire doclist will diff --git a/manifest b/manifest index 05041e4872..ecd1811831 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sOP_JournalMode\simplementation\sso\sthat\sit\sworks\seven\sif\sa\nsubstitute\ssqlite3PagerFilename()\sthat\smight\sreturn\sNULL\sis\sused. -D 2011-10-17T23:15:31.767 +C Fix\sa\sfloating-point\sexception\sthat\scan\soccur\swhen\san\sFTS4\squery\scontains\sa\slarge\snumber\sof\stokens\sconnected\sby\sAND\sor\sNEAR\soperators. +D 2011-10-18T12:44:04.580 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c d02bb1b3212f8ec9b98433630233d35278b43db2 +F ext/fts3/fts3.c 19f36945148cfd4ee3655b5fac0879ba4e0f3117 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 59c5a9475fed5d76c70a4763103b3c8e60424a68 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -471,7 +471,7 @@ F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 -F test/fts3defer.test 7c8a38d5f617d7b52ae1c43ed73c536e7e895a35 +F test/fts3defer.test ffd4e07f79a09660d4b3e2613b041ab9b6100d91 F test/fts3defer2.test 35867d33ba6db03f6c73bd6f5fc333ae14f68c81 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4becc47eb4d48686faca4f61e93e5f379b227fcc -R 39fd2a2cf30de71b2b3450062d311602 -U drh -Z 7b2456baf32ad39dc2142b8f75916654 +P 491ff5fb2504173d6905e38b8ea35737338aaa84 +R 58f061e71ad84767d73477085e2bfcf6 +U dan +Z b0882f47410096d3d98223e9ef02aa47 diff --git a/manifest.uuid b/manifest.uuid index 5d7b80b5e6..40229f72ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -491ff5fb2504173d6905e38b8ea35737338aaa84 \ No newline at end of file +3126754c72351c724be29d75a194bfc3e7b67205 \ No newline at end of file diff --git a/test/fts3defer.test b/test/fts3defer.test index 4bc0b0a7c3..ab30bbe2c3 100644 --- a/test/fts3defer.test +++ b/test/fts3defer.test @@ -449,5 +449,33 @@ do_execsql_test 3.3 { SELECT count(*) FROM x1 WHERE x1 MATCH '"d e f"' } {16} +# At one point the following was causing a floating-point exception. +# +do_execsql_test 4.1 { + CREATE VIRTUAL TABLE x2 USING FTS4(x); + BEGIN; + INSERT INTO x2 VALUES('m m m m m m m m m m m m m m m m m m m m m m m m m m'); + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 VALUES('a b c d e f g h i j k l m n o p q r s t u v w x y m'); + COMMIT; +} +do_execsql_test 4.2 { + SELECT * FROM x2 WHERE x2 MATCH 'a b c d e f g h i j k l m n o p q r s'; +} {{a b c d e f g h i j k l m n o p q r s t u v w x y m}} + finish_test From a986d33fd3e630ac8b16a5627761d242cb76d3be Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 18 Oct 2011 12:49:59 +0000 Subject: [PATCH 37/51] Cherrypick patch [3126754c72] from the trunk into the content= branch. FossilOrigin-Name: f9b5b217088a6aeb25eba184ab92d1a842a680a6 --- ext/fts3/fts3.c | 6 +++++- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts3defer.test | 28 ++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 6fa06907bf..951d131667 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4144,7 +4144,11 @@ static int fts3EvalSelectDeferred( fts3SegReaderCursorFree(pToken->pSegcsr); pToken->pSegcsr = 0; }else{ - nLoad4 = nLoad4*4; + /* Set nLoad4 to the value of (4^nOther) for the next iteration of the + ** for-loop. Except, limit the value to 2^24 to prevent it from + ** overflowing the 32-bit integer it is stored in. */ + if( ii<12 ) nLoad4 = nLoad4*4; + if( ii==0 || pTC->pPhrase->nToken>1 ){ /* Either this is the cheapest token in the entire query, or it is ** part of a multi-token phrase. Either way, the entire doclist will diff --git a/manifest b/manifest index 0c36a83a5c..78cf5c490d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sFTS4\sso\sthat\sif\sboth\sthe\scontent=xxx\soption\sand\scolumn\snames\sare\sspecified,\sthe\svirtual\stable\sassumes\sthat\sthe\snamed\scolumns\scorrespond\sto\scolumns\sof\stable\sxxx. -D 2011-10-05T15:11:30.760 +C Cherrypick\spatch\s[3126754c72]\sfrom\sthe\strunk\sinto\sthe\scontent=\sbranch. +D 2011-10-18T12:49:59.086 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c f2ed0ae669534e0c9c8ba95b60b6c137544e7e49 +F ext/fts3/fts3.c 15e1725f3dc7c0028676831d82b376e93b87527e F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 06f442ce096e6254432a6b16a56b6fe7b24bd372 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -469,7 +469,7 @@ F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 -F test/fts3defer.test 7c8a38d5f617d7b52ae1c43ed73c536e7e895a35 +F test/fts3defer.test ffd4e07f79a09660d4b3e2613b041ab9b6100d91 F test/fts3defer2.test 35867d33ba6db03f6c73bd6f5fc333ae14f68c81 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c @@ -966,7 +966,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P c6ba81fcad32192674bd510e607f787adc1f7038 -R 0217fe49810be9d8f9417ba3c648ab3e +P 289ee43179369fce2fde50870d72c445e184e896 +R 50f1458a2cdbee488c53894b18c71839 U dan -Z 1eb4f36513f7844867f45162778888e7 +Z e075e042ac91a648318521977fb348f1 diff --git a/manifest.uuid b/manifest.uuid index b8efcec3d4..f94940003d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -289ee43179369fce2fde50870d72c445e184e896 \ No newline at end of file +f9b5b217088a6aeb25eba184ab92d1a842a680a6 \ No newline at end of file diff --git a/test/fts3defer.test b/test/fts3defer.test index 4bc0b0a7c3..ab30bbe2c3 100644 --- a/test/fts3defer.test +++ b/test/fts3defer.test @@ -449,5 +449,33 @@ do_execsql_test 3.3 { SELECT count(*) FROM x1 WHERE x1 MATCH '"d e f"' } {16} +# At one point the following was causing a floating-point exception. +# +do_execsql_test 4.1 { + CREATE VIRTUAL TABLE x2 USING FTS4(x); + BEGIN; + INSERT INTO x2 VALUES('m m m m m m m m m m m m m m m m m m m m m m m m m m'); + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 VALUES('a b c d e f g h i j k l m n o p q r s t u v w x y m'); + COMMIT; +} +do_execsql_test 4.2 { + SELECT * FROM x2 WHERE x2 MATCH 'a b c d e f g h i j k l m n o p q r s'; +} {{a b c d e f g h i j k l m n o p q r s t u v w x y m}} + finish_test From e802c5da0101e9a3b4ad5e8925f47e636f8a9f3b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 18 Oct 2011 18:10:40 +0000 Subject: [PATCH 38/51] Improved handling of USING and NATURAL JOIN in 3-way and higher joins. Ticket [3338b3fa19ac4ab] FossilOrigin-Name: 551ce407bd77149865423511bd52eba2f404161a --- manifest | 16 +++++----- manifest.uuid | 2 +- src/resolve.c | 47 +++++++++++++++------------ test/where3.test | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index ecd1811831..ff182816e5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfloating-point\sexception\sthat\scan\soccur\swhen\san\sFTS4\squery\scontains\sa\slarge\snumber\sof\stokens\sconnected\sby\sAND\sor\sNEAR\soperators. -D 2011-10-18T12:44:04.580 +C Improved\shandling\sof\sUSING\sand\sNATURAL\sJOIN\sin\s3-way\sand\shigher\sjoins.\nTicket\s[3338b3fa19ac4ab] +D 2011-10-18T18:10:40.151 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -177,7 +177,7 @@ F src/pragma.c da8ef96b3eec351e81e0061c39810e548bcc96d7 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 F src/printf.c 03104cbff6959ff45df69dc9060ba6212f60a869 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 -F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4 +F src/resolve.c 365ab1c870e38596d6869e76fb544fe6e4ffc809 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 80f3ac44a8514b1d107b80f5df4a424ae059d2b6 F src/shell.c f0ab793261ab045a0b8c47fa2707e8a894d2898f @@ -913,7 +913,7 @@ F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a F test/walthread.test a2ed5270eb695284d4ad27d252517bdc3317ee2a F test/where.test de337a3fe0a459ec7c93db16a519657a90552330 F test/where2.test 43d4becaf5a5df854e6c21d624a1cb84c6904554 -F test/where3.test 8e1175c7ef710c70502858fc4fb08d784b3620b9 +F test/where3.test 667e75642102c97a00bf9b23d3cb267db321d006 F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 491ff5fb2504173d6905e38b8ea35737338aaa84 -R 58f061e71ad84767d73477085e2bfcf6 -U dan -Z b0882f47410096d3d98223e9ef02aa47 +P 3126754c72351c724be29d75a194bfc3e7b67205 +R ed8534091276e292d87550ffda27999e +U drh +Z a262b8d3562a7e10f8c3ec0f3139747f diff --git a/manifest.uuid b/manifest.uuid index 40229f72ff..bbfaa20303 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3126754c72351c724be29d75a194bfc3e7b67205 \ No newline at end of file +551ce407bd77149865423511bd52eba2f404161a \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index d29d2a8344..6d857f0074 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -98,6 +98,24 @@ static void resolveAlias( sqlite3DbFree(db, pDup); } + +/* +** Return TRUE if the name zCol occurs anywhere in the USING clause. +** +** Return FALSE if the USING clause is NULL or if it does not contain +** zCol. +*/ +static int nameInUsingClause(IdList *pUsing, const char *zCol){ + if( pUsing ){ + int k; + for(k=0; knId; k++){ + if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1; + } + } + return 0; +} + + /* ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up ** that name in the set of source tables in pSrcList and make the pExpr @@ -189,7 +207,14 @@ static int lookupName( } for(j=0, pCol=pTab->aCol; jnCol; j++, pCol++){ if( sqlite3StrICmp(pCol->zName, zCol)==0 ){ - IdList *pUsing; + /* If there has been exactly one prior match and this match + ** is for the right-hand table of a NATURAL JOIN or is in a + ** USING clause, then skip this match. + */ + if( cnt==1 ){ + if( pItem->jointype & JT_NATURAL ) continue; + if( nameInUsingClause(pItem->pUsing, zCol) ) continue; + } cnt++; pExpr->iTable = pItem->iCursor; pExpr->pTab = pTab; @@ -197,26 +222,6 @@ static int lookupName( pSchema = pTab->pSchema; /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j; - if( inSrc-1 ){ - if( pItem[1].jointype & JT_NATURAL ){ - /* If this match occurred in the left table of a natural join, - ** then skip the right table to avoid a duplicate match */ - pItem++; - i++; - }else if( (pUsing = pItem[1].pUsing)!=0 ){ - /* If this match occurs on a column that is in the USING clause - ** of a join, skip the search of the right table of the join - ** to avoid a duplicate match there. */ - int k; - for(k=0; knId; k++){ - if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ){ - pItem++; - i++; - break; - } - } - } - } break; } } diff --git a/test/where3.test b/test/where3.test index ab75fdec19..e08f9051e2 100644 --- a/test/where3.test +++ b/test/where3.test @@ -342,4 +342,87 @@ do_execsql_test where3-5.3 { 0 0 0 {USE TEMP B-TREE FOR ORDER BY} } +# Name resolution with NATURAL JOIN and USING +# +do_test where3-6.setup { + db eval { + CREATE TABLE t6w(a, w); + INSERT INTO t6w VALUES(1, 'w-one'); + INSERT INTO t6w VALUES(2, 'w-two'); + INSERT INTO t6w VALUES(9, 'w-nine'); + CREATE TABLE t6x(a, x); + INSERT INTO t6x VALUES(1, 'x-one'); + INSERT INTO t6x VALUES(3, 'x-three'); + INSERT INTO t6x VALUES(9, 'x-nine'); + CREATE TABLE t6y(a, y); + INSERT INTO t6y VALUES(1, 'y-one'); + INSERT INTO t6y VALUES(4, 'y-four'); + INSERT INTO t6y VALUES(9, 'y-nine'); + CREATE TABLE t6z(a, z); + INSERT INTO t6z VALUES(1, 'z-one'); + INSERT INTO t6z VALUES(5, 'z-five'); + INSERT INTO t6z VALUES(9, 'z-nine'); + } +} {} +set cnt 0 +foreach predicate { + {} + {ORDER BY a} + {ORDER BY t6w.a} + {WHERE a>0} + {WHERE t6y.a>0} + {WHERE a>0 ORDER BY a} +} { + incr cnt + do_test where3-6.$cnt.1 { + set sql "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y" + append sql " NATURAL JOIN t6z " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} + do_test where3-6.$cnt.2 { + set sql "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)" + append sql " JOIN t6z USING(a) " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} + do_test where3-6.$cnt.3 { + set sql "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)" + append sql " JOIN t6z USING(a) " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} + do_test where3-6.$cnt.4 { + set sql "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y" + append sql " JOIN t6z USING(a) " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} + do_test where3-6.$cnt.5 { + set sql "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)" + append sql " NATURAL JOIN t6z " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} + do_test where3-6.$cnt.6 { + set sql "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y" + append sql " NATURAL JOIN t6z " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} + do_test where3-6.$cnt.7 { + set sql "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)" + append sql " NATURAL JOIN t6z " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} + do_test where3-6.$cnt.8 { + set sql "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y" + append sql " JOIN t6z USING(a) " + append sql $::predicate + db eval $sql + } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine} +} + + finish_test From a2153f75c39b3da54c88b8f0a27847ddf6165969 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 18 Oct 2011 19:14:33 +0000 Subject: [PATCH 39/51] Fix an uninitialized variable in OR-clause processing. FossilOrigin-Name: 54aecd929867606d14a062b501abbfb6f5f05e37 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index ff182816e5..a0f8c053bc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\shandling\sof\sUSING\sand\sNATURAL\sJOIN\sin\s3-way\sand\shigher\sjoins.\nTicket\s[3338b3fa19ac4ab] -D 2011-10-18T18:10:40.151 +C Fix\san\suninitialized\svariable\sin\sOR-clause\sprocessing. +D 2011-10-18T19:14:33.246 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -251,7 +251,7 @@ F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582 F src/wal.c 9658df8d404b82e6b2d40fd05944463214e2d935 F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 813233b3b2059002178780d8523e2aec0c292e2c +F src/where.c b617d9e1eda592fe6bb38748307440c80da90771 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 3126754c72351c724be29d75a194bfc3e7b67205 -R ed8534091276e292d87550ffda27999e +P 551ce407bd77149865423511bd52eba2f404161a +R 95644f03839fa87055c65a00a0ad6110 U drh -Z a262b8d3562a7e10f8c3ec0f3139747f +Z e0ca001c10e0088cffb51eb7d7827b4b diff --git a/manifest.uuid b/manifest.uuid index bbfaa20303..891a2cb8e7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -551ce407bd77149865423511bd52eba2f404161a \ No newline at end of file +54aecd929867606d14a062b501abbfb6f5f05e37 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 4ea2b3a951..2fc990f4c5 100644 --- a/src/where.c +++ b/src/where.c @@ -1855,6 +1855,7 @@ static void bestOrClauseIndex( tempWC.pOuter = pWC; tempWC.op = TK_AND; tempWC.a = pOrTerm; + tempWC.wctrlFlags = 0; tempWC.nTerm = 1; bestIndex(pParse, &tempWC, pSrc, notReady, notValid, 0, &sTermCost); }else{ From 3f1ea8d114e20a377a12d5a7a88e5b4f6cc76e60 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 18 Oct 2011 19:39:41 +0000 Subject: [PATCH 40/51] If a token within an FTS query is prefixed with a '^' character, it must be the first token in a column of data to match. FossilOrigin-Name: 63ac33c860eb32ce96699f06bf83121cec2ffaca --- ext/fts3/fts3.c | 66 +++++++++++++++++++++++++++++++++++ ext/fts3/fts3Int.h | 1 + ext/fts3/fts3_expr.c | 17 +++++++-- ext/fts3/fts3_write.c | 1 + manifest | 23 ++++++------ manifest.uuid | 2 +- test/fts3defer.test | 7 ++++ test/fts3first.test | 79 ++++++++++++++++++++++++++++++++++++++++++ test/permutations.test | 1 + 9 files changed, 183 insertions(+), 14 deletions(-) create mode 100644 test/fts3first.test diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 951d131667..289adeb4df 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -2347,6 +2347,67 @@ static void fts3DoclistPhraseMerge( *pnRight = p - aOut; } +/* +** When this function is called, pList points to a doclist containing position +** data, length *pnList bytes. This removes all entries from the doclist that +** do not correspond to the first token in a column and overwrites pList +** with the result. *pnList is set to the length of the new doclist before +** returning. +** +** If bDescDoclist is true, then both the input and output are in descending +** order. Otherwise, ascending. +*/ +static void fts3DoclistFirstFilter( + int bDescDoclist, /* True if pList is a descending doclist */ + char *pList, /* Buffer containing doclist */ + int *pnList /* IN/OUT: Size of doclist */ +){ + char *p = pList; + char *pOut = pList; + char *pEnd = &pList[*pnList]; + + sqlite3_int64 iDoc; + sqlite3_int64 iPrev; + int bFirstOut = 0; + + fts3GetDeltaVarint3(&p, pEnd, 0, &iDoc); + while( p ){ + int bWritten = 0; + if( *p!=0x01 ){ + if( *p==0x02 ){ + fts3PutDeltaVarint3(&pOut, bDescDoclist, &iPrev, &bFirstOut, iDoc); + *pOut++ = 0x02; + bWritten = 1; + } + fts3ColumnlistCopy(0, &p); + } + + while( *p==0x01 ){ + sqlite3_int64 iCol; + p++; + p += sqlite3Fts3GetVarint(p, &iCol); + if( *p==0x02 ){ + if( bWritten==0 ){ + fts3PutDeltaVarint3(&pOut, bDescDoclist, &iPrev, &bFirstOut, iDoc); + bWritten = 1; + } + pOut += sqlite3Fts3PutVarint(pOut, iCol); + *pOut++ = 0x02; + } + fts3ColumnlistCopy(0, &p); + } + if( bWritten ){ + *pOut++ = 0x00; + } + + assert( *p==0x00 ); + p++; + fts3GetDeltaVarint3(&p, pEnd, bDescDoclist, &iDoc); + } + + *pnList = (pOut - pList); +} + /* ** Merge all doclists in the TermSelect.aaOutput[] array into a single @@ -3518,6 +3579,10 @@ static void fts3EvalPhraseMergeToken( ){ assert( iToken!=p->iDoclistToken ); + if( p->aToken[iToken].bFirst ){ + fts3DoclistFirstFilter(pTab->bDescIdx, pList, &nList); + } + if( pList==0 ){ sqlite3_free(p->doclist.aAll); p->doclist.aAll = 0; @@ -3721,6 +3786,7 @@ static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){ && p->nToken==1 && pFirst->pSegcsr && pFirst->pSegcsr->bLookup + && pFirst->bFirst==0 ){ /* Use the incremental approach. */ int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn); diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 552d73d764..c9b291c6cc 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -310,6 +310,7 @@ struct Fts3PhraseToken { char *z; /* Text of the token */ int n; /* Number of bytes in buffer z */ int isPrefix; /* True if token ends with a "*" character */ + int bFirst; /* True if token must appear at position 0 */ /* Variables above this point are populated when the expression is ** parsed (by code in fts3_expr.c). Below this point the variables are diff --git a/ext/fts3/fts3_expr.c b/ext/fts3/fts3_expr.c index 7eb2962d44..e6193a1392 100644 --- a/ext/fts3/fts3_expr.c +++ b/ext/fts3/fts3_expr.c @@ -180,9 +180,21 @@ static int getNextToken( pRet->pPhrase->aToken[0].isPrefix = 1; iEnd++; } - if( !sqlite3_fts3_enable_parentheses && iStart>0 && z[iStart-1]=='-' ){ - pParse->isNot = 1; + + while( 1 ){ + if( !sqlite3_fts3_enable_parentheses + && iStart>0 && z[iStart-1]=='-' + ){ + pParse->isNot = 1; + iStart--; + }else if( iStart>0 && z[iStart-1]=='^' ){ + pRet->pPhrase->aToken[0].bFirst = 1; + iStart--; + }else{ + break; + } } + } nConsumed = iEnd; } @@ -281,6 +293,7 @@ static int getNextString( pToken->n = nByte; pToken->isPrefix = (iEndbFirst = (iBegin>0 && zInput[iBegin-1]=='^'); nToken = ii+1; } } diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 47bed0dd5e..40c8e2f9ad 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -3117,6 +3117,7 @@ int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *pCsr){ for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){ Fts3PhraseToken *pPT = pDef->pToken; if( (pDef->iCol>=p->nColumn || pDef->iCol==i) + && (pPT->bFirst==0 || iPos==0) && (pPT->n==nToken || (pPT->isPrefix && pPT->nz, pPT->n)) ){ diff --git a/manifest b/manifest index 78cf5c490d..4ab3fba4d2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Cherrypick\spatch\s[3126754c72]\sfrom\sthe\strunk\sinto\sthe\scontent=\sbranch. -D 2011-10-18T12:49:59.086 +C If\sa\stoken\swithin\san\sFTS\squery\sis\sprefixed\swith\sa\s'^'\scharacter,\sit\smust\sbe\sthe\sfirst\stoken\sin\sa\scolumn\sof\sdata\sto\smatch. +D 2011-10-18T19:39:41.203 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,11 +62,11 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 15e1725f3dc7c0028676831d82b376e93b87527e +F ext/fts3/fts3.c e12a151b5f0f8d444744554f91dbb89dbf0654df F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 06f442ce096e6254432a6b16a56b6fe7b24bd372 +F ext/fts3/fts3Int.h bc27eebe2c5919115aa1858fdd308a230af6a359 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 -F ext/fts3/fts3_expr.c 23791de01b3a5d313d76e02befd2601d4096bc2b +F ext/fts3/fts3_expr.c dd0facbede8fd7d1376670cc6154f1fef3a4c5bc F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa @@ -77,7 +77,7 @@ F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c 06520aa8a0a32a7bed08b29a9004fde1cb7f0318 +F ext/fts3/fts3_write.c 567380f2d6671df16cfbb56324b321c71d5ab0d3 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -469,13 +469,14 @@ F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 -F test/fts3defer.test ffd4e07f79a09660d4b3e2613b041ab9b6100d91 +F test/fts3defer.test b7bdf79da91365b00e7c21d70e9d0c617b9306b9 F test/fts3defer2.test 35867d33ba6db03f6c73bd6f5fc333ae14f68c81 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 F test/fts3fault2.test b62a2bc843c20414405f80e5eeb78e39bc68fe53 +F test/fts3first.test 10f42914701d559c9fabfd7725b56c9f1b542fe8 F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be F test/fts3matchinfo.test 6507fe1c342e542300d65ea637d4110eccf894e6 F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 @@ -621,7 +622,7 @@ F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806 F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 -F test/permutations.test d850b5000a13baf042d5a20eb747079477dad45e +F test/permutations.test 522823b47238cb1754198f80817fe9f9158ede55 F test/pragma.test c8108e01da04f16e67e5754e610bc62c1b993f6c F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea @@ -966,7 +967,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P 289ee43179369fce2fde50870d72c445e184e896 -R 50f1458a2cdbee488c53894b18c71839 +P f9b5b217088a6aeb25eba184ab92d1a842a680a6 +R 4545768a323f698040377ce29e450e89 U dan -Z e075e042ac91a648318521977fb348f1 +Z a7972271e048cbba7c3ba6dcd813d2e6 diff --git a/manifest.uuid b/manifest.uuid index f94940003d..1ccbaef9b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f9b5b217088a6aeb25eba184ab92d1a842a680a6 \ No newline at end of file +63ac33c860eb32ce96699f06bf83121cec2ffaca \ No newline at end of file diff --git a/test/fts3defer.test b/test/fts3defer.test index ab30bbe2c3..7fbe6b14ea 100644 --- a/test/fts3defer.test +++ b/test/fts3defer.test @@ -426,6 +426,13 @@ foreach {tn setup} { SELECT rowid FROM t1 WHERE t1 MATCH '"jk xduvfhk" OR "zm azavwm"' } {8 15 26 92 96} } + + do_select_test 7.1 { + SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw' + } {56 62} + do_select_test 7.2 { + SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm' + } {43} } set testprefix fts3defer diff --git a/test/fts3first.test b/test/fts3first.test new file mode 100644 index 0000000000..6e309d0d9d --- /dev/null +++ b/test/fts3first.test @@ -0,0 +1,79 @@ +# 2011 October 18 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/malloc_common.tcl + +ifcapable !fts3 { + finish_test + return +} + +do_execsql_test 1.0 { + CREATE VIRTUAL TABLE x1 USING FTS4(a, b, c); + INSERT INTO x1(docid,a,b,c) VALUES(0, 'K H D S T', 'V M N Y K', 'S Z N Q S'); + INSERT INTO x1(docid,a,b,c) VALUES(1, 'K N J L W', 'S Z W J Q', 'D U W S E'); + INSERT INTO x1(docid,a,b,c) VALUES(2, 'B P M O I', 'R P H W S', 'R J L L E'); + INSERT INTO x1(docid,a,b,c) VALUES(3, 'U R Q M L', 'M J K A V', 'Q W J T J'); + INSERT INTO x1(docid,a,b,c) VALUES(4, 'N J C Y N', 'R U D X V', 'B O U A Q'); + INSERT INTO x1(docid,a,b,c) VALUES(5, 'Q L X L U', 'I F N X S', 'U Q A N Y'); + INSERT INTO x1(docid,a,b,c) VALUES(6, 'M R G U T', 'U V I Q P', 'X Y D L S'); + INSERT INTO x1(docid,a,b,c) VALUES(7, 'D Y P O I', 'X J P K R', 'V O T H V'); + INSERT INTO x1(docid,a,b,c) VALUES(8, 'R Y D L R', 'U U E S J', 'N W L M R'); + INSERT INTO x1(docid,a,b,c) VALUES(9, 'Z P F N P', 'W A X D U', 'V A E Q A'); + INSERT INTO x1(docid,a,b,c) VALUES(10, 'Q I A Q M', 'N D K H C', 'A H T Q Z'); + INSERT INTO x1(docid,a,b,c) VALUES(11, 'T E R Q B', 'C I B C B', 'F Z U W R'); + INSERT INTO x1(docid,a,b,c) VALUES(12, 'E S V U W', 'T P F W H', 'A M D J Q'); + INSERT INTO x1(docid,a,b,c) VALUES(13, 'X S B T Y', 'U D N D P', 'X Z Y G F'); + INSERT INTO x1(docid,a,b,c) VALUES(14, 'K H A B L', 'S R C C Z', 'D W E H J'); + INSERT INTO x1(docid,a,b,c) VALUES(15, 'C E U C C', 'W F M N M', 'T Z U X T'); + INSERT INTO x1(docid,a,b,c) VALUES(16, 'Q G C G H', 'H N N B H', 'B Q I H Y'); + INSERT INTO x1(docid,a,b,c) VALUES(17, 'Q T S K B', 'W B D Y N', 'V J P E C'); + INSERT INTO x1(docid,a,b,c) VALUES(18, 'A J M O Q', 'L G Y Y A', 'G N M R N'); + INSERT INTO x1(docid,a,b,c) VALUES(19, 'T R Y P Y', 'N V Y B X', 'L Z T N T'); + + CREATE VIRTUAL TABLE x2 USING FTS4(a, b, c, order=DESC); + INSERT INTO x2(docid, a, b, c) SELECT docid, a, b, c FROM x1; +} + +foreach x {1 2} { + foreach {tn match res} { + 1 "^K" {0 1 14} + 2 "^S" {0 1 14} + 3 "^W" {9 15 17} + 4 "^J" {} + 5 "^E" {12} + 6 "V ^-E" {0 3 4 6 7 9 17 19} + 7 "V -^E" {0 3 4 6 7 9 17 19} + 8 "^-E V" {0 3 4 6 7 9 17 19} + 9 "-^E V" {0 3 4 6 7 9 17 19} + 10 "V" {0 3 4 6 7 9 12 17 19} + + 11 {"^K H"} {0 14} + 12 {"K H"} {0 10 14} + 13 {"K ^H"} {} + } { + set rev [list] + for {set ii [expr [llength $res]-1]} {$ii>=0} {incr ii -1} { + lappend rev [lindex $res $ii] + } + do_execsql_test 1.$x.$tn.1 {SELECT docid FROM x1 WHERE x1 MATCH $match} $res + do_execsql_test 1.$x.$tn.2 {SELECT docid FROM x2 WHERE x2 MATCH $match} $rev + } + + do_execsql_test 1.$x.[expr $tn+1] { + INSERT INTO x1(x1) VALUES('optimize'); + INSERT INTO x2(x2) VALUES('optimize'); + } {} +} + +finish_test diff --git a/test/permutations.test b/test/permutations.test index 14330d0cc1..7c3b026c67 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -185,6 +185,7 @@ test_suite "fts3" -prefix "" -description { fts4aa.test fts4content.test fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test fts3corrupt2.test + fts3first.test } From 98655a696e8bb48db84f5be50a938dcb27054e45 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 18 Oct 2011 22:07:47 +0000 Subject: [PATCH 41/51] Fix the virtual table rename logic so that it works even if the database encoding is something other than UTF8. Ticket [8290242b2a9a81683] FossilOrigin-Name: d65f63531c3f8e3e55e656f049240714a3d7433f --- manifest | 14 ++++++------- manifest.uuid | 2 +- src/vdbe.c | 13 ++++++++---- test/fts3d.test | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index a0f8c053bc..a2eeca7d58 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\suninitialized\svariable\sin\sOR-clause\sprocessing. -D 2011-10-18T19:14:33.246 +C Fix\sthe\svirtual\stable\srename\slogic\sso\sthat\sit\sworks\seven\sif\sthe\sdatabase\nencoding\sis\ssomething\sother\sthan\sUTF8.\nTicket\s[8290242b2a9a81683] +D 2011-10-18T22:07:47.722 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -238,7 +238,7 @@ F src/update.c 25e046a8f69d5e557aabde2000487b8545509d8d F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 F src/util.c df83983bd57057df4951516880066b42b7055269 F src/vacuum.c 0c0ba2242355c6048d65e2b333abe0f7c06348fa -F src/vdbe.c 054e1d52587718605ac482e45cd93e0eae673298 +F src/vdbe.c 251381bff459154bf239e9977bd39b22bcb7a94c F src/vdbe.h f0725ee997db869ecae5bb70a71612aabeca7755 F src/vdbeInt.h 693d6ac6810298fc6b4c503cfbe3f99a240f40af F src/vdbeapi.c 11dc47987abacb76ad016dcf5abc0dc422482a98 @@ -470,7 +470,7 @@ F test/fts3conf.test 8e65ea56f88ced6cdd2252bdddb1a8327ae5af7e F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 -F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 +F test/fts3d.test bf640d79722b720fa1c81834c48cdaa45d531b1a F test/fts3defer.test ffd4e07f79a09660d4b3e2613b041ab9b6100d91 F test/fts3defer2.test 35867d33ba6db03f6c73bd6f5fc333ae14f68c81 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 551ce407bd77149865423511bd52eba2f404161a -R 95644f03839fa87055c65a00a0ad6110 +P 54aecd929867606d14a062b501abbfb6f5f05e37 +R dccf2fe03db8f585fac4df0bc3670756 U drh -Z e0ca001c10e0088cffb51eb7d7827b4b +Z aaf98f5abdd914fb531f49ab6760c2d4 diff --git a/manifest.uuid b/manifest.uuid index 891a2cb8e7..10b56c6753 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54aecd929867606d14a062b501abbfb6f5f05e37 \ No newline at end of file +d65f63531c3f8e3e55e656f049240714a3d7433f \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 7dcdf4621b..a5e3bb6265 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -5888,10 +5888,15 @@ case OP_VRename: { assert( memIsValid(pName) ); REGISTER_TRACE(pOp->p1, pName); assert( pName->flags & MEM_Str ); - rc = pVtab->pModule->xRename(pVtab, pName->z); - importVtabErrMsg(p, pVtab); - p->expired = 0; - + testcase( pName->enc==SQLITE_UTF8 ); + testcase( pName->enc==SQLITE_UTF16BE ); + testcase( pName->enc==SQLITE_UTF16LE ); + rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8); + if( rc==SQLITE_OK ){ + rc = pVtab->pModule->xRename(pVtab, pName->z); + importVtabErrMsg(p, pVtab); + p->expired = 0; + } break; } #endif diff --git a/test/fts3d.test b/test/fts3d.test index 715980d86d..1ae992b311 100644 --- a/test/fts3d.test +++ b/test/fts3d.test @@ -304,4 +304,57 @@ do_test fts3d-5.1 { } } {{Index already optimal} 2 0} + +# ALTER TABLE RENAME should work regardless of the database encoding. +# +do_test fts3d-6.0 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + PRAGMA encoding=UTF8; + CREATE VIRTUAL TABLE fts USING fts3(a,b,c); + SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; + } +} {fts_content fts_segdir fts_segments} +do_test fts3d-6.1 { + db eval { + ALTER TABLE fts RENAME TO xyz; + SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; + } +} {xyz_content xyz_segdir xyz_segments} +do_test fts3d-6.2 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + PRAGMA encoding=UTF16le; + CREATE VIRTUAL TABLE fts USING fts3(a,b,c); + SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; + } +} {fts_content fts_segdir fts_segments} +do_test fts3d-6.3 { + db eval { + ALTER TABLE fts RENAME TO xyz; + SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; + } +} {xyz_content xyz_segdir xyz_segments} +do_test fts3d-6.4 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + PRAGMA encoding=UTF16be; + CREATE VIRTUAL TABLE fts USING fts3(a,b,c); + SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; + } +} {fts_content fts_segdir fts_segments} +do_test fts3d-6.5 { + db eval { + ALTER TABLE fts RENAME TO xyz; + SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1; + } +} {xyz_content xyz_segdir xyz_segments} + + finish_test From 50a7544d6f281d0adf43930d00fd40db2e5acbc6 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 19 Oct 2011 09:40:49 +0000 Subject: [PATCH 42/51] Fix a problem in FTS to do with ^ tokens and the snippet() function. FossilOrigin-Name: 2c03b24f4cc6f2c28c9d5b9984320d41b8486c32 --- ext/fts3/fts3.c | 1 + ext/fts3/fts3_snippet.c | 1 + manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/fts3first.test | 31 ++++++++++++++++++++++++++----- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 289adeb4df..e82d1f5e89 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -2391,6 +2391,7 @@ static void fts3DoclistFirstFilter( fts3PutDeltaVarint3(&pOut, bDescDoclist, &iPrev, &bFirstOut, iDoc); bWritten = 1; } + *pOut++ = 0x01; pOut += sqlite3Fts3PutVarint(pOut, iCol); *pOut++ = 0x02; } diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 13d0ca3551..6a3d1ec893 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -368,6 +368,7 @@ static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){ int iFirst = 0; pPhrase->pList = pCsr; fts3GetDeltaPosition(&pCsr, &iFirst); + assert( iFirst>=0 ); pPhrase->pHead = pCsr; pPhrase->pTail = pCsr; pPhrase->iHead = iFirst; diff --git a/manifest b/manifest index 4ab3fba4d2..f9ee83d4ef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sa\stoken\swithin\san\sFTS\squery\sis\sprefixed\swith\sa\s'^'\scharacter,\sit\smust\sbe\sthe\sfirst\stoken\sin\sa\scolumn\sof\sdata\sto\smatch. -D 2011-10-18T19:39:41.203 +C Fix\sa\sproblem\sin\sFTS\sto\sdo\swith\s^\stokens\sand\sthe\ssnippet()\sfunction. +D 2011-10-19T09:40:49.185 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c e12a151b5f0f8d444744554f91dbb89dbf0654df +F ext/fts3/fts3.c 708122f0ed7b7b0aa9813fe302eb40a238956276 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h bc27eebe2c5919115aa1858fdd308a230af6a359 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -71,7 +71,7 @@ F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa F ext/fts3/fts3_porter.c 8d946908f4812c005d3d33fcbe78418b1f4eb70c -F ext/fts3/fts3_snippet.c 8838a1de5f7df3a559596870caaa4a9895248998 +F ext/fts3/fts3_snippet.c e1f3ed049efa35337d393a0ae971b32c28f4c88d F ext/fts3/fts3_term.c a5457992723455a58804cb75c8cbd8978db5c2ef F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 @@ -476,7 +476,7 @@ F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 F test/fts3fault2.test b62a2bc843c20414405f80e5eeb78e39bc68fe53 -F test/fts3first.test 10f42914701d559c9fabfd7725b56c9f1b542fe8 +F test/fts3first.test 8402101caa140802fdea7322652b22caa7662010 F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be F test/fts3matchinfo.test 6507fe1c342e542300d65ea637d4110eccf894e6 F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 @@ -967,7 +967,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P f9b5b217088a6aeb25eba184ab92d1a842a680a6 -R 4545768a323f698040377ce29e450e89 +P 63ac33c860eb32ce96699f06bf83121cec2ffaca +R 3121ed7658c54e3e7fae4ae1475b5670 U dan -Z a7972271e048cbba7c3ba6dcd813d2e6 +Z 5ad246c0f30695f9ad4b0b18222b341a diff --git a/manifest.uuid b/manifest.uuid index 1ccbaef9b8..4a839fd314 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -63ac33c860eb32ce96699f06bf83121cec2ffaca \ No newline at end of file +2c03b24f4cc6f2c28c9d5b9984320d41b8486c32 \ No newline at end of file diff --git a/test/fts3first.test b/test/fts3first.test index 6e309d0d9d..0c6de520fd 100644 --- a/test/fts3first.test +++ b/test/fts3first.test @@ -18,6 +18,14 @@ ifcapable !fts3 { return } +proc lreverse {L} { + set res [list] + for {set ii [expr [llength $L]-1]} {$ii>=0} {incr ii -1} { + lappend res [lindex $L $ii] + } + set res +} + do_execsql_test 1.0 { CREATE VIRTUAL TABLE x1 USING FTS4(a, b, c); INSERT INTO x1(docid,a,b,c) VALUES(0, 'K H D S T', 'V M N Y K', 'S Z N Q S'); @@ -33,7 +41,7 @@ do_execsql_test 1.0 { INSERT INTO x1(docid,a,b,c) VALUES(10, 'Q I A Q M', 'N D K H C', 'A H T Q Z'); INSERT INTO x1(docid,a,b,c) VALUES(11, 'T E R Q B', 'C I B C B', 'F Z U W R'); INSERT INTO x1(docid,a,b,c) VALUES(12, 'E S V U W', 'T P F W H', 'A M D J Q'); - INSERT INTO x1(docid,a,b,c) VALUES(13, 'X S B T Y', 'U D N D P', 'X Z Y G F'); + INSERT INTO x1(docid,a,b,c) VALUES(13, 'X S B X Y', 'U D N D P', 'X Z Y G F'); INSERT INTO x1(docid,a,b,c) VALUES(14, 'K H A B L', 'S R C C Z', 'D W E H J'); INSERT INTO x1(docid,a,b,c) VALUES(15, 'C E U C C', 'W F M N M', 'T Z U X T'); INSERT INTO x1(docid,a,b,c) VALUES(16, 'Q G C G H', 'H N N B H', 'B Q I H Y'); @@ -45,6 +53,7 @@ do_execsql_test 1.0 { INSERT INTO x2(docid, a, b, c) SELECT docid, a, b, c FROM x1; } + foreach x {1 2} { foreach {tn match res} { 1 "^K" {0 1 14} @@ -62,10 +71,7 @@ foreach x {1 2} { 12 {"K H"} {0 10 14} 13 {"K ^H"} {} } { - set rev [list] - for {set ii [expr [llength $res]-1]} {$ii>=0} {incr ii -1} { - lappend rev [lindex $res $ii] - } + set rev [lreverse $res] do_execsql_test 1.$x.$tn.1 {SELECT docid FROM x1 WHERE x1 MATCH $match} $res do_execsql_test 1.$x.$tn.2 {SELECT docid FROM x2 WHERE x2 MATCH $match} $rev } @@ -76,4 +82,19 @@ foreach x {1 2} { } {} } +foreach {tn match res} { + 1 {^K} {{[K] H D S T} {[K] N J L W} {[K] H A B L}} + 2 {^X} {{[X] Y D L S} {[X] J P K R} {[X] S B X Y}} + 3 {^X Y} {{[X] [Y] D L S} {D [Y] P O I...[X] J P K R} {[X] S B X [Y]}} +} { + set rev [lreverse $res] + + do_execsql_test 1.3.$tn.1 { + SELECT snippet(x1, '[', ']', '...') FROM x1 WHERE x1 MATCH $match + } $res + do_execsql_test 1.3.$tn.2 { + SELECT snippet(x2, '[', ']', '...') FROM x2 WHERE x2 MATCH $match + } $rev +} + finish_test From 8653fa850471e219c34e12bf4a7218422935c152 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 19 Oct 2011 10:18:01 +0000 Subject: [PATCH 43/51] Add tests for FTS ^ searches and matchinfo(). FossilOrigin-Name: 92618c1463fb304cf8057d082b2c7096152dff27 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/fts3first.test | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index f9ee83d4ef..f155d09e14 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sFTS\sto\sdo\swith\s^\stokens\sand\sthe\ssnippet()\sfunction. -D 2011-10-19T09:40:49.185 +C Add\stests\sfor\sFTS\s^\ssearches\sand\smatchinfo(). +D 2011-10-19T10:18:01.912 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -476,7 +476,7 @@ F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 F test/fts3fault2.test b62a2bc843c20414405f80e5eeb78e39bc68fe53 -F test/fts3first.test 8402101caa140802fdea7322652b22caa7662010 +F test/fts3first.test 5aa9e82202461a82066427df4cea9188155a4cd5 F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be F test/fts3matchinfo.test 6507fe1c342e542300d65ea637d4110eccf894e6 F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 @@ -967,7 +967,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P 63ac33c860eb32ce96699f06bf83121cec2ffaca -R 3121ed7658c54e3e7fae4ae1475b5670 +P 2c03b24f4cc6f2c28c9d5b9984320d41b8486c32 +R 402b5e477b47b6aa728a3149c74db091 U dan -Z 5ad246c0f30695f9ad4b0b18222b341a +Z 87cae0b85a25fbf32c49680729e400c4 diff --git a/manifest.uuid b/manifest.uuid index 4a839fd314..4e40bb93ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2c03b24f4cc6f2c28c9d5b9984320d41b8486c32 \ No newline at end of file +92618c1463fb304cf8057d082b2c7096152dff27 \ No newline at end of file diff --git a/test/fts3first.test b/test/fts3first.test index 0c6de520fd..e82a23dd0e 100644 --- a/test/fts3first.test +++ b/test/fts3first.test @@ -26,6 +26,14 @@ proc lreverse {L} { set res } +proc mit {blob} { + set scan(littleEndian) i* + set scan(bigEndian) I* + binary scan $blob $scan($::tcl_platform(byteOrder)) r + return $r +} +db func mit mit + do_execsql_test 1.0 { CREATE VIRTUAL TABLE x1 USING FTS4(a, b, c); INSERT INTO x1(docid,a,b,c) VALUES(0, 'K H D S T', 'V M N Y K', 'S Z N Q S'); @@ -54,6 +62,8 @@ do_execsql_test 1.0 { } +# Test queries. +# foreach x {1 2} { foreach {tn match res} { 1 "^K" {0 1 14} @@ -82,6 +92,8 @@ foreach x {1 2} { } {} } +# Test the snippet() function. +# foreach {tn match res} { 1 {^K} {{[K] H D S T} {[K] N J L W} {[K] H A B L}} 2 {^X} {{[X] Y D L S} {[X] J P K R} {[X] S B X Y}} @@ -92,9 +104,39 @@ foreach {tn match res} { do_execsql_test 1.3.$tn.1 { SELECT snippet(x1, '[', ']', '...') FROM x1 WHERE x1 MATCH $match } $res + do_execsql_test 1.3.$tn.2 { SELECT snippet(x2, '[', ']', '...') FROM x2 WHERE x2 MATCH $match } $rev } +# Test matchinfo(). +# +foreach {tn match res} { + 1 {^K} { + {1 3 3 0 0 0 0 0 0} + {1 3 3 0 0 0 0 0 0} + {1 3 3 0 0 0 0 0 0} + } + 2 {^X} { + {0 1 1 0 1 1 1 2 2} + {0 1 1 1 1 1 0 2 2} + {1 1 1 0 1 1 1 2 2} + } + 3 {^X Y} { + {0 1 1 0 1 1 1 2 2 0 6 5 0 5 4 1 4 4} + {0 1 1 1 1 1 0 2 2 1 6 5 0 5 4 0 4 4} + {1 1 1 0 1 1 1 2 2 1 6 5 0 5 4 1 4 4} + } +} { + set rev [lreverse $res] + + do_execsql_test 1.3.$tn.1 { + SELECT mit(matchinfo(x1, 'x')) FROM x1 WHERE x1 MATCH $match + } $res + do_execsql_test 1.3.$tn.2 { + SELECT mit(matchinfo(x2, 'x')) FROM x2 WHERE x2 MATCH $match + } $rev +} + finish_test From d17f70a624dd40670b547ebb50ac35015b35f7b7 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 19 Oct 2011 11:57:13 +0000 Subject: [PATCH 44/51] Change the way ^ tokens work in FTS so that the filtering is done as part of reading the FTS index instead of waiting until an entire doclist has been retrieved and then filtering it. FossilOrigin-Name: 9b58c59eb4efaa38ce50a3ce1b52f9ba578c71d6 --- ext/fts3/fts3.c | 97 ++++++++++++++++++------------------------- ext/fts3/fts3Int.h | 3 +- ext/fts3/fts3_write.c | 26 +++++++++--- manifest | 16 +++---- manifest.uuid | 2 +- 5 files changed, 72 insertions(+), 72 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index e82d1f5e89..e1330004a2 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -2348,65 +2348,53 @@ static void fts3DoclistPhraseMerge( } /* -** When this function is called, pList points to a doclist containing position -** data, length *pnList bytes. This removes all entries from the doclist that -** do not correspond to the first token in a column and overwrites pList -** with the result. *pnList is set to the length of the new doclist before -** returning. -** -** If bDescDoclist is true, then both the input and output are in descending -** order. Otherwise, ascending. +** Argument pList points to a position list nList bytes in size. This +** function checks to see if the position list contains any entries for +** a token in position 0 (of any column). If so, it writes argument iDelta +** to the output buffer pOut, followed by a position list consisting only +** of the entries from pList at position 0, and terminated by an 0x00 byte. +** The value returned is the number of bytes written to pOut (if any). */ -static void fts3DoclistFirstFilter( - int bDescDoclist, /* True if pList is a descending doclist */ - char *pList, /* Buffer containing doclist */ - int *pnList /* IN/OUT: Size of doclist */ +int sqlite3Fts3FirstFilter( + sqlite3_int64 iDelta, /* Varint that may be written to pOut */ + char *pList, /* Position list (no 0x00 term) */ + int nList, /* Size of pList in bytes */ + char *pOut /* Write output here */ ){ + int nOut = 0; + int bWritten = 0; /* True once iDelta has been written */ char *p = pList; - char *pOut = pList; - char *pEnd = &pList[*pnList]; + char *pEnd = &pList[nList]; - sqlite3_int64 iDoc; - sqlite3_int64 iPrev; - int bFirstOut = 0; - - fts3GetDeltaVarint3(&p, pEnd, 0, &iDoc); - while( p ){ - int bWritten = 0; - if( *p!=0x01 ){ - if( *p==0x02 ){ - fts3PutDeltaVarint3(&pOut, bDescDoclist, &iPrev, &bFirstOut, iDoc); - *pOut++ = 0x02; - bWritten = 1; - } - fts3ColumnlistCopy(0, &p); + if( *p!=0x01 ){ + if( *p==0x02 ){ + nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta); + pOut[nOut++] = 0x02; + bWritten = 1; } - - while( *p==0x01 ){ - sqlite3_int64 iCol; - p++; - p += sqlite3Fts3GetVarint(p, &iCol); - if( *p==0x02 ){ - if( bWritten==0 ){ - fts3PutDeltaVarint3(&pOut, bDescDoclist, &iPrev, &bFirstOut, iDoc); - bWritten = 1; - } - *pOut++ = 0x01; - pOut += sqlite3Fts3PutVarint(pOut, iCol); - *pOut++ = 0x02; - } - fts3ColumnlistCopy(0, &p); - } - if( bWritten ){ - *pOut++ = 0x00; - } - - assert( *p==0x00 ); - p++; - fts3GetDeltaVarint3(&p, pEnd, bDescDoclist, &iDoc); + fts3ColumnlistCopy(0, &p); } - *pnList = (pOut - pList); + while( pisPrefix ? FTS3_SEGMENT_PREFIX : 0) + | (pTok->bFirst ? FTS3_SEGMENT_FIRST : 0) | (iColumnnColumn ? FTS3_SEGMENT_COLUMN_FILTER : 0); filter.iCol = iColumn; filter.zTerm = pTok->z; @@ -3580,10 +3569,6 @@ static void fts3EvalPhraseMergeToken( ){ assert( iToken!=p->iDoclistToken ); - if( p->aToken[iToken].bFirst ){ - fts3DoclistFirstFilter(pTab->bDescIdx, pList, &nList); - } - if( pList==0 ){ sqlite3_free(p->doclist.aAll); p->doclist.aAll = 0; diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index c9b291c6cc..5f0f8dea01 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -429,6 +429,7 @@ int sqlite3Fts3SegReaderCursor( #define FTS3_SEGMENT_COLUMN_FILTER 0x00000004 #define FTS3_SEGMENT_PREFIX 0x00000008 #define FTS3_SEGMENT_SCAN 0x00000010 +#define FTS3_SEGMENT_FIRST 0x00000020 /* Type passed as 4th argument to SegmentReaderIterate() */ struct Fts3SegFilter { @@ -468,8 +469,8 @@ int sqlite3Fts3GetVarint32(const char *, int *); int sqlite3Fts3VarintLen(sqlite3_uint64); void sqlite3Fts3Dequote(char *); void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*); - int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *); +int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *); /* fts3_tokenizer.c */ const char *sqlite3Fts3NextToken(const char *, int *); diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 40c8e2f9ad..855e97764e 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -2509,6 +2509,7 @@ int sqlite3Fts3SegReaderStep( int isColFilter = (pCsr->pFilter->flags & FTS3_SEGMENT_COLUMN_FILTER); int isPrefix = (pCsr->pFilter->flags & FTS3_SEGMENT_PREFIX); int isScan = (pCsr->pFilter->flags & FTS3_SEGMENT_SCAN); + int isFirst = (pCsr->pFilter->flags & FTS3_SEGMENT_FIRST); Fts3SegReader **apSegment = pCsr->apSegment; int nSegment = pCsr->nSegment; @@ -2568,6 +2569,7 @@ int sqlite3Fts3SegReaderStep( assert( isIgnoreEmpty || (isRequirePos && !isColFilter) ); if( nMerge==1 && !isIgnoreEmpty + && !isFirst && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0) ){ pCsr->nDoclist = apSegment[0]->nDoclist; @@ -2633,12 +2635,24 @@ int sqlite3Fts3SegReaderStep( } pCsr->aBuffer = aNew; } - nDoclist += sqlite3Fts3PutVarint(&pCsr->aBuffer[nDoclist], iDelta); - iPrev = iDocid; - if( isRequirePos ){ - memcpy(&pCsr->aBuffer[nDoclist], pList, nList); - nDoclist += nList; - pCsr->aBuffer[nDoclist++] = '\0'; + + if( isFirst ){ + char *a = &pCsr->aBuffer[nDoclist]; + int nWrite; + + nWrite = sqlite3Fts3FirstFilter(iDelta, pList, nList, a); + if( nWrite ){ + iPrev = iDocid; + nDoclist += nWrite; + } + }else{ + nDoclist += sqlite3Fts3PutVarint(&pCsr->aBuffer[nDoclist], iDelta); + iPrev = iDocid; + if( isRequirePos ){ + memcpy(&pCsr->aBuffer[nDoclist], pList, nList); + nDoclist += nList; + pCsr->aBuffer[nDoclist++] = '\0'; + } } } diff --git a/manifest b/manifest index f155d09e14..df0a118c08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sfor\sFTS\s^\ssearches\sand\smatchinfo(). -D 2011-10-19T10:18:01.912 +C Change\sthe\sway\s^\stokens\swork\sin\sFTS\sso\sthat\sthe\sfiltering\sis\sdone\sas\spart\sof\sreading\sthe\sFTS\sindex\sinstead\sof\swaiting\suntil\san\sentire\sdoclist\shas\sbeen\sretrieved\sand\sthen\sfiltering\sit. +D 2011-10-19T11:57:13.985 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,9 +62,9 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 708122f0ed7b7b0aa9813fe302eb40a238956276 +F ext/fts3/fts3.c 064b660a11ae29651b647fa7c3e9954d901ab58a F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h bc27eebe2c5919115aa1858fdd308a230af6a359 +F ext/fts3/fts3Int.h 7a0deb219371d29b8d385fb5e929ede2bdc7c239 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 F ext/fts3/fts3_expr.c dd0facbede8fd7d1376670cc6154f1fef3a4c5bc F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 @@ -77,7 +77,7 @@ F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c 567380f2d6671df16cfbb56324b321c71d5ab0d3 +F ext/fts3/fts3_write.c aaf0885fd5d37c6869071ee58b5aa3ba07cc0d87 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -967,7 +967,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P 2c03b24f4cc6f2c28c9d5b9984320d41b8486c32 -R 402b5e477b47b6aa728a3149c74db091 +P 92618c1463fb304cf8057d082b2c7096152dff27 +R c2d7bdd9838ac956262a194e0ae43b40 U dan -Z 87cae0b85a25fbf32c49680729e400c4 +Z 8d1b6b02c37e3947f3ee71176bf9a674 diff --git a/manifest.uuid b/manifest.uuid index 4e40bb93ac..4b15a85377 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92618c1463fb304cf8057d082b2c7096152dff27 \ No newline at end of file +9b58c59eb4efaa38ce50a3ce1b52f9ba578c71d6 \ No newline at end of file From 97439483869d65fdbbbaba1695df93bb70050a0d Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 19 Oct 2011 15:52:48 +0000 Subject: [PATCH 45/51] Have FTS3 ignore ^ prefixes. The ^ syntax is only supported on FTS4 tables. FossilOrigin-Name: df36ac948179f37b432a88701b6c79299e073ce8 --- ext/fts3/fts3.c | 4 ++-- ext/fts3/fts3Int.h | 2 +- ext/fts3/fts3_expr.c | 7 +++++-- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- test/fts3defer.test | 17 +++++++++++------ test/fts3first.test | 21 +++++++++++++++++++++ 7 files changed, 51 insertions(+), 22 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index e1330004a2..c5f51a4ccf 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -2894,8 +2894,8 @@ static int fts3FilterMethod( return SQLITE_NOMEM; } - rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn, - iCol, zQuery, -1, &pCsr->pExpr + rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->bHasStat, + p->nColumn, iCol, zQuery, -1, &pCsr->pExpr ); if( rc!=SQLITE_OK ){ if( rc==SQLITE_ERROR ){ diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 5f0f8dea01..89672da971 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -489,7 +489,7 @@ void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *); /* fts3_expr.c */ int sqlite3Fts3ExprParse(sqlite3_tokenizer *, - char **, int, int, const char *, int, Fts3Expr ** + char **, int, int, int, const char *, int, Fts3Expr ** ); void sqlite3Fts3ExprFree(Fts3Expr *); #ifdef SQLITE_TEST diff --git a/ext/fts3/fts3_expr.c b/ext/fts3/fts3_expr.c index e6193a1392..46add008c7 100644 --- a/ext/fts3/fts3_expr.c +++ b/ext/fts3/fts3_expr.c @@ -93,6 +93,7 @@ typedef struct ParseContext ParseContext; struct ParseContext { sqlite3_tokenizer *pTokenizer; /* Tokenizer module */ const char **azCol; /* Array of column names for fts3 table */ + int bFts4; /* True to allow FTS4-only syntax */ int nCol; /* Number of entries in azCol[] */ int iDefaultCol; /* Default column to query */ int isNot; /* True if getNextNode() sees a unary - */ @@ -187,7 +188,7 @@ static int getNextToken( ){ pParse->isNot = 1; iStart--; - }else if( iStart>0 && z[iStart-1]=='^' ){ + }else if( pParse->bFts4 && iStart>0 && z[iStart-1]=='^' ){ pRet->pPhrase->aToken[0].bFirst = 1; iStart--; }else{ @@ -741,6 +742,7 @@ exprparse_out: int sqlite3Fts3ExprParse( sqlite3_tokenizer *pTokenizer, /* Tokenizer module */ char **azCol, /* Array of column names for fts3 table */ + int bFts4, /* True to allow FTS4-only syntax */ int nCol, /* Number of entries in azCol[] */ int iDefaultCol, /* Default column to query */ const char *z, int n, /* Text of MATCH query */ @@ -754,6 +756,7 @@ int sqlite3Fts3ExprParse( sParse.nCol = nCol; sParse.iDefaultCol = iDefaultCol; sParse.nNest = 0; + sParse.bFts4 = bFts4; if( z==0 ){ *ppExpr = 0; return SQLITE_OK; @@ -943,7 +946,7 @@ static void fts3ExprTest( } rc = sqlite3Fts3ExprParse( - pTokenizer, azCol, nCol, nCol, zExpr, nExpr, &pExpr + pTokenizer, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr ); if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){ sqlite3_result_error(context, "Error parsing expression", -1); diff --git a/manifest b/manifest index df0a118c08..50449c9718 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sway\s^\stokens\swork\sin\sFTS\sso\sthat\sthe\sfiltering\sis\sdone\sas\spart\sof\sreading\sthe\sFTS\sindex\sinstead\sof\swaiting\suntil\san\sentire\sdoclist\shas\sbeen\sretrieved\sand\sthen\sfiltering\sit. -D 2011-10-19T11:57:13.985 +C Have\sFTS3\signore\s^\sprefixes.\sThe\s^\ssyntax\sis\sonly\ssupported\son\sFTS4\stables. +D 2011-10-19T15:52:48.921 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,11 +62,11 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 064b660a11ae29651b647fa7c3e9954d901ab58a +F ext/fts3/fts3.c e8ee5c78a3c7715b597db4e5c890ec658ee0401a F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 7a0deb219371d29b8d385fb5e929ede2bdc7c239 +F ext/fts3/fts3Int.h 74afec80054924976b2d3a21eda17e33c6ff6b84 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 -F ext/fts3/fts3_expr.c dd0facbede8fd7d1376670cc6154f1fef3a4c5bc +F ext/fts3/fts3_expr.c 34dd0edf1e2723ce22d88039dc1ad687a95fb1bb F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c 6c8f395cdf9e1e3afa7fadb7e523dbbf381c6dfa @@ -469,14 +469,14 @@ F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 -F test/fts3defer.test b7bdf79da91365b00e7c21d70e9d0c617b9306b9 +F test/fts3defer.test 2ea3fa028f8d9523f9c33dd8acc4555d567ea4ac F test/fts3defer2.test 35867d33ba6db03f6c73bd6f5fc333ae14f68c81 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3fault.test f83e556465bb69dc8bc676339eca408dce4ca246 F test/fts3fault2.test b62a2bc843c20414405f80e5eeb78e39bc68fe53 -F test/fts3first.test 5aa9e82202461a82066427df4cea9188155a4cd5 +F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641 F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be F test/fts3matchinfo.test 6507fe1c342e542300d65ea637d4110eccf894e6 F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 @@ -967,7 +967,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P 92618c1463fb304cf8057d082b2c7096152dff27 -R c2d7bdd9838ac956262a194e0ae43b40 +P 9b58c59eb4efaa38ce50a3ce1b52f9ba578c71d6 +R b05473465da4d8af6fcb4e85b9ce8174 U dan -Z 8d1b6b02c37e3947f3ee71176bf9a674 +Z 1ed48059f0e9f692b253c99c9d63572e diff --git a/manifest.uuid b/manifest.uuid index 4b15a85377..0f7fa81637 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b58c59eb4efaa38ce50a3ce1b52f9ba578c71d6 \ No newline at end of file +df36ac948179f37b432a88701b6c79299e073ce8 \ No newline at end of file diff --git a/test/fts3defer.test b/test/fts3defer.test index 7fbe6b14ea..bc50874e4a 100644 --- a/test/fts3defer.test +++ b/test/fts3defer.test @@ -427,12 +427,17 @@ foreach {tn setup} { } {8 15 26 92 96} } - do_select_test 7.1 { - SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw' - } {56 62} - do_select_test 7.2 { - SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm' - } {43} + if {$tn>1} { + # These tests will not work with $tn==1, as in this case table t1 is + # created using FTS3. The ^ syntax is only available with FTS4 tables. + # + do_select_test 7.1 { + SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw' + } {56 62} + do_select_test 7.2 { + SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm' + } {43} + } } set testprefix fts3defer diff --git a/test/fts3first.test b/test/fts3first.test index e82a23dd0e..673f818deb 100644 --- a/test/fts3first.test +++ b/test/fts3first.test @@ -18,6 +18,8 @@ ifcapable !fts3 { return } +set testprefix fts3first + proc lreverse {L} { set res [list] for {set ii [expr [llength $L]-1]} {$ii>=0} {incr ii -1} { @@ -139,4 +141,23 @@ foreach {tn match res} { } $rev } +# Test that ^ is ignored for FTS3 tables. +# +do_execsql_test 2.1 { + CREATE VIRTUAL TABLE x3 USING fts3; + INSERT INTO x3 VALUES('A B C'); + INSERT INTO x3 VALUES('B A C'); + + CREATE VIRTUAL TABLE x4 USING fts4; + INSERT INTO x4 VALUES('A B C'); + INSERT INTO x4 VALUES('B A C'); +} + +do_execsql_test 2.2.1 { + SELECT * FROM x3 WHERE x3 MATCH '^A'; +} {{A B C} {B A C}} +do_execsql_test 2.2.2 { + SELECT * FROM x4 WHERE x4 MATCH '^A'; +} {{A B C}} + finish_test From d76b64e1c646c5bf463b6bf8e53741cfec301ed0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 19 Oct 2011 17:13:08 +0000 Subject: [PATCH 46/51] Fix comments on SQLITE_CONFIG_HEAP so that they do not interfere with the requirements scanner. FossilOrigin-Name: a3151ce15c256219646013d695b6e162e306cef8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 528e4691d0..17377c52ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\sfts4-content\sbranch\swith\sthe\strunk. -D 2011-10-19T16:20:40.613 +C Fix\scomments\son\sSQLITE_CONFIG_HEAP\sso\sthat\sthey\sdo\snot\sinterfere\swith\sthe\nrequirements\sscanner. +D 2011-10-19T17:13:08.805 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -181,7 +181,7 @@ F src/resolve.c 365ab1c870e38596d6869e76fb544fe6e4ffc809 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c 80f3ac44a8514b1d107b80f5df4a424ae059d2b6 F src/shell.c f0ab793261ab045a0b8c47fa2707e8a894d2898f -F src/sqlite.h.in 5ec7488ef4c124ae905286600a9f2d64250aebb1 +F src/sqlite.h.in c3d7085eb5f7d3b4ce7a484e0ecb9082e57daab1 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93 F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -972,7 +972,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P d65f63531c3f8e3e55e656f049240714a3d7433f df36ac948179f37b432a88701b6c79299e073ce8 -R 3877ede50d6923a62a70ae0714da94fb -U dan -Z e6c406cc06dcce98e86f6b11f422dc50 +P 8a4077057ddeb08e8edc5f20a75abaaba7a278ba +R b6475ab92965b41fc368318dd410ee81 +U drh +Z d1c63652bd6e0c53508e2b02187c5b10 diff --git a/manifest.uuid b/manifest.uuid index eef6d62dc6..61f55395f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8a4077057ddeb08e8edc5f20a75abaaba7a278ba \ No newline at end of file +a3151ce15c256219646013d695b6e162e306cef8 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 833d9c5ce6..32769c5829 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1399,8 +1399,8 @@ struct sqlite3_mem_methods { ** allocator is engaged to handle all of SQLites memory allocation needs. ** The first pointer (the memory pointer) must be aligned to an 8-byte ** boundary or subsequent behavior of SQLite will be undefined. -** The minimum allocation size is capped at 2^12. Reasonable values -** for the minimum allocation size are 2^5 through 2^8. +** The minimum allocation size is capped at 2**12. Reasonable values +** for the minimum allocation size are 2**5 through 2**8. ** ** [[SQLITE_CONFIG_MUTEX]]
SQLITE_CONFIG_MUTEX
**
^(This option takes a single argument which is a pointer to an From 6ed18b7110569d49ec3bcb3a9fdb984a31dbfc77 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 19 Oct 2011 18:21:47 +0000 Subject: [PATCH 47/51] Fix harmless compiler warnings in FTS4. FossilOrigin-Name: 1af4a25631c4077a9bfc64e15eb92fbf5146c89c --- ext/fts3/fts3.c | 5 +++-- ext/fts3/fts3_write.c | 4 ++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 41791cb3cb..12013f2b72 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1191,7 +1191,7 @@ static int fts3InitVtab( zCompress = 0; zUncompress = 0; if( nCol==0 ){ - sqlite3_free(aCol); + sqlite3_free((void*)aCol); aCol = 0; rc = fts3ContentColumns(db, argv[1], zContent, &aCol, &nCol, &nString); } @@ -1962,7 +1962,7 @@ static int fts3PoslistPhraseMerge( /* Never set both isSaveLeft and isExact for the same invocation. */ assert( isSaveLeft==0 || isExact==0 ); - assert( *p1!=0 && *p2!=0 ); + assert( p!=0 && *p1!=0 && *p2!=0 ); if( *p1==POS_COLUMN ){ p1++; p1 += sqlite3Fts3GetVarint32(p1, &iCol1); @@ -1997,6 +1997,7 @@ static int fts3PoslistPhraseMerge( iSave = isSaveLeft ? iPos1 : iPos2; fts3PutDeltaVarint(&p, &iPrev, iSave+2); iPrev -= 2; pSave = 0; + assert( p ); } if( (!isSaveLeft && iPos2<=(iPos1+nToken)) || iPos2<=iPos1 ){ if( (*p2&0xFE)==0 ) break; diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index d3a88cbe61..2904a9acaa 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -2968,8 +2968,8 @@ static int fts3DoRebuild(Fts3Table *p){ rc = fts3DeleteAll(p, 0); if( rc==SQLITE_OK ){ u32 *aSz = 0; - u32 *aSzIns; - u32 *aSzDel; + u32 *aSzIns = 0; + u32 *aSzDel = 0; sqlite3_stmt *pStmt = 0; int nEntry = 0; diff --git a/manifest b/manifest index 17377c52ac..f8cb18aece 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scomments\son\sSQLITE_CONFIG_HEAP\sso\sthat\sthey\sdo\snot\sinterfere\swith\sthe\nrequirements\sscanner. -D 2011-10-19T17:13:08.805 +C Fix\sharmless\scompiler\swarnings\sin\sFTS4. +D 2011-10-19T18:21:47.264 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 9c125699baf1c03a3d8d53fb7d8d27ab4ad7d6eb +F ext/fts3/fts3.c 246ef2d0cef67517d156d39c9247cd6c432f0d79 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h def7a900f98c5ab5fa4772e922bfa219d5097f05 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -77,7 +77,7 @@ F ext/fts3/fts3_test.c 24fa13f330db011500acb95590da9eee24951894 F ext/fts3/fts3_tokenizer.c 9ff7ec66ae3c5c0340fa081958e64f395c71a106 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68 -F ext/fts3/fts3_write.c f2545f59a4cc2eb6739acb3d026b8a91a1f3d429 +F ext/fts3/fts3_write.c c097228bff4d33c6b8a270c9717b9f8339068776 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 @@ -972,7 +972,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8a4077057ddeb08e8edc5f20a75abaaba7a278ba -R b6475ab92965b41fc368318dd410ee81 +P a3151ce15c256219646013d695b6e162e306cef8 +R c03f17b280572c2b36a89af35fc59d08 U drh -Z d1c63652bd6e0c53508e2b02187c5b10 +Z 9ceef528bc2e97c4ba4f48a0f47a964a diff --git a/manifest.uuid b/manifest.uuid index 61f55395f6..6c18d5b13a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a3151ce15c256219646013d695b6e162e306cef8 \ No newline at end of file +1af4a25631c4077a9bfc64e15eb92fbf5146c89c \ No newline at end of file From 60bdeb2aa9a6f0472d9dd397756f9e44c2014ba5 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 20 Oct 2011 00:55:54 +0000 Subject: [PATCH 48/51] Enhancements to the omittest.tcl script used to verify that the SQLITE_OMIT compile-time options are working. FossilOrigin-Name: 4344483f7d7f64dffadde0053e6c745948db9486 --- main.mk | 3 +++ manifest | 14 +++++++------- manifest.uuid | 2 +- tool/omittest.tcl | 44 ++++++++++++++++++++++++++------------------ 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/main.mk b/main.mk index 2b8f47a00c..4360d8626d 100644 --- a/main.mk +++ b/main.mk @@ -362,6 +362,9 @@ sqlite3$(EXE): $(TOP)/src/shell.c libsqlite3.a sqlite3.h $(TOP)/src/shell.c \ libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB) +sqlite3.o: sqlite3.c + $(TCCX) -c sqlite3.c + # This target creates a directory named "tsrc" and fills it with # copies of all of the C source code and header files needed to # build on the target system. Some of the C source code and header diff --git a/manifest b/manifest index f8cb18aece..4592d79c10 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sFTS4. -D 2011-10-19T18:21:47.264 +C Enhancements\sto\sthe\somittest.tcl\sscript\sused\sto\sverify\sthat\sthe\nSQLITE_OMIT\scompile-time\soptions\sare\sworking. +D 2011-10-20T00:55:54.955 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -104,7 +104,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk 0eb7d4edf00e3bb1e312766ec2edccd015703eec +F main.mk ac48970ca7506c9034f5c7b2212111fbeb0a1aaa F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -945,7 +945,7 @@ F tool/mksqlite3c.tcl 9fbac513cd9d5ac95ad55630f49bb16c5347ab75 F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 -F tool/omittest.tcl 8086c014cbae90f1f2b564d59d05a5e4ac1783c9 +F tool/omittest.tcl 72a49b8a9a8b0bf213a438180307a0df836d4380 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 @@ -972,7 +972,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P a3151ce15c256219646013d695b6e162e306cef8 -R c03f17b280572c2b36a89af35fc59d08 +P 1af4a25631c4077a9bfc64e15eb92fbf5146c89c +R f519850801e0581ab79d9a8c90ed8863 U drh -Z 9ceef528bc2e97c4ba4f48a0f47a964a +Z f005e14c521f1568740d231c984f07e1 diff --git a/manifest.uuid b/manifest.uuid index 6c18d5b13a..9127f8d266 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1af4a25631c4077a9bfc64e15eb92fbf5146c89c \ No newline at end of file +4344483f7d7f64dffadde0053e6c745948db9486 \ No newline at end of file diff --git a/tool/omittest.tcl b/tool/omittest.tcl index 33a71cee26..7f13a4cbe3 100644 --- a/tool/omittest.tcl +++ b/tool/omittest.tcl @@ -48,19 +48,18 @@ they do not respect the OPTS variable. # # proc run_quick_test {dir omit_symbol_list} { - set target "testfixture" # Compile the value of the OPTS Makefile variable. - set opts "-DSQLITE_MEMDEBUG -DSQLITE_DEBUG -DSQLITE_NO_SYNC" + set opts "" if {$::tcl_platform(platform)=="windows"} { - append opts " -DSQLITE_OS_WIN=1" + append opts "OPTS += -DSQLITE_OS_WIN=1\n" set target "testfixture.exe" } elseif {$::tcl_platform(platform)=="os2"} { - append opts " -DSQLITE_OS_OS2=1" + append opts "OPTS += -DSQLITE_OS_OS2=1\n" } else { - append opts " -DSQLITE_OS_UNIX=1" + append opts "OPTS += -DSQLITE_OS_UNIX=1\n" } foreach sym $omit_symbol_list { - append opts " -D${sym}=1" + append opts "OPTS += -D${sym}=1\n" } # Create the directory and do the build. If an error occurs return @@ -68,12 +67,20 @@ proc run_quick_test {dir omit_symbol_list} { file mkdir $dir puts -nonewline "Building $dir..." flush stdout -catch { - file copy -force ./config.h $dir - file copy -force ./libtool $dir -} + catch { + file copy -force ./config.h $dir + file copy -force ./libtool $dir + } + set fd [open $::MAKEFILE] + set mkfile [read $fd] + close $fd + regsub {\ninclude} $mkfile "\n$opts\ninclude" mkfile + set fd [open $dir/makefile w] + puts $fd $mkfile + close $fd + set rc [catch { - exec $::MAKEBIN -C $dir -f $::MAKEFILE clean $target OPTS=$opts >& $dir/build.log + exec $::MAKEBIN -C $dir -f makefile clean $::TARGET >& $dir/build.log }] if {$rc} { puts "No good. See $dir/build.log." @@ -102,7 +109,7 @@ catch { puts -nonewline "Testing $dir..." flush stdout set rc [catch { - exec $::MAKEBIN -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log + exec $::MAKEBIN -C $dir -f makefile test >& $dir/test.log }] if {$rc} { puts "No good. See $dir/test.log." @@ -126,6 +133,7 @@ proc process_options {argv} { set ::MAKEFILE ./Makefile.linux-gcc ;# Default value } set ::SKIP_RUN 0 ;# Default to attempt test + set ::TARGET testfixture ;# Default thing to build for {set i 0} {$i < [llength $argv]} {incr i} { switch -- [lindex $argv $i] { @@ -139,6 +147,11 @@ proc process_options {argv} { set ::MAKEFILE ./Makefile.msc } + -target { + incr i + set ::TARGET [lindex $argv $i] + } + -skip_run { set ::SKIP_RUN 1 } @@ -182,7 +195,6 @@ proc main {argv} { SQLITE_OMIT_DATETIME_FUNCS \ SQLITE_OMIT_DECLTYPE \ SQLITE_OMIT_DEPRECATED \ - xxxSQLITE_OMIT_DISKIO \ SQLITE_OMIT_EXPLAIN \ SQLITE_OMIT_FLAG_PRAGMAS \ SQLITE_OMIT_FLOATING_POINT \ @@ -224,15 +236,11 @@ proc main {argv} { SQLITE_DISABLE_DIRSYNC \ SQLITE_DISABLE_LFS \ SQLITE_ENABLE_ATOMIC_WRITE \ - xxxSQLITE_ENABLE_CEROD \ SQLITE_ENABLE_COLUMN_METADATA \ SQLITE_ENABLE_EXPENSIVE_ASSERT \ - xxxSQLITE_ENABLE_FTS1 \ - xxxSQLITE_ENABLE_FTS2 \ SQLITE_ENABLE_FTS3 \ SQLITE_ENABLE_FTS3_PARENTHESIS \ SQLITE_ENABLE_FTS4 \ - xxxSQLITE_ENABLE_ICU \ SQLITE_ENABLE_IOTRACE \ SQLITE_ENABLE_LOAD_EXTENSION \ SQLITE_ENABLE_LOCKING_STYLE \ @@ -241,7 +249,7 @@ proc main {argv} { SQLITE_ENABLE_MEMSYS5 \ SQLITE_ENABLE_OVERSIZE_CELL_CHECK \ SQLITE_ENABLE_RTREE \ - SQLITE_ENABLE_STAT2 \ + SQLITE_ENABLE_STAT3 \ SQLITE_ENABLE_UNLOCK_NOTIFY \ SQLITE_ENABLE_UPDATE_DELETE_LIMIT \ ] From d337c5bde89344df122e2853c7547aad39356757 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 20 Oct 2011 18:23:35 +0000 Subject: [PATCH 49/51] Fix an issue with finding the access permissions of journal files when 8+3 filenames are in use. FossilOrigin-Name: 2b35c5144ddcc2ed6d0fcaa8c0ba5d20b9487be7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4592d79c10..d5fdd2bfa3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\sthe\somittest.tcl\sscript\sused\sto\sverify\sthat\sthe\nSQLITE_OMIT\scompile-time\soptions\sare\sworking. -D 2011-10-20T00:55:54.955 +C Fix\san\sissue\swith\sfinding\sthe\saccess\spermissions\sof\sjournal\sfiles\swhen\n8+3\sfilenames\sare\sin\suse. +D 2011-10-20T18:23:35.274 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os.c 5d9b02782ed36345348d6fe21d7762ed3a9cfd2a F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 1e7dcc176a6b1ec3dc3256b27a058459b35c2a73 +F src/os_unix.c ddda0b1c5ae536669634d7bff31b3f8f4d654866 F src/os_win.c 49d418916428a59d773f39993db0ecde56ab4c37 F src/pager.c 60c80db526d39286b913c824cf8303d34ab17a89 F src/pager.h dbcaa791e8b6c3a6b77c168c5c27deec289fb176 @@ -972,7 +972,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 1af4a25631c4077a9bfc64e15eb92fbf5146c89c -R f519850801e0581ab79d9a8c90ed8863 +P 4344483f7d7f64dffadde0053e6c745948db9486 +R 8791a00ec886d9269177e370bb87a885 U drh -Z f005e14c521f1568740d231c984f07e1 +Z bc76726412c4dd0d1fa3c4a2fb94fbb7 diff --git a/manifest.uuid b/manifest.uuid index 9127f8d266..ca4f8c9ff0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4344483f7d7f64dffadde0053e6c745948db9486 \ No newline at end of file +2b35c5144ddcc2ed6d0fcaa8c0ba5d20b9487be7 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 2e43eabf17..0ea6daf27f 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4874,13 +4874,13 @@ static int findCreateFileMode( ** "-journalNN" ** "-walNN" ** - ** where NN is a 4 digit decimal number. The NN naming schemes are + ** where NN is a decimal number. The NN naming schemes are ** used by the test_multiplex.c module. */ nDb = sqlite3Strlen30(zPath) - 1; #ifdef SQLITE_ENABLE_8_3_NAMES - while( nDb>0 && zPath[nDb]!='-' && zPath[nDb]!='/' ) nDb--; - if( nDb==0 || zPath[nDb]=='/' ) return SQLITE_OK; + while( nDb>0 && !sqlite3Isalnum(zPath[nDb]) ) nDb--; + if( nDb==0 || zPath[nDb]!='-' ) return SQLITE_OK; #else while( zPath[nDb]!='-' ){ assert( nDb>0 ); From 1a83bc5b1aa45ef2d2c31d2929a7d92b477eab9f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 21 Oct 2011 14:27:32 +0000 Subject: [PATCH 50/51] If an error occurs while writing to the database file during a VACUUM, discard the contents of the in-memory cache. This is required as if the database is a zipvfs database, the contents of the cache may be inconsistent with respect to the database as stored on disk. FossilOrigin-Name: 07159e84b40b01fa40cac5fad1f433888e5984f8 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/backup.c | 2 ++ src/pager.c | 7 +++++++ src/pager.h | 1 + 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index d5fdd2bfa3..a81a623e1c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sissue\swith\sfinding\sthe\saccess\spermissions\sof\sjournal\sfiles\swhen\n8+3\sfilenames\sare\sin\suse. -D 2011-10-20T18:23:35.274 +C If\san\serror\soccurs\swhile\swriting\sto\sthe\sdatabase\sfile\sduring\sa\sVACUUM,\sdiscard\sthe\scontents\sof\sthe\sin-memory\scache.\sThis\sis\srequired\sas\sif\sthe\sdatabase\sis\sa\szipvfs\sdatabase,\sthe\scontents\sof\sthe\scache\smay\sbe\sinconsistent\swith\srespect\sto\sthe\sdatabase\sas\sstored\son\sdisk. +D 2011-10-21T14:27:32.821 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -121,7 +121,7 @@ F src/alter.c ac80a0f31189f8b4a524ebf661e47e84536ee7f5 F src/analyze.c 682fd999a01c897a682365a459190758b83de836 F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 6c140bafcb4d09738421d54d06853aa2fccf9e19 +F src/backup.c 4368158da74d4711888e03264105c5c527d76caf F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 32199e2d939233ade25340eaba450f818b37c079 @@ -167,8 +167,8 @@ F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c ddda0b1c5ae536669634d7bff31b3f8f4d654866 F src/os_win.c 49d418916428a59d773f39993db0ecde56ab4c37 -F src/pager.c 60c80db526d39286b913c824cf8303d34ab17a89 -F src/pager.h dbcaa791e8b6c3a6b77c168c5c27deec289fb176 +F src/pager.c ad62daa0c21e27ae332b3ceb4f579a2a97046ddc +F src/pager.h 9f81b08efb06db4ba8be69446e10b005c351373d F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 49e718c095810c6b3334e3a6d89970aceaddefce F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 @@ -972,7 +972,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4344483f7d7f64dffadde0053e6c745948db9486 -R 8791a00ec886d9269177e370bb87a885 -U drh -Z bc76726412c4dd0d1fa3c4a2fb94fbb7 +P 2b35c5144ddcc2ed6d0fcaa8c0ba5d20b9487be7 +R 6634e59d536aa69184f81d4953f270aa +U dan +Z b63f5f0c2bfaf50eddb56fa49684523d diff --git a/manifest.uuid b/manifest.uuid index ca4f8c9ff0..7b208dab71 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2b35c5144ddcc2ed6d0fcaa8c0ba5d20b9487be7 \ No newline at end of file +07159e84b40b01fa40cac5fad1f433888e5984f8 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 893a40e4d4..bdf96bd8e1 100644 --- a/src/backup.c +++ b/src/backup.c @@ -704,6 +704,8 @@ int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ rc = sqlite3_backup_finish(&b); if( rc==SQLITE_OK ){ pTo->pBt->pageSizeFixed = 0; + }else{ + sqlite3PagerClearCache(sqlite3BtreePager(b.pDest)); } assert( sqlite3BtreeIsInTrans(pTo)==0 ); diff --git a/src/pager.c b/src/pager.c index 421a7094f1..63dda3ddff 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6836,6 +6836,13 @@ int sqlite3PagerCloseWal(Pager *pPager){ return rc; } +/* +** Unless this is an in-memory or temporary database, clear the pager cache. +*/ +void sqlite3PagerClearCache(Pager *pPager){ + if( !MEMDB && pPager->tempFile==0 ) pager_reset(pPager); +} + #ifdef SQLITE_HAS_CODEC /* ** This function is called by the wal module when writing page content diff --git a/src/pager.h b/src/pager.h index 540557248a..e36e6c2e86 100644 --- a/src/pager.h +++ b/src/pager.h @@ -156,6 +156,7 @@ int sqlite3PagerNosync(Pager*); void *sqlite3PagerTempSpace(Pager*); int sqlite3PagerIsMemdb(Pager*); void sqlite3PagerCacheStat(Pager *, int, int, int *); +void sqlite3PagerClearCache(Pager *); /* Functions used to truncate the database file. */ void sqlite3PagerTruncateImage(Pager*,Pgno); From f9b22ca4164e29b5ed0ae27894792b04abd87516 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 21 Oct 2011 16:47:31 +0000 Subject: [PATCH 51/51] Remove stale requirements marks from the query planner. FossilOrigin-Name: 76de9914bed11abda3898928633ad09d5a284f84 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/where.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index a81a623e1c..368c393f8f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\san\serror\soccurs\swhile\swriting\sto\sthe\sdatabase\sfile\sduring\sa\sVACUUM,\sdiscard\sthe\scontents\sof\sthe\sin-memory\scache.\sThis\sis\srequired\sas\sif\sthe\sdatabase\sis\sa\szipvfs\sdatabase,\sthe\scontents\sof\sthe\scache\smay\sbe\sinconsistent\swith\srespect\sto\sthe\sdatabase\sas\sstored\son\sdisk. -D 2011-10-21T14:27:32.821 +C Remove\sstale\srequirements\smarks\sfrom\sthe\squery\splanner. +D 2011-10-21T16:47:31.558 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -251,7 +251,7 @@ F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582 F src/wal.c 9658df8d404b82e6b2d40fd05944463214e2d935 F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c b617d9e1eda592fe6bb38748307440c80da90771 +F src/where.c 922145a39cf91a5dbb83bbc54f0e316f52023fa2 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 @@ -972,7 +972,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 2b35c5144ddcc2ed6d0fcaa8c0ba5d20b9487be7 -R 6634e59d536aa69184f81d4953f270aa -U dan -Z b63f5f0c2bfaf50eddb56fa49684523d +P 07159e84b40b01fa40cac5fad1f433888e5984f8 +R 59b3b1fdd8178d0f82d2b752104b93d8 +U drh +Z 3d414bcbeacde088fb044f861f268a3d diff --git a/manifest.uuid b/manifest.uuid index 7b208dab71..f4d78eed3e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -07159e84b40b01fa40cac5fad1f433888e5984f8 \ No newline at end of file +76de9914bed11abda3898928633ad09d5a284f84 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 2fc990f4c5..7a4b8bfaee 100644 --- a/src/where.c +++ b/src/where.c @@ -705,7 +705,7 @@ static int isLikeOrGlob( if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){ z = (char *)sqlite3_value_text(pVal); } - sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); /* IMP: R-31526-56213 */ + sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER ); }else if( op==TK_STRING ){ z = pRight->u.zToken; @@ -723,7 +723,7 @@ static int isLikeOrGlob( *ppPrefix = pPrefix; if( op==TK_VARIABLE ){ Vdbe *v = pParse->pVdbe; - sqlite3VdbeSetVarmask(v, pRight->iColumn); /* IMP: R-31526-56213 */ + sqlite3VdbeSetVarmask(v, pRight->iColumn); if( *pisComplete && pRight->u.zToken[1] ){ /* If the rhs of the LIKE expression is a variable, and the current ** value of the variable means there is no need to invoke the LIKE @@ -2637,7 +2637,7 @@ static int valueFromExpr( || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) ){ int iVar = pExpr->iColumn; - sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-31526-56213 */ + sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); return SQLITE_OK; }