Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change the replace() function to return a copy of its first argument when the 2nd argument is an empty string. Ticket #3624. (CVS 6226) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ffebf10f6fb2c7f3083992e2c712682b |
User & Date: | drh 2009-02-01 18:08:41 |
Context
2009-02-01
| ||
19:23 | Fix the SUBSTR() function so that when the 3rd argument is negative, it counts backwards from the selected start point. Ticket #3625. (CVS 6227) check-in: 2217339b user: drh tags: trunk | |
18:08 | Change the replace() function to return a copy of its first argument when the 2nd argument is an empty string. Ticket #3624. (CVS 6226) check-in: ffebf10f user: drh tags: trunk | |
00:29 | Adjust comments in vdbe.c to use OP_MakeRecord instead of the obsolete OP_MakeIdxRec. Ticket #3619. (CVS 6225) check-in: 0d2abbbf user: drh tags: trunk | |
Changes
Changes to src/func.c.
12 12 ** This file contains the C functions that implement various SQL 13 13 ** functions of SQLite. 14 14 ** 15 15 ** There is only one exported symbol in this file - the function 16 16 ** sqliteRegisterBuildinFunctions() found at the bottom of the file. 17 17 ** All other code has file scope. 18 18 ** 19 -** $Id: func.c,v 1.211 2009/01/24 11:30:43 drh Exp $ 19 +** $Id: func.c,v 1.212 2009/02/01 18:08:41 drh Exp $ 20 20 */ 21 21 #include "sqliteInt.h" 22 22 #include <stdlib.h> 23 23 #include <assert.h> 24 24 #include "vdbeInt.h" 25 25 26 26 /* ................................................................................ 816 816 assert( argc==3 ); 817 817 UNUSED_PARAMETER(argc); 818 818 zStr = sqlite3_value_text(argv[0]); 819 819 if( zStr==0 ) return; 820 820 nStr = sqlite3_value_bytes(argv[0]); 821 821 assert( zStr==sqlite3_value_text(argv[0]) ); /* No encoding change */ 822 822 zPattern = sqlite3_value_text(argv[1]); 823 - if( zPattern==0 || zPattern[0]==0 ) return; 823 + if( zPattern==0 ){ 824 + assert( sqlite3_value_type(argv[1])==SQLITE_NULL ); 825 + return; 826 + } 827 + if( zPattern[0]==0 ){ 828 + assert( sqlite3_value_type(argv[1])!=SQLITE_NULL ); 829 + sqlite3_result_value(context, argv[0]); 830 + return; 831 + } 824 832 nPattern = sqlite3_value_bytes(argv[1]); 825 833 assert( zPattern==sqlite3_value_text(argv[1]) ); /* No encoding change */ 826 834 zRep = sqlite3_value_text(argv[2]); 827 835 if( zRep==0 ) return; 828 836 nRep = sqlite3_value_bytes(argv[2]); 829 837 assert( zRep==sqlite3_value_text(argv[2]) ); 830 838 nOut = nStr + 1;
Changes to test/func.test.
7 7 # May you find forgiveness for yourself and forgive others. 8 8 # May you share freely, never taking more than you give. 9 9 # 10 10 #*********************************************************************** 11 11 # This file implements regression tests for SQLite library. The 12 12 # focus of this file is testing built-in functions. 13 13 # 14 -# $Id: func.test,v 1.88 2009/01/31 22:28:49 drh Exp $ 14 +# $Id: func.test,v 1.89 2009/02/01 18:08:41 drh Exp $ 15 15 16 16 set testdir [file dirname $argv0] 17 17 source $testdir/tester.tcl 18 18 19 19 # Create a table to work with. 20 20 # 21 21 do_test func-0.0 { ................................................................................ 358 358 set encoding [db one {PRAGMA encoding}] 359 359 if {$encoding=="UTF-16le"} { 360 360 do_test func-9.11-utf16le { 361 361 execsql {SELECT hex(replace('abcdefg','ef','12'))} 362 362 } {6100620063006400310032006700} 363 363 do_test func-9.12-utf16le { 364 364 execsql {SELECT hex(replace('abcdefg','','12'))} 365 - } {{}} 365 + } {6100620063006400650066006700} 366 366 do_test func-9.13-utf16le { 367 367 execsql {SELECT hex(replace('aabcdefg','a','aaa'))} 368 368 } {610061006100610061006100620063006400650066006700} 369 369 } elseif {$encoding=="UTF-8"} { 370 370 do_test func-9.11-utf8 { 371 371 execsql {SELECT hex(replace('abcdefg','ef','12'))} 372 372 } {61626364313267} 373 373 do_test func-9.12-utf8 { 374 374 execsql {SELECT hex(replace('abcdefg','','12'))} 375 - } {{}} 375 + } {61626364656667} 376 376 do_test func-9.13-utf8 { 377 377 execsql {SELECT hex(replace('aabcdefg','a','aaa'))} 378 378 } {616161616161626364656667} 379 379 } 380 380 381 381 # Use the "sqlite_register_test_function" TCL command which is part of 382 382 # the text fixture in order to verify correct operation of some of