Fix SUBSTR() so that it returns NULL if any argument is NULL.

Ticket #3626. (CVS 6228)

FossilOrigin-Name: 779fce82b7a89b972da488ce8bd35e23ca120c04
This commit is contained in:
drh
2009-02-01 19:42:37 +00:00
parent 4e79c59454
commit 8198d25442
4 changed files with 33 additions and 10 deletions
+6 -1
View File
@@ -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]);