Merge in the latest trunk changes.

FossilOrigin-Name: 9ff4dfe1e36b40e386858b03f36cfab8f6806fdd
This commit is contained in:
drh 2013-12-11 14:17:06 +00:00
commit 07c5d0a901
18 changed files with 114 additions and 75 deletions

View File

@ -534,7 +534,7 @@ mptester$(EXE): sqlite3.c $(TOP)/mptest/mptest.c
mkdir tsrc mkdir tsrc
cp -f $(SRC) tsrc cp -f $(SRC) tsrc
rm tsrc/sqlite.h.in tsrc/parse.y rm tsrc/sqlite.h.in tsrc/parse.y
$(TCLSH_CMD) $(TOP)/tool/vdbe-compress.tcl <tsrc/vdbe.c >vdbe.new $(TCLSH_CMD) $(TOP)/tool/vdbe-compress.tcl $(OPTS) <tsrc/vdbe.c >vdbe.new
mv vdbe.new tsrc/vdbe.c mv vdbe.new tsrc/vdbe.c
touch .target_source touch .target_source

View File

@ -911,7 +911,7 @@ mptester.exe: $(TOP)\mptest\mptest.c libsqlite3.lib $(LIBRESOBJS) sqlite3.h
-mkdir tsrc -mkdir tsrc
for %i in ($(SRC)) do copy /Y %i tsrc for %i in ($(SRC)) do copy /Y %i tsrc
del /Q tsrc\sqlite.h.in tsrc\parse.y del /Q tsrc\sqlite.h.in tsrc\parse.y
$(TCLSH_CMD) $(TOP)\tool\vdbe-compress.tcl < tsrc\vdbe.c > vdbe.new $(TCLSH_CMD) $(TOP)\tool\vdbe-compress.tcl $(OPTS) < tsrc\vdbe.c > vdbe.new
move vdbe.new tsrc\vdbe.c move vdbe.new tsrc\vdbe.c
echo > .target_source echo > .target_source

View File

@ -402,7 +402,7 @@ target_source: $(SRC) $(TOP)/tool/vdbe-compress.tcl
mkdir tsrc mkdir tsrc
cp -f $(SRC) tsrc cp -f $(SRC) tsrc
rm tsrc/sqlite.h.in tsrc/parse.y rm tsrc/sqlite.h.in tsrc/parse.y
tclsh $(TOP)/tool/vdbe-compress.tcl <tsrc/vdbe.c >vdbe.new tclsh $(TOP)/tool/vdbe-compress.tcl $(OPTS) <tsrc/vdbe.c >vdbe.new
mv vdbe.new tsrc/vdbe.c mv vdbe.new tsrc/vdbe.c
touch target_source touch target_source

View File

