When SQLITE_MAX_SQL_LENGTH is 0, disable the limit. Make the default 0.

Once again build the sqlite3 CLI from individual source files so that
it can be built on systems that lack tclsh.  Tickets #2845 and #2846. (CVS 4636)

FossilOrigin-Name: 07aeca3b9c51e538ba7939950a970f62e51bd3ea
This commit is contained in:
drh 2007-12-17 16:20:06 +00:00
parent 92e3e09467
commit cbd2da9ce9
8 changed files with 61 additions and 46 deletions

View File

@ -317,18 +317,11 @@ libtclsqlite3.la: tclsqlite.lo libsqlite3.la
-rpath $(libdir)/sqlite \ -rpath $(libdir)/sqlite \
-version-info "8:6:8" -version-info "8:6:8"
testcli$(TEXE): $(TOP)/src/shell.c libsqlite3.la sqlite3.h sqlite3$(TEXE): $(TOP)/src/shell.c libsqlite3.la sqlite3.h
$(LTLINK) $(READLINE_FLAGS) $(LIBPTHREAD) \ $(LTLINK) $(READLINE_FLAGS) $(LIBPTHREAD) \
-o $@ $(TOP)/src/shell.c libsqlite3.la \ -o $@ $(TOP)/src/shell.c libsqlite3.la \
$(LIBREADLINE) $(TLIBS) $(LIBREADLINE) $(TLIBS)
sqlite3$(EXE): $(TOP)/src/shell.c sqlite3.c sqlite3.h
$(LTLINK) $(READLINE_FLAGS) -o $@ \
-DSQLITE_MAX_SQL_LENGTH=1000000000 \
-USQLITE_THREADSAFE -DSQLITE_THREADSAFE=0 \
$(TOP)/src/shell.c sqlite3.c \
$(LIBREADLINE) $(TLIBS) $(THREADLIB)
# This target creates a directory named "tsrc" and fills it with # This target creates a directory named "tsrc" and fills it with
# copies of all of the C source code and header files needed to # copies of all of the C source code and header files needed to
# build on the target system. Some of the C source code and header # build on the target system. Some of the C source code and header

View File

@ -277,18 +277,11 @@ libsqlite3.a: $(LIBOBJ)
$(AR) libsqlite3.a $(LIBOBJ) $(AR) libsqlite3.a $(LIBOBJ)
$(RANLIB) libsqlite3.a $(RANLIB) libsqlite3.a
testcli$(EXE): $(TOP)/src/shell.c libsqlite3.a sqlite3.h sqlite3$(EXE): $(TOP)/src/shell.c libsqlite3.a sqlite3.h
$(TCCX) $(READLINE_FLAGS) -o testcli$(EXE) \ $(TCCX) $(READLINE_FLAGS) -o testcli$(EXE) \
$(TOP)/src/shell.c \ $(TOP)/src/shell.c \
libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB) libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB)
sqlite3$(EXE): $(TOP)/src/shell.c sqlite3.c sqlite3.h
$(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) \
-DSQLITE_MAX_SQL_LENGTH=1000000000 \
-USQLITE_THREADSAFE -DSQLITE_THREADSAFE=0 \
$(TOP)/src/shell.c sqlite3.c \
$(LIBREADLINE) $(TLIBS) $(THREADLIB)
objects: $(LIBOBJ_ORIG) objects: $(LIBOBJ_ORIG)
# This target creates a directory named "tsrc" and fills it with # This target creates a directory named "tsrc" and fills it with

View File

