Compare commits

...

2 Commits

Author SHA1 Message Date
mistachkin 823329b88c Harmonize function names.
FossilOrigin-Name: db43d7aa5db218f804b2a2d2a2a9150cf9c8c64e1e6a04c53b5943e23dc3fde4
2024-06-05 20:54:40 +00:00
mistachkin da58172758 Add an experimental concatb() function.
FossilOrigin-Name: 07d8420285a49867b9c34f9e344eb666448dd9ce85c7791fa9480d98458684d9
2024-06-05 20:52:50 +00:00
4 changed files with 73 additions and 28 deletions
+7 -7
View File
@@ -1,5 +1,5 @@
C Fix\sharmless\scompilation\sissues\sseen\swith\sMSVC.
D 2024-06-05T20:50:39.523
C Harmonize\sfunction\snames.
D 2024-06-05T20:54:40.597
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -708,7 +708,7 @@ F src/delete.c cb766727c78e715f9fb7ec8a7d03658ed2a3016343ca687acfcec9083cdca500
F src/expr.c 585109ab97149b2d484697e7469f28c91d495cd1330cc760d24711b7be8d22fb
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 852f93c0ef995e0c2b8983059a2b97151c194cc8259e21f5bc2b7ac508348c2a
F src/func.c f1f57c6863c1380f31ecf3d61732495bfff847a8e35a832c7e306e310db5a799
F src/func.c 4daef1c773c7dc55a974dc8d54b9d433a6efe1c0d8ad8594430b15a7d6ddc2df
F src/global.c 61a419dd9e993b9be0f91de4c4ccf322b053eb829868e089f0321dd669be3b90
F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
@@ -1237,7 +1237,7 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75
F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9
F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d
F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
F test/func.test b56905748ce0567c01d60005f3e6ad1af19453d224ba4730ee687d048fd09ef9
F test/func.test 8e18545298489aadc95ee653e2aff1e4a98ebe119d356a52b83f8d528a7ea72c
F test/func2.test 69f6ae3751b4ec765bdc3b803c0a255aa0f693f28f44805bef03e6b4a3fd242f
F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a
F test/func4.test a3f9062487dbd826776f54f4e0e9517fe8c3cf689af92735308965774d51fac5
@@ -2194,8 +2194,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 8080c6eafd1280ea870a6ab1ba715ac5af67387e69771be6cbd46dda77c3eaa8
R b1d29e4b163a20c9d9aadcb22bf1cdb9
P 07d8420285a49867b9c34f9e344eb666448dd9ce85c7791fa9480d98458684d9
R e26286215208735e6e38d174733a8a9f
U mistachkin
Z 0cf3ec6bb41ed4737c063035dfa47552
Z 523d5e338790c61751ca83e3ee126827
# Remove this line to create a well-formed Fossil manifest.
+1 -1
View File
@@ -1 +1 @@
816d4749384c7f398912c905a16c83b88f4c55632050b4c6117c61301d1a53e1
db43d7aa5db218f804b2a2d2a2a9150cf9c8c64e1e6a04c53b5943e23dc3fde4
+55 -20
View File
@@ -1551,18 +1551,19 @@ static void trimFunc(
sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
}
/* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...)
** functions.
/* The core implementation of the CONCAT(...), CONCATB(...), and
** CONCAT_WS(SEP,...) functions.
**
** Return a string value that is the concatenation of all non-null
** entries in argv[]. Use zSep as the separator.
** Return a string or blob value that is the concatenation of all
** non-null entries in argv[]. Use zSep as the separator.
*/
static void concatFuncCore(
sqlite3_context *context,
int argc,
sqlite3_value **argv,
int nSep,
const char *zSep
const char *zSep,
int bBlob
){
i64 j, k, n = 0;
int i;
@@ -1577,35 +1578,68 @@ static void concatFuncCore(
return;
}
j = 0;
for(i=0; i<argc; i++){
k = sqlite3_value_bytes(argv[i]);
if( k>0 ){
const char *v = (const char*)sqlite3_value_text(argv[i]);
if( v!=0 ){
if( j>0 && nSep>0 ){
memcpy(&z[j], zSep, nSep);
j += nSep;
if( bBlob ){
for(i=0; i<argc; i++){
k = sqlite3_value_bytes(argv[i]);
if( k>0 ){
const char *v = (const char*)sqlite3_value_blob(argv[i]);
if( v!=0 ){
if( j>0 && nSep>0 ){
memcpy(&z[j], zSep, nSep);
j += nSep;
}
memcpy(&z[j], v, k);
j += k;
}
}
}
}else{
for(i=0; i<argc; i++){
k = sqlite3_value_bytes(argv[i]);
if( k>0 ){
const char *v = (const char*)sqlite3_value_text(argv[i]);
if( v!=0 ){
if( j>0 && nSep>0 ){
memcpy(&z[j], zSep, nSep);
j += nSep;
}
memcpy(&z[j], v, k);
j += k;
}
memcpy(&z[j], v, k);
j += k;
}
}
}
z[j] = 0;
assert( j<=n );
sqlite3_result_text64(context, z, j, sqlite3_free, SQLITE_UTF8);
if( bBlob ){
sqlite3_result_blob64(context, z, j, sqlite3_free);
}else{
sqlite3_result_text64(context, z, j, sqlite3_free, SQLITE_UTF8);
}
}
/*
** The CONCAT(...) function. Generate a string result that is the
** concatentation of all non-null arguments.
*/
static void concatFunc(
static void concatTextFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
concatFuncCore(context, argc, argv, 0, "");
concatFuncCore(context, argc, argv, 0, "", 0);
}
/*
** The CONCATB(...) function. Generate a blob result that is the
** concatentation of all non-null arguments.
*/
static void concatBlobFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
concatFuncCore(context, argc, argv, 0, "", 1);
}
/*
@@ -1623,7 +1657,7 @@ static void concatwsFunc(
int nSep = sqlite3_value_bytes(argv[0]);
const char *zSep = (const char*)sqlite3_value_text(argv[0]);
if( zSep==0 ) return;
concatFuncCore(context, argc-1, argv+1, nSep, zSep);
concatFuncCore(context, argc-1, argv+1, nSep, zSep, 0);
}
@@ -2640,7 +2674,8 @@ void sqlite3RegisterBuiltinFunctions(void){
FUNCTION(hex, 1, 0, 0, hexFunc ),
FUNCTION(unhex, 1, 0, 0, unhexFunc ),
FUNCTION(unhex, 2, 0, 0, unhexFunc ),
FUNCTION(concat, -1, 0, 0, concatFunc ),
FUNCTION(concat, -1, 0, 0, concatTextFunc ),
FUNCTION(concatb, -1, 1, 0, concatBlobFunc ),
FUNCTION(concat, 0, 0, 0, 0 ),
FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ),
FUNCTION(concat_ws, 0, 0, 0, 0 ),
+10
View File
@@ -1582,4 +1582,14 @@ for {set i 2} {$i<10} {incr i} {
} {Inf Inf Inf}
}
# Tests for the CONCATB function.
#
do_execsql_test func-40.1 {
SELECT typeof(concatb(NULL, '1', X'ABCD', 'test'));
} {blob}
do_execsql_test func-40.2 {
SELECT hex(concatb(NULL, '1', X'ABCD', 'test'));
} {31ABCD74657374}
finish_test