From: danielk1977 Date: Tue, 16 Sep 2008 12:06:08 +0000 (+0000) Subject: Modify the sqlite3VdbeMemCompare() routine so that it does not modify any Mem.z value... X-Git-Tag: version-3.6.10~471 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7eae4f52ee653b25c9fbcc5edb48dc4405a00497;p=thirdparty%2Fsqlite.git Modify the sqlite3VdbeMemCompare() routine so that it does not modify any Mem.z values. Ticket #3376. (CVS 5706) FossilOrigin-Name: 2d4505510032bf903a9c5d582edda442a0592c77 --- diff --git a/manifest b/manifest index 6a8ad4672c..bc0d6fedb4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scase\sfor\sticket\s#3376.\s(CVS\s5705) -D 2008-09-16T11:58:20 +C Modify\sthe\ssqlite3VdbeMemCompare()\sroutine\sso\sthat\sit\sdoes\snot\smodify\sany\sMem.z\svalues.\sTicket\s#3376.\s(CVS\s5706) +D 2008-09-16T12:06:08 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in d15a7ebfe5e057a72a49805ffb302dbb601c8329 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -196,7 +196,7 @@ F src/vdbeapi.c c0f87aabb2bcf8c760ff9cb289119f7f6ba1797a F src/vdbeaux.c e1198d1ea2e129bd56863794a223da670e1359c7 F src/vdbeblob.c f93110888ddc246215e9ba1f831d3d375bfd8355 F src/vdbefifo.c 20fda2a7c4c0bcee1b90eb7e545fefcdbf2e1de7 -F src/vdbemem.c 51538ff193e1fcd462123ccef65323ccd2cc030c +F src/vdbemem.c ead88713b852576e2a924bc4ae696964bfbaec0a F src/vtab.c 527c180e9c5fca417c9167d02af4b5039f892b4b F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d F src/where.c a9958b26cc87ea1446fbe6d004a7959b8d5d75c1 @@ -636,7 +636,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 5dff20f4bc8d98017e76d3a771ab49310bddda63 -R bbe3c956b65ecfe3fc9d4f701a790ef2 -U drh -Z 010c83f95916a850b415d2bd020d7b81 +P c64260579d353df3eae8c355b082b8206bc6185b +R 7535949cc5ece243cee76f2451e698a1 +U danielk1977 +Z f8c645f05684cc478b17c2db72cd6df0 diff --git a/manifest.uuid b/manifest.uuid index c1fbbe6222..b133435f40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c64260579d353df3eae8c355b082b8206bc6185b \ No newline at end of file +2d4505510032bf903a9c5d582edda442a0592c77 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 1bf8aa0c69..6db624a43b 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -15,7 +15,7 @@ ** only within the VDBE. Interface routines refer to a Mem using the ** name sqlite_value ** -** $Id: vdbemem.c,v 1.122 2008/08/22 14:41:01 drh Exp $ +** $Id: vdbemem.c,v 1.123 2008/09/16 12:06:08 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -738,22 +738,21 @@ int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){ ** comparison function directly */ return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z); }else{ - u8 origEnc = pMem1->enc; const void *v1, *v2; int n1, n2; - /* Convert the strings into the encoding that the comparison - ** function expects */ - v1 = sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc); - n1 = v1==0 ? 0 : pMem1->n; - assert( n1==sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc) ); - v2 = sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc); - n2 = v2==0 ? 0 : pMem2->n; - assert( n2==sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc) ); - /* Do the comparison */ + Mem c1; + Mem c2; + memset(&c1, 0, sizeof(c1)); + memset(&c2, 0, sizeof(c2)); + sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem); + sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem); + v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc); + n1 = v1==0 ? 0 : c1.n; + v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc); + n2 = v2==0 ? 0 : c2.n; rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2); - /* Convert the strings back into the database encoding */ - sqlite3ValueText((sqlite3_value*)pMem1, origEnc); - sqlite3ValueText((sqlite3_value*)pMem2, origEnc); + sqlite3VdbeMemRelease(&c1); + sqlite3VdbeMemRelease(&c2); return rc; } }