@ -1,9 +1,9 @@
C Have\sthe\scrash-test\sinfrastructure\scode\sin\stest6.c\sread\sand\swrite\sthe\s512-byte\sblock\scontaining\sthe\spending-byte\slock\sas\snormal.\sEarlier\sversions\sdid\snot\saccess\sthis\spart\sof\sthe\sfile\sin\sorder\sto\savoid\striggering\san\sassert\sin\sos_unix.c.\sBut\sthe\sassert()\shas\ssince\sbeen\sremoved.\sAnd\snot\sreading/writing\sthis\spart\sof\sthe\sfile\scauses\sproblems\sfor\smultiplexor\stests. C Merge\sin\sthe\slatest\strunk\schanges.
D 2013-12-11T11:03:19.250 D 2013-12-11T14:17:06.145
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F Makefile.msc bb1f271c8ee9773489c89be00f3f8ad7ed7ae8e0 F Makefile.msc 4d4ead6b71d1bf03028fbd61da0ba0ec5e1556e1
F Makefile.vxworks db21ed42a01d5740e656b16f92cb5d8d5e5dd315 F Makefile.vxworks db21ed42a01d5740e656b16f92cb5d8d5e5dd315
F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6
F VERSION 8ed548d87d0a27fd7d7620476f9e25f9fa742d73 F VERSION 8ed548d87d0a27fd7d7620476f9e25f9fa742d73
@ -142,7 +142,7 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt f439556c5ce01ced70987e5ee86549a45165d9ff F magic.txt f439556c5ce01ced70987e5ee86549a45165d9ff
F main.mk 82fd90375561d7b66287ae5a8b09e1e027394019 F main.mk 9f091ea7920f8b15e48c7b6e5b6fb0182577ab2e
F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh d2a981497b404d6498f5ff3e3b1f3816bdfcb338 F mkextw.sh d2a981497b404d6498f5ff3e3b1f3816bdfcb338
@ -178,7 +178,7 @@ F src/delete.c b36db1f79ee50eaca979660c9dd36437f5410b93
F src/expr.c 31a2b65339f6c3795d4cfa5e99798cd72f9fdfdf F src/expr.c 31a2b65339f6c3795d4cfa5e99798cd72f9fdfdf
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 2ab0f5384b70594468ef3ac5c7ed8ca24bfd17d5 F src/fkey.c 2ab0f5384b70594468ef3ac5c7ed8ca24bfd17d5
F src/func.c ef30d26ae4d79bbc7300c74e77fd117a0ba30235 F src/func.c fed87f35cf4da4a798b726d84abefc209b48d831
F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486 F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486
F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22
@ -188,8 +188,8 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303
F src/main.c 355fc9ab213b43a4d8a96aadf2a84622e6668f0a F src/main.c a79c8ca051a914e50d6b221d56801d47835714d8
F src/malloc.c 543a8eb5508eaf4cadf55a9b503379eba2088128 F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b
F src/mem2.c dce31758da87ec2cfa52ba4c5df1aed6e07d8e8f F src/mem2.c dce31758da87ec2cfa52ba4c5df1aed6e07d8e8f
@ -207,7 +207,7 @@ F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_unix.c 60a7b3b23e6fcf83a50d1e320b280b551724e11f F src/os_unix.c 60a7b3b23e6fcf83a50d1e320b280b551724e11f
F src/os_win.c 16eac0961603182ffc10c02b39fe830126538e07 F src/os_win.c 16eac0961603182ffc10c02b39fe830126538e07
F src/pager.c 994b3ee3716c89707952051115d72e0bd877e7b9 F src/pager.c 95a568497d789d5729927fca93fec653c485df45
F src/pager.h 6a790b64a9ea79bc2c849bdefdd39e2344bca94a F src/pager.h 6a790b64a9ea79bc2c849bdefdd39e2344bca94a
F src/parse.y acee1a9958539e21263362b194594c5255ad2fca F src/parse.y acee1a9958539e21263362b194594c5255ad2fca
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
@ -215,12 +215,12 @@ F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63 F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63
F src/pragma.c 5ab7279d132143feb77f773688a24ab05da75fd7 F src/pragma.c 5ab7279d132143feb77f773688a24ab05da75fd7
F src/prepare.c 359d1a1e9c9bd4488e4dd3a1aaaf2d2ebb9bb768 F src/prepare.c 359d1a1e9c9bd4488e4dd3a1aaaf2d2ebb9bb768
F src/printf.c aacd7f73018122689dbbe89d85c2e37f737b931f F src/printf.c b2778aa160ef792ba51c9f11b743bfc015b66679
F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6 F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c d41381d80a22d3a83352aeca274cccf264ac277a F src/select.c d41381d80a22d3a83352aeca274cccf264ac277a
F src/shell.c 936a72ff784efff3832cce274a96ed0b036e6758 F src/shell.c 18924f6ccfa70da98bf9e388bab512c0fd1e792e
F src/sqlite.h.in 592057b6b3881573c2d516bad30fb20171f16b05 F src/sqlite.h.in 592057b6b3881573c2d516bad30fb20171f16b05
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
@ -280,15 +280,15 @@ F src/update.c d1c2477dcf14d90999d1935af4efb4806553250b
F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269 F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
F src/util.c 76ed0519296e3f62e97e57dab1999e34184c8e49 F src/util.c 76ed0519296e3f62e97e57dab1999e34184c8e49
F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
F src/vdbe.c 4bfb1fe75a0ad08646e9b82670691c62699bc5ee F src/vdbe.c 919422843c859a1db08db0c88189912dbf625fc7
F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644 F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644
F src/vdbeInt.h 7e38eef8f4bd7141e1638b0eacaebf9bc41b26bc F src/vdbeInt.h a7bc268f844d75be48bb7ae16f77b418fd3c641c
F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
F src/vdbeaux.c d64bc2a057e77aef3e2a4bc6670b80f516a36d55 F src/vdbeaux.c 74f3ad068f91d60ff56179a22610e7b0ef71e5d6
F src/vdbeblob.c 8cd05a5630e6d5563ad017bf82edaf812b28acde F src/vdbeblob.c 8cd05a5630e6d5563ad017bf82edaf812b28acde
F src/vdbemem.c 2293b66374f4adf54bbdcd662c05a003318600e1 F src/vdbemem.c ac71e169dc056936f7a26ccaa808cd17456ffab1
F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147 F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147
F src/vdbetrace.c e7ec40e1999ff3c6414424365d5941178966dcbc F src/vdbetrace.c f7eb148eb3b4fa3401b20024630dcb43d322e73c
F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd
F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
@ -804,7 +804,7 @@ F test/shell1.test e7c0b9ebda25d5e78f0a3ea0dc4e31bb6d8098c0
F test/shell2.test e1d3790f064e50b2f973502f45750012667486df F test/shell2.test e1d3790f064e50b2f973502f45750012667486df
F test/shell3.test 5e8545ec72c4413a0e8d4c6be56496e3c257ca29 F test/shell3.test 5e8545ec72c4413a0e8d4c6be56496e3c257ca29
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9 F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
F test/shell5.test 46c8c18d62732415c4fe084816c13d559831705e F test/shell5.test cee83b4385f842fec1f2a0bec9ea811f35386edf
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868 F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868
F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329
@ -1142,11 +1142,11 @@ F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43
F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d
F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 46231af985a1a872d1dc3418591cbaacb0b7c249 P fdc3f3fa3de1481860e1e2a819db2d6c4eb05658 5e239ecda0f7835ce037b38b04627a574b5854cd
R cf82896d56fef77694a1be0de6074b9d R 67e94d0b56b00fc27eeae35854bf8ba9
U dan U drh
Z ff5d29c735004d7eb85a84bef2a95faa Z 7c7b3737dbf629b19ab7333ee0081c4f

