summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLandry Breuil <landry@cvs.openbsd.org>2013-06-09 14:42:47 +0000
committerLandry Breuil <landry@cvs.openbsd.org>2013-06-09 14:42:47 +0000
commitf6d411e289d520a48fe3f71c06cd8c4b58699674 (patch)
tree32770a4a47740aca8be48211f0c050b6464b0839 /lib
parent89ecd126ef395f93a0f542ed684ec71f06c3a7f4 (diff)
Update to sqlite 3.7.17.
See for changes: http://www.sqlite.org/releaselog/3_7_16.html http://www.sqlite.org/releaselog/3_7_16_1.html http://www.sqlite.org/releaselog/3_7_16_2.html http://www.sqlite.org/releaselog/3_7_17.html tested by sebastia@ on vax & sparc, by myself on hppa/amd64/sparc64/sgi/i386/macppc. looks ok to espie@ (a lot of kittens died during the preparation of this cvs import)
Diffstat (limited to 'lib')
-rw-r--r--lib/libsqlite3/ext/fts3/fts3_tokenize_vtab.c2
-rw-r--r--lib/libsqlite3/ext/misc/fuzzer.c16
-rw-r--r--lib/libsqlite3/ext/misc/spellfix.c72
3 files changed, 23 insertions, 67 deletions
diff --git a/lib/libsqlite3/ext/fts3/fts3_tokenize_vtab.c b/lib/libsqlite3/ext/fts3/fts3_tokenize_vtab.c
index fb99f8b8064..364852ef82e 100644
--- a/lib/libsqlite3/ext/fts3/fts3_tokenize_vtab.c
+++ b/lib/libsqlite3/ext/fts3/fts3_tokenize_vtab.c
@@ -163,7 +163,7 @@ static int fts3tokConnectMethod(
sqlite3_vtab **ppVtab, /* OUT: New sqlite3_vtab object */
char **pzErr /* OUT: sqlite3_malloc'd error message */
){
- Fts3tokTable *pTab = 0;
+ Fts3tokTable *pTab;
const sqlite3_tokenizer_module *pMod = 0;
sqlite3_tokenizer *pTok = 0;
int rc;
diff --git a/lib/libsqlite3/ext/misc/fuzzer.c b/lib/libsqlite3/ext/misc/fuzzer.c
index dc03161aafa..642b8f9e92d 100644
--- a/lib/libsqlite3/ext/misc/fuzzer.c
+++ b/lib/libsqlite3/ext/misc/fuzzer.c
@@ -342,8 +342,7 @@ static int fuzzerLoadOneRule(
rc = SQLITE_NOMEM;
}else{
memset(pRule, 0, sizeof(*pRule));
- pRule->zFrom = pRule->zTo;
- pRule->zFrom += nTo + 1;
+ pRule->zFrom = &pRule->zTo[nTo+1];
pRule->nFrom = nFrom;
memcpy(pRule->zFrom, zFrom, nFrom+1);
memcpy(pRule->zTo, zTo, nTo+1);
@@ -1078,16 +1077,9 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
int iDistTerm = -1;
int iRulesetTerm = -1;
int i;
- int seenMatch = 0;
const struct sqlite3_index_constraint *pConstraint;
- double rCost = 1e12;
-
pConstraint = pIdxInfo->aConstraint;
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
- if( pConstraint->iColumn==0
- && pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH ){
- seenMatch = 1;
- }
if( pConstraint->usable==0 ) continue;
if( (iPlan & 1)==0
&& pConstraint->iColumn==0
@@ -1096,7 +1088,6 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
iPlan |= 1;
pIdxInfo->aConstraintUsage[i].argvIndex = 1;
pIdxInfo->aConstraintUsage[i].omit = 1;
- rCost /= 1e6;
}
if( (iPlan & 2)==0
&& pConstraint->iColumn==1
@@ -1105,7 +1096,6 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
iPlan |= 2;
iDistTerm = i;
- rCost /= 10.0;
}
if( (iPlan & 4)==0
&& pConstraint->iColumn==2
@@ -1114,7 +1104,6 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
iPlan |= 4;
pIdxInfo->aConstraintUsage[i].omit = 1;
iRulesetTerm = i;
- rCost /= 10.0;
}
}
if( iPlan & 2 ){
@@ -1133,8 +1122,7 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
pIdxInfo->orderByConsumed = 1;
}
- if( seenMatch && (iPlan&1)==0 ) rCost = 1e99;
- pIdxInfo->estimatedCost = rCost;
+ pIdxInfo->estimatedCost = (double)10000;
return SQLITE_OK;
}
diff --git a/lib/libsqlite3/ext/misc/spellfix.c b/lib/libsqlite3/ext/misc/spellfix.c
index a6f780584c2..eb5442ed2ff 100644
--- a/lib/libsqlite3/ext/misc/spellfix.c
+++ b/lib/libsqlite3/ext/misc/spellfix.c
@@ -26,8 +26,8 @@ SQLITE_EXTENSION_INIT1
# define NEVER(X) 0
typedef unsigned char u8;
typedef unsigned short u16;
+# include <ctype.h>
#endif
-#include <ctype.h>
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -356,7 +356,7 @@ static int substituteCost(char cPrev, char cFrom, char cTo){
static int editdist1(const char *zA, const char *zB, int *pnMatch){
int nA, nB; /* Number of characters in zA[] and zB[] */
int xA, xB; /* Loop counters for zA[] and zB[] */
- char cA = 0, cB; /* Current character of zA and zB */
+ char cA, cB; /* Current character of zA and zB */
char cAprev, cBprev; /* Previous character of zA and zB */
char cAnext, cBnext; /* Next character in zA and zB */
int d; /* North-west cost value */
@@ -1893,7 +1893,7 @@ static int spellfix1Init(
char **pzErr
){
spellfix1_vtab *pNew = 0;
- /* const char *zModule = argv[0]; // not used */
+ const char *zModule = argv[0];
const char *zDbName = argv[1];
const char *zTableName = argv[2];
int nDbName;
@@ -1933,6 +1933,7 @@ static int spellfix1Init(
#define SPELLFIX_COL_COMMAND 11
}
if( rc==SQLITE_OK && isCreate ){
+ sqlite3_uint64 r;
spellfix1DbExec(&rc, db,
"CREATE TABLE IF NOT EXISTS \"%w\".\"%w_vocab\"(\n"
" id INTEGER PRIMARY KEY,\n"
@@ -1944,10 +1945,11 @@ static int spellfix1Init(
");\n",
zDbName, zTableName
);
+ sqlite3_randomness(sizeof(r), &r);
spellfix1DbExec(&rc, db,
- "CREATE INDEX IF NOT EXISTS \"%w\".\"%w_vocab_index_langid_k2\" "
+ "CREATE INDEX IF NOT EXISTS \"%w\".\"%w_index_%llx\" "
"ON \"%w_vocab\"(langid,k2);",
- zDbName, zTableName, zTableName
+ zDbName, zModule, r, zTableName
);
}
for(i=3; rc==SQLITE_OK && i<argc; i++){
@@ -2049,7 +2051,6 @@ static int spellfix1Close(sqlite3_vtab_cursor *cur){
** (D) scope = $scope
** (E) distance < $distance
** (F) distance <= $distance
-** (G) rowid = $rowid
**
** The plan number is a bit mask formed with these bits:
**
@@ -2059,9 +2060,8 @@ static int spellfix1Close(sqlite3_vtab_cursor *cur){
** 0x08 (D) is found
** 0x10 (E) is found
** 0x20 (F) is found
-** 0x40 (G) is found
**
-** filter.argv[*] values contains $str, $langid, $top, $scope and $rowid
+** filter.argv[*] values contains $str, $langid, $top, and $scope,
** if specified and in that order.
*/
static int spellfix1BestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
@@ -2070,7 +2070,6 @@ static int spellfix1BestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
int iTopTerm = -1;
int iScopeTerm = -1;
int iDistTerm = -1;
- int iRowidTerm = -1;
int i;
const struct sqlite3_index_constraint *pConstraint;
pConstraint = pIdxInfo->aConstraint;
@@ -2123,15 +2122,6 @@ static int spellfix1BestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
iPlan |= pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT ? 16 : 32;
iDistTerm = i;
}
-
- /* Terms of the form: distance < $dist or distance <= $dist */
- if( (iPlan & 64)==0
- && pConstraint->iColumn<0
- && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ
- ){
- iPlan |= 64;
- iRowidTerm = i;
- }
}
if( iPlan&1 ){
int idx = 2;
@@ -2158,15 +2148,10 @@ static int spellfix1BestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
pIdxInfo->aConstraintUsage[iDistTerm].argvIndex = idx++;
pIdxInfo->aConstraintUsage[iDistTerm].omit = 1;
}
- pIdxInfo->estimatedCost = 1e5;
- }else if( (iPlan & 64) ){
- pIdxInfo->idxNum = 64;
- pIdxInfo->aConstraintUsage[iRowidTerm].argvIndex = 1;
- pIdxInfo->aConstraintUsage[iRowidTerm].omit = 1;
- pIdxInfo->estimatedCost = 5;
+ pIdxInfo->estimatedCost = (double)10000;
}else{
pIdxInfo->idxNum = 0;
- pIdxInfo->estimatedCost = 1e50;
+ pIdxInfo->estimatedCost = (double)10000000;
}
return SQLITE_OK;
}
@@ -2480,23 +2465,16 @@ static int spellfix1FilterForFullScan(
int argc,
sqlite3_value **argv
){
- int rc = SQLITE_OK;
+ int rc;
char *zSql;
spellfix1_vtab *pVTab = pCur->pVTab;
spellfix1ResetCursor(pCur);
- assert( idxNum==0 || idxNum==64 );
zSql = sqlite3_mprintf(
- "SELECT word, rank, NULL, langid, id FROM \"%w\".\"%w_vocab\"%s",
- pVTab->zDbName, pVTab->zTableName,
- ((idxNum & 64) ? " WHERE rowid=?" : "")
- );
+ "SELECT word, rank, NULL, langid, id FROM \"%w\".\"%w_vocab\"",
+ pVTab->zDbName, pVTab->zTableName);
if( zSql==0 ) return SQLITE_NOMEM;
rc = sqlite3_prepare_v2(pVTab->db, zSql, -1, &pCur->pFullScan, 0);
sqlite3_free(zSql);
- if( rc==SQLITE_OK && (idxNum & 64) ){
- assert( argc==1 );
- rc = sqlite3_bind_value(pCur->pFullScan, 1, argv[0]);
- }
pCur->nRow = pCur->iRow = 0;
if( rc==SQLITE_OK ){
rc = sqlite3_step(pCur->pFullScan);
@@ -2694,7 +2672,7 @@ static int spellfix1Update(
const char *zCmd =
(const char*)sqlite3_value_text(argv[SPELLFIX_COL_COMMAND+2]);
if( zCmd==0 ){
- pVTab->zErrMsg = sqlite3_mprintf("NOT NULL constraint failed: %s.word",
+ pVTab->zErrMsg = sqlite3_mprintf("%s.word may not be NULL",
p->zTableName);
return SQLITE_CONSTRAINT_NOTNULL;
}
@@ -2736,22 +2714,12 @@ static int spellfix1Update(
return SQLITE_NOMEM;
}
if( sqlite3_value_type(argv[0])==SQLITE_NULL ){
- if( sqlite3_value_type(argv[1])==SQLITE_NULL ){
- spellfix1DbExec(&rc, db,
- "INSERT INTO \"%w\".\"%w_vocab\"(rank,langid,word,k1,k2) "
- "VALUES(%d,%d,%Q,%Q,%Q)",
- p->zDbName, p->zTableName,
- iRank, iLang, zWord, zK1, zK2
- );
- }else{
- newRowid = sqlite3_value_int64(argv[1]);
- spellfix1DbExec(&rc, db,
- "INSERT INTO \"%w\".\"%w_vocab\"(id,rank,langid,word,k1,k2) "
- "VALUES(%lld,%d,%d,%Q,%Q,%Q)",
- p->zDbName, p->zTableName,
- newRowid, iRank, iLang, zWord, zK1, zK2
- );
- }
+ spellfix1DbExec(&rc, db,
+ "INSERT INTO \"%w\".\"%w_vocab\"(rank,langid,word,k1,k2) "
+ "VALUES(%d,%d,%Q,%Q,%Q)",
+ p->zDbName, p->zTableName,
+ iRank, iLang, zWord, zK1, zK2
+ );
*pRowid = sqlite3_last_insert_rowid(db);
}else{
rowid = sqlite3_value_int64(argv[0]);