diff options
-rw-r--r-- | manifest | 18 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/expr.c | 21 | ||||
-rw-r--r-- | src/select.c | 26 | ||||
-rw-r--r-- | test/bind.test | 13 | ||||
-rw-r--r-- | test/select1.test | 34 |
6 files changed, 72 insertions, 42 deletions
@@ -1,5 +1,5 @@ -C Remove\sobsolete\scode\sfrom\sselect.c,\sincluding\sthe\s"affinity"\sparameter\nto\sthe\ssqlite3Select()\smodule.\s(CVS\s5380) -D 2008-07-08T23:40:20 +C Additional\stest\scoverage\sin\sselect.c\sand\sexpr.c.\s(CVS\s5381) +D 2008-07-09T01:39:44 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -103,7 +103,7 @@ F src/callback.c aa492a0ad8c2d454edff9fb8a57fae13743cf71d F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c F src/date.c e841168e5520bbbb2a1cbcdce7531d8b23017b4d F src/delete.c 4a1f98fb2ffead69c8c685dcac33253ac6f9d56d -F src/expr.c 6343c50c2bc39ac4f653b1eebd1339e25378b0e7 +F src/expr.c 17f7deae5c7a7813a86295813e757219d1a25cf9 F src/fault.c 3638519d1e0b82bccfafcb9f5ff491918b28f8e1 F src/func.c 08422a7bd06c25c5e6823d525f7c63563e3fcf61 F src/global.c f12dc84d23f52d2ed42d1bdb5460fa3caf63e890 @@ -140,7 +140,7 @@ F src/pragma.c 6fad83fbcc7ec6e76d91fe2805fe972ff3af6a0c F src/prepare.c c9bb0aacb7a571d049805699ed18f2bb136ea091 F src/printf.c 0e4bd1413226e8aaeadec251ffcee93448400417 F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a -F src/select.c 02b7877754dd8391e48c3ba94b2b3bc8c3a74f20 +F src/select.c e6edf11f024a5207e34683a25f33a700a2f1b43b F src/shell.c 484e7297e066f22830f9c15d7abbcdd2acb097b0 F src/sqlite.h.in 22c32cedf7e435d5b3bb8564ce0a640c40dbbfb1 F src/sqlite3ext.h 1e3887c9bd3ae66cb599e922824b04cd0d0f2c3e @@ -216,7 +216,7 @@ F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f F test/between.test 16b1776c6323faadb097a52d673e8e3d8be7d070 F test/bigfile.test 9a6a8346e4042d9c781ed6cb6553ac871ae30618 F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747 -F test/bind.test 6cd35462394bdbf5928ad3f80f6fc43eab0be5ba +F test/bind.test b5e3ffbad2b43b7cf675dd3624176510d8379978 F test/bindxfer.test 995d2cf8df61204d748cde6960443121c4ccd2e1 F test/bitvec.test 62a512c3f7041d1df12558eb25990e5a19820571 F test/blob.test 2a38d867bdf08f9ce081776acec1ac8d4bca66be @@ -441,7 +441,7 @@ F test/rtree.test a8404a59bbc3a7827db9bfb334790c852f0391b3 F test/safety.test b69e2b2dd5d52a3f78e216967086884bbc1a09c6 F test/schema.test a8b000723375fd42c68d310091bdbd744fde647c F test/schema2.test 35e1c9696443d6694c8980c411497c2b5190d32e -F test/select1.test 9f9d90c40b84d1d2cff651db1c0245a882e2b180 +F test/select1.test 6cea013e127fd8091ce1f80984a5bbe687088587 F test/select2.test 06a2660de57673e2d076c29c0fd73f961a930f87 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 F test/select4.test 0618c9377013840194b7901e6224d841cd3e7193 @@ -600,7 +600,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 9da0b32c8c55b41cbcb4eb635c51348072101ea9 -R ddba1a74c7f8c0729773c7fe021be047 +P cbd3c1585b7a8f8042aa1448fe1be87de056c41a +R 9c8b6c813e587d92b499775ff9d0704e U drh -Z 19507801db0a91231559be894402bb80 +Z 797145b83fcaf2766400631bd4924b1a diff --git a/manifest.uuid b/manifest.uuid index ff5dc166a..1333ce0d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbd3c1585b7a8f8042aa1448fe1be87de056c41a
\ No newline at end of file +c6cf08477cc4d622a05ad6706cb9418cf7eea432
\ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 1929eb7d2..b6f55a19b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.384 2008/07/08 23:40:20 drh Exp $ +** $Id: expr.c,v 1.385 2008/07/09 01:39:44 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -246,7 +246,7 @@ static int codeCompare( addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1, (void*)p4, P4_COLLSEQ); sqlite3VdbeChangeP5(pParse->pVdbe, p5); - if( p5 & SQLITE_AFF_MASK ){ + if( (p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_NONE ){ sqlite3ExprCacheAffinityChange(pParse, in1, 1); sqlite3ExprCacheAffinityChange(pParse, in2, 1); } @@ -375,12 +375,15 @@ Expr *sqlite3Expr( pNew->pLeft = pLeft; pNew->pRight = pRight; pNew->iAgg = -1; + pNew->span.z = (u8*)""; if( pToken ){ assert( pToken->dyn==0 ); pNew->span = pNew->token = *pToken; }else if( pLeft ){ if( pRight ){ - sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span); + if( pRight->span.dyn==0 && pLeft->span.dyn==0 ){ + sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span); + } if( pRight->flags & EP_ExpCollate ){ pNew->flags |= EP_ExpCollate; pNew->pColl = pRight->pColl; @@ -456,19 +459,15 @@ Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){ /* ** Set the Expr.span field of the given expression to span all -** text between the two given tokens. +** text between the two given tokens. Both tokens must be pointing +** at the same string. */ void sqlite3ExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){ assert( pRight!=0 ); assert( pLeft!=0 ); if( pExpr && pRight->z && pLeft->z ){ - assert( pLeft->dyn==0 || pLeft->z[pLeft->n]==0 ); - if( pLeft->dyn==0 && pRight->dyn==0 ){ - pExpr->span.z = pLeft->z; - pExpr->span.n = pRight->n + (pRight->z - pLeft->z); - }else{ - pExpr->span.z = 0; - } + pExpr->span.z = pLeft->z; + pExpr->span.n = pRight->n + (pRight->z - pLeft->z); } } diff --git a/src/select.c b/src/select.c index 7bd7c59e9..f5ee47d92 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.451 2008/07/08 23:40:20 drh Exp $ +** $Id: select.c,v 1.452 2008/07/09 01:39:44 drh Exp $ */ #include "sqliteInt.h" @@ -542,11 +542,7 @@ static void selectInnerLoop( if( v==0 ) return; assert( pEList!=0 ); - - /* If there was a LIMIT clause on the SELECT statement, then do the check - ** to see if this row should be output. - */ - hasDistinct = distinct>=0 && pEList->nExpr>0; + hasDistinct = distinct>=0; if( pOrderBy==0 && !hasDistinct ){ codeOffset(v, p, iContinue); } @@ -724,7 +720,9 @@ static void selectInnerLoop( /* Jump to the end of the loop if the LIMIT is reached. */ - if( p->iLimit && pOrderBy==0 ){ + if( p->iLimit ){ + assert( pOrderBy==0 ); /* If there is an ORDER BY, the call to + ** pushOntoSorter() would have cleared p->iLimit */ sqlite3VdbeAddOp2(v, OP_AddImm, p->iLimit, -1); sqlite3VdbeAddOp2(v, OP_IfZero, p->iLimit, iBreak); } @@ -1079,9 +1077,7 @@ static void generateColumnNames( if( pEList->a[i].zName ){ char *zName = pEList->a[i].zName; sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, strlen(zName)); - continue; - } - if( p->op==TK_COLUMN && pTabList ){ + }else if( p->op==TK_COLUMN && pTabList ){ Table *pTab; char *zCol; int iCol = p->iColumn; @@ -1095,7 +1091,7 @@ static void generateColumnNames( }else{ zCol = pTab->aCol[iCol].zName; } - if( !shortNames && !fullNames && p->span.z && p->span.z[0] ){ + if( !shortNames && !fullNames ){ sqlite3VdbeSetColName(v, i, COLNAME_NAME, (char*)p->span.z, p->span.n); }else if( fullNames || (!shortNames && pTabList->nSrc>1) ){ char *zName = 0; @@ -1108,14 +1104,8 @@ static void generateColumnNames( }else{ sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, strlen(zCol)); } - }else if( p->span.z && p->span.z[0] ){ - sqlite3VdbeSetColName(v, i, COLNAME_NAME, (char*)p->span.z, p->span.n); - /* sqlite3VdbeCompressSpace(v, addr); */ }else{ - char zName[30]; - assert( p->op!=TK_COLUMN || pTabList==0 ); - sqlite3_snprintf(sizeof(zName), zName, "column%d", i+1); - sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, 0); + sqlite3VdbeSetColName(v, i, COLNAME_NAME, (char*)p->span.z, p->span.n); } } generateColumnTypes(pParse, pTabList, pEList); diff --git a/test/bind.test b/test/bind.test index 3b7499866..57cec03e8 100644 --- a/test/bind.test +++ b/test/bind.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_bind API. # -# $Id: bind.test,v 1.43 2008/07/08 00:06:51 drh Exp $ +# $Id: bind.test,v 1.44 2008/07/09 01:39:44 drh Exp $ # set testdir [file dirname $argv0] @@ -438,7 +438,7 @@ do_test bind-9.2 { } msg] lappend rc $msg } {1 {(1) variable number must be between ?1 and ?999}} -do_test bind-9.3 { +do_test bind-9.3.1 { set VM [ sqlite3_prepare $DB { INSERT INTO t2(a,b) VALUES(?1,?999) @@ -447,6 +447,15 @@ do_test bind-9.3 { sqlite3_bind_parameter_count $VM } {999} catch {sqlite3_finalize $VM} +do_test bind-9.3.2 { + set VM [ + sqlite3_prepare $DB { + INSERT INTO t2(a,b) VALUES(?2,?998) + } -1 TAIL + ] + sqlite3_bind_parameter_count $VM +} {998} +catch {sqlite3_finalize $VM} do_test bind-9.4 { set VM [ sqlite3_prepare $DB { diff --git a/test/select1.test b/test/select1.test index 431081dde..0b04b3916 100644 --- a/test/select1.test +++ b/test/select1.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # -# $Id: select1.test,v 1.61 2008/06/24 12:46:31 drh Exp $ +# $Id: select1.test,v 1.62 2008/07/09 01:39:44 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -506,6 +506,38 @@ do_test select1-6.9.2 { lappend v $msg } {0 {f1 11 f1 11 f1 33 f1 33 f1 11 f1 11 f1 33 f1 33}} +do_test select1-6.9.3 { + db eval { + PRAGMA short_column_names=OFF; + PRAGMA full_column_names=OFF; + } + execsql2 { + SELECT test1 . f1, test1 . f2 FROM test1 LIMIT 1 + } +} {{test1 . f1} 11 {test1 . f2} 22} +do_test select1-6.9.4 { + db eval { + PRAGMA short_column_names=OFF; + PRAGMA full_column_names=ON; + } + execsql2 { + SELECT test1 . f1, test1 . f2 FROM test1 LIMIT 1 + } +} {test1.f1 11 test1.f2 22} +do_test select1-6.9.5 { + db eval { + PRAGMA short_column_names=OFF; + PRAGMA full_column_names=ON; + } + execsql2 { + SELECT 123.45; + } +} {123.45 123.45} +db eval { + PRAGMA short_column_names=ON; + PRAGMA full_column_names=OFF; +} + ifcapable compound { do_test select1-6.10 { set v [catch {execsql2 { |