View File

@ -1 +1 @@
fdc3f3fa3de1481860e1e2a819db2d6c4eb05658 9ff4dfe1e36b40e386858b03f36cfab8f6806fdd

View File

@ -1511,11 +1511,11 @@ static void groupConcatStep(
zSep = ","; zSep = ",";
nSep = 1; nSep = 1;
} }
sqlite3StrAccumAppend(pAccum, zSep, nSep); if( nSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep);
} }
zVal = (char*)sqlite3_value_text(argv[0]); zVal = (char*)sqlite3_value_text(argv[0]);
nVal = sqlite3_value_bytes(argv[0]); nVal = sqlite3_value_bytes(argv[0]);
sqlite3StrAccumAppend(pAccum, zVal, nVal); if( nVal ) sqlite3StrAccumAppend(pAccum, zVal, nVal);
} }
} }
static void groupConcatFinalize(sqlite3_context *context){ static void groupConcatFinalize(sqlite3_context *context){

View File

@ -588,7 +588,8 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
db->lookaside.bEnabled = 1; db->lookaside.bEnabled = 1;
db->lookaside.bMalloced = pBuf==0 ?1:0; db->lookaside.bMalloced = pBuf==0 ?1:0;
}else{ }else{
db->lookaside.pEnd = 0; db->lookaside.pStart = db;
db->lookaside.pEnd = db;
db->lookaside.bEnabled = 0; db->lookaside.bEnabled = 0;
db->lookaside.bMalloced = 0; db->lookaside.bMalloced = 0;
} }

View File

