Allow the SQLITE_MAX_EXPR_DEPTH compile-time parameter to be set to 0 in
order to disable expression depth checking.  Ticket #3143. (CVS 5166)

FossilOrigin-Name: 5ceef40e397fc535173996404345b93f695e8cac
diff --git a/src/expr.c b/src/expr.c
index bc5f0ea..5813e2d 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.371 2008/05/01 17:16:53 drh Exp $
+** $Id: expr.c,v 1.372 2008/05/28 13:49:36 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -738,7 +738,6 @@
   }
 }
 
-
 /* The following three functions, heightOfExpr(), heightOfExprList()
 ** and heightOfSelect(), are used to determine the maximum height
 ** of any expression tree referenced by the structure passed as the
@@ -748,6 +747,7 @@
 ** to by pnHeight, the second parameter, then set *pnHeight to that
 ** value.
 */
+#if SQLITE_MAX_EXPR_DEPTH>0
 static void heightOfExpr(Expr *p, int *pnHeight){
   if( p ){
     if( p->nHeight>*pnHeight ){
@@ -775,6 +775,7 @@
     heightOfSelect(p->pPrior, pnHeight);
   }
 }
+#endif /* SQLITE_MAX_EXPR_DEPTH>0 */
 
 /*
 ** Set the Expr.nHeight variable in the structure passed as an 
@@ -783,6 +784,7 @@
 ** has a height equal to the maximum height of any other 
 ** referenced Expr plus one.
 */
+#if SQLITE_MAX_EXPR_DEPTH>0
 void sqlite3ExprSetHeight(Expr *p){
   int nHeight = 0;
   heightOfExpr(p->pLeft, &nHeight);
@@ -791,16 +793,19 @@
   heightOfSelect(p->pSelect, &nHeight);
   p->nHeight = nHeight + 1;
 }
+#endif /* SQLITE_MAX_EXPR_DEPTH>0 */
 
 /*
 ** Return the maximum height of any expression tree referenced
 ** by the select statement passed as an argument.
 */
+#if SQLITE_MAX_EXPR_DEPTH>0
 int sqlite3SelectExprHeight(Select *p){
   int nHeight = 0;
   heightOfSelect(p, &nHeight);
   return nHeight;
 }
+#endif /* SQLITE_MAX_EXPR_DEPTH>0 */
 
 /*
 ** Delete an entire expression list.
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 2e22319..b00a8a5 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.704 2008/05/13 13:27:34 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.705 2008/05/28 13:49:36 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -1142,8 +1142,7 @@
   Select *pSelect;       /* When the expression is a sub-select.  Also the
                          ** right side of "<expr> IN (<select>)" */
   Table *pTab;           /* Table for OP_Column expressions. */
-/*  Schema *pSchema; */
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
+#if SQLITE_MAX_EXPR_DEPTH>0
   int nHeight;           /* Height of the tree headed by this node */
 #endif
 };
@@ -1533,9 +1532,7 @@
   int nVtabLock;             /* Number of virtual tables to lock */
   Table **apVtabLock;        /* Pointer to virtual tables needing locking */
 #endif
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
   int nHeight;            /* Expression tree height of current sub-select */
-#endif
 };
 
 #ifdef SQLITE_OMIT_VIRTUALTABLE
@@ -2198,11 +2195,12 @@
   #define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile)
 #endif
 
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
+#if SQLITE_MAX_EXPR_DEPTH>0
   void sqlite3ExprSetHeight(Expr *);
   int sqlite3SelectExprHeight(Select *);
 #else
   #define sqlite3ExprSetHeight(x)
+  #define sqlite3SelectExprHeight(x) 0
 #endif
 
 u32 sqlite3Get4byte(const u8*);