Fix SUBSTR() so that it returns NULL if any argument is NULL.
Ticket #3626. (CVS 6228) FossilOrigin-Name: 779fce82b7a89b972da488ce8bd35e23ca120c04
This commit is contained in:
parent
4e79c59454
commit
8198d25442
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sthe\sSUBSTR()\sfunction\sso\sthat\swhen\sthe\s3rd\sargument\sis\snegative,\nit\scounts\sbackwards\sfrom\sthe\sselected\sstart\spoint.\s\sTicket\s#3625.\s(CVS\s6227)
|
||||
D 2009-02-01T19:23:32
|
||||
C Fix\sSUBSTR()\sso\sthat\sit\sreturns\sNULL\sif\sany\sargument\sis\sNULL.\nTicket\s#3626.\s(CVS\s6228)
|
||||
D 2009-02-01T19:42:38
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -113,7 +113,7 @@ F src/date.c 870770dde3fb56772ab247dfb6a6eda44d16cfbc
|
||||
F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc
|
||||
F src/expr.c 76dc3dc83b56ab8db50a772714fac49def8bbf12
|
||||
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
||||
F src/func.c 5a9abbe0c9a39cacf10d2f554994d04ada7cfd97
|
||||
F src/func.c 910be7d21b6fa78328504fffc7daf7a09c385b8d
|
||||
F src/global.c ab003581ea4ff193cfe17a00e1303bc51db619a5
|
||||
F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55
|
||||
F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
|
||||
@ -538,7 +538,7 @@ F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
|
||||
F test/sqllimits1.test 2f7ca3c7e7cef39a9c499e941e98b7f1708c4780
|
||||
F test/subquery.test b524f57c9574b2c0347045b4510ef795d4686796
|
||||
F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4
|
||||
F test/substr.test ab7e08b417c7ecf4ad4d6971b7a307738566dbab
|
||||
F test/substr.test d08879fe398c4d2d332cbf8f5a112861635e3278
|
||||
F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3
|
||||
F test/table.test 0aac9468b69d2683e68ee2682cdae28d82a453ec
|
||||
F test/tableapi.test 505031f15b18a750184d967d2c896cf88fcc969c
|
||||
@ -693,7 +693,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P ffebf10f6fb2c7f3083992e2c712682b4cdcc6f0
|
||||
R d0d1ee83ba6397bbefb0b7fb547d0a98
|
||||
P 2217339badf1e84edbed1309c39b9f8dfd7646ff
|
||||
R 0730f756ab24d1612ff83af32750a0c7
|
||||
U drh
|
||||
Z dfb41a03d301c769a684a42ff2c19839
|
||||
Z 8488f2bfd0bfcec2e393ed58aeee481e
|
||||
|
@ -1 +1 @@
|
||||
2217339badf1e84edbed1309c39b9f8dfd7646ff
|
||||
779fce82b7a89b972da488ce8bd35e23ca120c04
|
@ -16,7 +16,7 @@
|
||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||
** All other code has file scope.
|
||||
**
|
||||
** $Id: func.c,v 1.213 2009/02/01 19:23:32 drh Exp $
|
||||
** $Id: func.c,v 1.214 2009/02/01 19:42:38 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdlib.h>
|
||||
@ -171,6 +171,11 @@ static void substrFunc(
|
||||
i64 p1, p2;
|
||||
|
||||
assert( argc==3 || argc==2 );
|
||||
if( sqlite3_value_type(argv[1])==SQLITE_NULL
|
||||
|| (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)
|
||||
){
|
||||
return;
|
||||
}
|
||||
p0type = sqlite3_value_type(argv[0]);
|
||||
if( p0type==SQLITE_BLOB ){
|
||||
len = sqlite3_value_bytes(argv[0]);
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the built-in SUBSTR() functions.
|
||||
#
|
||||
# $Id: substr.test,v 1.4 2009/02/01 19:23:32 drh Exp $
|
||||
# $Id: substr.test,v 1.5 2009/02/01 19:42:38 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -79,6 +79,24 @@ substr-test 1.14 abcdefg -5 -1 b
|
||||
substr-test 1.15 abcdefg -5 -2 ab
|
||||
substr-test 1.16 abcdefg -5 -3 ab
|
||||
|
||||
# Make sure NULL is returned if any parameter is NULL
|
||||
#
|
||||
do_test substr-1.90 {
|
||||
db eval {SELECT ifnull(substr(NULL,1,1),'nil')}
|
||||
} nil
|
||||
do_test substr-1.91 {
|
||||
db eval {SELECT ifnull(substr(NULL,1),'nil')}
|
||||
} nil
|
||||
do_test substr-1.92 {
|
||||
db eval {SELECT ifnull(substr('abcdefg',NULL,1),'nil')}
|
||||
} nil
|
||||
do_test substr-1.93 {
|
||||
db eval {SELECT ifnull(substr('abcdefg',NULL),'nil')}
|
||||
} nil
|
||||
do_test substr-1.94 {
|
||||
db eval {SELECT ifnull(substr('abcdefg',1,NULL),'nil')}
|
||||
} nil
|
||||
|
||||
# Make sure everything works with long unicode characters
|
||||
#
|
||||
substr-test 2.1 \u1234\u2345\u3456 1 1 \u1234
|
||||
|
Loading…
Reference in New Issue
Block a user