Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Set the MEM_Term flag when an internal string has a nul-terminator appended to it. Fix for #2213. (CVS 3627) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
fc969ad991e5114c3612f4796e342a6d |
User & Date: | danielk1977 2007-02-05 14:21:48.000 |
Context
2007-02-06
| ||
11:11 | Check the return value of lseek() in os_unix.c to make sure it really worked. (CVS 3628) (check-in: e4408dd1fd user: drh tags: trunk) | |
2007-02-05
| ||
14:21 | Set the MEM_Term flag when an internal string has a nul-terminator appended to it. Fix for #2213. (CVS 3627) (check-in: fc969ad991 user: danielk1977 tags: trunk) | |
2007-02-02
| ||
12:44 | Minor tweaks to collating sequences. We'll hold of making major changes until 3.4.0, since we'll likely end up with some minor technical imcompatibilities. (CVS 3626) (check-in: 9740aa95a3 user: drh tags: trunk) | |
Changes
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.228 2007/02/05 14:21:48 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
605 606 607 608 609 610 611 612 613 614 615 616 617 618 | memset(&x, 0, sizeof(x)); (void)sqlite3_exec((sqlite3*)sqlite3_user_data(context), (char*)sqlite3_value_text(argv[0]), execFuncCallback, &x, 0); sqlite3_result_text(context, x.z, x.nUsed, SQLITE_TRANSIENT); sqliteFree(x.z); } /* ** Usage: sqlite_test_create_function DB ** ** Call the sqlite3_create_function API on the given database in order ** to create a function named "x_coalesce". This function does the same thing ** as the "coalesce" function. This function also registers an SQL function | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | memset(&x, 0, sizeof(x)); (void)sqlite3_exec((sqlite3*)sqlite3_user_data(context), (char*)sqlite3_value_text(argv[0]), execFuncCallback, &x, 0); sqlite3_result_text(context, x.z, x.nUsed, SQLITE_TRANSIENT); sqliteFree(x.z); } /* ** Implementation of tkt2213func(), a scalar function that takes exactly ** one argument. It has two interesting features: ** ** * It calls sqlite3_value_text() 3 times on the argument sqlite3_value*. ** If the three pointers returned are not the same an SQL error is raised. ** ** * Otherwise it returns a copy of the text representation of it's ** argument in such a way as the VDBE representation is a Mem* cell ** with the MEM_Term flag clear. ** ** Ticket #2213 can therefore be tested by evaluating the following ** SQL expression: ** ** tkt2213func(tkt2213func('a string')); */ static void tkt2213Function( sqlite3_context *context, int argc, sqlite3_value **argv ){ int nText; unsigned char const *zText1; unsigned char const *zText2; unsigned char const *zText3; nText = sqlite3_value_bytes(argv[0]); zText1 = sqlite3_value_text(argv[0]); zText2 = sqlite3_value_text(argv[0]); zText3 = sqlite3_value_text(argv[0]); if( zText1!=zText2 || zText2!=zText3 ){ sqlite3_result_error(context, "tkt2213 is not fixed", -1); }else{ char *zCopy = (char *)sqlite3_malloc(nText); memcpy(zCopy, zText1, nText); sqlite3_result_text(context, zCopy, nText, sqlite3_free); } } /* ** Usage: sqlite_test_create_function DB ** ** Call the sqlite3_create_function API on the given database in order ** to create a function named "x_coalesce". This function does the same thing ** as the "coalesce" function. This function also registers an SQL function |
︙ | ︙ | |||
647 648 649 650 651 652 653 654 655 656 657 658 659 660 | rc = sqlite3_create_function(db, "hex8", 1, SQLITE_ANY, 0, hex8Func, 0, 0); } if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "hex16", 1, SQLITE_ANY, 0, hex16Func, 0, 0); } #ifndef SQLITE_OMIT_UTF16 /* Use the sqlite3_create_function16() API here. Mainly for fun, but also ** because it is not tested anywhere else. */ if( rc==SQLITE_OK ){ sqlite3_value *pVal; #ifdef SQLITE_MEMDEBUG | > > > > | 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | rc = sqlite3_create_function(db, "hex8", 1, SQLITE_ANY, 0, hex8Func, 0, 0); } if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "hex16", 1, SQLITE_ANY, 0, hex16Func, 0, 0); } if( rc==SQLITE_OK ){ rc = sqlite3_create_function(db, "tkt2213func", 1, SQLITE_ANY, 0, tkt2213Function, 0, 0); } #ifndef SQLITE_OMIT_UTF16 /* Use the sqlite3_create_function16() API here. Mainly for fun, but also ** because it is not tested anywhere else. */ if( rc==SQLITE_OK ){ sqlite3_value *pVal; #ifdef SQLITE_MEMDEBUG |
︙ | ︙ |
Changes to src/vdbemem.c.
︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | if( pMem->xDel ){ pMem->xDel(pMem->z); }else{ sqliteFree(pMem->z); } pMem->xDel = 0; pMem->z = z; } return SQLITE_OK; } /* ** Add MEM_Str to the set of representations for the given Mem. Numbers ** are converted using sqlite3_snprintf(). Converting a BLOB to a string | > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | if( pMem->xDel ){ pMem->xDel(pMem->z); }else{ sqliteFree(pMem->z); } pMem->xDel = 0; pMem->z = z; pMem->flags |= MEM_Term; } return SQLITE_OK; } /* ** Add MEM_Str to the set of representations for the given Mem. Numbers ** are converted using sqlite3_snprintf(). Converting a BLOB to a string |
︙ | ︙ |
Added test/tkt2213.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # 2007 Febuary 05 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests to verify that ticket #2213 has been # fixed. # # # $Id: tkt2213.test,v 1.1 2007/02/05 14:21:48 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test tkt2213-1 { sqlite3_create_function db catchsql { SELECT tkt2213func(tkt2213func('abcd')); } } {0 abcd} finish_test |