From 8ad5c9492de91da83d5dc388bd9eb7892ad73b5a Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 23 Mar 2011 10:38:49 +0000 Subject: [PATCH 1/6] Change the rtree module to support queries with multiple comparison operators (i.e. > or <) of the same type on a single column. FossilOrigin-Name: 387b55aa9bb0f978641f9c2fa40f84fd98662047 --- ext/rtree/rtree.c | 43 +++++++------------------------------------ ext/rtree/rtree6.test | 34 ++++++++++++++++++++++++++++++++++ manifest | 26 ++++++++------------------ manifest.uuid | 2 +- 4 files changed, 50 insertions(+), 55 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index d47c1092ef..13e5ea241c 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1353,7 +1353,7 @@ static int rtreeFilter( */ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int rc = SQLITE_OK; - int ii, cCol; + int ii; int iIdx = 0; char zIdxStr[RTREE_MAX_DIMENSIONS*8+1]; @@ -1361,7 +1361,7 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ UNUSED_PARAMETER(tab); assert( pIdxInfo->idxStr==0 ); - for(ii=0; iinConstraint; ii++){ + for(ii=0; iinConstraint && iIdx<(sizeof(zIdxStr)-1); ii++){ struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii]; if( p->usable && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){ @@ -1385,9 +1385,7 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ } if( p->usable && (p->iColumn>0 || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){ - int j, opmsk; - static const unsigned char compatible[] = { 0, 0, 1, 1, 2, 2 }; - u8 op = 0; + u8 op; switch( p->op ){ case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break; case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break; @@ -1399,37 +1397,10 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ op = RTREE_MATCH; break; } - assert( op!=0 ); - - /* Make sure this particular constraint has not been used before. - ** If it has been used before, ignore it. - ** - ** A <= or < can be used if there is a prior >= or >. - ** A >= or > can be used if there is a prior < or <=. - ** A <= or < is disqualified if there is a prior <=, <, or ==. - ** A >= or > is disqualified if there is a prior >=, >, or ==. - ** A == is disqualifed if there is any prior constraint. - */ - assert( compatible[RTREE_EQ & 7]==0 ); - assert( compatible[RTREE_LT & 7]==1 ); - assert( compatible[RTREE_LE & 7]==1 ); - assert( compatible[RTREE_GT & 7]==2 ); - assert( compatible[RTREE_GE & 7]==2 ); - cCol = p->iColumn - 1 + 'a'; - opmsk = compatible[op & 7]; - for(j=0; jaConstraintUsage[ii].argvIndex = (iIdx/2); - pIdxInfo->aConstraintUsage[ii].omit = 1; - } + zIdxStr[iIdx++] = op; + zIdxStr[iIdx++] = p->iColumn - 1 + 'a'; + pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2); + pIdxInfo->aConstraintUsage[ii].omit = 1; } } diff --git a/ext/rtree/rtree6.test b/ext/rtree/rtree6.test index 0a29f44165..7fe346b0c7 100644 --- a/ext/rtree/rtree6.test +++ b/ext/rtree/rtree6.test @@ -106,4 +106,38 @@ do_eqp_test rtree6.2.5 { 0 1 1 {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} } +do_execsql_test rtree6-3.1 { + CREATE VIRTUAL TABLE t3 USING rtree(id, x1, x2, y1, y2); + INSERT INTO t3 VALUES(NULL, 1, 1, 2, 2); + SELECT * FROM t3 WHERE + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5; +} {1 1.0 1.0 2.0 2.0} + +do_test rtree6.3.2 { + rtree_strategy { + SELECT * FROM t3 WHERE + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 + } +} {EaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEa} +do_test rtree6.3.4 { + rtree_strategy { + SELECT * FROM t3 WHERE + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 + } +} {EaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEa} + + finish_test diff --git a/manifest b/manifest index 5220ffdf42..52f3cbadbd 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Add\sthe\sability\sto\senable\sand\sdisable\sforeign\skey\sconstraints\sand\striggers\nusing\scalls\sto\ssqlite3_db_config(). -D 2011-03-21T17:15:58.841 +C Change\sthe\srtree\smodule\sto\ssupport\squeries\swith\smultiple\scomparison\soperators\s(i.e.\s>\sor\s<)\sof\sthe\ssame\stype\son\sa\ssingle\scolumn. +D 2011-03-23T10:38:50 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -84,14 +81,14 @@ F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 115b499415ddef9be75615ced99b11232826e64d +F ext/rtree/rtree.c 48705ee892c30cc05cd40006d2509ad192530907 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test dbd4250ac0ad367a262eb9676f7e3080b0368206 F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba F ext/rtree/rtree3.test a494da55c30ee0bc9b01a91c80c81b387b22d2dc F ext/rtree/rtree4.test 0061e6f464fd3dc6a79f82454c5a1c3dadbe42af F ext/rtree/rtree5.test ce3d7ccae2cfd9d2e1052b462424964c9bdcda12 -F ext/rtree/rtree6.test 309806a2a27ef5897d4dd6aee2e8006bf754cc22 +F ext/rtree/rtree6.test 1edf30467ec39b2282874c2175b81b7690d2c706 F ext/rtree/rtree7.test bcb647b42920b3b5d025846689147778485cc318 F ext/rtree/rtree8.test 9772e16da71e17e02bdebf0a5188590f289ab37d F ext/rtree/rtree9.test df9843d1a9195249c8d3b4ea6aedda2d5c73e9c2 @@ -918,14 +915,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P eedbcf0a0ba91bb8b9cd3d115081ba297e9959fe -R 280ad38169dd48b2d9e175160372c567 -U drh -Z e8e199200b835ba249870038ad2cd6dc ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNh4fToxKgR168RlERAhHRAJ4u99dZIoFOU0P2cr07ePpksHkgggCfST1g -F/4WAG+YZz9MPVjqi2BaEUo= -=dT9z ------END PGP SIGNATURE----- +P 09e167f9c14625924b17bbb1f292f89ac9ddc93a +R 52342b1b5ec5b2f1eb5941c495729364 +U dan +Z a3dc1db2deb58c4b0fccde75b160266c diff --git a/manifest.uuid b/manifest.uuid index 4585895670..1154a5fc3e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -09e167f9c14625924b17bbb1f292f89ac9ddc93a \ No newline at end of file +387b55aa9bb0f978641f9c2fa40f84fd98662047 \ No newline at end of file From fb1f98a1ac16fe252587dcef0c936ae5c2889f61 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 23 Mar 2011 10:52:23 +0000 Subject: [PATCH 2/6] Fix a numbering issue in rtree6.test. Add a couple of extra tests. FossilOrigin-Name: 0b7668a71ef8995ea0306c7d890f87761961426e --- ext/rtree/rtree6.test | 15 ++++++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ext/rtree/rtree6.test b/ext/rtree/rtree6.test index 7fe346b0c7..ba0e53c994 100644 --- a/ext/rtree/rtree6.test +++ b/ext/rtree/rtree6.test @@ -127,7 +127,7 @@ do_test rtree6.3.2 { x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 } } {EaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEa} -do_test rtree6.3.4 { +do_test rtree6.3.3 { rtree_strategy { SELECT * FROM t3 WHERE x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND @@ -139,5 +139,18 @@ do_test rtree6.3.4 { } } {EaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEaEa} +do_execsql_test rtree6-3.4 { + SELECT * FROM t3 WHERE x1>0.5 AND x1>0.8 AND x1>1.1 +} {} +do_execsql_test rtree6-3.5 { + SELECT * FROM t3 WHERE + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND + x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>1.1 +} {} + finish_test diff --git a/manifest b/manifest index 52f3cbadbd..f013a88380 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\srtree\smodule\sto\ssupport\squeries\swith\smultiple\scomparison\soperators\s(i.e.\s>\sor\s<)\sof\sthe\ssame\stype\son\sa\ssingle\scolumn. -D 2011-03-23T10:38:50 +C Fix\sa\snumbering\sissue\sin\srtree6.test.\sAdd\sa\scouple\sof\sextra\stests. +D 2011-03-23T10:52:24 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -88,7 +88,7 @@ F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba F ext/rtree/rtree3.test a494da55c30ee0bc9b01a91c80c81b387b22d2dc F ext/rtree/rtree4.test 0061e6f464fd3dc6a79f82454c5a1c3dadbe42af F ext/rtree/rtree5.test ce3d7ccae2cfd9d2e1052b462424964c9bdcda12 -F ext/rtree/rtree6.test 1edf30467ec39b2282874c2175b81b7690d2c706 +F ext/rtree/rtree6.test 0b380bd9af93f3bc496eef42502a336f58949c1b F ext/rtree/rtree7.test bcb647b42920b3b5d025846689147778485cc318 F ext/rtree/rtree8.test 9772e16da71e17e02bdebf0a5188590f289ab37d F ext/rtree/rtree9.test df9843d1a9195249c8d3b4ea6aedda2d5c73e9c2 @@ -915,7 +915,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 09e167f9c14625924b17bbb1f292f89ac9ddc93a -R 52342b1b5ec5b2f1eb5941c495729364 +P 387b55aa9bb0f978641f9c2fa40f84fd98662047 +R 42f78a66f5fb996ecb166be6e5e2801d U dan -Z a3dc1db2deb58c4b0fccde75b160266c +Z 48e98177ee9f2d2bd6fc7fbe27e37892 diff --git a/manifest.uuid b/manifest.uuid index 1154a5fc3e..cb2b1b4819 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -387b55aa9bb0f978641f9c2fa40f84fd98662047 \ No newline at end of file +0b7668a71ef8995ea0306c7d890f87761961426e \ No newline at end of file From c8ba212665d5d04cfb962c42a9c53360e7f3d4ee Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 23 Mar 2011 11:16:22 +0000 Subject: [PATCH 3/6] In the shell, make sure the ".log" command has at least one argument. FossilOrigin-Name: 1ed5e361ca7bfa9226fec265704394e0f228f0c5 --- manifest | 24 +++++++++++++++++------- manifest.uuid | 2 +- src/shell.c | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f013a88380..04ac2cbb62 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\snumbering\sissue\sin\srtree6.test.\sAdd\sa\scouple\sof\sextra\stests. -D 2011-03-23T10:52:24 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C In\sthe\sshell,\smake\ssure\sthe\s".log"\scommand\shas\sat\sleast\sone\sargument. +D 2011-03-23T11:16:22.642 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -177,7 +180,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 -F src/shell.c 4a5e0ad845475c84881f0b25b1abba2ddaab0a72 +F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a F src/sqlite.h.in 9d85096265a53db6c9d452eb478d5ced15308275 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 1de0edab31cc9e5c2f3540e08e8b97926f84bfeb @@ -915,7 +918,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 387b55aa9bb0f978641f9c2fa40f84fd98662047 -R 42f78a66f5fb996ecb166be6e5e2801d -U dan -Z 48e98177ee9f2d2bd6fc7fbe27e37892 +P 0b7668a71ef8995ea0306c7d890f87761961426e +R 88a09b7469ff1146f51987afec7567e4 +U drh +Z f1bfc5b8226ce4dbe953fcf48ca565ea +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNidaJoxKgR168RlERApqOAJwNgpXn213VO6fr+LnJXQLkyKs6wACePFP8 +pc1Sc0TC4VKU22K9u5+NaOQ= +=M8WR +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index cb2b1b4819..1e4ab125fd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b7668a71ef8995ea0306c7d890f87761961426e \ No newline at end of file +1ed5e361ca7bfa9226fec265704394e0f228f0c5 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 7eed290918..be4e0de281 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1851,7 +1851,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ }else #endif - if( c=='l' && strncmp(azArg[0], "log", n)==0 && nArg>=1 ){ + if( c=='l' && strncmp(azArg[0], "log", n)==0 && nArg>=2 ){ const char *zFile = azArg[1]; if( p->pLog && p->pLog!=stdout && p->pLog!=stderr ){ fclose(p->pLog); From 0370493760d5780bd42be4f73eed06a337622c6c Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 23 Mar 2011 17:10:43 +0000 Subject: [PATCH 4/6] Fix a bug in fts4 to do with matchinfo and deferred tokens. FossilOrigin-Name: 30d42dc66f19ef5cc5b27d6273eadf56619a3ce8 --- ext/fts3/fts3_snippet.c | 8 ++++---- manifest | 26 ++++++++------------------ manifest.uuid | 2 +- test/fts3defer2.test | 15 ++++++++++++--- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 54371db1c8..6b74535079 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -880,13 +880,13 @@ static int fts3ExprLocalHitsCb( void *pCtx /* Pointer to MatchInfo structure */ ){ MatchInfo *p = (MatchInfo *)pCtx; + int iStart = iPhrase * p->nCol * 3; + int i; + + for(i=0; inCol; i++) p->aMatchinfo[iStart+i*3] = 0; if( pExpr->aDoclist ){ char *pCsr; - int iStart = iPhrase * p->nCol * 3; - int i; - - for(i=0; inCol; i++) p->aMatchinfo[iStart+i*3] = 0; pCsr = sqlite3Fts3FindPositions(pExpr, p->pCursor->iPrevId, -1); if( pCsr ){ diff --git a/manifest b/manifest index 04ac2cbb62..4ecb663b1e 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C In\sthe\sshell,\smake\ssure\sthe\s".log"\scommand\shas\sat\sleast\sone\sargument. -D 2011-03-23T11:16:22.642 +C Fix\sa\sbug\sin\sfts4\sto\sdo\swith\smatchinfo\sand\sdeferred\stokens. +D 2011-03-23T17:10:44 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -73,7 +70,7 @@ F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295 F ext/fts3/fts3_porter.c d61cfd81fb0fd8fbcb25adcaee0ba671aefaa5c2 -F ext/fts3/fts3_snippet.c bfefb42b5debf8725a30fd5122572aaeedc99397 +F ext/fts3/fts3_snippet.c e857c6a89d81d3b89df59f3b44b35c68d8ed5c62 F ext/fts3/fts3_tokenizer.c 055f3dc7369585350b28db1ee0f3b214dca6724d F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 6e5cbaa588924ac578263a598e4fb9f5c9bb179d @@ -455,7 +452,7 @@ F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 F test/fts3defer.test d6cb0db9b5997ecf863d96ff419f83f8f2c87f4f -F test/fts3defer2.test da840efaedebfdd54293d04b36098e2d9872caa6 +F test/fts3defer2.test 288bef6de15557319b8c12d476ebdc83688ef96c F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a @@ -918,14 +915,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0b7668a71ef8995ea0306c7d890f87761961426e -R 88a09b7469ff1146f51987afec7567e4 -U drh -Z f1bfc5b8226ce4dbe953fcf48ca565ea ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFNidaJoxKgR168RlERApqOAJwNgpXn213VO6fr+LnJXQLkyKs6wACePFP8 -pc1Sc0TC4VKU22K9u5+NaOQ= -=M8WR ------END PGP SIGNATURE----- +P 1ed5e361ca7bfa9226fec265704394e0f228f0c5 +R 2f8b1c68ec4ce4809965697dec333ba6 +U dan +Z 998dcc0bc86840532e7dbf16c79e79d3 diff --git a/manifest.uuid b/manifest.uuid index 1e4ab125fd..107f784eee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1ed5e361ca7bfa9226fec265704394e0f228f0c5 \ No newline at end of file +30d42dc66f19ef5cc5b27d6273eadf56619a3ce8 \ No newline at end of file diff --git a/test/fts3defer2.test b/test/fts3defer2.test index 142c92a9dd..8441803300 100644 --- a/test/fts3defer2.test +++ b/test/fts3defer2.test @@ -80,7 +80,7 @@ do_execsql_test 2.1.2 "INSERT INTO t2 VALUES('[string repeat {a } 10000]')" do_execsql_test 2.1.3 "INSERT INTO t2 VALUES('b [string repeat {z } 10000]')" do_execsql_test 2.1.4 [string repeat "INSERT INTO t2 VALUES('x');" 50] do_execsql_test 2.1.5 { - INSERT INTO t2 VALUES('a b c d e f g'); + INSERT INTO t2 VALUES('a b c d e f g z'); INSERT INTO t2 VALUES('a b c d e f g'); } foreach {tn sql} { @@ -92,12 +92,21 @@ foreach {tn sql} { } { execsql $sql - do_execsql_test 2.2.$tn { + do_execsql_test 2.2.$tn.1 { SELECT mit(matchinfo(t2, 'pcxnal')) FROM t2 WHERE t2 MATCH 'a b'; } [list \ - [list 2 1 1 54 54 1 3 3 54 372 7] \ + [list 2 1 1 54 54 1 3 3 54 372 8] \ [list 2 1 1 54 54 1 3 3 54 372 7] \ ] + + set sqlite_fts3_enable_parentheses 1 + do_execsql_test 2.2.$tn.2 { + SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'g OR (g z)'; + } [list \ + [list 1 2 2 1 2 2 1 54 54] \ + [list 1 2 2 1 2 2 0 54 54] \ + ] + set sqlite_fts3_enable_parentheses 0 } do_execsql_test 2.3.1 { From 01c7dc887c35ce8107363073fcf31f425fba46f4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 23 Mar 2011 18:22:34 +0000 Subject: [PATCH 5/6] Increase the upper bound on SQLITE_MAX_ATTACHED from 30 to 62. FossilOrigin-Name: 7aaf8772274422f5020fad9eea490e195170720f --- manifest | 34 ++++++++++++++++++++++------------ manifest.uuid | 2 +- src/build.c | 8 ++++---- src/main.c | 4 ++-- src/sqliteInt.h | 11 +++++++++-- src/vdbeInt.h | 2 +- src/vdbeaux.c | 4 ++-- test/attach.test | 36 ++++++++++++++++++++---------------- 8 files changed, 61 insertions(+), 40 deletions(-) diff --git a/manifest b/manifest index 4ecb663b1e..03f32c272f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Fix\sa\sbug\sin\sfts4\sto\sdo\swith\smatchinfo\sand\sdeferred\stokens. -D 2011-03-23T17:10:44 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Increase\sthe\supper\sbound\son\sSQLITE_MAX_ATTACHED\sfrom\s30\sto\s62. +D 2011-03-23T18:22:34.232 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +127,7 @@ F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c 43302cc4f3de6479b90fa6bb271b65d86333d00e F src/btree.h e2f2cd9933bf30724f53ffa12c4c5a3a864bbd6e F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4 -F src/build.c 3b86c8efc0cbe716d82c510463f448b9cdee0619 +F src/build.c 821d4b3c6b1da068a4eb1e9c8c414b75612d34c2 F src/callback.c 5069f224882cbdccd559f591271d28d7f37745bc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01 @@ -143,7 +146,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 8af9fcc75708d60b88636ccba38b4a7b3c155c3e -F src/main.c 6d10370bfc2235b7d6cf78510b20c94c00123357 +F src/main.c 3679460ba5ee8f842e32def2117d5bd2260cdbf0 F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -180,7 +183,7 @@ F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a F src/sqlite.h.in 9d85096265a53db6c9d452eb478d5ced15308275 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h 1de0edab31cc9e5c2f3540e08e8b97926f84bfeb +F src/sqliteInt.h f8f1d00a22c98fd3f2fbc94da74eeb880879f89f F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -233,9 +236,9 @@ F src/util.c cd997077bad039efc0597eb027c929658f93c018 F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f F src/vdbe.c 8430780c643bf67d4b5da27f24d6ad39804fdaf4 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 -F src/vdbeInt.h 6e6f28e9bccc6c703dca1372fd661c57b5c15fb0 +F src/vdbeInt.h e1c6254641168507d25b46affb6dfb53c782f553 F src/vdbeapi.c a09ad9164cafc505250d5dd6b69660c960f1308c -F src/vdbeaux.c 00439455c80ff7b37d7f2e5be5c0cf02de732a42 +F src/vdbeaux.c cfd3f3ac674691ba1166ceb9a2698b0d00b2ef91 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 @@ -263,7 +266,7 @@ F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6 F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test f3592d79c84d6e83a5f50d3fd500445f7d97dfdf -F test/attach.test f2b4ac6931f45695082b9f02be959c9c262e4f4d +F test/attach.test 2bb09073d7d5499127db00f50780766dcea913e1 F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437 F test/attach3.test bd9830bc3a0d22ed1310c9bff6896927937017dc F test/attachmalloc.test 1d5b821a676f7bf0b00d87cc106b78966789ba57 @@ -915,7 +918,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 1ed5e361ca7bfa9226fec265704394e0f228f0c5 -R 2f8b1c68ec4ce4809965697dec333ba6 -U dan -Z 998dcc0bc86840532e7dbf16c79e79d3 +P 30d42dc66f19ef5cc5b27d6273eadf56619a3ce8 +R 53e5c0654506b9d27fce0da478ef2182 +U drh +Z af69b516e428dca392e47d50225e2cb4 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFNijptoxKgR168RlERAqbvAJ9dZZGQfzqQkUsnDColXnPTvyc73wCdHwqj +BdLhxD0af4MbaUFMS6jVKTQ= +=BE7n +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 107f784eee..a416a0e5e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -30d42dc66f19ef5cc5b27d6273eadf56619a3ce8 \ No newline at end of file +7aaf8772274422f5020fad9eea490e195170720f \ No newline at end of file diff --git a/src/build.c b/src/build.c index 79ac436f07..e7c56c9ab0 100644 --- a/src/build.c +++ b/src/build.c @@ -148,7 +148,7 @@ void sqlite3FinishCoding(Parse *pParse){ ** on each used database. */ if( pParse->cookieGoto>0 ){ - u32 mask; + tAttachMask mask; int iDb; sqlite3VdbeJumpHere(v, pParse->cookieGoto-1); for(iDb=0, mask=1; iDbnDb; mask<<=1, iDb++){ @@ -3444,12 +3444,12 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ } if( iDb>=0 ){ sqlite3 *db = pToplevel->db; - int mask; + tAttachMask mask; assert( iDbnDb ); assert( db->aDb[iDb].pBt!=0 || iDb==1 ); assert( iDbcookieMask & mask)==0 ){ pToplevel->cookieMask |= mask; pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie; @@ -3476,7 +3476,7 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){ Parse *pToplevel = sqlite3ParseToplevel(pParse); sqlite3CodeVerifySchema(pParse, iDb); - pToplevel->writeMask |= 1<writeMask |= ((tAttachMask)1)<isMultiWrite |= setStatement; } diff --git a/src/main.c b/src/main.c index 4872efb520..ac82256a98 100644 --- a/src/main.c +++ b/src/main.c @@ -1723,8 +1723,8 @@ static const int aHardLimit[] = { #if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000 # error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000 #endif -#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>30 -# error SQLITE_MAX_ATTACHED must be between 0 and 30 +#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>62 +# error SQLITE_MAX_ATTACHED must be between 0 and 62 #endif #if SQLITE_MAX_LIKE_PATTERN_LENGTH<1 # error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ec8ce936c5..0825af4cdf 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2125,6 +2125,13 @@ struct TriggerPrg { TriggerPrg *pNext; /* Next entry in Parse.pTriggerPrg list */ }; +/* Datatype for the bitmask of all attached databases */ +#if SQLITE_MAX_ATTACHED>30 + typedef sqlite3_uint64 tAttachMask; +#else + typedef unsigned int tAttachMask; +#endif + /* ** An SQL parser context. A copy of this structure is passed through ** the parser and down into all the parser action routine in order to @@ -2173,8 +2180,8 @@ struct Parse { int iReg; /* Reg with value of this column. 0 means none. */ int lru; /* Least recently used entry has the smallest value */ } aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */ - u32 writeMask; /* Start a write transaction on these databases */ - u32 cookieMask; /* Bitmask of schema verified databases */ + tAttachMask writeMask; /* Start a write transaction on these databases */ + tAttachMask cookieMask; /* Bitmask of schema verified databases */ u8 isMultiWrite; /* True if statement may affect/insert multiple rows */ u8 mayAbort; /* True if statement may throw an ABORT exception */ int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ diff --git a/src/vdbeInt.h b/src/vdbeInt.h index b42729d236..65cda0bcc5 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -302,7 +302,7 @@ struct Vdbe { u8 readOnly; /* True for read-only statements */ u8 isPrepareV2; /* True if prepared with prepare_v2() */ int nChange; /* Number of db changes made since last reset */ - int btreeMask; /* Bitmask of db->aDb[] entries referenced */ + tAttachMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ int iStatement; /* Statement number (or 0 if has not opened stmt) */ int aCounter[3]; /* Counters used by sqlite3_stmt_status() */ BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index c7acbcb646..36e0d260b3 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -950,8 +950,8 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ ** in order (and released in reverse order) to avoid deadlocks. */ void sqlite3VdbeUsesBtree(Vdbe *p, int i){ - int mask; - assert( i>=0 && idb->nDb && i=0 && idb->nDb && ibtreeMask)*8 ); mask = ((u32)1)<btreeMask & mask)==0 ){ diff --git a/test/attach.test b/test/attach.test index a5af8f751d..1bb596cb90 100644 --- a/test/attach.test +++ b/test/attach.test @@ -152,14 +152,16 @@ do_test attach-1.18 { ATTACH 'test.db' as db11; } } {0 {}} -do_test attach-1.19 { - catchsql { - ATTACH 'test.db' as db12; - } -} {1 {too many attached databases - max 10}} -do_test attach-1.19.1 { - db errorcode -} {1} +if {$SQLITE_MAX_ATTACHED==10} { + do_test attach-1.19 { + catchsql { + ATTACH 'test.db' as db12; + } + } {1 {too many attached databases - max 10}} + do_test attach-1.19.1 { + db errorcode + } {1} +} do_test attach-1.20.1 { execsql { DETACH db5; @@ -179,14 +181,16 @@ do_test attach-1.21 { ATTACH 'test.db' as db12; } } {0 {}} -do_test attach-1.22 { - catchsql { - ATTACH 'test.db' as db13; - } -} {1 {too many attached databases - max 10}} -do_test attach-1.22.1 { - db errorcode -} {1} +if {$SQLITE_MAX_ATTACHED==10} { + do_test attach-1.22 { + catchsql { + ATTACH 'test.db' as db13; + } + } {1 {too many attached databases - max 10}} + do_test attach-1.22.1 { + db errorcode + } {1} +} do_test attach-1.23 { catchsql { DETACH "db14"; From 58ad580ffa93cc3bd6d4a4179470bca3cb2041ae Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 23 Mar 2011 22:02:23 +0000 Subject: [PATCH 6/6] Change the xSetSyscall methods of the VFS so that they do not cast object pointers into function pointers. Fix other unrelated compiler warnings. FossilOrigin-Name: e059152adce3a8fb693f082b82b5669a238c8d6f --- manifest | 22 +++++++-------- manifest.uuid | 2 +- src/main.c | 2 +- src/os_unix.c | 71 ++++++++++++++++++++++++++++--------------------- src/sqlite.h.in | 5 ++-- 5 files changed, 56 insertions(+), 46 deletions(-) diff --git a/manifest b/manifest index 03f32c272f..33efc4be6d 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Increase\sthe\supper\sbound\son\sSQLITE_MAX_ATTACHED\sfrom\s30\sto\s62. -D 2011-03-23T18:22:34.232 +C Change\sthe\sxSetSyscall\smethods\sof\sthe\sVFS\sso\sthat\sthey\sdo\snot\scast\sobject\npointers\sinto\sfunction\spointers.\s\sFix\sother\sunrelated\scompiler\swarnings. +D 2011-03-23T22:02:23.988 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f 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 8af9fcc75708d60b88636ccba38b4a7b3c155c3e -F src/main.c 3679460ba5ee8f842e32def2117d5bd2260cdbf0 +F src/main.c c4ecb1973419a1e2467cfea31054458da293a307 F src/malloc.c 92d59a007d7a42857d4e9454aa25b6b703286be1 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -165,7 +165,7 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 2596fd2d5d0976c6c0c628d0c3c7c4e7a724f4cf -F src/os_unix.c 919972244dd7267815f9fc176b662390ff0b2348 +F src/os_unix.c 942a9dca5d17c599300127c88a48413e6d55666f F src/os_win.c 24d72407a90551969744cf9bcbb1b4c72c5fa845 F src/pager.c 6aa906b60a59664ba58d3f746164bb010d407ce1 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 @@ -181,7 +181,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a -F src/sqlite.h.in 9d85096265a53db6c9d452eb478d5ced15308275 +F src/sqlite.h.in 2ab8766c32afed165c0ea74292e18483e3aa64b1 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h f8f1d00a22c98fd3f2fbc94da74eeb880879f89f F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -918,14 +918,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 30d42dc66f19ef5cc5b27d6273eadf56619a3ce8 -R 53e5c0654506b9d27fce0da478ef2182 +P 7aaf8772274422f5020fad9eea490e195170720f +R 5f5be2467ac2e1a296459a4f106ade8d U drh -Z af69b516e428dca392e47d50225e2cb4 +Z fe6ea374366d1c79bf722f1efd9278ca -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNijptoxKgR168RlERAqbvAJ9dZZGQfzqQkUsnDColXnPTvyc73wCdHwqj -BdLhxD0af4MbaUFMS6jVKTQ= -=BE7n +iD8DBQFNim3zoxKgR168RlERAinxAJ4/cXafMYIecY7RnHEnjd/FDN5wWgCeO1Gr +HyMtzimZVos8zD8aJn2Sy94= +=JB2d -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index a416a0e5e3..49ea63e4ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7aaf8772274422f5020fad9eea490e195170720f \ No newline at end of file +e059152adce3a8fb693f082b82b5669a238c8d6f \ No newline at end of file diff --git a/src/main.c b/src/main.c index ac82256a98..94fdf384b1 100644 --- a/src/main.c +++ b/src/main.c @@ -529,7 +529,7 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){ { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys }, { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger }, }; - int i; + unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ for(i=0; i