Merge in the latest changes from trunk. Simplify the implementation of the

tointeger() and toreal() functions.  Fix test cases and put unambiguous
labels on all testcase names.

FossilOrigin-Name: 9b837b0508fbfb395f0a0d8e4bd127730c80ffc5
This commit is contained in:
drh 2013-06-21 19:29:33 +00:00
commit 0057a74675
11 changed files with 430 additions and 247 deletions

View File

@ -1081,6 +1081,8 @@ static int fts3InitVtab(
char *zUncompress = 0; /* uncompress=? parameter (or NULL) */
char *zContent = 0; /* content=? parameter (or NULL) */
char *zLanguageid = 0; /* languageid=? parameter (or NULL) */
char **azNotindexed = 0; /* The set of notindexed= columns */
int nNotindexed = 0; /* Size of azNotindexed[] array */
assert( strlen(argv[0])==4 );
assert( (sqlite3_strnicmp(argv[0], "fts4", 4)==0 && isFts4)
@ -1090,9 +1092,19 @@ static int fts3InitVtab(
nDb = (int)strlen(argv[1]) + 1;
nName = (int)strlen(argv[2]) + 1;
aCol = (const char **)sqlite3_malloc(sizeof(const char *) * (argc-2) );
if( !aCol ) return SQLITE_NOMEM;
memset((void *)aCol, 0, sizeof(const char *) * (argc-2));
nByte = sizeof(const char *) * (argc-2);
aCol = (const char **)sqlite3_malloc(nByte);
if( aCol ){
memset(aCol, 0, nByte);
azNotindexed = (char **)sqlite3_malloc(nByte);
}
if( azNotindexed ){
memset(azNotindexed, 0, nByte);
}
if( !aCol || !azNotindexed ){
rc = SQLITE_NOMEM;
goto fts3_init_out;
}
/* Loop through all of the arguments passed by the user to the FTS3/4
** module (i.e. all the column names and special arguments). This loop
@ -1131,7 +1143,8 @@ static int fts3InitVtab(
{ "uncompress", 10 }, /* 3 -> UNCOMPRESS */
{ "order", 5 }, /* 4 -> ORDER */
{ "content", 7 }, /* 5 -> CONTENT */
{ "languageid", 10 } /* 6 -> LANGUAGEID */
{ "languageid", 10 }, /* 6 -> LANGUAGEID */
{ "notindexed", 10 } /* 7 -> NOTINDEXED */
};
int iOpt;
@ -1197,6 +1210,11 @@ static int fts3InitVtab(
zLanguageid = zVal;
zVal = 0;
break;
case 7: /* NOTINDEXED */
azNotindexed[nNotindexed++] = zVal;
zVal = 0;
break;
}
}
sqlite3_free(zVal);
@ -1268,6 +1286,7 @@ static int fts3InitVtab(
nByte = sizeof(Fts3Table) + /* Fts3Table */
nCol * sizeof(char *) + /* azColumn */
nIndex * sizeof(struct Fts3Index) + /* aIndex */
nCol * sizeof(u8) + /* abNotindexed */
nName + /* zName */
nDb + /* zDb */
nString; /* Space for azColumn strings */
@ -1301,9 +1320,10 @@ static int fts3InitVtab(
for(i=0; i<nIndex; i++){
fts3HashInit(&p->aIndex[i].hPending, FTS3_HASH_STRING, 1);
}
p->abNotindexed = (u8 *)&p->aIndex[nIndex];
/* Fill in the zName and zDb fields of the vtab structure. */
zCsr = (char *)&p->aIndex[nIndex];
zCsr = (char *)&p->abNotindexed[nCol];
p->zName = zCsr;
memcpy(zCsr, argv[2], nName);
zCsr += nName;
@ -1324,7 +1344,26 @@ static int fts3InitVtab(
assert( zCsr <= &((char *)p)[nByte] );
}
if( (zCompress==0)!=(zUncompress==0) ){
/* Fill in the abNotindexed array */
for(iCol=0; iCol<nCol; iCol++){
int n = strlen(p->azColumn[iCol]);
for(i=0; i<nNotindexed; i++){
char *zNot = azNotindexed[i];
if( zNot && 0==sqlite3_strnicmp(p->azColumn[iCol], zNot, n) ){
p->abNotindexed[iCol] = 1;
sqlite3_free(zNot);
azNotindexed[i] = 0;
}
}
}
for(i=0; i<nNotindexed; i++){
if( azNotindexed[i] ){
*pzErr = sqlite3_mprintf("no such column: %s", azNotindexed[i]);
rc = SQLITE_ERROR;
}
}
if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){
char const *zMiss = (zCompress==0 ? "compress" : "uncompress");
rc = SQLITE_ERROR;
*pzErr = sqlite3_mprintf("missing %s parameter in fts4 constructor", zMiss);
@ -1365,7 +1404,9 @@ fts3_init_out:
sqlite3_free(zUncompress);
sqlite3_free(zContent);
sqlite3_free(zLanguageid);
for(i=0; i<nNotindexed; i++) sqlite3_free(azNotindexed[i]);
sqlite3_free((void *)aCol);
sqlite3_free((void *)azNotindexed);
if( rc!=SQLITE_OK ){
if( p ){
fts3DisconnectMethod((sqlite3_vtab *)p);

View File

@ -206,6 +206,7 @@ struct Fts3Table {
const char *zName; /* virtual table name */
int nColumn; /* number of named columns in virtual table */
char **azColumn; /* column names. malloced */
u8 *abNotindexed; /* True for 'notindexed' columns */
sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
char *zContentTbl; /* content=xxx option, or NULL */
char *zLanguageid; /* languageid=xxx option, or NULL */
@ -433,7 +434,6 @@ int sqlite3Fts3SegReaderPending(
Fts3Table*,int,const char*,int,int,Fts3SegReader**);
void sqlite3Fts3SegReaderFree(Fts3SegReader *);
int sqlite3Fts3AllSegdirs(Fts3Table*, int, int, int, sqlite3_stmt **);
int sqlite3Fts3ReadLock(Fts3Table *);
int sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char **, int*, int*);
int sqlite3Fts3SelectDoctotal(Fts3Table *, sqlite3_stmt **);

View File

@ -900,12 +900,15 @@ static int fts3InsertTerms(
){
int i; /* Iterator variable */
for(i=2; i<p->nColumn+2; i++){
const char *zText = (const char *)sqlite3_value_text(apVal[i]);
int rc = fts3PendingTermsAdd(p, iLangid, zText, i-2, &aSz[i-2]);
if( rc!=SQLITE_OK ){
return rc;
int iCol = i-2;
if( p->abNotindexed[iCol]==0 ){
const char *zText = (const char *)sqlite3_value_text(apVal[i]);
int rc = fts3PendingTermsAdd(p, iLangid, zText, iCol, &aSz[iCol]);
if( rc!=SQLITE_OK ){
return rc;
}
aSz[p->nColumn] += sqlite3_value_bytes(apVal[i]);
}
aSz[p->nColumn] += sqlite3_value_bytes(apVal[i]);
}
return SQLITE_OK;
}
@ -1052,9 +1055,12 @@ static void fts3DeleteTerms(
int iLangid = langidFromSelect(p, pSelect);
rc = fts3PendingTermsDocid(p, iLangid, sqlite3_column_int64(pSelect, 0));
for(i=1; rc==SQLITE_OK && i<=p->nColumn; i++){
const char *zText = (const char *)sqlite3_column_text(pSelect, i);
rc = fts3PendingTermsAdd(p, iLangid, zText, -1, &aSz[i-1]);
aSz[p->nColumn] += sqlite3_column_bytes(pSelect, i);
int iCol = i-1;
if( p->abNotindexed[iCol]==0 ){
const char *zText = (const char *)sqlite3_column_text(pSelect, i);
rc = fts3PendingTermsAdd(p, iLangid, zText, -1, &aSz[iCol]);
aSz[p->nColumn] += sqlite3_column_bytes(pSelect, i);
}
}
if( rc!=SQLITE_OK ){
sqlite3_reset(pSelect);
@ -3296,9 +3302,11 @@ static int fts3DoRebuild(Fts3Table *p){
rc = fts3PendingTermsDocid(p, iLangid, sqlite3_column_int64(pStmt, 0));
memset(aSz, 0, sizeof(aSz[0]) * (p->nColumn+1));
for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);
rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);
aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);
if( p->abNotindexed[iCol]==0 ){
const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);
rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);
aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);
}
}
if( p->bHasDocsize ){
fts3InsertDocsize(&rc, p, aSz);
@ -5101,35 +5109,37 @@ int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *pCsr){
iDocid = sqlite3_column_int64(pCsr->pStmt, 0);
for(i=0; i<p->nColumn && rc==SQLITE_OK; i++){
const char *zText = (const char *)sqlite3_column_text(pCsr->pStmt, i+1);
sqlite3_tokenizer_cursor *pTC = 0;
rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);
while( rc==SQLITE_OK ){
char const *zToken; /* Buffer containing token */
int nToken = 0; /* Number of bytes in token */
int iDum1 = 0, iDum2 = 0; /* Dummy variables */
int iPos = 0; /* Position of token in zText */
rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);
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->n<nToken))
&& (0==memcmp(zToken, pPT->z, pPT->n))
){
fts3PendingListAppend(&pDef->pList, iDocid, i, iPos, &rc);
if( p->abNotindexed[i]==0 ){
const char *zText = (const char *)sqlite3_column_text(pCsr->pStmt, i+1);
sqlite3_tokenizer_cursor *pTC = 0;
rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);
while( rc==SQLITE_OK ){
char const *zToken; /* Buffer containing token */
int nToken = 0; /* Number of bytes in token */
int iDum1 = 0, iDum2 = 0; /* Dummy variables */
int iPos = 0; /* Position of token in zText */
rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);
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->n<nToken))
&& (0==memcmp(zToken, pPT->z, pPT->n))
){
fts3PendingListAppend(&pDef->pList, iDocid, i, iPos, &rc);
}
}
}
if( pTC ) pModule->xClose(pTC);
if( rc==SQLITE_DONE ) rc = SQLITE_OK;
}
if( pTC ) pModule->xClose(pTC);
if( rc==SQLITE_DONE ) rc = SQLITE_OK;
}
for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){
if( pDef->pList ){
rc = fts3PendingListAppendVarint(&pDef->pList, 0);
for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){
if( pDef->pList ){
rc = fts3PendingListAppendVarint(&pDef->pList, 0);
}
}
}
}

