Add comments, assertions, and test cases to demonstrate that the

problem described in ticket #2742 is not a real problem. (CVS 4510)

FossilOrigin-Name: c085d6dfc0f5849113986cb2a25e64d0c95b3dfb
This commit is contained in:
drh 2007-10-23 18:55:48 +00:00
parent 9e0ebbfa41
commit 0cf19ed817
4 changed files with 65 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Add\scomments\sto\sthe\scode\swarning\sthat\s_XOPEN_SOURCE\smight\sneed\sto\sbe\ndefined\smanually\sif\susing\sUSE_PREAD\sor\sUSE_PREAD64.\s(CVS\s4509) C Add\scomments,\sassertions,\sand\stest\scases\sto\sdemonstrate\sthat\sthe\nproblem\sdescribed\sin\sticket\s#2742\sis\snot\sa\sreal\sproblem.\s(CVS\s4510)
D 2007-10-23T15:59:18 D 2007-10-23T18:55:49
F Makefile.in 30c7e3ba426ddb253b8ef037d1873425da6009a8 F Makefile.in 30c7e3ba426ddb253b8ef037d1873425da6009a8
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -90,7 +90,7 @@ F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6 F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6
F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1 F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c 650f30eba63f9635d5f31a6717c4db7d720eae2c F src/expr.c 23fac3749024deeaaa6c25b6b5c521e8d140a2c5
F src/func.c e8e8978804ba453e9e1377db8824c90871b53cfb F src/func.c e8e8978804ba453e9e1377db8824c90871b53cfb
F src/hash.c 45a7005aac044b6c86bd7e49c44bc15d30006d6c F src/hash.c 45a7005aac044b6c86bd7e49c44bc15d30006d6c
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53 F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
@ -216,7 +216,7 @@ F test/btree9.test 5d8711b241145b90f65dd1795d5dd8290846fa5e
F test/busy.test 0271c854738e23ad76e10d4096a698e5af29d211 F test/busy.test 0271c854738e23ad76e10d4096a698e5af29d211
F test/cache.test 3ff445c445742a7b6b9ba6e1d62a25263f9424b9 F test/cache.test 3ff445c445742a7b6b9ba6e1d62a25263f9424b9
F test/capi2.test 3c5066836cbaa9923bcc8282c010aa227bb5efd4 F test/capi2.test 3c5066836cbaa9923bcc8282c010aa227bb5efd4
F test/capi3.test ba20464efde48b33b5792cad9ac71dfe2e8d8cd9 F test/capi3.test 1eddefd4db279b7a2a64838cb60322a12a1e89a0
F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97 F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97
F test/capi3c.test 40dfef274e7b9363cbd15ccfce9ce364b7b097a4 F test/capi3c.test 40dfef274e7b9363cbd15ccfce9ce364b7b097a4
F test/cast.test c4780b58b569bab4947458195410ae8791ac216b F test/cast.test c4780b58b569bab4947458195410ae8791ac216b
@ -584,7 +584,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 36465aeb1f8f92d336faf16c25608c9a8a6585d3 P d7ed7cd077fe5f9ffba2bca48b84b231ccfd85b0
R c0b489346bd15c8b48b3e65fee073c1d R 038cadfe29415eab90fa87425599b5e1
U drh U drh
Z 77c133e74d0121e59bb624a0598e2ce9 Z 4b76268e2531d74156d78787b834a33e

View File

@ -1 +1 @@
d7ed7cd077fe5f9ffba2bca48b84b231ccfd85b0 c085d6dfc0f5849113986cb2a25e64d0c95b3dfb

View File

