1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-24 09:53:10 +03:00

Fix some compiler warnings. Add the (untested) zeroblob() SQL function. (CVS 3895)

FossilOrigin-Name: 6f4f8ba7ec15f214f36fa78e593dd4522ab717f5
This commit is contained in:
drh
2007-05-02 02:08:28 +00:00
parent b026e05eb2
commit 8cff382e7d
4 changed files with 28 additions and 12 deletions

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.143 2007/04/27 21:59:53 drh Exp $
** $Id: func.c,v 1.144 2007/05/02 02:08:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -682,6 +682,20 @@ static void hexFunc(
sqlite3_result_text(context, zHex, n*2, sqlite3_free);
}
/*
** The zeroblob(N) function returns a zero-filled blob of size N bytes.
*/
static void zeroblobFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
int n;
assert( argc==1 );
n = sqlite3_value_int(argv[0]);
sqlite3_result_zeroblob(context, n);
}
/*
** The replace() function. Three arguments are all strings: call
** them A, B, and C. The result is also a string which is derived
@@ -764,10 +778,10 @@ static void trimFunc(
if( zIn==0 ) return;
if( argc==1 ){
static const unsigned char lenOne[] = { 1 };
static const char *azOne[] = { " " };
static const unsigned char *azOne[] = { (u8*)" " };
nChar = 1;
aLen = (unsigned char*)lenOne;
azChar = (const unsigned char**)azOne;
aLen = (u8*)lenOne;
azChar = azOne;
zCharSet = 0;
}else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){
return;
@@ -1244,6 +1258,7 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
{ "rtrim", 2, 2, SQLITE_UTF8, 0, trimFunc },
{ "trim", 1, 3, SQLITE_UTF8, 0, trimFunc },
{ "trim", 2, 3, SQLITE_UTF8, 0, trimFunc },
{ "zeroblob", 1, 0, SQLITE_UTF8, 0, zeroblobFunc },
#ifdef SQLITE_SOUNDEX
{ "soundex", 1, 0, SQLITE_UTF8, 0, soundexFunc},
#endif