@ -1,7 +1,7 @@
C Version\s3.5.4\s(CVS\s4635) C When\sSQLITE_MAX_SQL_LENGTH\sis\s0,\sdisable\sthe\slimit.\s\sMake\sthe\sdefault\s0.\nOnce\sagain\sbuild\sthe\ssqlite3\sCLI\sfrom\sindividual\ssource\sfiles\sso\sthat\nit\scan\sbe\sbuilt\son\ssystems\sthat\slack\stclsh.\s\sTickets\s#2845\sand\s#2846.\s(CVS\s4636)
D 2007-12-14T17:39:24 D 2007-12-17T16:20:07
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in e66cf1239b8009b073156b36f92e68657d4755da F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F VERSION 6055d543dbd832b5c0209d6cc787413c1814efdc F VERSION 6055d543dbd832b5c0209d6cc787413c1814efdc
@ -64,7 +64,7 @@ F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33
F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2 F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387 F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
F main.mk c7c4fa7703f650f5191dd8d8817c2c6c08144257 F main.mk 90104c59b05cd2d907613533f982cf57d012df3e
F mkdll.sh 5f8438dcac98e795d7df6529159a1ec566de0183 F mkdll.sh 5f8438dcac98e795d7df6529159a1ec566de0183
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
@ -137,7 +137,7 @@ F src/shell.c c97be281cfc3dcb14902f45e4b16f20038eb83ff
F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f
F src/sqlite3ext.h a93f59cdee3638dc0c9c086f80df743a4e68c3cb F src/sqlite3ext.h a93f59cdee3638dc0c9c086f80df743a4e68c3cb
F src/sqliteInt.h 445530263725d19d6315f137f234aea08ad59303 F src/sqliteInt.h 445530263725d19d6315f137f234aea08ad59303
F src/sqliteLimit.h e9831389adb60e1d6091d75a4c37322c1efa1684 F src/sqliteLimit.h ee4430f88f69bf63527967bb35ca52af7b0ccb1e
F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4 F src/table.c 1aeb9eab57b4235db86fe15a35dec76fb445a9c4
F src/tclsqlite.c 9923abeffc9b3d7dad58e92b319661521f60debf F src/tclsqlite.c 9923abeffc9b3d7dad58e92b319661521f60debf
F src/test1.c 537fea45996bd33d4885c3c1f53761da14011e9b F src/test1.c 537fea45996bd33d4885c3c1f53761da14011e9b
@ -162,13 +162,13 @@ F src/test_schema.c 12c9de7661d6294eec2d57afbb52e2af1128084f
F src/test_server.c a6ece6c835e7eae835054124e09e947e422b1ac5 F src/test_server.c a6ece6c835e7eae835054124e09e947e422b1ac5
F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59 F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59
F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730 F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
F src/tokenize.c 67e42600ab34f976f2b1288c499ad6c98d652f0e F src/tokenize.c a4e04438c11fed2c67ec47fe3edbef9cca2d1b48
F src/trigger.c 66695e1375b969ea41a38dec9f40ea28bb0ac767 F src/trigger.c 66695e1375b969ea41a38dec9f40ea28bb0ac767
F src/update.c 57c07b63410cdd3d14888e33439aa1955a3514c1 F src/update.c 57c07b63410cdd3d14888e33439aa1955a3514c1
F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736 F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624 F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624
F src/vacuum.c 25ffbd766f25bca099ead1c1e11f5528c86102b8 F src/vacuum.c 25ffbd766f25bca099ead1c1e11f5528c86102b8
F src/vdbe.c cd669cd873e12ec248469b834d183a17bc84491d F src/vdbe.c b2f1bcd4b9c9db31dbd79f387139d6740627fa8c
F src/vdbe.h 79e09ff13b85457abe437d9814454534ebbc1fe3 F src/vdbe.h 79e09ff13b85457abe437d9814454534ebbc1fe3
F src/vdbeInt.h 630145b9bfaa19190ab491f52658a7db550f2247 F src/vdbeInt.h 630145b9bfaa19190ab491f52658a7db550f2247
F src/vdbeapi.c dd2c43317294e0a013e9f634ee4209a3ea459b43 F src/vdbeapi.c dd2c43317294e0a013e9f634ee4209a3ea459b43
@ -432,7 +432,7 @@ F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a
F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded
F test/speed3.test e312d7e442a5047d730569fdae2ba99bc94e1a13 F test/speed3.test e312d7e442a5047d730569fdae2ba99bc94e1a13
F test/speed4.test 20d8ea20bea3ca09c3ef3b5ec820a17e58e132cb F test/speed4.test 20d8ea20bea3ca09c3ef3b5ec820a17e58e132cb
F test/sqllimits1.test e7a6c34f6915c334a66db8065484d686dbabece0 F test/sqllimits1.test ede9874fc0ffbfa1ebfbc84cbe5d283cfa00f772
F test/subquery.test 8203f85db56ba022a57a0589890090c8feed4e59 F test/subquery.test 8203f85db56ba022a57a0589890090c8feed4e59
F test/subselect.test 974e87f8fc91c5f00dd565316d396a5a6c3106c4 F test/subselect.test 974e87f8fc91c5f00dd565316d396a5a6c3106c4
F test/substr.test 4be572ac017143e59b4058dc75c91a0d0dc6d4e0 F test/substr.test 4be572ac017143e59b4058dc75c91a0d0dc6d4e0
@ -600,7 +600,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 5c653bfc7ffafcd3572d399aba05e39ea839068a P cf4a11b2a8afcbc9cdcf5fa907ddb9865847ed11
R ff47409f2a9a3518644e7f89b8fb52de R 2fb1f868f422a022f8eefcb02651a201
U drh U drh
Z 41bedfa8d554f94c72f67c2e02cbe860 Z 786f0cda535230caba90f27262a5a98a

