Exclude a few more lines of code using OMIT macros. (CVS 2253)
FossilOrigin-Name: c6fc49e61033419e78b6b10638d57f4942087961
diff --git a/src/btree.c b/src/btree.c
index e55d450..8eb474c 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.242 2005/01/21 00:22:38 drh Exp $
+** $Id: btree.c,v 1.243 2005/01/21 08:13:14 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -1324,10 +1324,12 @@
** is a very low but non-zero probability of damage. Level 3 reduces the
** probability of damage to near zero but with a write performance reduction.
*/
+#ifndef SQLITE_OMIT_PAGER_PRAGMAS
int sqlite3BtreeSetSafetyLevel(Btree *pBt, int level){
sqlite3pager_set_safety_level(pBt->pPager, level);
return SQLITE_OK;
}
+#endif
/*
** Change the default pages size and the number of reserved bytes per page.
diff --git a/src/expr.c b/src/expr.c
index c96eb59..a47e350 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.186 2005/01/20 22:48:48 drh Exp $
+** $Id: expr.c,v 1.187 2005/01/21 08:13:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -446,6 +446,15 @@
}
return pNew;
}
+
+/*
+** If cursors, triggers, views and subqueries are all omitted from
+** the build, then none of the following routines, except for
+** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes
+** called with a NULL argument.
+*/
+#if !defined(SQLITE_OMIT_CURSOR) || !defined(SQLITE_OMIT_VIEW) \
+ || !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_SUBQUERY)
SrcList *sqlite3SrcListDup(SrcList *p){
SrcList *pNew;
int i;
@@ -509,6 +518,12 @@
pNew->pFetch = 0;
return pNew;
}
+#else
+Select *sqlite3SelectDup(Select *p){
+ assert( p==0 );
+ return 0;
+}
+#endif
/*
@@ -1549,7 +1564,6 @@
VdbeComment((v, "# load subquery result"));
break;
}
-#endif
case TK_IN: {
int addr;
char affinity;
@@ -1577,6 +1591,7 @@
break;
}
+#endif
case TK_BETWEEN: {
Expr *pLeft = pExpr->pLeft;
struct ExprList_item *pLItem = pExpr->pList->a;
@@ -1669,6 +1684,7 @@
}
}
+#ifndef SQLITE_OMIT_TRIGGER
/*
** Generate code that evalutes the given expression and leaves the result
** on the stack. See also sqlite3ExprCode().
@@ -1693,6 +1709,7 @@
pExpr->op = TK_REGISTER;
}
}
+#endif
/*
** Generate code that pushes the value of every element of the given
diff --git a/src/main.c b/src/main.c
index 302caa6..e2ffd31 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.272 2005/01/18 16:02:40 drh Exp $
+** $Id: main.c,v 1.273 2005/01/21 08:13:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -713,6 +713,7 @@
return SQLITE_ERROR;
}
+#ifndef SQLITE_OMIT_UTF16
/* If SQLITE_UTF16 is specified as the encoding type, transform this
** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
@@ -732,6 +733,9 @@
if( rc!=SQLITE_OK ) return rc;
enc = SQLITE_UTF16BE;
}
+#else
+ enc = SQLITE_UTF8;
+#endif
p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 1);
if( p==0 ) return SQLITE_NOMEM;
@@ -741,6 +745,7 @@
p->pUserData = pUserData;
return SQLITE_OK;
}
+#ifndef SQLITE_OMIT_UTF16
int sqlite3_create_function16(
sqlite3 *db,
const void *zFunctionName,
@@ -769,6 +774,7 @@
pUserData, xFunc, xStep, xFinal);
return rc;
}
+#endif
/*
** Register a trace function. The pArg from the previously registered trace
@@ -1013,6 +1019,7 @@
if( pzTail ) *pzTail = sParse.zTail;
rc = sParse.rc;
+#ifndef SQLITE_OMIT_EXPLAIN
if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){
sqlite3VdbeSetNumCols(sParse.pVdbe, 5);
sqlite3VdbeSetColName(sParse.pVdbe, 0, "addr", P3_STATIC);
@@ -1021,6 +1028,7 @@
sqlite3VdbeSetColName(sParse.pVdbe, 3, "p2", P3_STATIC);
sqlite3VdbeSetColName(sParse.pVdbe, 4, "p3", P3_STATIC);
}
+#endif
prepare_out:
if( sqlite3SafetyOff(db) ){
diff --git a/src/pager.c b/src/pager.c
index 1a53c4c..5f0f71a 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.184 2005/01/20 11:32:24 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.185 2005/01/21 08:13:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -1438,11 +1438,13 @@
** Numeric values associated with these states are OFF==1, NORMAL=2,
** and FULL=3.
*/
+#ifndef SQLITE_OMIT_PAGER_PRAGMAS
void sqlite3pager_set_safety_level(Pager *pPager, int level){
pPager->noSync = level==1 || pPager->tempFile;
pPager->fullSync = level==3 && !pPager->tempFile;
if( pPager->noSync ) pPager->needSync = 0;
}
+#endif
/*
** Open a temporary file. Write the name of the file into zName
@@ -2847,6 +2849,7 @@
}
+#ifndef SQLITE_OMIT_MEMORYDB
/*
** Clear a PgHistory block
*/
@@ -2856,6 +2859,9 @@
pHist->pOrig = 0;
pHist->pStmt = 0;
}
+#else
+#define clearHistory(x)
+#endif
/*
** Commit all changes to the database and release the write lock.
@@ -3418,7 +3424,7 @@
}
#endif
-#ifdef SQLITE_TEST
+#ifdef SQLITE_DEBUG
/*
** Print a listing of all referenced pages and their ref count.
*/
diff --git a/src/select.c b/src/select.c
index 74c4c04..533d1b2 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.232 2005/01/20 22:48:48 drh Exp $
+** $Id: select.c,v 1.233 2005/01/21 08:13:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -475,6 +475,7 @@
break;
}
+#ifndef SQLITE_OMIT_SUBQUERY
/* If we are creating a set for an "expr IN (SELECT ...)" construct,
** then there should be a single item on the stack. Write this
** item into the set table with bogus data.
@@ -515,6 +516,7 @@
}
break;
}
+#endif /* #ifndef SQLITE_OMIT_SUBQUERY */
/* Send the data to the callback function.
*/
@@ -543,6 +545,7 @@
break;
}
+#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_CURSOR)
/* Discard the results. This is used for SELECT statements inside
** the body of a TRIGGER. The purpose of such selects is to call
** user-defined functions that have side effects. We do not care
@@ -553,6 +556,7 @@
sqlite3VdbeAddOp(v, OP_Pop, nColumn, 0);
break;
}
+#endif
}
return 0;
}
@@ -608,6 +612,7 @@
sqlite3VdbeAddOp(v, OP_PutIntKey, iParm, 0);
break;
}
+#ifndef SQLITE_OMIT_SUBQUERY
case SRT_Set: {
assert( nColumn==1 );
sqlite3VdbeAddOp(v, OP_NotNull, -1, sqlite3VdbeCurrentAddr(v)+3);
@@ -625,6 +630,7 @@
sqlite3VdbeAddOp(v, OP_Goto, 0, end1);
break;
}
+#endif
case SRT_Callback:
case SRT_Subroutine: {
int i;
@@ -692,11 +698,13 @@
}
break;
}
+#ifndef SQLITE_OMIT_SUBQUERY
case TK_SELECT: {
Select *pS = pExpr->pSelect;
zType = columnType(pParse, pS->pSrc, pS->pEList->a[0].pExpr);
break;
}
+#endif
default:
zType = 0;
}
@@ -803,6 +811,7 @@
generateColumnTypes(pParse, pTabList, pEList);
}
+#ifndef SQLITE_OMIT_COMPOUND_SELECT
/*
** Name of the connection operator, used for error messages.
*/
@@ -816,6 +825,7 @@
}
return z;
}
+#endif /* SQLITE_OMIT_COMPOUND_SELECT */
/*
** Forward declaration
@@ -958,6 +968,7 @@
return 0;
}
if( pFrom->zName==0 ){
+#ifndef SQLITE_OMIT_SUBQUERY
/* A sub-query in the FROM clause of a SELECT */
assert( pFrom->pSelect!=0 );
if( pFrom->zAlias==0 ){
@@ -974,6 +985,7 @@
** pTab is not pointing to a persistent table structure that defines
** part of the schema. */
pTab->isTransient = 1;
+#endif
}else{
/* An ordinary table or view name in the FROM clause */
pFrom->pTab = pTab =
@@ -981,6 +993,7 @@
if( pTab==0 ){
return 1;
}
+#ifndef SQLITE_OMIT_VIEW
if( pTab->pSelect ){
/* We reach here if the named table is a really a view */
if( sqlite3ViewGetColumnNames(pParse, pTab) ){
@@ -995,6 +1008,7 @@
pFrom->pSelect = sqlite3SelectDup(pTab->pSelect);
}
}
+#endif
}
}
@@ -1147,6 +1161,7 @@
}
#endif
+#ifndef SQLITE_OMIT_COMPOUND_SELECT
/*
** This routine associates entries in an ORDER BY expression list with
** columns in a result. For each ORDER BY expression, the opcode of
@@ -1229,6 +1244,7 @@
}
return nErr;
}
+#endif /* #ifndef SQLITE_OMIT_COMPOUND_SELECT */
/*
** Get a VDBE for the given parser context. Create a new one if necessary.
@@ -2376,11 +2392,13 @@
** only a single column may be output.
*/
assert( eDest!=SRT_Exists || pEList->nExpr==1 );
+#ifndef SQLITE_OMIT_SUBQUERY
if( (eDest==SRT_Mem || eDest==SRT_Set) && pEList->nExpr>1 ){
sqlite3ErrorMsg(pParse, "only a single result allowed for "
"a SELECT that is part of an expression");
goto select_end;
}
+#endif
/* ORDER BY is ignored for some destinations.
*/
@@ -2707,6 +2725,7 @@
generateSortTail(pParse, p, v, pEList->nExpr, eDest, iParm);
}
+#ifndef SQLITE_OMIT_SUBQUERY
/* If this was a subquery, we have now converted the subquery into a
** temporary table. So delete the subquery structure from the parent
** to prevent this subquery from being evaluated again and to force the
@@ -2718,6 +2737,7 @@
sqlite3SelectDelete(p);
pParent->pSrc->a[parentTab].pSelect = 0;
}
+#endif
/* The SELECT was successfully coded. Set the return code to 0
** to indicate no errors.
diff --git a/src/test3.c b/src/test3.c
index 2997a29..800f86f 100644
--- a/src/test3.c
+++ b/src/test3.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test3.c,v 1.60 2005/01/20 05:24:33 danielk1977 Exp $
+** $Id: test3.c,v 1.61 2005/01/21 08:13:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -546,7 +546,9 @@
return TCL_ERROR;
}
pBt = sqlite3TextToPtr(argv[1]);
+#ifdef SQLITE_DEBUG
sqlite3pager_refdump(sqlite3BtreePager(pBt));
+#endif
return TCL_OK;
}
diff --git a/src/vdbe.c b/src/vdbe.c
index 5c0ec7d..69b5c94 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
-** $Id: vdbe.c,v 1.444 2005/01/20 22:48:48 drh Exp $
+** $Id: vdbe.c,v 1.445 2005/01/21 08:13:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -680,6 +680,7 @@
** into an OP_String before it is executed for the first time.
*/
case OP_String8: { /* same as TK_STRING */
+#ifndef SQLITE_OMIT_UTF16
pOp->opcode = OP_String;
if( db->enc!=SQLITE_UTF8 && pOp->p3 ){
@@ -696,6 +697,7 @@
pOp->p3 = pTos->z;
break;
}
+#endif
/* Otherwise fall through to the next case, OP_String */
}
@@ -757,7 +759,6 @@
/* Fall through to the next case, OP_Blob. */
}
-#endif /* SQLITE_OMIT_BLOB_LITERAL */
/* Opcode: Blob P1 * P3
**
@@ -766,13 +767,14 @@
** by the compiler. Instead, the compiler layer specifies
** an OP_HexBlob opcode, with the hex string representation of
** the blob as P3. This opcode is transformed to an OP_Blob
-** before execution (within the sqlite3_prepare() function).
+** the first time it is executed.
*/
case OP_Blob: {
pTos++;
sqlite3VdbeMemSetStr(pTos, pOp->p3, pOp->p1, 0, 0);
break;
}
+#endif /* SQLITE_OMIT_BLOB_LITERAL */
/* Opcode: Variable P1 * *
**
@@ -1752,6 +1754,7 @@
sqlite3BtreeDataSize(pCrsr, &payloadSize);
}
nField = pC->nField;
+#ifndef SQLITE_OMIT_TRIGGER
}else if( pC->pseudoTable ){
/* The record is the sole entry of a pseudo-table */
payloadSize = pC->nData;
@@ -1760,6 +1763,7 @@
assert( payloadSize==0 || zRec!=0 );
nField = pC->nField;
pCrsr = 0;
+#endif
}else{
zRec = 0;
payloadSize = 0;
@@ -2448,6 +2452,7 @@
break;
}
+#ifndef SQLITE_OMIT_TRIGGER
/* Opcode: OpenPseudo P1 * *
**
** Open a new cursor that points to a fake table that contains a single
@@ -2469,6 +2474,7 @@
pCx->pIncrKey = &pCx->bogusIncrKey;
break;
}
+#endif
/* Opcode: Close P1 * *
**
@@ -3020,6 +3026,7 @@
}else{
assert( pTos->flags & (MEM_Blob|MEM_Str) );
}
+#ifndef SQLITE_OMIT_TRIGGER
if( pC->pseudoTable ){
/* PutStrKey does not work for pseudo-tables.
** The following assert makes sure we are not trying to use
@@ -3041,8 +3048,12 @@
}
pC->nullRow = 0;
}else{
+#endif
rc = sqlite3BtreeInsert(pC->pCursor, zKey, nKey, pTos->z, pTos->n);
+#ifndef SQLITE_OMIT_TRIGGER
}
+#endif
+
pC->recnoIsValid = 0;
pC->deferredMoveto = 0;
pC->cacheValid = 0;
@@ -3173,10 +3184,12 @@
}else{
sqlite3BtreeData(pCrsr, 0, n, pTos->z);
}
+#ifndef SQLITE_OMIT_TRIGGER
}else if( pC->pseudoTable ){
pTos->n = pC->nData;
pTos->z = pC->pData;
pTos->flags = MEM_Blob|MEM_Ephem;
+#endif
}else{
pTos->flags = MEM_Null;
}
@@ -3217,6 +3230,7 @@
break;
}
+#ifndef SQLITE_OMIT_COMPOUND_SELECT
/* Opcode: FullKey P1 * *
**
** Extract the complete key from the record that cursor P1 is currently
@@ -3265,6 +3279,7 @@
}
break;
}
+#endif
/* Opcode: NullRow P1 * *
**
@@ -3937,6 +3952,7 @@
break;
}
+#ifndef SQLITE_OMIT_TRIGGER
/* Opcode: ContextPush * * *
**
** Save the current Vdbe context such that it can be restored by a ContextPop
@@ -3977,6 +3993,7 @@
p->pList = pContext->pList;
break;
}
+#endif /* #ifndef SQLITE_OMIT_TRIGGER */
/* Opcode: SortPut * * *
**