View File

@ -1,5 +1,5 @@
C Merge\supdates\sfrom\strunk.
D 2013-06-21T18:32:11.955
C Merge\sin\sthe\slatest\schanges\sfrom\strunk.\s\sSimplify\sthe\simplementation\sof\sthe\ntointeger()\sand\storeal()\sfunctions.\s\sFix\stest\scases\sand\sput\sunambiguous\nlabels\son\sall\stestcase\snames.
D 2013-06-21T19:29:33.743
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -78,9 +78,9 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c 931b3c83abdd1ab3bb389b2130431c2a9ff73b91
F ext/fts3/fts3.c 3cb4afd0accf903fbe66e2cc48d6f44e5ccb8a76
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h cb4df04cf886d9920a71df9e8faaa5aae2fa48c6
F ext/fts3/fts3Int.h a50cd231e906da818f00f0a81845bbf7bbeba002
F ext/fts3/fts3_aux.c b02632f6dd0e375ce97870206d914ea6d8df5ccd
F ext/fts3/fts3_expr.c f8eb1046063ba342c7114eba175cabb31c4a64e7
F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914
@ -96,7 +96,7 @@ F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3
F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
F ext/fts3/fts3_unicode.c 92391b4b4fb043564c6539ea9b8661e3bcba47b9
F ext/fts3/fts3_unicode2.c 0113d3acf13429e6dc38e0647d1bc71211c31a4d
F ext/fts3/fts3_write.c 6a1fc0e922e76b68e594bf7bc33bac72af9dc47b
F ext/fts3/fts3_write.c cd264daa4f92b8eb6d61245333d0e3b147e8fd80
F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
F ext/fts3/tool/fts3view.c 6cfc5b67a5f0e09c0d698f9fd012c784bfaa9197
@ -174,7 +174,7 @@ F src/delete.c aeabdabeeeaa0584127f291baa9617153d334778
F src/expr.c ac9d259eea3123faa05fabe6dd8717696aca72b1
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179
F src/func.c 771ceaa9b3e8e3a4ee55839b03e5f99ddf300c1d
F src/func.c 835168be942c8c18a6c6b3b78462bc378d25c7b4
F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759
F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22
@ -220,7 +220,7 @@ F src/shell.c ab6eea968c8745be3aa74e45fedb37d057b4cd0d
F src/sqlite.h.in 5b390ca5d94e09e56e7fee6a51ddde4721b89f8e
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h d936f797812c28b81b26ed18345baf8db28a21a5
F src/sqliteInt.h c3279fe5faf68ba7faaf0263514dca3017399b03
F src/sqliteInt.h 46fb17f604ce941551fe64c342dbeb4dbed3edaa
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@ -530,7 +530,7 @@ F test/fts3expr3.test 1bfb762b53a794f990f3dffaae8bbea5736422f7
F test/fts3fault.test cb72dccb0a3b9f730f16c5240f3fcb9303eb1660
F test/fts3fault2.test 3198eef2804deea7cac8403e771d9cbcb752d887
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
F test/fts3malloc.test b86ea33db9e8c58c0c2f8027a9fcadaf6a1568be
F test/fts3malloc.test 1e3df7598534e77a7072aad610d46554cface3e9
F test/fts3matchinfo.test ecb08f586d027eb03941bcfcded6cb9d8ccb3a66
F test/fts3near.test 12895557870b0f9af7cc0be81a0171abb2d12f12
F test/fts3prefix.test b36d4f00b128a51e7b386cc013a874246d9d7dc1
@ -550,12 +550,13 @@ F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee
F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891
F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7
F test/fts4merge4.test c19c85ca1faa7b6d536832b49c12e1867235f584
F test/fts4noti.test aed33ba44808852dcb24bf70fa132e7bf530f057
F test/fts4unicode.test c8ac44217bf6c17812b03eaafa6c06995ad304c2
F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
F test/func.test b0fc34fdc36897769651975a2b0a606312753643
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a
F test/func4.test cf09a622b456d3e2f33a3fb1a2be8eec7a8e35e2
F test/func4.test 0e2d0e295bc9093676c6e34ff6e33e2541417985
F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74
F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6
F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167
@ -707,7 +708,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/percentile.test 4614301e38398df7fdd5f28f4ed8f272b328251b
F test/permutations.test d997a947ab8aabb15f763d50a030b3c11e8ef1b6
F test/permutations.test 7161be2569550924a8a437272acabfe9e6f48b86
F test/pragma.test 5e7de6c32a5d764f09437d2025f07e4917b9e178
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
@ -1094,7 +1095,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P 6fbad957259eb8c15eaf7e5657240ae24aaf343e b674462243138fcee192ef05d434665e30c681c4
R 612ff5a12d31b338ed757ecbce2de7e8
U mistachkin
Z d50d5563e695cb5fa48c05a0f64143b0
P fa2a91e6c631864846484d13cffdc51856953cd1 096ae1d8f9a08f92daedece6b0615f4d22b05023
R 6ba2737cc75280e9c7b2e803134db342
U drh
Z 3e127bc98d3edb650de7203bad06de46

