New SQL function for testing/debugging use only: parseuri().

FossilOrigin-Name: 37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312
This commit is contained in:
drh 2024-10-06 15:01:31 +00:00
parent 2c72c55dca
commit 74672acd94
3 changed files with 95 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Back\sout\s[2f7eab381e16]\sbecause\sthe\sstderr\soutput\son\ssystems\swithout\sgmake\scauses\sgrief\sin\sthe\stesting\stools.
D 2024-10-05T21:44:21.913
C New\sSQL\sfunction\sfor\stesting/debugging\suse\sonly:\sparseuri().
D 2024-10-06T15:01:31.737
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -722,7 +722,7 @@ F src/delete.c 03a77ba20e54f0f42ebd8eddf15411ed6bdb06a2c472ac4b6b336521bf7cea42
F src/expr.c 6d5f2c38fe3ec06a7eac599dac822788b36064124e20112a844e9cd5156cb239
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 928ed2517e8732113d2b9821aa37af639688d752f4ea9ac6e0e393d713eeb76f
F src/func.c df400a1d3f4625997d4dd8a81951c303e066277c29b861d37e03cd152d7858dd
F src/func.c ed6baeeb414ef18ce729793587dae8bd30f11e6aacec8675bd33727e0bcb3765
F src/global.c a19e4b1ca1335f560e9560e590fc13081e21f670643367f99cb9e8f9dc7d615b
F src/hash.c 9ee4269fb1d6632a6fecfb9479c93a1f29271bddbbaf215dd60420bcb80c7220
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
@ -2215,8 +2215,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 2f7eab381e16760952d1c90a9119d2a217933f0136442d8f6eeb6d95e366ca4f
R 97cc1dd0446101afb82e95a43b8cd5d1
U stephan
Z 6431efa2a9010e78c1fbe7fa1b33270f
P cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135
R 6e07384677af3f3c36d6573a7730f2e0
T *branch * parseuri
T *sym-parseuri *
T -sym-trunk *
U drh
Z a932a90a1e85d41407c9c1eb7bdee53f
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
cc6f3de0320aceb0e9d81413fa4c021ad2b4ee1c72ecef13438d80c4d3701135
37d3b6b17e92b2c760239c3053bbc7fb85091acd688c54a73af7611fe9501312

View File

@ -2535,7 +2535,13 @@ static void signFunc(
** Implementation of fpdecode(x,y,z) function.
**
** x is a real number that is to be decoded. y is the precision.
** z is the maximum real precision.
** z is the maximum real precision. Return a string that shows the
** results of the sqlite3FpDecode() function.
**
** Used for testing and debugging only, specifically testing and debugging
** of the sqlite3FpDecode() function. This SQL function does not appear
** in production builds. This function is not an API and is subject to
** modification or removal in future versions of SQLite.
*/
static void fpdecodeFunc(
sqlite3_context *context,
@ -2562,6 +2568,82 @@ static void fpdecodeFunc(
}
#endif /* SQLITE_DEBUG */
#ifdef SQLITE_DEBUG
/*
** Implementation of parseuri(uri,flags) function.
**
** Required Arguments:
** "uri" The URI to parse.
** "flags" Bitmask of flags, as if to sqlite3_open_v2().
**
** Additional arguments beyond the first two make calls to
** sqlite3_uri_key() for integers and sqlite3_uri_parameter for
** anything else.
**
** The result is a string showing the results of calling sqlite3ParseUri().
**
** Used for testing and debugging only, specifically testing and debugging
** of the sqlite3ParseUri() function. This SQL function does not appear
** in production builds. This function is not an API and is subject to
** modification or removal in future versions of SQLite.
*/
static void parseuriFunc(
sqlite3_context *ctx,
int argc,
sqlite3_value **argv
){
sqlite3_str *pResult;
const char *zVfs;
const char *zUri;
unsigned int flgs;
int rc;
sqlite3_vfs *pVfs = 0;
char *zFile = 0;
char *zErr = 0;
if( argc<2 ) return;
pVfs = sqlite3_vfs_find(0);
assert( pVfs );
zVfs = pVfs->zName;
zUri = (const char*)sqlite3_value_text(argv[0]);
if( zUri==0 ) return;
flgs = (unsigned int)sqlite3_value_int(argv[1]);
rc = sqlite3ParseUri(zVfs, zUri, &flgs, &pVfs, &zFile, &zErr);
pResult = sqlite3_str_new(0);
if( pResult ){
int i;
sqlite3_str_appendf(pResult, "rc=%d", rc);
sqlite3_str_appendf(pResult, ", flags=0x%x", flgs);
sqlite3_str_appendf(pResult, ", vfs=%Q", pVfs ? pVfs->zName: 0);
sqlite3_str_appendf(pResult, ", err=%Q", zErr);
sqlite3_str_appendf(pResult, ", file=%Q", zFile);
if( zFile ){
const char *z = zFile;
z += sqlite3Strlen30(z)+1;
while( z[0] ){
sqlite3_str_appendf(pResult, ", %Q", z);
z += sqlite3Strlen30(z)+1;
}
for(i=2; i<argc; i++){
const char *zArg;
if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){
int k = sqlite3_value_int(argv[i]);
sqlite3_str_appendf(pResult, ", '%d:%q'",k,sqlite3_uri_key(zFile, k));
}else if( (zArg = (const char*)sqlite3_value_text(argv[i]))!=0 ){
sqlite3_str_appendf(pResult, ", '%q:%q'",
zArg, sqlite3_uri_parameter(zFile,zArg));
}else{
sqlite3_str_appendf(pResult, ", NULL");
}
}
}
sqlite3_result_text(ctx, sqlite3_str_finish(pResult), -1, sqlite3_free);
}
sqlite3_free_filename(zFile);
sqlite3_free(zErr);
}
#endif /* SQLITE_DEBUG */
/*
** All of the FuncDef structures in the aBuiltinFunc[] array above
** to the global function hash table. This occurs at start-time (as
@ -2635,6 +2717,7 @@ void sqlite3RegisterBuiltinFunctions(void){
FUNCTION(abs, 1, 0, 0, absFunc ),
#ifdef SQLITE_DEBUG
FUNCTION(fpdecode, 3, 0, 0, fpdecodeFunc ),
FUNCTION(parseuri, -1, 0, 0, parseuriFunc ),
#endif
#ifndef SQLITE_OMIT_FLOATING_POINT
FUNCTION(round, 1, 0, 0, roundFunc ),