From a9f9d1c08b26485efd8339c66faa68c18f3f101e Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 29 Jun 2002 02:20:08 +0000 Subject: [PATCH] Add a few more tests and fix a few bugs that the tests uncovered. (CVS 652) FossilOrigin-Name: 91c0db66c86facb21b5b522afadd83d91a488256 --- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/expr.c | 4 ++-- src/select.c | 8 +++++--- src/sqliteInt.h | 3 ++- src/update.c | 10 +++------- src/vdbe.c | 23 ++++++++++++++++++----- test/expr.test | 6 +++--- test/func.test | 32 ++++++++++++++++++++++++++++++-- test/subselect.test | 20 +++++++++++++++++++- 10 files changed, 96 insertions(+), 38 deletions(-) diff --git a/manifest b/manifest index 38597d349f..a2d62defe6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\stest\scases\sadded.\s\sThe\sfollowing\sbug\sfixed:\sA\ssegfault\swas\soccurring\nif\sa\sVIEW\sconsisted\sof\sa\sjoin\swith\sa\sUSING\sclause.\s(CVS\s651) -D 2002-06-28T12:18:47 +C Add\sa\sfew\smore\stests\sand\sfix\sa\sfew\sbugs\sthat\sthe\stests\suncovered.\s(CVS\s652) +D 2002-06-29T02:20:08 F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0 @@ -23,7 +23,7 @@ F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3 F src/build.c 0834185cbe316dda5173de50886ed804b82e3ba6 F src/delete.c 44c45460b1e03033756e35adc6d569ffbf30b725 F src/encode.c 346b12b46148506c32038524b95c4631ab46d760 -F src/expr.c c5b8ee4d51df4de4ee51cadfd0123294e3d683d5 +F src/expr.c ecd8267f70f4099b760c3862527a52cdfb768612 F src/func.c 5eae8227a8b0d276a64d51a3880a6e86f238fedf F src/hash.c 6a6236b89c8c060c65dabd300a1c8ce7c10edb72 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8 @@ -37,11 +37,11 @@ F src/pager.h 6fddfddd3b73aa8abc081b973886320e3c614f0e F src/parse.y c75ea2580de675bcb80ff8b7c10c0a15e02a21ab F src/printf.c 236ed7a79386feed4456fa728fff8be793f1547c F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe -F src/select.c 473670ff00c30ffa92784a49766c522181239a9a +F src/select.c 63a10ea636c8ac8cdf2fbb804fbfcfd372150717 F src/shell.c 0b06e4421ddf34f30263a2674abe768a2b5fd538 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/sqlite.h.in 75c5bbb066d0faf34424b7d1babf8b44d5b31af2 -F src/sqliteInt.h 0f2cca162fbb352ca53f97283dbafce31495dcce +F src/sqliteInt.h 314a4feb08cccdeb90b434e6dde86b93d2f36b8e F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63 F src/tclsqlite.c e932591c0bb522b0a35ea7dc861c623ccb2e3aa8 F src/test1.c 29ed719d8ce890733fbeadb53cacc4e542d423ed @@ -50,9 +50,9 @@ F src/test3.c 72ac6a9017a70e542954907a1dfd87ab6f7824e3 F src/threadtest.c 81f0598e0f031c1bd506af337fdc1b7e8dff263f F src/tokenize.c ac4c46f190346b87da54ec3e2605d160af80c619 F src/trigger.c d88ab4d68d68955c217b38fb6717e090fbbf54a4 -F src/update.c 6f6a4dcd71cd9ff730b7f12c83de5498cde4924f +F src/update.c 06303bf3895032c7eccb748927f650ed02b9f0cf F src/util.c 876b259f9186e84b944b72e793dd3dad50e63e95 -F src/vdbe.c 0c7783ba52b1bd9e40331937c32d3aa3351ff4a3 +F src/vdbe.c c83ece2aeb3a6ce7de9a1636c98c3feec9267499 F src/vdbe.h a9292f2b5fcecef924fa255fb74609e9cbc776c2 F src/where.c 6a43aa6c80eab12221eeca754cba852a9ecd1e13 F test/all.test e4d3821eeba751829b419cd47814bd20af4286d1 @@ -63,8 +63,8 @@ F test/btree3.test 9caa9e22491dd8cd8aa36d7ac3b48b089817c895 F test/conflict.test 4518cc3c1c40c4ba74220d9ee814257ae7d09c47 F test/copy.test 92e21ebea11319c3f70448d3763fdaa0e2f1c21f F test/delete.test c904a62129fe102b314a96111a8417f10249e4d8 -F test/expr.test c61a92f7d76d63d7379d58bc35245e156c9b63c3 -F test/func.test 628ab513b0d9c54251a63e026a26b7b4347e54ab +F test/expr.test 5fadd0bc87c223b424ce6752b576c1df346abf1f +F test/func.test 7e5500c9db4b02fd62f9737931a6ada01e3b55d0 F test/in.test c09312672e3f0709fa02c8e2e9cd8fb4bd6269aa F test/index.test c8a471243bbf878974b99baf5badd59407237cf3 F test/insert.test a122afb86911e77c181d912348866a5b1a61eeab @@ -94,7 +94,7 @@ F test/select4.test 10ba54f24ef6ca7958a7045b001079378db2370c F test/select5.test c2a6c4a003316ee42cbbd689eebef8fdce0db2ac F test/select6.test efb8d0c07a440441db87db2c4ade6904e1407e85 F test/sort.test 3b996ce7ca385f9cd559944ac0f4027a23aa546b -F test/subselect.test f3bc1dcbddddcea08d818fcff75228ad3464fc83 +F test/subselect.test 64e71b1be804dc57c72b61d2bd7b506dbc962c40 F test/table.test 42511f98a3e9bbee62913e3ae1774777faa23d35 F test/tableapi.test 3c80421a889e1d106df16e5800fa787f0d2914a6 F test/tclsqlite.test 6f4b9760681c7dbca52a18d0ab46a1679cdc79b9 @@ -137,7 +137,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P c07e493b62125e85eaea36b6945f1e146e2792b8 -R 533eee0cd3864ec067733fb32b2f681d +P 96515b813eb57e1f48c28d357d1f38639b2fdcfa +R c1f2449afe59030f9bd638b2fb549a9b U drh -Z 42e105a8fbfb4f79b6ee97023cbdbecf +Z e559f098ea075de4e2b198f365f605ef diff --git a/manifest.uuid b/manifest.uuid index 5edd00ebdc..dbe121612b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96515b813eb57e1f48c28d357d1f38639b2fdcfa \ No newline at end of file +91c0db66c86facb21b5b522afadd83d91a488256 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 5b0cbd1b28..5b2d762e6d 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.75 2002/06/28 12:18:47 drh Exp $ +** $Id: expr.c,v 1.76 2002/06/29 02:20:08 drh Exp $ */ #include "sqliteInt.h" #include @@ -370,7 +370,7 @@ int sqliteExprIsInteger(Expr *p, int *pValue){ /* ** Return TRUE if the given string is a row-id column name. */ -static int sqliteIsRowid(const char *z){ +int sqliteIsRowid(const char *z){ if( sqliteStrICmp(z, "_ROWID_")==0 ) return 1; if( sqliteStrICmp(z, "ROWID")==0 ) return 1; if( sqliteStrICmp(z, "OID")==0 ) return 1; diff --git a/src/select.c b/src/select.c index d815061a3b..92fa302a52 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.101 2002/06/28 12:18:47 drh Exp $ +** $Id: select.c,v 1.102 2002/06/29 02:20:08 drh Exp $ */ #include "sqliteInt.h" @@ -436,14 +436,16 @@ static int selectInnerLoop( ** item into the set table with bogus data. */ case SRT_Set: { + int lbl = sqliteVdbeMakeLabel(v); assert( nColumn==1 ); - sqliteVdbeAddOp(v, OP_IsNull, -1, sqliteVdbeCurrentAddr(v)+3); - sqliteVdbeAddOp(v, OP_String, 0, 0); + sqliteVdbeAddOp(v, OP_IsNull, -1, lbl); if( pOrderBy ){ pushOntoSorter(pParse, v, pOrderBy); }else{ + sqliteVdbeAddOp(v, OP_String, 0, 0); sqliteVdbeAddOp(v, OP_PutStrKey, iParm, 0); } + sqliteVdbeResolveLabel(v, lbl); break; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f8b45567b7..5f842e0c03 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.132 2002/06/28 12:18:47 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.133 2002/06/29 02:20:09 drh Exp $ */ #include "sqlite.h" #include "hash.h" @@ -908,6 +908,7 @@ void sqliteRollbackTransaction(Parse*); char *sqlite_mprintf(const char *, ...); int sqliteExprIsConstant(Expr*); int sqliteExprIsInteger(Expr*, int*); +int sqliteIsRowid(const char*); void sqliteGenerateRowDelete(Vdbe*, Table*, int, int); void sqliteGenerateRowIndexDelete(Vdbe*, Table*, int, char*); void sqliteGenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int); diff --git a/src/update.c b/src/update.c index 61ef0d267b..0a6f6db203 100644 --- a/src/update.c +++ b/src/update.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** -** $Id: update.c,v 1.45 2002/06/19 14:27:06 drh Exp $ +** $Id: update.c,v 1.46 2002/06/29 02:20:09 drh Exp $ */ #include "sqliteInt.h" @@ -293,12 +293,8 @@ void sqliteUpdate( ** on top of the stack.) */ if( chngRecno ){ - if( pTab->iPKey<0 || (j = aXRef[pTab->iPKey])<0 ){ - sqliteVdbeAddOp(v, OP_Dup, 0, 0); - }else{ - sqliteExprCode(pParse, pChanges->a[j].pExpr); - sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); - } + sqliteExprCode(pParse, pRecnoExpr); + sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0); } /* Compute new data for this record. diff --git a/src/vdbe.c b/src/vdbe.c index 1d3cbd9fa2..83b36d90ce 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -30,7 +30,7 @@ ** But other routines are also provided to help in building up ** a program instruction by instruction. ** -** $Id: vdbe.c,v 1.162 2002/06/28 01:02:38 drh Exp $ +** $Id: vdbe.c,v 1.163 2002/06/29 02:20:09 drh Exp $ */ #include "sqliteInt.h" #include @@ -1649,7 +1649,8 @@ case OP_NullCallback: { ** Look at the first P1 elements of the stack. Append them all ** together with the lowest element first. Use P3 as a separator. ** Put the result on the top of the stack. The original P1 elements -** are popped from the stack if P2==0 and retained if P2==1. +** are popped from the stack if P2==0 and retained if P2==1. If +** any element of the stack is NULL, then the result is NULL. ** ** If P3 is NULL, then use no separator. When P1==1, this routine ** makes a copy of the top stack element into memory obtained @@ -1671,12 +1672,21 @@ case OP_Concat: { nByte = 1 - nSep; for(i=p->tos-nField+1; i<=p->tos; i++){ if( aStack[i].flags & STK_Null ){ - nByte += nSep; + nByte = -1; + break; }else{ if( Stringify(p, i) ) goto no_mem; nByte += aStack[i].n - 1 + nSep; } } + if( nByte<0 ){ + if( pOp->p2==0 ) PopStack(p, nField); + VERIFY( NeedStack(p, p->tos+1); ) + p->tos++; + aStack[p->tos].flags = STK_Null; + zStack[p->tos] = 0; + break; + } zNew = sqliteMalloc( nByte ); if( zNew==0 ) goto no_mem; j = 0; @@ -4194,11 +4204,14 @@ case OP_SortPut: { pSorter->pNext = p->pSort; p->pSort = pSorter; assert( aStack[tos].flags & STK_Dyn ); - assert( aStack[nos].flags & STK_Dyn ); pSorter->nKey = aStack[tos].n; pSorter->zKey = zStack[tos]; pSorter->nData = aStack[nos].n; - pSorter->pData = zStack[nos]; + if( aStack[nos].flags & STK_Dyn ){ + pSorter->pData = zStack[nos]; + }else{ + pSorter->pData = sqliteStrDup(zStack[nos]); + } aStack[tos].flags = 0; aStack[nos].flags = 0; zStack[tos] = 0; diff --git a/test/expr.test b/test/expr.test index 1acb06203d..c672988cb7 100644 --- a/test/expr.test +++ b/test/expr.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing expressions. # -# $Id: expr.test,v 1.24 2002/05/31 15:51:26 drh Exp $ +# $Id: expr.test,v 1.25 2002/06/29 02:20:09 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -181,8 +181,8 @@ test_expr expr-3.27 {t1=NULL, t2='hi'} {t1 notnull} 0 test_expr expr-3.28 {t1=NULL, t2='hi'} {t2 notnull} 1 test_expr expr-3.28b {t1=NULL, t2='hi'} {t2 is not null} 1 test_expr expr-3.29 {t1='xyz', t2='abc'} {t1||t2} {xyzabc} -test_expr expr-3.30 {t1=NULL, t2='abc'} {t1||t2} {abc} -test_expr expr-3.31 {t1='xyz', t2=NULL} {t1||t2} {xyz} +test_expr expr-3.30 {t1=NULL, t2='abc'} {t1||t2} {{}} +test_expr expr-3.31 {t1='xyz', t2=NULL} {t1||t2} {{}} test_expr expr-3.32 {t1='xyz', t2='abc'} {t1||' hi '||t2} {{xyz hi abc}} test_expr expr-4.1 {t1='abc', t2='Abc'} {t1