-C Allow\sa\sVACUUM\soperation\sto\schange\sthe\spage-size\sin\sthe\ssame\sway\sas\sit\scan\sbe\sused\sto\schange\sa\sdatabase\sbetween\sauto-vacuum\sand\snormal\smode.\s(CVS\s4896)
-D 2008-03-20T11:04:21
+C Initial\simplementation\sof\sper-connection\slimits\sand\sthe\ssqlite3_limit()\sAPI.\nThe\ssqllimits1.test\sscript\scrashes.\s\sSQLITE_LIMIT_PAGE_COUNT\sand\nSQLITE_LIMIT_VDBE_OP\sare\scurrently\signored.\s(CVS\s4897)
+D 2008-03-20T14:03:29
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F sqlite3.pc.in 32b8a014799c2028c8e0c9cc5659718262fc493f
F src/alter.c b42d782906fc3b92c331efbe06e9389617b47ce7
F src/analyze.c a78ac494668581fe7f54ee63700815bb0ea34261
-F src/attach.c e7cf4ae2a2c8ebd554dc6ca06859b587fa7197c2
+F src/attach.c bdc75e759ca25a16f4dc7fbdbc6d37ad2561bb24
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
F src/bitvec.c fac68429a9916a50229c4ab88abb69c00c438f7f
F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
F src/btree.c 77304a2086a9089fe5e5ee8861248b72d6cca5d6
F src/btree.h 19dcf5ad23c17b98855da548e9a8e3eb4429d5eb
F src/btreeInt.h d7d2f4d9d7f2e72c455326d48b2b478b842a81f6
-F src/build.c fa70bc0fb02e4d08202dd6a752ab5f5df5676e50
+F src/build.c 31ed5af4e8ac40c30bb0f88d7fec75e72cc16e0e
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
-F src/date.c 7b80383c47beafd9b49f2c1be65a72747593c4e1
+F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d
F src/delete.c 217cd5559e00bb135dc626d4ea4ac713604729e8
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
-F src/expr.c 242f2f57a32f6909270e4a22ce1c810a150f5a17
+F src/expr.c 11e00cafa3c6c7e432b06f06c923d1332349354a
F src/fault.c 039abb45c9dbcbdf575ec2a23ae38db01bc2f7b2
-F src/func.c ffce8131bbc2117168beb32afce7fb75bd2c055f
+F src/func.c 3ac6e84e601321519d1b452c95cf92a51403fc4d
F src/hash.c 53655c312280211444bfe23af6490a460aec2980
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
F src/insert.c 358c80592c20a61a8d5b4a127215b5e25de652f4
F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2
F src/legacy.c cb1939fdeb91ea88fb44fbd2768a10e14bc44650
-F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
F src/loadext.c f26b22f7c84153c9d5dbd7c240848823c6e6b6dc
-F src/main.c 9dd4646a7dadcde7efa36c2904792f992872b2bc
+F src/main.c 03a53976e226dfb5867b3102db5b9ec2e40fc0e7
F src/malloc.c 60e392a4c12c839517f9b0db7b995f825444fb35
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c fc716ff521b6dd3e43eaa211967383308800e70a
F src/pager.h b1e2258f03878c14b06a95bfa362e8c5c9638170
F src/parse.y 00f2698c8ae84f315be5e3f10b63c94f531fdd6d
F src/pragma.c f64eed914518c28d1863356163dea1e6f58e28f2
-F src/prepare.c 88e32e985921e9fb5d3ca22ccc74e054ebfe49f2
-F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
+F src/prepare.c 1b71b5d43ba3d88f2d3c2a6d084f28ac209df956
+F src/printf.c 88674589be4b9eac3987ff735e74681864c88c32
F src/random.c 8b6ab5418cf0f4dde551730825d67da1457c2b3c
-F src/select.c d0a1e01a2a6c05bd60324e843c7e4581d3605950
+F src/select.c 2a0f383a16c780b8ee8108e994c2f6c4f82233a9
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 22297fffa6f00a6c6d44020fa13b1184a1bb372d
-F src/sqlite.h.in c82088b99b3262c017ddadc14d45b2d5877cbeae
+F src/sqlite.h.in be6a431e128b831df7d62fc48b7ce2043f55cf90
F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
-F src/sqliteInt.h 160aadae3b44b53b9176d615bbada6b0ba7d00c4
-F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e
+F src/sqliteInt.h ec78c602dc2675f675ca4f9fbc72e60a262c40e9
+F src/sqliteLimit.h eecbc288b410ae5565e71aaa4a439aae57bb0707
F src/table.c 2c48c575dd59b3a6c5c306bc55f51a9402cf429a
F src/tclsqlite.c d42912617d4734b8f9195416badf5b27e512ded2
F src/test1.c 935f327fe989694a3aa07ab78ae5c00705651b34
F src/test_async.c 3147c64c34721f088d5ab20f85dabd5d7732c007
F src/test_autoext.c 5e892ab84aece3f0428920bf46923f16ac83962a
F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
-F src/test_config.c 4c1fe5184b1e9db8a4bb130889f3a2e91f07508b
+F src/test_config.c a0c779e589df63a9de36d4fe3971bc04975e2675
F src/test_devsym.c cee1aecaa90c895030399ca4ae38f84a08038f8a
F src/test_func.c 9e9b33ff083b65da91c389cece903bc32de06f01
F src/test_hexio.c 1a1cd8324d57585ea86b922f609fa1fbaaf9662d
F src/test_server.c a6ece6c835e7eae835054124e09e947e422b1ac5
F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59
F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
-F src/tokenize.c c4b79fd48ddb709b2b8522b7d93a5a3d98168ca4
+F src/tokenize.c 13113f94bd1c15dea9e922f08b10f3eee6863474
F src/trigger.c 9bd3b6fa0beff4a02d262c96466f752ec15a7fc3
F src/update.c d2c59643af98f966c2a04d392463089b715ca18f
F src/utf.c 32b00d6e19010025e58f2ecb2f921d5e126771b4
F src/util.c dba9e04121eb17ec4643d6ca231ff859452cf0e2
F src/vacuum.c 3524411bfb58aac0d87eadd3e5b7cd532772af30
-F src/vdbe.c 86033e43d89892ea6a817e8bcd4e6273bc1ebdf5
+F src/vdbe.c 5ac49cf526843436ed295f5150a508a38b192b89
F src/vdbe.h 58a7d931ffb704e034b2a725981cfa5bd406fad9
F src/vdbeInt.h 76c81d057a39813de0fda3cad1498655d53ec69d
-F src/vdbeapi.c 6e6f2bd51a74b74a72e31f6db409f55a98bc8ea2
+F src/vdbeapi.c a3bddeee0f011faadb20316926cc97f95efa6415
F src/vdbeaux.c 82f3c8913e68b4928de28c3fa117464356d59df6
F src/vdbeblob.c 63c750acc7b5012479f508c0e9627372a82cb65d
F src/vdbefifo.c a30c237b2a3577e1415fb6e288cbb6b8ed1e5736
-F src/vdbemem.c 5de8de022bb93674cd6d48dd919242b517c27c60
+F src/vdbemem.c 67662aac917b627356262f9501591206db2a8845
F src/vtab.c 00cd16317b29495c185ff40e4b227917d5a371b2
F src/where.c 78d6689d7154d8d41c1a913e17bce9a320981653
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/fts3atoken.test 25c2070e1e8755d414bf9c8200427b277a9f99fa
F test/fts3b.test b3a25180a633873d37d86e1ccd00ed690d37237a
F test/fts3near.test 2d4dadcaac5025ab65bb87e66c45f39e92966194
-F test/func.test c805453a6fc95b20266682eb10a6325b4e7d8bd3
+F test/func.test 03502ed9cbf3acc0cddf5f41efa61fdb05d03139
F test/fuzz.test 62fc19dd36a427777fd671b569df07166548628a
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
F test/fuzz_common.tcl ff4bc2dfc465f6878f8e2d819620914365382731
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 8b198617f572d35f04d119ba688e0f5c67f81144
-R a308dd47ecbf55342f9cd3c4b73f760c
-U danielk1977
-Z ca52892929aebf794b5fd5229c74cc6b
+P 871df0e7c36a88f175cfc63797745e52a1b1796b
+R 4c7da889f1547b07b3861cee6e60887d
+U drh
+Z 1218328931920895e6af9308ec904100
-871df0e7c36a88f175cfc63797745e52a1b1796b
\ No newline at end of file
+60c77882b2de9f6a45f8bd87c9c6a0cc613f8373
\ No newline at end of file
*************************************************************************
** This file contains code used to implement the ATTACH and DETACH commands.
**
-** $Id: attach.c,v 1.73 2008/03/19 21:45:51 drh Exp $
+** $Id: attach.c,v 1.74 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
** * Transaction currently open
** * Specified database name already being used.
*/
- if( db->nDb>=SQLITE_MAX_ATTACHED+2 ){
+ if( db->nDb>=db->aLimit[SQLITE_LIMIT_ATTACHED]+2 ){
sqlite3_snprintf(
sizeof(zErr), zErr, "too many attached databases - max %d",
- SQLITE_MAX_ATTACHED
+ db->aLimit[SQLITE_LIMIT_ATTACHED]
);
goto attach_error;
}
** COMMIT
** ROLLBACK
**
-** $Id: build.c,v 1.474 2008/03/06 09:58:50 mlcreech Exp $
+** $Id: build.c,v 1.475 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
int i;
char *z;
Column *pCol;
+ sqlite3 *db = pParse->db;
if( (p = pParse->pNewTable)==0 ) return;
- if( p->nCol+1>SQLITE_MAX_COLUMN ){
+#if SQLITE_MAX_COLUMN
+ if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){
sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName);
return;
}
+#endif
z = sqlite3NameFromToken(pParse->db, pName);
if( z==0 ) return;
for(i=0; i<p->nCol; i++){
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: date.c,v 1.78 2008/03/19 21:45:51 drh Exp $
+** $Id: date.c,v 1.79 2008/03/20 14:03:29 drh Exp $
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
}
if( n<sizeof(zBuf) ){
z = zBuf;
- }else if( n>SQLITE_MAX_LENGTH ){
+ }else if( n>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
sqlite3_result_error_toobig(context);
return;
}else{
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.354 2008/03/12 10:39:00 danielk1977 Exp $
+** $Id: expr.c,v 1.355 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
** use it as the variable number */
int i;
pExpr->iTable = i = atoi((char*)&pToken->z[1]);
- if( i<1 || i>SQLITE_MAX_VARIABLE_NUMBER ){
+ if( i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
- SQLITE_MAX_VARIABLE_NUMBER);
+ db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
}
if( i>pParse->nVar ){
pParse->nVar = i;
}
}
}
- if( !pParse->nErr && pParse->nVar>SQLITE_MAX_VARIABLE_NUMBER ){
+ if( !pParse->nErr && pParse->nVar>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "too many SQL variables");
}
}
}
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
/* 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
heightOfSelect(p, &nHeight);
return nHeight;
}
-#endif
/*
** Delete an entire expression list.
Expr *pExpr /* The expression to be analyzed. */
){
int savedHasAgg;
+
if( pExpr==0 ) return 0;
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
- if( (pExpr->nHeight+pNC->pParse->nHeight)>SQLITE_MAX_EXPR_DEPTH ){
- sqlite3ErrorMsg(pNC->pParse,
- "Expression tree is too large (maximum depth %d)",
- SQLITE_MAX_EXPR_DEPTH
- );
- return 1;
+#if SQLITE_MAX_EXPR_DEPTH>0
+ {
+ int mxDepth = pNC->pParse->db->aLimit[SQLITE_LIMIT_EXPR_DEPTH];
+ if( (pExpr->nHeight+pNC->pParse->nHeight)>mxDepth ){
+ sqlite3ErrorMsg(pNC->pParse,
+ "Expression tree is too large (maximum depth %d)", mxDepth
+ );
+ return 1;
+ }
+ pNC->pParse->nHeight += pExpr->nHeight;
}
- pNC->pParse->nHeight += pExpr->nHeight;
#endif
savedHasAgg = pNC->hasAgg;
pNC->hasAgg = 0;
walkExprTree(pExpr, nameResolverStep, pNC);
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
+#if SQLITE_MAX_EXPR_DEPTH>0
pNC->pParse->nHeight -= pExpr->nHeight;
#endif
if( pNC->nErr>0 ){
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.189 2008/03/19 21:45:51 drh Exp $
+** $Id: func.c,v 1.190 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
if( argc==3 ){
p2 = sqlite3_value_int(argv[2]);
}else{
- p2 = SQLITE_MAX_LENGTH;
+ p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
}
if( p1<0 ){
p1 += len;
** the database handle that malloc() has failed.
*/
static void *contextMalloc(sqlite3_context *context, int nByte){
- char *z = sqlite3_malloc(nByte);
- if( !z && nByte>0 ){
- sqlite3_result_error_nomem(context);
+ char *z;
+ if( nByte>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
+ sqlite3_result_error_toobig(context);
+ z = 0;
+ }else{
+ z = sqlite3_malloc(nByte);
+ if( !z && nByte>0 ){
+ sqlite3_result_error_nomem(context);
+ }
}
return z;
}
if( n<1 ){
n = 1;
}
- if( n>SQLITE_MAX_LENGTH ){
- sqlite3_result_error_toobig(context);
- return;
- }
p = contextMalloc(context, n);
if( p ){
sqlite3_randomness(n, p);
){
const unsigned char *zA, *zB;
int escape = 0;
+ sqlite3 *db = sqlite3_context_db_handle(context);
zB = sqlite3_value_text(argv[0]);
zA = sqlite3_value_text(argv[1]);
/* Limit the length of the LIKE or GLOB pattern to avoid problems
** of deep recursion and N*N behavior in patternCompare().
*/
- if( sqlite3_value_bytes(argv[0])>SQLITE_MAX_LIKE_PATTERN_LENGTH ){
+ if( sqlite3_value_bytes(argv[0]) >
+ db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){
sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1);
return;
}
char const *zBlob = sqlite3_value_blob(argv[0]);
int nBlob = sqlite3_value_bytes(argv[0]);
assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */
-
- if( 2*nBlob+4>SQLITE_MAX_LENGTH ){
- sqlite3_result_error_toobig(context);
- return;
- }
zText = (char *)contextMalloc(context, (2*nBlob)+4);
if( zText ){
int i;
if( zArg==0 ) return;
for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\'' ) n++; }
- if( i+n+3>SQLITE_MAX_LENGTH ){
- sqlite3_result_error_toobig(context);
- return;
- }
z = contextMalloc(context, i+n+3);
if( z ){
z[0] = '\'';
assert( argc==1 );
pBlob = sqlite3_value_blob(argv[0]);
n = sqlite3_value_bytes(argv[0]);
- if( n*2+1>SQLITE_MAX_LENGTH ){
- sqlite3_result_error_toobig(context);
- return;
- }
assert( pBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */
z = zHex = contextMalloc(context, n*2 + 1);
if( zHex ){
zOut[j++] = zStr[i];
}else{
u8 *zOld;
+ sqlite3 *db = sqlite3_context_db_handle(context);
nOut += nRep - nPattern;
- if( nOut>=SQLITE_MAX_LENGTH ){
+ if( nOut>=db->aLimit[SQLITE_LIMIT_LENGTH] ){
sqlite3_result_error_toobig(context);
sqlite3_free(zOut);
return;
pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
if( pAccum ){
+ sqlite3 *db = sqlite3_context_db_handle(context);
pAccum->useMalloc = 1;
+ pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
if( pAccum->nChar ){
if( argc==2 ){
zSep = (char*)sqlite3_value_text(argv[1]);
+++ /dev/null
-/*
-** 2007 May 7
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-**
-** This file defines various limits of what SQLite can process.
-**
-** @(#) $Id: limits.h,v 1.9 2007/06/09 09:53:51 drh Exp $
-*/
-
-/*
-** The maximum length of a TEXT or BLOB in bytes. This also
-** limits the size of a row in a table or index.
-**
-** The hard limit is the ability of a 32-bit signed integer
-** to count the size: 2^31-1 or 2147483647.
-*/
-#ifndef SQLITE_MAX_LENGTH
-# define SQLITE_MAX_LENGTH 1000000000
-#endif
-
-/*
-** This is the maximum number of
-**
-** * Columns in a table
-** * Columns in an index
-** * Columns in a view
-** * Terms in the SET clause of an UPDATE statement
-** * Terms in the result set of a SELECT statement
-** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
-** * Terms in the VALUES clause of an INSERT statement
-**
-** The hard upper limit here is 32676. Most database people will
-** tell you that in a well-normalized database, you usually should
-** not have more than a dozen or so columns in any table. And if
-** that is the case, there is no point in having more than a few
-** dozen values in any of the other situations described above.
-*/
-#ifndef SQLITE_MAX_COLUMN
-# define SQLITE_MAX_COLUMN 2000
-#endif
-
-/*
-** The maximum length of a single SQL statement in bytes.
-** The hard limit here is the same as SQLITE_MAX_LENGTH.
-*/
-#ifndef SQLITE_MAX_SQL_LENGTH
-# define SQLITE_MAX_SQL_LENGTH 1000000
-#endif
-
-/*
-** The maximum depth of an expression tree. This is limited to
-** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
-** want to place more severe limits on the complexity of an
-** expression. A value of 0 (the default) means do not enforce
-** any limitation on expression tree depth.
-*/
-#ifndef SQLITE_MAX_EXPR_DEPTH
-# define SQLITE_MAX_EXPR_DEPTH 1000
-#endif
-
-/*
-** The maximum number of terms in a compound SELECT statement.
-** The code generator for compound SELECT statements does one
-** level of recursion for each term. A stack overflow can result
-** if the number of terms is too large. In practice, most SQL
-** never has more than 3 or 4 terms. Use a value of 0 to disable
-** any limit on the number of terms in a compount SELECT.
-*/
-#ifndef SQLITE_MAX_COMPOUND_SELECT
-# define SQLITE_MAX_COMPOUND_SELECT 500
-#endif
-
-/*
-** The maximum number of opcodes in a VDBE program.
-** Not currently enforced.
-*/
-#ifndef SQLITE_MAX_VDBE_OP
-# define SQLITE_MAX_VDBE_OP 25000
-#endif
-
-/*
-** The maximum number of arguments to an SQL function.
-*/
-#ifndef SQLITE_MAX_FUNCTION_ARG
-# define SQLITE_MAX_FUNCTION_ARG 100
-#endif
-
-/*
-** The maximum number of in-memory pages to use for the main database
-** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
-*/
-#ifndef SQLITE_DEFAULT_CACHE_SIZE
-# define SQLITE_DEFAULT_CACHE_SIZE 2000
-#endif
-#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
-# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
-#endif
-
-/*
-** The maximum number of attached databases. This must be at least 2
-** in order to support the main database file (0) and the file used to
-** hold temporary tables (1). And it must be less than 32 because
-** we use a bitmask of databases with a u32 in places (for example
-** the Parse.cookieMask field).
-*/
-#ifndef SQLITE_MAX_ATTACHED
-# define SQLITE_MAX_ATTACHED 10
-#endif
-
-
-/*
-** The maximum value of a ?nnn wildcard that the parser will accept.
-*/
-#ifndef SQLITE_MAX_VARIABLE_NUMBER
-# define SQLITE_MAX_VARIABLE_NUMBER 999
-#endif
-
-/*
-** The default size of a database page.
-*/
-#ifndef SQLITE_DEFAULT_PAGE_SIZE
-# define SQLITE_DEFAULT_PAGE_SIZE 1024
-#endif
-
-/* Maximum page size. The upper bound on this value is 32768. This a limit
-** imposed by the necessity of storing the value in a 2-byte unsigned integer
-** and the fact that the page size must be a power of 2.
-*/
-#ifndef SQLITE_MAX_PAGE_SIZE
-# define SQLITE_MAX_PAGE_SIZE 32768
-#endif
-
-/*
-** Maximum number of pages in one database file.
-**
-** This is really just the default value for the max_page_count pragma.
-** This value can be lowered (or raised) at run-time using that the
-** max_page_count macro.
-*/
-#ifndef SQLITE_MAX_PAGE_COUNT
-# define SQLITE_MAX_PAGE_COUNT 1073741823
-#endif
-
-/*
-** Maximum length (in bytes) of the pattern in a LIKE or GLOB
-** operator.
-*/
-#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
-# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
-#endif
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.425 2008/03/20 11:04:21 danielk1977 Exp $
+** $Id: main.c,v 1.426 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
}
+/*
+** This array defines hard upper bounds on limit values. The
+** initializer must be kept in sync with the SQLITE_LIMIT_*
+** #defines in sqlite3.h.
+*/
+static const aHardLimit[] = {
+ SQLITE_MAX_LENGTH,
+ SQLITE_MAX_SQL_LENGTH,
+ SQLITE_MAX_COLUMN,
+ SQLITE_MAX_EXPR_DEPTH,
+ SQLITE_MAX_COMPOUND_SELECT,
+ SQLITE_MAX_VDBE_OP,
+ SQLITE_MAX_FUNCTION_ARG,
+ SQLITE_MAX_ATTACHED,
+ SQLITE_MAX_PAGE_COUNT,
+ SQLITE_MAX_LIKE_PATTERN_LENGTH,
+ SQLITE_MAX_VARIABLE_NUMBER,
+};
+
+/*
+** Make sure the hard limits are set to reasonable values
+*/
+#if SQLITE_MAX_LENGTH<100
+# error SQLITE_MAX_LENGTH must be at least 100
+#endif
+#if SQLITE_MAX_SQL_LENGTH<100
+# error SQLITE_MAX_SQL_LENGTH must be at least 100
+#endif
+#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH
+# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH
+#endif
+#if SQLITE_MAX_COLUMN<1
+# error SQLITE_MAX_COLUMN must be at least 1
+#endif
+#if SQLITE_MAX_EXPR_DEPTH<1
+# error SQLITE_MAX_EXPR_DEPTH must be at least 1
+#endif
+#if SQLITE_MAX_COMPOUND_SELECT<2
+# error SQLITE_MAX_COMPOUND_SELECT must be at least 2
+#endif
+#if SQLITE_MAX_VDBE_OP<40
+# error SQLITE_MAX_VDBE_OP must be at least 40
+#endif
+#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>255
+# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 255
+#endif
+#if SQLITE_MAX_ATTACH<0 || SQLITE_MAX_ATTACH>30
+# error SQLITE_MAX_ATTACH must be between 0 and 30
+#endif
+#if SQLITE_MAX_PAGE_COUNT<1
+# error SQLITE_MAX_PAGE_COUNT must be at least 1
+#endif
+#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1
+# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1
+#endif
+#if SQLITE_MAX_VARIABLE_NUMBER<1
+# error SQLITE_MAX_VARIABLE_NUMBER must be at least 1
+#endif
+
+
+/*
+** Change the value of a limit. Report the old value.
+** If an invalid limit index is supplied, report -1.
+** Make no changes but still report the old value if the
+** new limit is negative.
+**
+** A new lower limit does not shrink existing constructs.
+** It merely prevents new constructs that exceed the limit
+** from forming.
+*/
+int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
+ int oldLimit;
+ if( limitId<0 || limitId>SQLITE_N_LIMIT ){
+ return -1;
+ }
+ oldLimit = db->aLimit[limitId];
+ if( newLimit>=0 ){
+ if( newLimit==0 ){
+ newLimit = aHardLimit[limitId];
+ }else if( aHardLimit[limitId]>0 && newLimit>aHardLimit[limitId] ){
+ newLimit = aHardLimit[limitId];
+ }
+ db->aLimit[limitId] = newLimit;
+ }
+ return oldLimit;
+}
+
/*
** This routine does the work of opening a database on behalf of
** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
db->nDb = 2;
db->magic = SQLITE_MAGIC_BUSY;
db->aDb = db->aDbStatic;
+ assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
+ memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
db->autoCommit = 1;
db->nextAutovac = -1;
db->nextPagesize = 0;
** interface, and routines that contribute to loading the database schema
** from disk.
**
-** $Id: prepare.c,v 1.79 2008/03/19 13:03:34 drh Exp $
+** $Id: prepare.c,v 1.80 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
sParse.db = db;
if( nBytes>=0 && zSql[nBytes]!=0 ){
char *zSqlCopy;
- if( SQLITE_MAX_SQL_LENGTH>0 && nBytes>SQLITE_MAX_SQL_LENGTH ){
+ int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
+ if( nBytes>mxLen ){
sqlite3Error(db, SQLITE_TOOBIG, "statement too long");
(void)sqlite3SafetyOff(db);
return SQLITE_TOOBIG;
}
}else{
p->nAlloc += p->nAlloc + N + 1;
- if( p->nAlloc > SQLITE_MAX_LENGTH ){
- p->nAlloc = SQLITE_MAX_LENGTH;
+ if( p->nAlloc > p->mxAlloc ){
+ p->nAlloc = p->mxAlloc;
if( p->nChar+N >= p->nAlloc ){
sqlite3StrAccumReset(p);
p->tooBig = 1;
/*
** Initialize a string accumulator
*/
-static void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n){
+static void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){
p->zText = p->zBase = zBase;
p->nChar = 0;
p->nAlloc = n;
+ p->mxAlloc = mx;
p->useMalloc = 1;
p->tooBig = 0;
p->mallocFailed = 0;
char *z;
char zBase[SQLITE_PRINT_BUF_SIZE];
StrAccum acc;
- sqlite3StrAccumInit(&acc, zBase, sizeof(zBase));
+ sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
+ db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);
vxprintf(&acc, 1, zFormat, ap);
z = sqlite3StrAccumFinish(&acc);
if( acc.mallocFailed && db ){
char *z;
char zBase[SQLITE_PRINT_BUF_SIZE];
StrAccum acc;
- sqlite3StrAccumInit(&acc, zBase, sizeof(zBase));
+ sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
vxprintf(&acc, 0, zFormat, ap);
z = sqlite3StrAccumFinish(&acc);
return z;
if( n<=0 ){
return zBuf;
}
- sqlite3StrAccumInit(&acc, zBuf, n);
+ sqlite3StrAccumInit(&acc, zBuf, n, 0);
acc.useMalloc = 0;
va_start(ap,zFormat);
vxprintf(&acc, 0, zFormat, ap);
va_list ap;
StrAccum acc;
char zBuf[500];
- sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf));
+ sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
acc.useMalloc = 0;
va_start(ap,zFormat);
vxprintf(&acc, 0, zFormat, ap);
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.415 2008/03/04 17:45:01 mlcreech Exp $
+** $Id: select.c,v 1.416 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
sqlite3ExprListDelete(pEList);
p->pEList = pNew;
}
- if( p->pEList && p->pEList->nExpr>SQLITE_MAX_COLUMN ){
+#if SQLITE_MAX_COLUMN
+ if( p->pEList && p->pEList->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){
sqlite3ErrorMsg(pParse, "too many columns in result set");
rc = SQLITE_ERROR;
}
+#endif
if( db->mallocFailed ){
rc = SQLITE_NOMEM;
}
ExprList *pEList;
if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;
- if( pOrderBy->nExpr>SQLITE_MAX_COLUMN ){
+#if SQLITE_MAX_COLUMN
+ if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){
const char *zType = isOrder ? "ORDER" : "GROUP";
sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType);
return 1;
}
+#endif
pEList = pSelect->pEList;
if( pEList==0 ){
return 0;
pOrderBy = pSelect->pOrderBy;
if( pOrderBy==0 ) return 0;
- if( pOrderBy->nExpr>SQLITE_MAX_COLUMN ){
+ db = pParse->db;
+#if SQLITE_MAX_COLUMN
+ if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){
sqlite3ErrorMsg(pParse, "too many terms in ORDER BY clause");
return 1;
}
- db = pParse->db;
+#endif
for(i=0; i<pOrderBy->nExpr; i++){
pOrderBy->a[i].done = 0;
}
if( p->pRightmost==0 ){
Select *pLoop, *pRight = 0;
int cnt = 0;
+ int mxSelect;
for(pLoop=p; pLoop; pLoop=pLoop->pPrior, cnt++){
pLoop->pRightmost = p;
pLoop->pNext = pRight;
pRight = pLoop;
}
- if( SQLITE_MAX_COMPOUND_SELECT>0 && cnt>SQLITE_MAX_COMPOUND_SELECT ){
+ mxSelect = db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT];
+ if( mxSelect && cnt>mxSelect ){
sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
return 1;
}
}else{
needRestoreContext = 0;
}
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
/* Increment Parse.nHeight by the height of the largest expression
** tree refered to by this, the parent select. The child select
** may contain expression trees of at most
** an exact limit.
*/
pParse->nHeight += sqlite3SelectExprHeight(p);
-#endif
sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);
sqlite3Select(pParse, pItem->pSelect, &dest, p, i, &isAgg, 0);
if( db->mallocFailed ){
goto select_end;
}
-#if defined(SQLITE_TEST) || SQLITE_MAX_EXPR_DEPTH>0
pParse->nHeight -= sqlite3SelectExprHeight(p);
-#endif
if( needRestoreContext ){
pParse->zAuthContext = zSavedAuthContext;
}
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
-** @(#) $Id: sqlite.h.in,v 1.295 2008/03/20 00:32:20 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.296 2008/03/20 14:03:29 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
** constant SQLITE_MAX_XYZ. Attempts to increase a limit above its
** hard upper bound are silently truncated.
**
+** Run time limits are intended for use in applications that manage
+** both their own internal database and also databases that are controlled
+** by untrusted external sources. An example application might be a
+** webbrowser that has its own databases for storing history and
+** separate databases controlled by javascript applications downloaded
+** of the internet. The internal databases can be given the
+** large, default limits. Databases managed by external sources can
+** be given much smaller limits designed to prevent a denial of service
+** attach.
+**
** This interface is currently considered experimental and is subject
** to change or removal without prior notice.
**
**
** {F12763} A successful call to [sqlite3_limit(D,C,V)] where V is
** positive changes the
-** limit on the size of construct C in [database connetion] D
+** limit on the size of construct C in [database connection] D
** to the lessor of V and the hard upper bound on the size
** of C that is set at compile-time.
**
** {F12763} A successful call to [sqlite3_limit(D,C,V)] where V is zero
** changes the limit on the size of construct C in
-** [database connetion] D to be the hard upper bound on the size
+** [database connection] D to be the hard upper bound on the size
** of C that is set at compile-time.
**
** {F12766} A successful call to [sqlite3_limit(D,C,V)] where V is negative
**
** {F12769} A successful call to [sqlite3_limit(D,C,V)] returns the
** value of the limit on the size of construct C in
-** in [database connetion] D as it was prior to the call.
+** in [database connection] D as it was prior to the call.
*/
int sqlite3_limit(sqlite3*, int id, int newVal);
**
** These constants define various aspects of a [database connection]
** that can be limited in size by calls to [sqlite3_limit()].
+** The meanings of the various limits are as follows:
+**
+** <dl>
+** <dt>SQLITE_LIMIT_LENGTH</dt>
+** <dd>The maximum size of any
+** string or blob or table row.<dd>
+**
+** <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
+** <dd>The maximum length of an SQL statement.</dd>
+**
+** <dt>SQLITE_LIMIT_COLUMN</dt>
+** <dd>The maximum number of columns in a table definition or in the
+** result set of a SELECT or the maximum number of columns in an index
+** or in an ORDER BY or GROUP BY clause.</dd>
+**
+** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
+** <dd>The maximum depth of the parse tree on any expression.</dd>
+**
+** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
+** <dd>The maximum number of terms in a compound SELECT statement.</dd>
+**
+** <dt>SQLITE_LIMIT_VDBE_OP</dt>
+** <dd>The maximum number of instructions in a virtual machine program
+** used to implement an SQL statement.</dd>
+**
+** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
+** <dd>The maximum number of arguments on a function.</dd>
+**
+** <dt>SQLITE_LIMIT_ATTACHED</dt>
+** <dd>The maximum number of attached databases.</dd>
+**
+** <dt>SQLITE_LIMIT_PAGE_COUNT</dt>
+** <dd>The maximum number of pages in a database.</dd>
+**
+** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
+** <dd>The maximum length of the pattern argument to the LIKE or
+** GLOB operators.</dd>
+**
+** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
+** <dd>The maximum number of variables in an SQL statement that can
+** be bound.</dd>
+** </dl>
*/
#define SQLITE_LIMIT_LENGTH 0
#define SQLITE_LIMIT_SQL_LENGTH 1
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.676 2008/03/20 11:04:21 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.677 2008/03/20 14:03:29 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
** (otherwise we get an empty default).
*/
#include "config.h"
+#include "sqliteLimit.h"
/* Needed for various definitions... */
#define _GNU_SOURCE
#endif
-#include "sqliteLimit.h"
-
-/*
-** For testing purposes, the various size limit constants are really
-** variables that we can modify in the testfixture.
-*/
-#ifdef SQLITE_TEST
- #undef SQLITE_MAX_LENGTH
- #undef SQLITE_MAX_COLUMN
- #undef SQLITE_MAX_SQL_LENGTH
- #undef SQLITE_MAX_EXPR_DEPTH
- #undef SQLITE_MAX_COMPOUND_SELECT
- #undef SQLITE_MAX_VDBE_OP
- #undef SQLITE_MAX_FUNCTION_ARG
- #undef SQLITE_MAX_VARIABLE_NUMBER
- #undef SQLITE_MAX_PAGE_SIZE
- #undef SQLITE_MAX_PAGE_COUNT
- #undef SQLITE_MAX_LIKE_PATTERN_LENGTH
-
- #define SQLITE_MAX_LENGTH sqlite3MAX_LENGTH
- #define SQLITE_MAX_COLUMN sqlite3MAX_COLUMN
- #define SQLITE_MAX_SQL_LENGTH sqlite3MAX_SQL_LENGTH
- #define SQLITE_MAX_EXPR_DEPTH sqlite3MAX_EXPR_DEPTH
- #define SQLITE_MAX_COMPOUND_SELECT sqlite3MAX_COMPOUND_SELECT
- #define SQLITE_MAX_VDBE_OP sqlite3MAX_VDBE_OP
- #define SQLITE_MAX_FUNCTION_ARG sqlite3MAX_FUNCTION_ARG
- #define SQLITE_MAX_VARIABLE_NUMBER sqlite3MAX_VARIABLE_NUMBER
- #define SQLITE_MAX_PAGE_SIZE sqlite3MAX_PAGE_SIZE
- #define SQLITE_MAX_PAGE_COUNT sqlite3MAX_PAGE_COUNT
- #define SQLITE_MAX_LIKE_PATTERN_LENGTH sqlite3MAX_LIKE_PATTERN_LENGTH
-
- extern int sqlite3MAX_LENGTH;
- extern int sqlite3MAX_COLUMN;
- extern int sqlite3MAX_SQL_LENGTH;
- extern int sqlite3MAX_EXPR_DEPTH;
- extern int sqlite3MAX_COMPOUND_SELECT;
- extern int sqlite3MAX_VDBE_OP;
- extern int sqlite3MAX_FUNCTION_ARG;
- extern int sqlite3MAX_VARIABLE_NUMBER;
- extern int sqlite3MAX_PAGE_SIZE;
- extern int sqlite3MAX_PAGE_COUNT;
- extern int sqlite3MAX_LIKE_PATTERN_LENGTH;
-#endif
-
-
/*
** The SQLITE_THREADSAFE macro must be defined as either 0 or 1.
** Older versions of SQLite used an optional THREADSAFE macro.
char *zText; /* The string collected so far */
int nChar; /* Length of the string so far */
int nAlloc; /* Amount of space allocated in zText */
+ int mxAlloc; /* Maximum allowed string length */
u8 mallocFailed; /* Becomes true if any memory allocation fails */
u8 useMalloc; /* True if zText is enlargable using realloc */
u8 tooBig; /* Becomes true if string size exceeds limits */
**
** This file defines various limits of what SQLite can process.
**
-** @(#) $Id: sqliteLimit.h,v 1.6 2007/12/17 16:20:07 drh Exp $
+** @(#) $Id: sqliteLimit.h,v 1.7 2008/03/20 14:03:29 drh Exp $
*/
/*
/*
** The maximum length of a single SQL statement in bytes.
-** A value of zero means there is no limit.
+**
+** It used to be the case that setting this value to zero would
+** turn the limit off. That is no longer true. It is not possible
+** to turn this limit off.
*/
#ifndef SQLITE_MAX_SQL_LENGTH
-# define SQLITE_MAX_SQL_LENGTH 0
+# define SQLITE_MAX_SQL_LENGTH 1000000000
#endif
/*
** The maximum depth of an expression tree. This is limited to
** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
** want to place more severe limits on the complexity of an
-** expression. A value of 0 (the default) means do not enforce
-** any limitation on expression tree depth.
+** expression.
+**
+** A value of 0 used to mean that the limit was not enforced.
+** But that is no longer true. The limit is now strictly enforced
+** at all times.
*/
#ifndef SQLITE_MAX_EXPR_DEPTH
# define SQLITE_MAX_EXPR_DEPTH 1000
** The focus of this file is providing the TCL testing layer
** access to compile-time constants.
**
-** $Id: test_config.c,v 1.21 2008/03/19 14:15:35 drh Exp $
+** $Id: test_config.c,v 1.22 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteLimit.h"
-int sqlite3MAX_LENGTH = SQLITE_MAX_LENGTH;
-int sqlite3MAX_COLUMN = SQLITE_MAX_COLUMN;
-int sqlite3MAX_SQL_LENGTH = SQLITE_MAX_SQL_LENGTH;
-int sqlite3MAX_EXPR_DEPTH = SQLITE_MAX_EXPR_DEPTH;
-int sqlite3MAX_COMPOUND_SELECT = SQLITE_MAX_COMPOUND_SELECT;
-int sqlite3MAX_VDBE_OP = SQLITE_MAX_VDBE_OP;
-int sqlite3MAX_FUNCTION_ARG = SQLITE_MAX_FUNCTION_ARG;
-int sqlite3MAX_VARIABLE_NUMBER = SQLITE_MAX_VARIABLE_NUMBER;
-int sqlite3MAX_PAGE_SIZE = SQLITE_MAX_PAGE_SIZE;
-int sqlite3MAX_PAGE_COUNT = SQLITE_MAX_PAGE_COUNT;
-int sqlite3MAX_LIKE_PATTERN_LENGTH = SQLITE_MAX_LIKE_PATTERN_LENGTH;
-
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
Tcl_SetVar2(interp, "sqlite_options", "vtab", "1", TCL_GLOBAL_ONLY);
#endif
-#define LINKVAR(x) \
- Tcl_LinkVar(interp, "SQLITE_" #x, (char *)&(sqlite3 ## x), TCL_LINK_INT)
+#define LINKVAR(x) { \
+ static const int cv_ ## x = SQLITE_ ## x; \
+ Tcl_LinkVar(interp, "SQLITE_" #x, (char *)&(cv_ ## x), \
+ TCL_LINK_INT | TCL_LINK_READ_ONLY); }
LINKVAR( MAX_LENGTH );
LINKVAR( MAX_COLUMN );
LINKVAR( MAX_PAGE_SIZE );
LINKVAR( MAX_PAGE_COUNT );
LINKVAR( MAX_LIKE_PATTERN_LENGTH );
+ LINKVAR( DEFAULT_TEMP_CACHE_SIZE );
+ LINKVAR( DEFAULT_CACHE_SIZE );
+ LINKVAR( DEFAULT_PAGE_SIZE );
+ LINKVAR( DEFAULT_FILE_FORMAT );
+ LINKVAR( MAX_ATTACHED );
{
- static int sqlite_default_temp_cache_size = SQLITE_DEFAULT_TEMP_CACHE_SIZE;
- Tcl_LinkVar(interp, "SQLITE_DEFAULT_TEMP_CACHE_SIZE",
- (char*)&sqlite_default_temp_cache_size,
- TCL_LINK_INT|TCL_LINK_READ_ONLY);
- }
- {
- static int sqlite_default_cache_size = SQLITE_DEFAULT_CACHE_SIZE;
- Tcl_LinkVar(interp, "SQLITE_DEFAULT_CACHE_SIZE",
- (char*)&sqlite_default_cache_size, TCL_LINK_INT|TCL_LINK_READ_ONLY);
- }
- {
- static int sqlite_default_page_size = SQLITE_DEFAULT_PAGE_SIZE;
- Tcl_LinkVar(interp, "SQLITE_DEFAULT_PAGE_SIZE",
- (char*)&sqlite_default_page_size, TCL_LINK_INT|TCL_LINK_READ_ONLY);
- }
- {
- static int temp_store = TEMP_STORE;
- Tcl_LinkVar(interp, "TEMP_STORE",
- (char*)&temp_store, TCL_LINK_INT|TCL_LINK_READ_ONLY);
- }
- {
- static int sqlite_default_file_format = SQLITE_DEFAULT_FILE_FORMAT;
- Tcl_LinkVar(interp, "SQLITE_DEFAULT_FILE_FORMAT",
- (char*)&sqlite_default_file_format, TCL_LINK_INT|TCL_LINK_READ_ONLY);
- }
- {
- static int sqlite_max_attached = SQLITE_MAX_ATTACHED;
- Tcl_LinkVar(interp, "SQLITE_MAX_ATTACHED",
- (char*)&sqlite_max_attached, TCL_LINK_INT|TCL_LINK_READ_ONLY);
+ static const int cv_TEMP_STORE = TEMP_STORE;
+ Tcl_LinkVar(interp, "TEMP_STORE", (char *)&(cv_TEMP_STORE),
+ TCL_LINK_INT | TCL_LINK_READ_ONLY);
}
}
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
-** $Id: tokenize.c,v 1.138 2008/01/22 23:37:10 drh Exp $
+** $Id: tokenize.c,v 1.139 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
int tokenType;
int lastTokenParsed = -1;
sqlite3 *db = pParse->db;
+ int mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
if( db->activeVdbeCnt==0 ){
db->u1.isInterrupted = 0;
assert( pParse->sLastToken.dyn==0 );
pParse->sLastToken.n = getToken((unsigned char*)&zSql[i],&tokenType);
i += pParse->sLastToken.n;
- if( SQLITE_MAX_SQL_LENGTH>0 && i>SQLITE_MAX_SQL_LENGTH ){
+ if( i>mxSqlLen ){
pParse->rc = SQLITE_TOOBIG;
break;
}
** 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.713 2008/03/19 21:45:51 drh Exp $
+** $Id: vdbe.c,v 1.714 2008/03/20 14:03:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
pOp->p4type = P4_DYNAMIC;
pOp->p4.z = pOut->z;
pOp->p1 = pOut->n;
- if( pOp->p1>SQLITE_MAX_LENGTH ){
+ if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
UPDATE_MAX_BLOBSIZE(pOut);
break;
}
#endif
- if( pOp->p1>SQLITE_MAX_LENGTH ){
+ if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
/* Fall through to the next case, OP_String */
ExpandBlob(pIn2);
Stringify(pIn2, encoding);
nByte = pIn1->n + pIn2->n;
- if( nByte>SQLITE_MAX_LENGTH ){
+ if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
MemSetTypeFlag(pOut, MEM_Str);
assert( pDest->flags&MEM_Null );
goto op_column_out;
}
- if( payloadSize>SQLITE_MAX_LENGTH ){
+ if( payloadSize>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
nHdr++;
}
nByte = nHdr+nData-nZero;
- if( nByte>SQLITE_MAX_LENGTH ){
+ if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
i64 n64;
assert( !pC->isTable );
sqlite3BtreeKeySize(pCrsr, &n64);
- if( n64>SQLITE_MAX_LENGTH ){
+ if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
n = n64;
}else{
sqlite3BtreeDataSize(pCrsr, &n);
- if( n>SQLITE_MAX_LENGTH ){
+ if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
}
/* Force an SQLITE_TOOBIG error. */
void sqlite3_result_error_toobig(sqlite3_context *pCtx){
assert( sqlite3_mutex_held(pCtx->s.db->mutex) );
- sqlite3VdbeMemSetZeroBlob(&pCtx->s, SQLITE_MAX_LENGTH+1);
+ pCtx->isError = SQLITE_TOOBIG;
+ sqlite3VdbeMemSetStr(&pCtx->s, "string or blob too big", -1,
+ SQLITE_UTF8, SQLITE_STATIC);
}
/* An SQLITE_NOMEM error. */
if( p->flags & MEM_Zero ){
n += p->u.i;
}
- return n>SQLITE_MAX_LENGTH;
+ return n>p->db->aLimit[SQLITE_LIMIT_LENGTH];
}
return 0;
}
# This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions.
#
-# $Id: func.test,v 1.73 2008/03/19 16:35:24 drh Exp $
+# $Id: func.test,v 1.74 2008/03/20 14:03:29 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test func-9.12-utf16le {
execsql {SELECT hex(replace('abcdefg','','12'))}
} {{}}
- breakpoint
do_test func-9.13-utf16le {
execsql {SELECT hex(replace('aabcdefg','a','aaa'))}
} {610061006100610061006100620063006400650066006700}
do_test func-9.12-utf8 {
execsql {SELECT hex(replace('abcdefg','','12'))}
} {{}}
- breakpoint
do_test func-9.13-utf8 {
execsql {SELECT hex(replace('aabcdefg','a','aaa'))}
} {616161616161626364656667}