@ -433,7 +433,7 @@ void sqlite3ScratchFree(void *p){
*/ */
#ifndef SQLITE_OMIT_LOOKASIDE #ifndef SQLITE_OMIT_LOOKASIDE
static int isLookaside(sqlite3 *db, void *p){ static int isLookaside(sqlite3 *db, void *p){
return p && p>=db->lookaside.pStart && p<db->lookaside.pEnd; return p>=db->lookaside.pStart && p<db->lookaside.pEnd;
} }
#else #else
#define isLookaside(A,B) 0 #define isLookaside(A,B) 0
@ -449,8 +449,9 @@ int sqlite3MallocSize(void *p){
return sqlite3GlobalConfig.m.xSize(p); return sqlite3GlobalConfig.m.xSize(p);
} }
int sqlite3DbMallocSize(sqlite3 *db, void *p){ int sqlite3DbMallocSize(sqlite3 *db, void *p){
assert( db==0 || sqlite3_mutex_held(db->mutex) ); assert( db!=0 );
if( db && isLookaside(db, p) ){ assert( sqlite3_mutex_held(db->mutex) );
if( isLookaside(db, p) ){
return db->lookaside.sz; return db->lookaside.sz;
}else{ }else{
assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) ); assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );

View File

@ -5785,7 +5785,7 @@ int sqlite3PagerWrite(DbPage *pDbPage){
assert( pPager->eState!=PAGER_ERROR ); assert( pPager->eState!=PAGER_ERROR );
assert( assert_pager_state(pPager) ); assert( assert_pager_state(pPager) );
if( pPager->sectorSize > pPager->pageSize ){ if( pPager->sectorSize > (u32)pPager->pageSize ){
Pgno nPageCount; /* Total number of pages in database file */ Pgno nPageCount; /* Total number of pages in database file */
Pgno pg1; /* First page of the sector pPg is located on. */ Pgno pg1; /* First page of the sector pPg is located on. */
int nPage = 0; /* Number of pages starting at pg1 to journal */ int nPage = 0; /* Number of pages starting at pg1 to journal */

View File

@ -637,7 +637,7 @@ void sqlite3VXPrintf(
} }
case etTOKEN: { case etTOKEN: {
Token *pToken = va_arg(ap, Token*); Token *pToken = va_arg(ap, Token*);
if( pToken ){ if( pToken && pToken->n ){
sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n); sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n);
} }
length = width = 0; length = width = 0;
@ -691,7 +691,7 @@ void sqlite3VXPrintf(
** Append N bytes of text from z to the StrAccum object. ** Append N bytes of text from z to the StrAccum object.
*/ */
void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
assert( z!=0 || N==0 ); assert( z!=0 );
assert( p->zText!=0 || p->nChar==0 || p->accError ); assert( p->zText!=0 || p->nChar==0 || p->accError );
assert( N>=0 ); assert( N>=0 );
assert( p->accError==0 || p->nAlloc==0 ); assert( p->accError==0 || p->nAlloc==0 );
@ -743,7 +743,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
** Append the complete text of zero-terminated string z[] to the p string. ** Append the complete text of zero-terminated string z[] to the p string.
*/ */
void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){ void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){
return sqlite3StrAccumAppend(p, z, sqlite3Strlen30(z)); sqlite3StrAccumAppend(p, z, sqlite3Strlen30(z));
} }

View File

@ -1836,7 +1836,7 @@ static void csv_append_char(CSVReader *p, int c){
** + Report syntax errors on stderr ** + Report syntax errors on stderr
*/ */
static char *csv_read_one_field(CSVReader *p){ static char *csv_read_one_field(CSVReader *p){
int c, pc; int c, pc, ppc;
int cSep = p->cSeparator; int cSep = p->cSeparator;
p->n = 0; p->n = 0;
c = fgetc(p->in); c = fgetc(p->in);
@ -1847,7 +1847,7 @@ static char *csv_read_one_field(CSVReader *p){
if( c=='"' ){ if( c=='"' ){
int startLine = p->nLine; int startLine = p->nLine;
int cQuote = c; int cQuote = c;
pc = 0; pc = ppc = 0;
while( 1 ){ while( 1 ){
c = fgetc(p->in); c = fgetc(p->in);
if( c=='\n' ) p->nLine++; if( c=='\n' ) p->nLine++;
@ -1859,7 +1859,7 @@ static char *csv_read_one_field(CSVReader *p){
} }
if( (c==cSep && pc==cQuote) if( (c==cSep && pc==cQuote)
|| (c=='\n' && pc==cQuote) || (c=='\n' && pc==cQuote)
|| (c=='\n' && pc=='\r' && p->n>=2 && p->z[p->n-2]==cQuote) || (c=='\n' && pc=='\r' && ppc==cQuote)
|| (c==EOF && pc==cQuote) || (c==EOF && pc==cQuote)
){ ){
do{ p->n--; }while( p->z[p->n]!=cQuote ); do{ p->n--; }while( p->z[p->n]!=cQuote );
@ -1877,6 +1877,7 @@ static char *csv_read_one_field(CSVReader *p){
break; break;
} }
csv_append_char(p, c); csv_append_char(p, c);
ppc = pc;
pc = c; pc = c;
} }
}else{ }else{

View File

@ -2595,16 +2595,22 @@ case OP_MakeRecord: {
pOut = &aMem[pOp->p3]; pOut = &aMem[pOp->p3];
memAboutToChange(p, pOut); memAboutToChange(p, pOut);
/* Apply the requested affinity to all inputs
*/
assert( pData0<=pLast );
if( zAffinity ){
pRec = pData0;
do{
applyAffinity(pRec, *(zAffinity++), encoding);
}while( (++pRec)<=pLast );
}
/* Loop through the elements that will make up the record to figure /* Loop through the elements that will make up the record to figure
** out how much space is required for the new record. ** out how much space is required for the new record.
*/ */
assert( pData0<=pLast );
pRec = pLast; pRec = pLast;
do{ do{
assert( memIsValid(pRec) ); assert( memIsValid(pRec) );
if( zAffinity ){
applyAffinity(pRec, zAffinity[pRec-pData0], encoding);
}
serial_type = sqlite3VdbeSerialType(pRec, file_format); serial_type = sqlite3VdbeSerialType(pRec, file_format);
len = sqlite3VdbeSerialTypeLen(serial_type); len = sqlite3VdbeSerialTypeLen(serial_type);
if( pRec->flags & MEM_Zero ){ if( pRec->flags & MEM_Zero ){
@ -2656,7 +2662,7 @@ case OP_MakeRecord: {
do{ do{
serial_type = sqlite3VdbeSerialType(pRec, file_format); serial_type = sqlite3VdbeSerialType(pRec, file_format);
i += putVarint32(&zNewRecord[i], serial_type); /* serial type */ i += putVarint32(&zNewRecord[i], serial_type); /* serial type */
j += sqlite3VdbeSerialPut(&zNewRecord[j], pRec, file_format); /* content */ j += sqlite3VdbeSerialPut(&zNewRecord[j], pRec, serial_type); /* content */
}while( (++pRec)<=pLast ); }while( (++pRec)<=pLast );
assert( i==nHdr ); assert( i==nHdr );
assert( j==nByte ); assert( j==nByte );
@ -2688,6 +2694,7 @@ case OP_Count: { /* out2-prerelease */
pCrsr = p->apCsr[pOp->p1]->pCursor; pCrsr = p->apCsr[pOp->p1]->pCursor;
assert( pCrsr ); assert( pCrsr );
nEntry = 0; /* Not needed. Only used to silence a warning. */
rc = sqlite3BtreeCount(pCrsr, &nEntry); rc = sqlite3BtreeCount(pCrsr, &nEntry);
pOut->u.i = nEntry; pOut->u.i = nEntry;
break; break;
@ -3708,7 +3715,6 @@ case OP_Found: { /* jump, in3 */
if( pOp->opcode!=OP_NoConflict ) sqlite3_found_count++; if( pOp->opcode!=OP_NoConflict ) sqlite3_found_count++;
#endif #endif
alreadyExists = 0;
assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p1>=0 && pOp->p1<p->nCursor );
assert( pOp->p4type==P4_INT32 ); assert( pOp->p4type==P4_INT32 );
pC = p->apCsr[pOp->p1]; pC = p->apCsr[pOp->p1];
@ -3716,6 +3722,7 @@ case OP_Found: { /* jump, in3 */
pIn3 = &aMem[pOp->p3]; pIn3 = &aMem[pOp->p3];
assert( pC->pCursor!=0 ); assert( pC->pCursor!=0 );
assert( pC->isTable==0 ); assert( pC->isTable==0 );
pFree = 0; /* Not needed. Only used to suppress a compiler warning. */
if( pOp->p4.i>0 ){ if( pOp->p4.i>0 ){
r.pKeyInfo = pC->pKeyInfo; r.pKeyInfo = pC->pKeyInfo;
r.nField = (u16)pOp->p4.i; r.nField = (u16)pOp->p4.i;
@ -4648,6 +4655,7 @@ case OP_IdxRowid: { /* out2-prerelease */
assert( pC->deferredMoveto==0 ); assert( pC->deferredMoveto==0 );
assert( pC->isTable==0 ); assert( pC->isTable==0 );
if( !pC->nullRow ){ if( !pC->nullRow ){
rowid = 0; /* Not needed. Only used to silence a warning. */
rc = sqlite3VdbeIdxRowid(db, pCrsr, &rowid); rc = sqlite3VdbeIdxRowid(db, pCrsr, &rowid);
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
goto abort_due_to_error; goto abort_due_to_error;
@ -4711,6 +4719,7 @@ case OP_IdxGE: { /* jump */
#ifdef SQLITE_DEBUG #ifdef SQLITE_DEBUG
{ int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); } { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif #endif
res = 0; /* Not needed. Only used to silence a warning. */
rc = sqlite3VdbeIdxKeyCompare(pC, &r, &res); rc = sqlite3VdbeIdxKeyCompare(pC, &r, &res);
if( pOp->opcode==OP_IdxLT ){ if( pOp->opcode==OP_IdxLT ){
res = -res; res = -res;
@ -4771,6 +4780,7 @@ case OP_Destroy: { /* out2-prerelease */
iDb = pOp->p3; iDb = pOp->p3;
assert( iCnt==1 ); assert( iCnt==1 );
assert( (p->btreeMask & (((yDbMask)1)<<iDb))!=0 ); assert( (p->btreeMask & (((yDbMask)1)<<iDb))!=0 );
iMoved = 0; /* Not needed. Only to silence a warning. */
rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved); rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);
pOut->flags = MEM_Int; pOut->flags = MEM_Int;
pOut->u.i = iMoved; pOut->u.i = iMoved;
@ -5343,7 +5353,6 @@ case OP_FkIfZero: { /* jump */
** an integer. ** an integer.
*/ */
case OP_MemMax: { /* in2 */ case OP_MemMax: { /* in2 */
Mem *pIn1;
VdbeFrame *pFrame; VdbeFrame *pFrame;
if( p->pFrame ){ if( p->pFrame ){
for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);

View File

@ -389,7 +389,7 @@ void sqlite3VdbePrintOp(FILE*, int, Op*);
#endif #endif
u32 sqlite3VdbeSerialTypeLen(u32); u32 sqlite3VdbeSerialTypeLen(u32);
u32 sqlite3VdbeSerialType(Mem*, int); u32 sqlite3VdbeSerialType(Mem*, int);
u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, int); u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*); u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
void sqlite3VdbeDeleteAuxData(Vdbe*, int, int); void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);

View File

@ -2835,8 +2835,7 @@ static u64 floatSwap(u64 in){
** of bytes in the zero-filled tail is included in the return value only ** of bytes in the zero-filled tail is included in the return value only
** if those bytes were zeroed in buf[]. ** if those bytes were zeroed in buf[].
*/ */
u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, int file_format){ u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
u32 serial_type = sqlite3VdbeSerialType(pMem, file_format);
u32 len; u32 len;
/* Integer and Real */ /* Integer and Real */

View File

@ -59,18 +59,14 @@ int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
/* /*
** Make sure pMem->z points to a writable allocation of at least ** Make sure pMem->z points to a writable allocation of at least
** n bytes. ** min(n,32) bytes.
** **
** If the third argument passed to this function is true, then memory ** If the bPreserve argument is true, then copy of the content of
** cell pMem must contain a string or blob. In this case the content is ** pMem->z into the new allocation. pMem must be either a string or
** preserved. Otherwise, if the third parameter to this function is false, ** blob if bPreserve is true. If bPreserve is false, any prior content
** any current string or blob value may be discarded. ** in pMem->z is discarded.
**
** This function sets the MEM_Dyn flag and clears any xDel callback.
** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
** not set, Mem.n is zeroed.
*/ */
int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve){ int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
assert( 1 >= assert( 1 >=
((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) + ((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) +
(((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) + (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +
@ -79,37 +75,39 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve){
); );
assert( (pMem->flags&MEM_RowSet)==0 ); assert( (pMem->flags&MEM_RowSet)==0 );
/* If the preserve flag is set to true, then the memory cell must already /* If the bPreserve flag is set to true, then the memory cell must already
** contain a valid string or blob value. */ ** contain a valid string or blob value. */
assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
testcase( bPreserve && pMem->z==0 );
if( n<32 ) n = 32; if( pMem->zMalloc==0 || sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){ if( n<32 ) n = 32;
if( preserve && pMem->z==pMem->zMalloc ){ if( bPreserve && pMem->z==pMem->zMalloc ){
pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
preserve = 0; bPreserve = 0;
}else{ }else{
sqlite3DbFree(pMem->db, pMem->zMalloc); sqlite3DbFree(pMem->db, pMem->zMalloc);
pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n); pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
} }
if( pMem->zMalloc==0 ){
sqlite3VdbeMemRelease(pMem);
pMem->flags = MEM_Null;
return SQLITE_NOMEM;
}
} }
if( pMem->z && preserve && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ if( pMem->z && bPreserve && pMem->z!=pMem->zMalloc ){
memcpy(pMem->zMalloc, pMem->z, pMem->n); memcpy(pMem->zMalloc, pMem->z, pMem->n);
} }
if( pMem->flags&MEM_Dyn && pMem->xDel ){ if( (pMem->flags&MEM_Dyn)!=0 && pMem->xDel ){
assert( pMem->xDel!=SQLITE_DYNAMIC ); assert( pMem->xDel!=SQLITE_DYNAMIC );
pMem->xDel((void *)(pMem->z)); pMem->xDel((void *)(pMem->z));
} }
pMem->z = pMem->zMalloc; pMem->z = pMem->zMalloc;
if( pMem->z==0 ){ pMem->flags &= ~(MEM_Ephem|MEM_Static);
pMem->flags = MEM_Null;
}else{
pMem->flags &= ~(MEM_Ephem|MEM_Static);
}
pMem->xDel = 0; pMem->xDel = 0;
return (pMem->z ? SQLITE_OK : SQLITE_NOMEM); return SQLITE_OK;
} }
/* /*
@ -1221,7 +1219,7 @@ static void recordFunc(
}else{ }else{
aRet[0] = nSerial+1; aRet[0] = nSerial+1;
sqlite3PutVarint(&aRet[1], iSerial); sqlite3PutVarint(&aRet[1], iSerial);
sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], file_format); sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);
sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT); sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);
sqlite3DbFree(db, aRet); sqlite3DbFree(db, aRet);
} }

View File

@ -92,6 +92,7 @@ char *sqlite3VdbeExpandSql(
const char *zStart = zRawSql; const char *zStart = zRawSql;
while( *(zRawSql++)!='\n' && *zRawSql ); while( *(zRawSql++)!='\n' && *zRawSql );
sqlite3StrAccumAppend(&out, "-- ", 3); sqlite3StrAccumAppend(&out, "-- ", 3);
assert( (zRawSql - zStart) > 0 );
sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart)); sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
} }
}else{ }else{

View File

@ -268,4 +268,23 @@ do_test shell5-1.9 {
} {1 {} 11 | 2 x 22 | 3 {"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {"} | 8 88 hello | {} 9 99 | x 10 110 | {"} 11 121 | hello 12 132 |} } {1 {} 11 | 2 x 22 | 3 {"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {"} | 8 88 hello | {} 9 99 | x 10 110 | {"} 11 121 | hello 12 132 |}
db close db close
# Import columns containing quoted strings
do_test shell5-1.10 {
set out [open shell5.csv w]
fconfigure $out -translation lf
puts $out {column1,column2,column3,column4}
puts $out "field1,field2,\"x3 \"\"\r\ndata\"\" 3\",field4"
puts $out "x1,x2,\"x3 \"\"\ndata\"\" 3\",x4"
close $out
forcedelete test.db
catchcmd test.db {.mode csv
CREATE TABLE t1(a,b,c,d);
.import shell5.csv t1
}
sqlite3 db test.db
db eval {SELECT hex(c) FROM t1 ORDER BY rowid}
} {636F6C756D6E33 783320220D0A64617461222033 783320220A64617461222033}
db close
finish_test finish_test

View File

@ -13,7 +13,7 @@
# Script usage: # Script usage:
# #
# mv vdbe.c vdbe.c.template # mv vdbe.c vdbe.c.template
# tclsh vdbe-compress.tcl <vdbe.c.template >vdbe.c # tclsh vdbe-compress.tcl $CFLAGS <vdbe.c.template >vdbe.c
# #
# Modifications made: # Modifications made:
# #
@ -42,6 +42,16 @@ set unionDef {} ;# C code of the union
set afterUnion {} ;# C code after the union set afterUnion {} ;# C code after the union
set sCtr 0 ;# Context counter set sCtr 0 ;# Context counter
# If the SQLITE_SMALL_STACK compile-time option is missing, then
# this transformation becomes a no-op.
#
if {![regexp {SQLITE_SMALL_STACK} $argv]} {
while {![eof stdin]} {
puts [gets stdin]
}
exit
}
# Read program text up to the spot where the union should be # Read program text up to the spot where the union should be
# inserted. # inserted.
# #