Add the experimental "quote()" function to the set of build-in functions. (CVS 1077)
FossilOrigin-Name: 9699c68508db5da6238904e518835a629d430db6
This commit is contained in:
parent
5d9d757626
commit
4739470341
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sthe\s"onecolumn"\smethod\sto\sthe\sTCL\slanguage\sbindings.\s(CVS\s1076)
|
||||
D 2003-08-19T14:31:01
|
||||
C Add\sthe\sexperimental\s"quote()"\sfunction\sto\sthe\sset\sof\sbuild-in\sfunctions.\s(CVS\s1077)
|
||||
D 2003-08-20T01:03:34
|
||||
F Makefile.in 9ad23ed4ca97f9670c4496432e3fbd4b3760ebde
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -29,7 +29,7 @@ F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73
|
||||
F src/delete.c 0f81e6799c089487615d38e042a2de4d2d6192bc
|
||||
F src/encode.c 25ea901a9cefb3d93774afa4a06b57cb58acf544
|
||||
F src/expr.c 03c321ac66c1e998c2e0faf22184b5a808b559ca
|
||||
F src/func.c 2b196fdca328838c0c02f290ec833d05d63d7a32
|
||||
F src/func.c 8cd63ca63d0f5115c371ee3888bcc94ed7200c1d
|
||||
F src/hash.c 058f077c1f36f266581aa16f907a3903abf64aa3
|
||||
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
|
||||
F src/insert.c dc200ae04a36bd36e575272a069e20c528b7fbdf
|
||||
@ -168,7 +168,7 @@ F www/speed.tcl 2f6b1155b99d39adb185f900456d1d592c4832b3
|
||||
F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
P 7d8d3252df1e9f6bec5e105b6eca3313cb7e226a
|
||||
R d1a2b335d94bf870fe28343e60ff8361
|
||||
P c7b4c28fbc0bca5645af5750fd353f4eca400b40
|
||||
R f0e36a3323c0eee33584e7783fcb7726
|
||||
U drh
|
||||
Z 3a0f7413336c1c88c47d903a1a6bf2bc
|
||||
Z 2c287b9d3454cd33d4083df643e4ab27
|
||||
|
@ -1 +1 @@
|
||||
c7b4c28fbc0bca5645af5750fd353f4eca400b40
|
||||
9699c68508db5da6238904e518835a629d430db6
|
40
src/func.c
40
src/func.c
@ -16,7 +16,7 @@
|
||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||
** All other code has file scope.
|
||||
**
|
||||
** $Id: func.c,v 1.28 2003/08/10 01:50:55 drh Exp $
|
||||
** $Id: func.c,v 1.29 2003/08/20 01:03:34 drh Exp $
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
@ -256,6 +256,43 @@ static void versionFunc(sqlite_func *context, int argc, const char **argv){
|
||||
sqlite_set_result_string(context, sqlite_version, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
** EXPERIMENTAL - This is not an official function. The interface may
|
||||
** change. This function may disappear. Do not write code that depends
|
||||
** on this function.
|
||||
**
|
||||
** Implementation of the QUOTE() function. This function takes a single
|
||||
** argument. If the argument is numeric, the return value is the same as
|
||||
** the argument. If the argument is NULL, the return value is the string
|
||||
** "NULL". Otherwise, the argument is enclosed in single quotes with
|
||||
** single-quote escapes.
|
||||
*/
|
||||
static void quoteFunc(sqlite_func *context, int argc, const char **argv){
|
||||
if( argc<1 ) return;
|
||||
if( argv[0]==0 ){
|
||||
sqlite_set_result_string(context, "NULL", 4);
|
||||
}else if( sqliteIsNumber(argv[0]) ){
|
||||
sqlite_set_result_string(context, argv[0], -1);
|
||||
}else{
|
||||
int i,j,n;
|
||||
char *z;
|
||||
for(i=n=0; argv[0][i]; i++){ if( argv[0][i]=='\'' ) n++; }
|
||||
z = sqliteMalloc( i+n+3 );
|
||||
if( z==0 ) return;
|
||||
z[0] = '\'';
|
||||
for(i=0, j=1; argv[0][i]; i++){
|
||||
z[j++] = argv[0][i];
|
||||
if( argv[0][i]=='\'' ){
|
||||
z[j++] = '\'';
|
||||
}
|
||||
}
|
||||
z[j++] = '\'';
|
||||
z[j] = 0;
|
||||
sqlite_set_result_string(context, z, j);
|
||||
sqliteFree(z);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SQLITE_SOUNDEX
|
||||
/*
|
||||
** Compute the soundex encoding of a word.
|
||||
@ -830,6 +867,7 @@ void sqliteRegisterBuiltinFunctions(sqlite *db){
|
||||
{ "glob", 2, SQLITE_NUMERIC, globFunc },
|
||||
{ "nullif", 2, SQLITE_ARGS, nullifFunc },
|
||||
{ "sqlite_version",0,SQLITE_TEXT, versionFunc},
|
||||
{ "quote", 1, SQLITE_ARGS, quoteFunc },
|
||||
#ifndef SQLITE_OMIT_DATETIME_FUNCS
|
||||
{ "julianday", -1, SQLITE_NUMERIC, juliandayFunc },
|
||||
{ "timestamp", -1, SQLITE_TEXT, timestampFunc },
|
||||
|
Loading…
x
Reference in New Issue
Block a user