@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and ** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite. ** for generating VDBE code that evaluates expressions in SQLite.
** **
** $Id: expr.c,v 1.314 2007/10/23 15:39:45 drh Exp $ ** $Id: expr.c,v 1.315 2007/10/23 18:55:49 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@ -1694,12 +1694,17 @@ static char *dup8bytes(Vdbe *v, const char *in){
/* /*
** Generate an instruction that will put the floating point ** Generate an instruction that will put the floating point
** value described by z[0..n-1] on the stack. ** value described by z[0..n-1] on the stack.
**
** The z[] string will probably not be zero-terminated. But the
** z[n] character is guaranteed to be something that does not look
** like the continuation of the number.
*/ */
static void codeReal(Vdbe *v, const char *z, int n, int negateFlag){ static void codeReal(Vdbe *v, const char *z, int n, int negateFlag){
assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed ); assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
if( z ){ if( z ){
double value; double value;
char *zV; char *zV;
assert( !isdigit(z[n]) );
sqlite3AtoF(z, &value); sqlite3AtoF(z, &value);
if( negateFlag ) value = -value; if( negateFlag ) value = -value;
zV = dup8bytes(v, (char*)&value); zV = dup8bytes(v, (char*)&value);
@ -1711,11 +1716,16 @@ static void codeReal(Vdbe *v, const char *z, int n, int negateFlag){
/* /*
** Generate an instruction that will put the integer describe by ** Generate an instruction that will put the integer describe by
** text z[0..n-1] on the stack. ** text z[0..n-1] on the stack.
**
** The z[] string will probably not be zero-terminated. But the
** z[n] character is guaranteed to be something that does not look
** like the continuation of the number.
*/ */
static void codeInteger(Vdbe *v, const char *z, int n, int negateFlag){ static void codeInteger(Vdbe *v, const char *z, int n, int negateFlag){
assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed ); assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
if( z ){ if( z ){
int i; int i;
assert( !isdigit(z[n]) );
if( sqlite3GetInt32(z, &i) ){ if( sqlite3GetInt32(z, &i) ){
if( negateFlag ) i = -i; if( negateFlag ) i = -i;
sqlite3VdbeAddOp(v, OP_Integer, i, 0); sqlite3VdbeAddOp(v, OP_Integer, i, 0);

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this script testing the callback-free C/C++ API. # focus of this script testing the callback-free C/C++ API.
# #
# $Id: capi3.test,v 1.55 2007/08/29 19:15:09 drh Exp $ # $Id: capi3.test,v 1.56 2007/10/23 18:55:50 drh Exp $
# #
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
@ -1020,6 +1020,51 @@ do_test capi3-15.2 {
do_test capi3-15.3 { do_test capi3-15.3 {
sqlite3_finalize $STMT sqlite3_finalize $STMT
} {SQLITE_OK} } {SQLITE_OK}
do_test capi3-15.4 {
# 123456789 1234567
set sql {SELECT 1234567890}
set STMT [sqlite3_prepare $DB $sql 8 TAIL]
sqlite3_step $STMT
set v1 [sqlite3_column_int $STMT 0]
sqlite3_finalize $STMT
set v1
} {1}
do_test capi3-15.5 {
# 123456789 1234567
set sql {SELECT 1234567890}
set STMT [sqlite3_prepare $DB $sql 9 TAIL]
sqlite3_step $STMT
set v1 [sqlite3_column_int $STMT 0]
sqlite3_finalize $STMT
set v1
} {12}
do_test capi3-15.6 {
# 123456789 1234567
set sql {SELECT 1234567890}
set STMT [sqlite3_prepare $DB $sql 12 TAIL]
sqlite3_step $STMT
set v1 [sqlite3_column_int $STMT 0]
sqlite3_finalize $STMT
set v1
} {12345}
do_test capi3-15.7 {
# 123456789 1234567
set sql {SELECT 12.34567890}
set STMT [sqlite3_prepare $DB $sql 12 TAIL]
sqlite3_step $STMT
set v1 [sqlite3_column_double $STMT 0]
sqlite3_finalize $STMT
set v1
} {12.34}
do_test capi3-15.8 {
# 123456789 1234567
set sql {SELECT 12.34567890}
set STMT [sqlite3_prepare $DB $sql 14 TAIL]
sqlite3_step $STMT
set v1 [sqlite3_column_double $STMT 0]
sqlite3_finalize $STMT
set v1
} {12.3456}
# Make sure code is always generated even if an IF EXISTS or # Make sure code is always generated even if an IF EXISTS or
# IF NOT EXISTS clause is present that the table does not or # IF NOT EXISTS clause is present that the table does not or