Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Modify the sqlite3VdbeMemCompare() routine so that it does not modify any Mem.z values. Ticket #3376. (CVS 5706) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2d4505510032bf903a9c5d582edda442 |
User & Date: | danielk1977 2008-09-16 12:06:08 |
References
2010-10-15
| ||
14:45 | Cherry-pick the change at [2d4505510032bf9] into the 3.6.1 branch. check-in: ecb1419e4b user: drh tags: branch-3.6.1 | |
Context
2008-09-16
| ||
14:38 | If the xAccess() call used by "PRAGMA temp_store_directory = /new/path/" to determine if the supplied directory is writable returns an error, assume the directory is not writable. (CVS 5707) check-in: e8418588f2 user: danielk1977 tags: trunk | |
12:06 | Modify the sqlite3VdbeMemCompare() routine so that it does not modify any Mem.z values. Ticket #3376. (CVS 5706) check-in: 2d45055100 user: danielk1977 tags: trunk | |
11:58 | Add test case for ticket #3376. (CVS 5705) check-in: c64260579d user: drh tags: trunk | |
Changes
Changes to src/vdbemem.c.
11 11 ************************************************************************* 12 12 ** 13 13 ** This file contains code use to manipulate "Mem" structure. A "Mem" 14 14 ** stores a single value in the VDBE. Mem is an opaque structure visible 15 15 ** only within the VDBE. Interface routines refer to a Mem using the 16 16 ** name sqlite_value 17 17 ** 18 -** $Id: vdbemem.c,v 1.122 2008/08/22 14:41:01 drh Exp $ 18 +** $Id: vdbemem.c,v 1.123 2008/09/16 12:06:08 danielk1977 Exp $ 19 19 */ 20 20 #include "sqliteInt.h" 21 21 #include <ctype.h> 22 22 #include "vdbeInt.h" 23 23 24 24 /* 25 25 ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*) ................................................................................ 734 734 735 735 if( pColl ){ 736 736 if( pMem1->enc==pColl->enc ){ 737 737 /* The strings are already in the correct encoding. Call the 738 738 ** comparison function directly */ 739 739 return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z); 740 740 }else{ 741 - u8 origEnc = pMem1->enc; 742 741 const void *v1, *v2; 743 742 int n1, n2; 744 - /* Convert the strings into the encoding that the comparison 745 - ** function expects */ 746 - v1 = sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc); 747 - n1 = v1==0 ? 0 : pMem1->n; 748 - assert( n1==sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc) ); 749 - v2 = sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc); 750 - n2 = v2==0 ? 0 : pMem2->n; 751 - assert( n2==sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc) ); 752 - /* Do the comparison */ 743 + Mem c1; 744 + Mem c2; 745 + memset(&c1, 0, sizeof(c1)); 746 + memset(&c2, 0, sizeof(c2)); 747 + sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem); 748 + sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem); 749 + v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc); 750 + n1 = v1==0 ? 0 : c1.n; 751 + v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc); 752 + n2 = v2==0 ? 0 : c2.n; 753 753 rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2); 754 - /* Convert the strings back into the database encoding */ 755 - sqlite3ValueText((sqlite3_value*)pMem1, origEnc); 756 - sqlite3ValueText((sqlite3_value*)pMem2, origEnc); 754 + sqlite3VdbeMemRelease(&c1); 755 + sqlite3VdbeMemRelease(&c2); 757 756 return rc; 758 757 } 759 758 } 760 759 /* If a NULL pointer was passed as the collate function, fall through 761 760 ** to the blob case and use memcmp(). */ 762 761 } 763 762