1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-25 20:58:26 +03:00

Change the replace() function to return a copy of its first argument when

the 2nd argument is an empty string.  Ticket #3624. (CVS 6226)

FossilOrigin-Name: ffebf10f6fb2c7f3083992e2c712682b4cdcc6f0
This commit is contained in:
drh
2009-02-01 18:08:40 +00:00
parent 9437bd2945
commit a605fe8d8b
4 changed files with 21 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
C Adjust\scomments\sin\svdbe.c\sto\suse\sOP_MakeRecord\sinstead\sof\sthe\sobsolete\nOP_MakeIdxRec.\s\sTicket\s#3619.\s(CVS\s6225) C Change\sthe\sreplace()\sfunction\sto\sreturn\sa\scopy\sof\sits\sfirst\sargument\swhen\nthe\s2nd\sargument\sis\san\sempty\sstring.\s\sTicket\s#3624.\s(CVS\s6226)
D 2009-02-01T00:29:57 D 2009-02-01T18:08:41
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52 F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -113,7 +113,7 @@ F src/date.c 870770dde3fb56772ab247dfb6a6eda44d16cfbc
F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc
F src/expr.c 76dc3dc83b56ab8db50a772714fac49def8bbf12 F src/expr.c 76dc3dc83b56ab8db50a772714fac49def8bbf12
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
F src/func.c 51b41e10d41cdf4d0a6072f2eba16ed96ebda7cc F src/func.c 8ead6d9a505fcb00817516060c2ebcd47665c720
F src/global.c ab003581ea4ff193cfe17a00e1303bc51db619a5 F src/global.c ab003581ea4ff193cfe17a00e1303bc51db619a5
F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55 F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55
F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
@@ -371,7 +371,7 @@ F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
F test/fts3expr.test 000f05df771e203187ceac49ad21c303c720b783 F test/fts3expr.test 000f05df771e203187ceac49ad21c303c720b783
F test/fts3expr2.test 8501de895a4c0631e7226c9bac055cd49c9f6646 F test/fts3expr2.test 8501de895a4c0631e7226c9bac055cd49c9f6646
F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077 F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
F test/func.test e361349bcae8c51976f1826fd7d6355e483cf9b8 F test/func.test c98d620d6ecd10957896960da334540542a240fe
F test/fuzz.test 8bad3b9b09bad47c50f3433f9598707a70247ce1 F test/fuzz.test 8bad3b9b09bad47c50f3433f9598707a70247ce1
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5 F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
@@ -693,7 +693,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 3ba1a17b1306bc61b9861ec8d3b239e16a3081ba P 0d2abbbff5d9e12e2382ed201bf1648c5918c1c0
R 90eddc956187936681160cacf59e095a R 87a8317c9de06e2182db29db65f9d562
U drh U drh
Z 8c709cf1d1e6f4628aafbad8fe6d0390 Z 69ffdf34dd35b084b6e374302eafe7c5

View File

@@ -1 +1 @@
0d2abbbff5d9e12e2382ed201bf1648c5918c1c0 ffebf10f6fb2c7f3083992e2c712682b4cdcc6f0

View File

@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope. ** All other code has file scope.
** **
** $Id: func.c,v 1.211 2009/01/24 11:30:43 drh Exp $ ** $Id: func.c,v 1.212 2009/02/01 18:08:41 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <stdlib.h> #include <stdlib.h>
@@ -820,7 +820,15 @@ static void replaceFunc(
nStr = sqlite3_value_bytes(argv[0]); nStr = sqlite3_value_bytes(argv[0]);
assert( zStr==sqlite3_value_text(argv[0]) ); /* No encoding change */ assert( zStr==sqlite3_value_text(argv[0]) ); /* No encoding change */
zPattern = sqlite3_value_text(argv[1]); zPattern = sqlite3_value_text(argv[1]);
if( zPattern==0 || zPattern[0]==0 ) return; if( zPattern==0 ){
assert( sqlite3_value_type(argv[1])==SQLITE_NULL );
return;
}
if( zPattern[0]==0 ){
assert( sqlite3_value_type(argv[1])!=SQLITE_NULL );
sqlite3_result_value(context, argv[0]);
return;
}
nPattern = sqlite3_value_bytes(argv[1]); nPattern = sqlite3_value_bytes(argv[1]);
assert( zPattern==sqlite3_value_text(argv[1]) ); /* No encoding change */ assert( zPattern==sqlite3_value_text(argv[1]) ); /* No encoding change */
zRep = sqlite3_value_text(argv[2]); zRep = sqlite3_value_text(argv[2]);

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing built-in functions. # focus of this file is testing built-in functions.
# #
# $Id: func.test,v 1.88 2009/01/31 22:28:49 drh Exp $ # $Id: func.test,v 1.89 2009/02/01 18:08:41 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -362,7 +362,7 @@ if {$encoding=="UTF-16le"} {
} {6100620063006400310032006700} } {6100620063006400310032006700}
do_test func-9.12-utf16le { do_test func-9.12-utf16le {
execsql {SELECT hex(replace('abcdefg','','12'))} execsql {SELECT hex(replace('abcdefg','','12'))}
} {{}} } {6100620063006400650066006700}
do_test func-9.13-utf16le { do_test func-9.13-utf16le {
execsql {SELECT hex(replace('aabcdefg','a','aaa'))} execsql {SELECT hex(replace('aabcdefg','a','aaa'))}
} {610061006100610061006100620063006400650066006700} } {610061006100610061006100620063006400650066006700}
@@ -372,7 +372,7 @@ if {$encoding=="UTF-16le"} {
} {61626364313267} } {61626364313267}
do_test func-9.12-utf8 { do_test func-9.12-utf8 {
execsql {SELECT hex(replace('abcdefg','','12'))} execsql {SELECT hex(replace('abcdefg','','12'))}
} {{}} } {61626364656667}
do_test func-9.13-utf8 { do_test func-9.13-utf8 {
execsql {SELECT hex(replace('aabcdefg','a','aaa'))} execsql {SELECT hex(replace('aabcdefg','a','aaa'))}
} {616161616161626364656667} } {616161616161626364656667}