1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Add a few more tests and fix a few bugs that the tests uncovered. (CVS 652)

FossilOrigin-Name: 91c0db66c86facb21b5b522afadd83d91a488256
This commit is contained in:
drh
2002-06-29 02:20:08 +00:00
parent 3b167c7583
commit a9f9d1c08b
10 changed files with 96 additions and 38 deletions

View File

@@ -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 <ctype.h>
@@ -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;

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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.

View File

@@ -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 <ctype.h>
@@ -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;