View File

@ -1 +1 @@
cf4a11b2a8afcbc9cdcf5fa907ddb9865847ed11 07aeca3b9c51e538ba7939950a970f62e51bd3ea

View File

@ -12,7 +12,7 @@
** **
** This file defines various limits of what SQLite can process. ** This file defines various limits of what SQLite can process.
** **
** @(#) $Id: sqliteLimit.h,v 1.5 2007/12/13 21:54:11 drh Exp $ ** @(#) $Id: sqliteLimit.h,v 1.6 2007/12/17 16:20:07 drh Exp $
*/ */
/* /*
@ -49,10 +49,10 @@
/* /*
** The maximum length of a single SQL statement in bytes. ** The maximum length of a single SQL statement in bytes.
** The hard limit is 1 million. ** A value of zero means there is no limit.
*/ */
#ifndef SQLITE_MAX_SQL_LENGTH #ifndef SQLITE_MAX_SQL_LENGTH
# define SQLITE_MAX_SQL_LENGTH 1000000 # define SQLITE_MAX_SQL_LENGTH 0
#endif #endif
/* /*

View File

@ -15,7 +15,7 @@
** individual tokens and sends those tokens one-by-one over to the ** individual tokens and sends those tokens one-by-one over to the
** parser for analysis. ** parser for analysis.
** **
** $Id: tokenize.c,v 1.136 2007/08/27 23:26:59 drh Exp $ ** $Id: tokenize.c,v 1.137 2007/12/17 16:20:07 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@ -418,7 +418,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
assert( pParse->sLastToken.dyn==0 ); assert( pParse->sLastToken.dyn==0 );
pParse->sLastToken.n = getToken((unsigned char*)&zSql[i],&tokenType); pParse->sLastToken.n = getToken((unsigned char*)&zSql[i],&tokenType);
i += pParse->sLastToken.n; i += pParse->sLastToken.n;
if( i>SQLITE_MAX_SQL_LENGTH ){ if( SQLITE_MAX_SQL_LENGTH>0 && i>SQLITE_MAX_SQL_LENGTH ){
pParse->rc = SQLITE_TOOBIG; pParse->rc = SQLITE_TOOBIG;
break; break;
} }

View File

@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing ** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code. ** commenting and indentation practices when changing or adding code.
** **
** $Id: vdbe.c,v 1.660 2007/12/13 21:54:11 drh Exp $ ** $Id: vdbe.c,v 1.661 2007/12/17 16:20:07 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@ -760,8 +760,6 @@ case OP_String8: { /* same as TK_STRING */
assert( pOp->p3!=0 ); assert( pOp->p3!=0 );
pOp->opcode = OP_String; pOp->opcode = OP_String;
pOp->p1 = strlen(pOp->p3); pOp->p1 = strlen(pOp->p3);
assert( SQLITE_MAX_SQL_LENGTH <= SQLITE_MAX_LENGTH );
assert( pOp->p1 <= SQLITE_MAX_LENGTH );
#ifndef SQLITE_OMIT_UTF16 #ifndef SQLITE_OMIT_UTF16
if( encoding!=SQLITE_UTF8 ){ if( encoding!=SQLITE_UTF8 ){
@ -777,11 +775,16 @@ case OP_String8: { /* same as TK_STRING */
pOp->p3type = P3_DYNAMIC; pOp->p3type = P3_DYNAMIC;
pOp->p3 = pTos->z; pOp->p3 = pTos->z;
pOp->p1 = pTos->n; pOp->p1 = pTos->n;
assert( pOp->p1 <= SQLITE_MAX_LENGTH ); /* Due to SQLITE_MAX_SQL_LENGTH */ if( pOp->p1>SQLITE_MAX_LENGTH ){
goto too_big;
}
break; break;
} }
#endif #endif
/* Otherwise fall through to the next case, OP_String */ if( pOp->p1>SQLITE_MAX_LENGTH ){
goto too_big;
}
/* Fall through to the next case, OP_String */
} }
/* Opcode: String P1 * P3 /* Opcode: String P1 * P3
@ -789,7 +792,6 @@ case OP_String8: { /* same as TK_STRING */
** The string value P3 of length P1 (bytes) is pushed onto the stack. ** The string value P3 of length P1 (bytes) is pushed onto the stack.
*/ */
case OP_String: { case OP_String: {
assert( pOp->p1 <= SQLITE_MAX_LENGTH ); /* Due to SQLITE_MAX_SQL_LENGTH */
pTos++; pTos++;
assert( pOp->p3!=0 ); assert( pOp->p3!=0 );
pTos->flags = MEM_Str|MEM_Static|MEM_Term; pTos->flags = MEM_Str|MEM_Static|MEM_Term;
@ -823,8 +825,9 @@ case OP_Null: {
case OP_HexBlob: { /* same as TK_BLOB */ case OP_HexBlob: { /* same as TK_BLOB */
pOp->opcode = OP_Blob; pOp->opcode = OP_Blob;
pOp->p1 = strlen(pOp->p3)/2; pOp->p1 = strlen(pOp->p3)/2;
assert( SQLITE_MAX_SQL_LENGTH <= SQLITE_MAX_LENGTH ); if( pOp->p1>SQLITE_MAX_LENGTH ){
assert( pOp->p1 <= SQLITE_MAX_LENGTH ); goto too_big;
}
if( pOp->p1 ){ if( pOp->p1 ){
char *zBlob = sqlite3HexToBlob(db, pOp->p3); char *zBlob = sqlite3HexToBlob(db, pOp->p3);
if( !zBlob ) goto no_mem; if( !zBlob ) goto no_mem;
@ -855,7 +858,7 @@ case OP_HexBlob: { /* same as TK_BLOB */
*/ */
case OP_Blob: { case OP_Blob: {
pTos++; pTos++;
assert( pOp->p1 <= SQLITE_MAX_LENGTH ); /* Due to SQLITE_MAX_SQL_LENGTH */ assert( pOp->p1 <= SQLITE_MAX_LENGTH );
sqlite3VdbeMemSetStr(pTos, pOp->p3, pOp->p1, 0, 0); sqlite3VdbeMemSetStr(pTos, pOp->p3, pOp->p1, 0, 0);
pTos->enc = encoding; pTos->enc = encoding;
break; break;

View File

@ -12,7 +12,7 @@
# This file contains tests to verify that the limits defined in # This file contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced. # sqlite source file limits.h are enforced.
# #
# $Id: sqllimits1.test,v 1.20 2007/11/28 22:36:41 drh Exp $ # $Id: sqllimits1.test,v 1.21 2007/12/17 16:20:07 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -141,16 +141,42 @@ do_test sqllimits-1.15 {
} {1 {string or blob too big}} } {1 {string or blob too big}}
db eval {DROP TABLE t4} db eval {DROP TABLE t4}
set ::SQLITE_MAX_SQL_LENGTH 0
set strvalue [string repeat A $::SQLITE_MAX_LENGTH]
do_test sqllimits-1.16 {
catchsql "SELECT '$strvalue'"
} [list 0 $strvalue]
do_test sqllimits-1.17 {
catchsql "SELECT 'A$strvalue'"
} [list 1 {string or blob too big}]
set blobvalue [string repeat 41 $::SQLITE_MAX_LENGTH]
do_test sqllimits-1.18 {
catchsql "SELECT x'$blobvalue'"
} [list 0 $strvalue]
do_test sqllimits-1.19 {
catchsql "SELECT '41$blobvalue'"
} [list 1 {string or blob too big}]
unset strvalue
unset blobvalue
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Test cases sqllimits-2.* test that the SQLITE_MAX_SQL_LENGTH limit # Test cases sqllimits-2.* test that the SQLITE_MAX_SQL_LENGTH limit
# is enforced. # is enforced.
# #
do_test sqllimits-2.1 { do_test sqllimits-2.1 {
set ::SQLITE_MAX_SQL_LENGTH 50000
set sql "SELECT 1 WHERE 1==1" set sql "SELECT 1 WHERE 1==1"
set N [expr {$::SQLITE_MAX_SQL_LENGTH / [string length " AND 1==1"]}] set tail " /* A comment to take up space in order to make the string\
append sql [string repeat " AND 1==1" $N] longer without increasing the expression depth */\
AND 1 == 1"
set N [expr {($::SQLITE_MAX_SQL_LENGTH / [string length $tail])+1}]
append sql [string repeat $tail $N]
catchsql $sql catchsql $sql
} {1 {String or BLOB exceeded size limit}} } {1 {String or BLOB exceeded size limit}}
do_test sqllimits-2.2 {
set ::SQLITE_MAX_SQL_LENGTH 0
catchsql $sql
} {0 1}
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Test cases sqllimits-3.* test that the limit set using the # Test cases sqllimits-3.* test that the limit set using the