1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

More coverage improvements. (CVS 6148)

FossilOrigin-Name: 6e171c0a64850013b26a223189d5bebcc0a01a8b
This commit is contained in:
drh
2009-01-09 02:49:31 +00:00
parent e2f02bacc1
commit 1c767f0df3
8 changed files with 80 additions and 71 deletions

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.497 2009/01/09 01:12:28 drh Exp $
** $Id: select.c,v 1.498 2009/01/09 02:49:32 drh Exp $
*/
#include "sqliteInt.h"
@@ -342,7 +342,7 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){
Table *pRightTab = pRight->pTab;
int isOuter;
if( pLeftTab==0 || pRightTab==0 ) continue;
if( NEVER(pLeftTab==0 || pRightTab==0) ) continue;
isOuter = (pRight->jointype & JT_OUTER)!=0;
/* When the NATURAL keyword is present, add WHERE clause terms for
@@ -542,7 +542,8 @@ static void selectInnerLoop(
int iParm = pDest->iParm; /* First argument to disposal method */
int nResultCol; /* Number of result columns */
if( v==0 ) return;
assert( v );
if( NEVER(v==0) ) return;
assert( pEList!=0 );
hasDistinct = distinct>=0;
if( pOrderBy==0 && !hasDistinct ){
@@ -560,11 +561,8 @@ static void selectInnerLoop(
pDest->iMem = pParse->nMem+1;
pDest->nMem = nResultCol;
pParse->nMem += nResultCol;
}else if( pDest->nMem!=nResultCol ){
/* This happens when two SELECTs of a compound SELECT have differing
** numbers of result columns. The error message will be generated by
** a higher-level routine. */
return;
}else{
assert( pDest->nMem==nResultCol );
}
regResult = pDest->iMem;
if( nColumn>0 ){
@@ -813,6 +811,8 @@ static void generateSortTail(
switch( eDest ){
case SRT_Table:
case SRT_EphemTab: {
testcase( eDest==SRT_Table );
testcase( eDest==SRT_EphemTab );
sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
@@ -836,6 +836,8 @@ static void generateSortTail(
case SRT_Output:
case SRT_Coroutine: {
int i;
testcase( eDest==SRT_Output );
testcase( eDest==SRT_Coroutine );
sqlite3VdbeAddOp2(v, OP_Integer, 1, regRowid);
sqlite3VdbeAddOp3(v, OP_Insert, pseudoTab, regRow, regRowid);
for(i=0; i<nColumn; i++){
@@ -946,7 +948,7 @@ static const char *columnType(
** of the SELECT statement. Return the declaration type and origin
** data for the result-set column of the sub-select.
*/
if( iCol>=0 && iCol<pS->pEList->nExpr ){
if( ALWAYS(iCol>=0 && iCol<pS->pEList->nExpr) ){
/* If iCol is less than zero, then the expression requests the
** rowid of the sub-select or view. This expression is legal (see
** test case misc2.2.2) - it always evaluates to NULL.
@@ -958,7 +960,7 @@ static const char *columnType(
sNC.pParse = pNC->pParse;
zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
}
}else if( pTab->pSchema ){
}else if( ALWAYS(pTab->pSchema) ){
/* A real table */
assert( !pS );
if( iCol<0 ) iCol = pTab->iPKey;
@@ -1098,13 +1100,9 @@ static void generateColumnNames(
if( !shortNames && !fullNames ){
sqlite3VdbeSetColName(v, i, COLNAME_NAME,
sqlite3DbStrNDup(db, (char*)p->span.z, p->span.n), SQLITE_DYNAMIC);
}else if( fullNames || (!shortNames && pTabList->nSrc>1) ){
}else if( fullNames ){
char *zName = 0;
char *zTab;
zTab = pTabList->a[j].zAlias;
if( fullNames || zTab==0 ) zTab = pTab->zName;
zName = sqlite3MPrintf(db, "%s.%s", zTab, zCol);
zName = sqlite3MPrintf(db, "%s.%s", pTab->zName, zCol);
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);
}else{
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);