View File

@ -1 +1 @@
fa2a91e6c631864846484d13cffdc51856953cd1
9b837b0508fbfb395f0a0d8e4bd127730c80ffc5

View File

@ -19,9 +19,6 @@
#include "sqliteInt.h"
#include <stdlib.h>
#include <assert.h>
#ifndef SQLITE_OMIT_FLOATING_POINT
# include <math.h>
#endif
#include "vdbeInt.h"
/*
@ -969,19 +966,9 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
}
/*
** EXPERIMENTAL - This is not an official function. The interface may
** change. This function may disappear. Do not write code that depends
** on this function.
**
** Implementation of the tointeger() function. This function takes a
** single argument. If the argument is an integer or is a double that
** can be losslessly converted to an integer, the return value is the
** same as the argument. If the argument is a double that cannot be
** losslessly represented as an integer, the return value is NULL.
** If the argument is NULL, the return value is NULL. Otherwise, an
** attempt is made to convert the argument to an integer. If the
** conversion is successful, the integer value is returned; otherwise,
** NULL is returned.
** tointeger(X): If X is any value (integer, double, or string) that can
** be losslessly converted into an integer, then make the conversion and
** return the result. Otherwise, return NULL.
*/
static void tointegerFunc(
sqlite3_context *context,
@ -991,20 +978,14 @@ static void tointegerFunc(
assert( argc==1 );
UNUSED_PARAMETER(argc);
switch( sqlite3_value_type(argv[0]) ){
case SQLITE_FLOAT:
#ifndef SQLITE_OMIT_FLOATING_POINT
{
case SQLITE_FLOAT: {
double rVal = sqlite3_value_double(argv[0]);
double rIntVal = 0.0;
if( !sqlite3IsNaN(rVal) && modf(rVal, &rIntVal)==0.0 &&
rIntVal>=SMALLEST_INT64 && rIntVal<=LARGEST_INT64 ){
sqlite3_result_int64(context, (i64)rIntVal);
return;
i64 iVal = (i64)rVal;
if( !sqlite3IsNaN(rVal) && rVal==(double)iVal ){
sqlite3_result_int64(context, iVal);
}
sqlite3_result_null(context);
break;
}
#endif
case SQLITE_INTEGER: {
sqlite3_result_int64(context, sqlite3_value_int64(argv[0]));
break;
@ -1018,37 +999,22 @@ static void tointegerFunc(
i64 iVal;
if( !sqlite3Atoi64(zStr, &iVal, nStr, SQLITE_UTF8) ){
sqlite3_result_int64(context, iVal);
return;
}
}
}
sqlite3_result_null(context);
break;
}
default: {
assert( sqlite3_value_type(argv[0])==SQLITE_NULL );
sqlite3_result_null(context);
break;
}
}
}
/*
** EXPERIMENTAL - This is not an official function. The interface may
** change. This function may disappear. Do not write code that depends
** on this function.
**
** Implementation of the toreal() function. This function takes a
** single argument. If the argument is a double or is an integer that
** can be losslessly converted to a double, the return value is the
** same as the argument. If the argument is an integer that cannot be
** losslessly represented as a double, the return value is NULL.
** If the argument is NULL, the return value is NULL. Otherwise, an
** attempt is made to convert the argument to a double. If the
** conversion is successful, the double value is returned; otherwise,
** NULL is returned.
** toreal(X): If X can be losslessly converted into a real number, then
** do so and return that real number. Otherwise return NULL.
*/
#ifndef SQLITE_OMIT_FLOATING_POINT
static void torealFunc(
sqlite3_context *context,
int argc,
@ -1066,9 +1032,7 @@ static void torealFunc(
double rVal = (double)iVal;
if( iVal==rVal ){
sqlite3_result_double(context, rVal);
return;
}
sqlite3_result_null(context);
break;
}
case SQLITE_BLOB:
@ -1084,17 +1048,14 @@ static void torealFunc(
}
}
}
sqlite3_result_null(context);
break;
}
default: {
assert( sqlite3_value_type(argv[0])==SQLITE_NULL );
sqlite3_result_null(context);
break;
}
}
}
#endif
/*
** The unicode() function. Return the integer unicode code-point value
@ -1805,9 +1766,7 @@ void sqlite3RegisterGlobalFunctions(void){
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
FUNCTION(quote, 1, 0, 0, quoteFunc ),
FUNCTION(tointeger, 1, 0, 0, tointegerFunc ),
#ifndef SQLITE_OMIT_FLOATING_POINT
FUNCTION(toreal, 1, 0, 0, torealFunc ),
#endif
FUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid),
FUNCTION(changes, 0, 0, 0, changes ),
FUNCTION(total_changes, 0, 0, 0, total_changes ),

View File

@ -343,8 +343,6 @@
# define SQLITE_OMIT_TRACE 1
# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
# undef SQLITE_HAVE_ISNAN
#else
# include <math.h>
#endif
#ifndef SQLITE_BIG_DBL
# define SQLITE_BIG_DBL (1e99)

View File

@ -62,6 +62,9 @@ do_error_test fts3_malloc-1.5 {
do_write_test fts3_malloc-1.6 sqlite_master {
CREATE VIRTUAL TABLE ft6 USING fts3(a, b, tokenize porter)
}
do_write_test fts3_malloc-1.7 sqlite_master {
CREATE VIRTUAL TABLE ft7 USING fts4(a, b, notindexed=b)
}
# Test the xConnect/xDisconnect methods:
#db eval { ATTACH 'test2.db' AS aux }
@ -81,6 +84,7 @@ do_test fts3_malloc-2.0 {
DROP TABLE ft3;
DROP TABLE ft4;
DROP TABLE ft6;
DROP TABLE ft7;
}
execsql { CREATE VIRTUAL TABLE ft USING fts3(a, b) }
for {set ii 1} {$ii < 32} {incr ii} {

171
test/fts4noti.test Normal file
View File

@ -0,0 +1,171 @@
# 2013 June 21
#
# 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 notindexed=xxx FTS4 option.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix fts4noti
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
finish_test
return
}
#-------------------------------------------------------------------------
# Test that typos in "notindexed=" column names are detected.
#
do_execsql_test 1.0 {
CREATE TABLE cc(a, b, c);
}
foreach {tn arg res} {
1 "(b, c, notindexed=a)" {1 {no such column: a}}
2 "(a, b, notindexed=a)" {0 {}}
3 "(a, b, notindexed=a, notindexed=a)" {0 {}}
4 "(notindexed=a, a, b)" {0 {}}
5 "(notindexed=a, notindexed=b, notindexed=c, a, b, c, d)" {0 {}}
6 "(notindexed=a, notindexed=B, notindexed=c, a, b, c, d)" {0 {}}
7 "(notindexed=a, notindexed=b, notindexed=c, a, B, c, d)" {0 {}}
8 "(notindexed=d, content=cc)" {1 {no such column: d}}
9 "(notindexed=a, content=cc)" {0 {}}
10 "(notindexed=a, notindexed=b, a)" {1 {no such column: b}}
11 "(notindexed=a, notindexed=b, b)" {1 {no such column: a}}
} {
do_catchsql_test 1.$tn "CREATE VIRTUAL TABLE t1 USING fts4 $arg" $res
if {[lindex $res 0]==0} { execsql "DROP TABLE t1" }
}
do_execsql_test 1.x { SELECT name FROM sqlite_master } {cc}
#-------------------------------------------------------------------------
# Test that notindexed columns are not indexed.
#
foreach {tn schema} {
1 {
CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, notindexed=b);
}
2 {
CREATE TABLE c1(a, b, c);
INSERT INTO c1 VALUES('one two', 'three four', 'five six');
INSERT INTO c1 VALUES('three four', 'five six', 'one two');
CREATE VIRTUAL TABLE t1 USING fts4(content=c1, notindexed=b);
}
3 {
CREATE VIRTUAL TABLE t1 USING fts4(content="", a, b, c, notindexed=b);
}
} {
execsql $schema
do_execsql_test 2.$tn.1 {
INSERT INTO t1(docid,a,b,c) VALUES(1, 'one two', 'three four', 'five six');
INSERT INTO t1(docid,a,b,c) VALUES(2, 'three four', 'five six', 'one two');
}
do_execsql_test 2.$tn.2 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.$tn.3 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.$tn.4 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
do_execsql_test 2.$tn.5 { INSERT INTO t1(t1) VALUES('optimize') }
do_execsql_test 2.$tn.6 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.$tn.7 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.$tn.8 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
if {$tn!=3} {
do_execsql_test 2.$tn.9 { INSERT INTO t1(t1) VALUES('rebuild') }
do_execsql_test 2.$tn.10 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}
do_execsql_test 2.$tn.11 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}
do_execsql_test 2.$tn.12 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}
do_execsql_test 2.$tn.13 {
SELECT a,b,c FROM t1 WHERE docid=1
} {{one two} {three four} {five six}}
do_execsql_test 2.$tn.14 {
SELECT a,b,c FROM t1 WHERE docid=2
} {{three four} {five six} {one two}}
}
do_execsql_test 2.x { DROP TABLE t1 }
}
#-------------------------------------------------------------------------
# Test that notindexed columns are not scanned for deferred tokens.
#
do_execsql_test 3.1 {
CREATE VIRTUAL TABLE t2 USING fts4(x, y, notindexed=x);
}
do_test 3.2 {
set v [string repeat " 1" 50000]
set v1 "x $v"
set v2 "y $v"
execsql {
INSERT INTO t2 VALUES(1, 'x y z');
INSERT INTO t2 VALUES(2, $v1);
INSERT INTO t2 VALUES(3, $v2);
INSERT INTO t2 VALUES(4, $v2);
INSERT INTO t2 VALUES(5, $v2);
INSERT INTO t2 VALUES(6, $v2);
}
} {}
do_execsql_test 3.3 { SELECT x FROM t2 WHERE t2 MATCH '2' } {}
do_execsql_test 3.4 { SELECT x FROM t2 WHERE t2 MATCH '1' } {2 3 4 5 6}
do_execsql_test 3.5 { SELECT x FROM t2 WHERE t2 MATCH 'x' } {1 2}
do_execsql_test 3.6 { SELECT x FROM t2 WHERE t2 MATCH 'x 1' } {2}
do_execsql_test 3.x { DROP TABLE t2 }
#-------------------------------------------------------------------------
# Test that the types of notindexed columns are not modified.
#
do_execsql_test 4.1 {
CREATE VIRTUAL TABLE t2 USING fts4(poi, addr, notindexed=poi);
INSERT INTO t2 VALUES(114, 'x x x');
INSERT INTO t2 VALUES(X'1234', 'y y y');
INSERT INTO t2 VALUES(NULL, 'z z z');
INSERT INTO t2 VALUES(113.2, 'w w w');
INSERT INTO t2 VALUES('poi', 'v v v');
}
do_execsql_test 4.2 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'x' } {integer}
do_execsql_test 4.3 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'y' } {blob}
do_execsql_test 4.4 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'z' } {null}
do_execsql_test 4.5 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'w' } {real}
do_execsql_test 4.6 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'v' } {text}
do_execsql_test 4.x { DROP TABLE t2 }
#-------------------------------------------------------------------------
# Test that multiple notindexed options on a single table work as expected.
#
do_execsql_test 5.1 {
CREATE VIRTUAL TABLE t2 USING fts4(
notindexed="three", one, two, three, notindexed="one",
);
INSERT INTO t2 VALUES('a', 'b', 'c');
INSERT INTO t2 VALUES('c', 'a', 'b');
INSERT INTO t2 VALUES('b', 'c', 'a');
}
do_execsql_test 5.2 { SELECT docid FROM t2 WHERE t2 MATCH 'a' } {2}
do_execsql_test 5.3 { SELECT docid FROM t2 WHERE t2 MATCH 'b' } {1}
do_execsql_test 5.4 { SELECT docid FROM t2 WHERE t2 MATCH 'c' } {3}
do_execsql_test 5.x { DROP TABLE t2 }
finish_test

View File

@ -15,465 +15,464 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set i 0
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.1 {
SELECT tointeger(NULL);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.2 {
SELECT tointeger('');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.3 {
SELECT tointeger(' ');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.4 {
SELECT tointeger('1234');
} {1234}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.5 {
SELECT tointeger(' 1234');
} {1234}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.6 {
SELECT tointeger('bad');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.7 {
SELECT tointeger('0xBAD');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.8 {
SELECT tointeger('123BAD');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.9 {
SELECT tointeger('0x123BAD');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.10 {
SELECT tointeger('123NO');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.11 {
SELECT tointeger('0x123NO');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.12 {
SELECT tointeger('-0x1');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.13 {
SELECT tointeger('-0x0');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.14 {
SELECT tointeger('0x0');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.15 {
SELECT tointeger('0x1');
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.16 {
SELECT tointeger(-1);
} {-1}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.17 {
SELECT tointeger(-0);
} {0}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.18 {
SELECT tointeger(0);
} {0}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.19 {
SELECT tointeger(1);
} {1}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.20 {
SELECT tointeger(-1.79769313486232e308 - 1);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.21 {
SELECT tointeger(-1.79769313486232e308);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.22 {
SELECT tointeger(-1.79769313486232e308 + 1);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.23 {
SELECT tointeger(-9223372036854775808 - 1);
} {-9223372036854775808}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.24 {
SELECT tointeger(-9223372036854775808);
} {-9223372036854775808}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.25 {
SELECT tointeger(-9223372036854775808 + 1);
} {-9223372036854775807}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.26 {
SELECT tointeger(-2147483648 - 1);
} {-2147483649}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.27 {
SELECT tointeger(-2147483648);
} {-2147483648}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.28 {
SELECT tointeger(-2147483648 + 1);
} {-2147483647}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.29 {
SELECT tointeger(2147483647 - 1);
} {2147483646}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.30 {
SELECT tointeger(2147483647);
} {2147483647}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.31 {
SELECT tointeger(2147483647 + 1);
} {2147483648}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.32 {
SELECT tointeger(9223372036854775807 - 1);
} {9223372036854775806}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.33 {
SELECT tointeger(9223372036854775807);
} {9223372036854775807}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.34 {
SELECT tointeger(9223372036854775807 + 1);
} {-9223372036854775808}
do_execsql_test func4-1.[incr i] {
} {{}}
do_execsql_test func4-1.35 {
SELECT tointeger(1.79769313486232e308 - 1);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.36 {
SELECT tointeger(1.79769313486232e308);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.37 {
SELECT tointeger(1.79769313486232e308 + 1);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.38 {
SELECT tointeger(4503599627370496 - 1);
} {4503599627370495}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.39 {
SELECT tointeger(4503599627370496);
} {4503599627370496}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.40 {
SELECT tointeger(4503599627370496 + 1);
} {4503599627370497}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.41 {
SELECT tointeger(9007199254740992 - 1);
} {9007199254740991}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.42 {
SELECT tointeger(9007199254740992);
} {9007199254740992}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.43 {
SELECT tointeger(9007199254740992 + 1);
} {9007199254740993}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.44 {
SELECT tointeger(9223372036854775808 - 1);
} {-9223372036854775808}
do_execsql_test func4-1.[incr i] {
} {{}}
do_execsql_test func4-1.45 {
SELECT tointeger(9223372036854775808);
} {-9223372036854775808}
do_execsql_test func4-1.[incr i] {
} {{}}
do_execsql_test func4-1.46 {
SELECT tointeger(9223372036854775808 + 1);
} {-9223372036854775808}
do_execsql_test func4-1.[incr i] {
} {{}}
do_execsql_test func4-1.47 {
SELECT tointeger(18446744073709551616 - 1);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.48 {
SELECT tointeger(18446744073709551616);
} {{}}
do_execsql_test func4-1.[incr i] {
do_execsql_test func4-1.49 {
SELECT tointeger(18446744073709551616 + 1);
} {{}}
ifcapable floatingpoint {
set i 0
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.1 {
SELECT toreal(NULL);
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.2 {
SELECT toreal('');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.3 {
SELECT toreal(' ');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.4 {
SELECT toreal('1234');
} {1234.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.5 {
SELECT toreal(' 1234');
} {1234.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.6 {
SELECT toreal('bad');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.7 {
SELECT toreal('0xBAD');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.8 {
SELECT toreal('123BAD');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.9 {
SELECT toreal('0x123BAD');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.10 {
SELECT toreal('123NO');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.11 {
SELECT toreal('0x123NO');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.12 {
SELECT toreal('-0x1');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.13 {
SELECT toreal('-0x0');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.14 {
SELECT toreal('0x0');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.15 {
SELECT toreal('0x1');
} {{}}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.16 {
SELECT toreal(-1);
} {-1.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.17 {
SELECT toreal(-0);
} {0.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.18 {
SELECT toreal(0);
} {0.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.19 {
SELECT toreal(1);
} {1.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.20 {
SELECT toreal(-1.79769313486232e308 - 1);
} {-Inf}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.21 {
SELECT toreal(-1.79769313486232e308);
} {-Inf}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.22 {
SELECT toreal(-1.79769313486232e308 + 1);
} {-Inf}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.23 {
SELECT toreal(-9223372036854775808 - 1);
} {-9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.24 {
SELECT toreal(-9223372036854775808);
} {-9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.25 {
SELECT toreal(-9223372036854775808 + 1);
} {-9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.26 {
SELECT toreal(-2147483648 - 1);
} {-2147483649.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.27 {
SELECT toreal(-2147483648);
} {-2147483648.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.28 {
SELECT toreal(-2147483648 + 1);
} {-2147483647.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.29 {
SELECT toreal(2147483647 - 1);
} {2147483646.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.30 {
SELECT toreal(2147483647);
} {2147483647.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.31 {
SELECT toreal(2147483647 + 1);
} {2147483648.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.32 {
SELECT toreal(9223372036854775807 - 1);
} {9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.33 {
SELECT toreal(9223372036854775807);
} {9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.34 {
SELECT toreal(9223372036854775807 + 1);
} {9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.35 {
SELECT toreal(1.79769313486232e308 - 1);
} {Inf}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.36 {
SELECT toreal(1.79769313486232e308);
} {Inf}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.37 {
SELECT toreal(1.79769313486232e308 + 1);
} {Inf}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.38 {
SELECT toreal(4503599627370496 - 1);
} {4503599627370500.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.39 {
SELECT toreal(4503599627370496);
} {4503599627370500.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.40 {
SELECT toreal(4503599627370496 + 1);
} {4503599627370500.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.41 {
SELECT toreal(9007199254740992 - 1);
} {9007199254740990.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.42 {
SELECT toreal(9007199254740992);
} {9007199254740990.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.43 {
SELECT toreal(9007199254740992 + 1);
} {9007199254740990.0}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.44 {
SELECT toreal(9223372036854775808 - 1);
} {9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.45 {
SELECT toreal(9223372036854775808);
} {9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.46 {
SELECT toreal(9223372036854775808 + 1);
} {9.22337203685478e+18}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.47 {
SELECT toreal(18446744073709551616 - 1);
} {1.84467440737096e+19}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.48 {
SELECT toreal(18446744073709551616);
} {1.84467440737096e+19}
do_execsql_test func4-2.[incr i] {
do_execsql_test func4-2.49 {
SELECT toreal(18446744073709551616 + 1);
} {1.84467440737096e+19}
}
ifcapable check {
set i 0
do_execsql_test func4-3.[incr i] {
do_execsql_test func4-3.1 {
CREATE TABLE t1(
x INTEGER CHECK(tointeger(x) IS NOT NULL AND x = CAST(x AS INTEGER))
);
} {}
do_test func4-3.[incr i] {
do_test func4-3.2 {
catchsql {
INSERT INTO t1 (x) VALUES (NULL);
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.3 {
catchsql {
INSERT INTO t1 (x) VALUES (NULL);
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.4 {
catchsql {
INSERT INTO t1 (x) VALUES ('');
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.5 {
catchsql {
INSERT INTO t1 (x) VALUES ('bad');
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.6 {
catchsql {
INSERT INTO t1 (x) VALUES ('1234bad');
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.7 {
catchsql {
INSERT INTO t1 (x) VALUES ('1234.56bad');
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.8 {
catchsql {
INSERT INTO t1 (x) VALUES (1234);
}
} {0 {}}
do_test func4-3.[incr i] {
do_test func4-3.9 {
catchsql {
INSERT INTO t1 (x) VALUES (1234.56);
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.10 {
catchsql {
INSERT INTO t1 (x) VALUES ('1234');
}
} {0 {}}
do_test func4-3.[incr i] {
do_test func4-3.11 {
catchsql {
INSERT INTO t1 (x) VALUES ('1234.56');
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.12 {
catchsql {
INSERT INTO t1 (x) VALUES (ZEROBLOB(4));
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.13 {
catchsql {
INSERT INTO t1 (x) VALUES (X'');
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.14 {
catchsql {
INSERT INTO t1 (x) VALUES (X'1234');
}
} {1 {constraint failed}}
do_test func4-3.[incr i] {
do_test func4-3.15 {
catchsql {
INSERT INTO t1 (x) VALUES (X'12345678');
}
} {1 {constraint failed}}
do_execsql_test func4-3.[incr i] {
do_execsql_test func4-3.16 {
SELECT x FROM t1 ORDER BY x;
} {1234 1234}
ifcapable floatingpoint {
set i 0
do_execsql_test func4-4.[incr i] {
do_execsql_test func4-4.1 {
CREATE TABLE t2(
x REAL CHECK(toreal(x) IS NOT NULL)
);
} {}
do_test func4-4.[incr i] {
do_test func4-4.2 {
catchsql {
INSERT INTO t2 (x) VALUES (NULL);
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.3 {
catchsql {
INSERT INTO t2 (x) VALUES (NULL);
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.4 {
catchsql {
INSERT INTO t2 (x) VALUES ('');
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.5 {
catchsql {
INSERT INTO t2 (x) VALUES ('bad');
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.6 {
catchsql {
INSERT INTO t2 (x) VALUES ('1234bad');
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.7 {
catchsql {
INSERT INTO t2 (x) VALUES ('1234.56bad');
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.8 {
catchsql {
INSERT INTO t2 (x) VALUES (1234);
}
} {0 {}}
do_test func4-4.[incr i] {
do_test func4-4.9 {
catchsql {
INSERT INTO t2 (x) VALUES (1234.56);
}
} {0 {}}
do_test func4-4.[incr i] {
do_test func4-4.10 {
catchsql {
INSERT INTO t2 (x) VALUES ('1234');
}
} {0 {}}
do_test func4-4.[incr i] {
do_test func4-4.11 {
catchsql {
INSERT INTO t2 (x) VALUES ('1234.56');
}
} {0 {}}
do_test func4-4.[incr i] {
do_test func4-4.12 {
catchsql {
INSERT INTO t2 (x) VALUES (ZEROBLOB(4));
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.13 {
catchsql {
INSERT INTO t2 (x) VALUES (X'');
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.14 {
catchsql {
INSERT INTO t2 (x) VALUES (X'1234');
}
} {1 {constraint failed}}
do_test func4-4.[incr i] {
do_test func4-4.15 {
catchsql {
INSERT INTO t2 (x) VALUES (X'12345678');
}
} {1 {constraint failed}}
do_execsql_test func4-4.[incr i] {
do_execsql_test func4-4.16 {
SELECT x FROM t2 ORDER BY x;
} {1234.0 1234.0 1234.56 1234.56}
}

View File

@ -194,7 +194,7 @@ test_suite "fts3" -prefix "" -description {
fts4aa.test fts4content.test
fts3conf.test fts3prefix.test fts3fault2.test fts3corrupt.test
fts3corrupt2.test fts3first.test fts4langid.test fts4merge.test
fts4check.test fts4unicode.test
fts4check.test fts4unicode.test fts4noti.test
}
test_suite "nofaultsim" -prefix "" -description {