CLI enhancements to facilitate SQLite core testing:
(1) Add built-in functions strtod() and dtostr() that convert text to floating point and back using C-library routines. (2) Do not disable all of ".testctrl" without --unsafe-testing, but only those subcommands of .testctrl that are actually dangerous. FossilOrigin-Name: 669996a8ddcbf35f3de66cf466508fc1e6dd09ab269aba395ac86a11b2ec238c
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
C Enhance\sthe\sSUM()\saggregate\s(and\srelated\sAVG()\sand\sTOTAL())\sso\sthat\sthe\srunning\nsum\sis\saccurate\sto\sabout\s100\sbits.
|
||||
D 2023-06-28T12:02:48.388
|
||||
C CLI\senhancements\sto\sfacilitate\sSQLite\score\stesting:\n(1)\sAdd\sbuilt-in\sfunctions\sstrtod()\sand\sdtostr()\sthat\sconvert\stext\sto\nfloating\spoint\sand\sback\susing\sC-library\sroutines.\n(2)\sDo\snot\sdisable\sall\sof\s".testctrl"\swithout\s--unsafe-testing,\sbut\sonly\nthose\ssubcommands\sof\s.testctrl\sthat\sare\sactually\sdangerous.
|
||||
D 2023-06-29T12:14:10.203
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -638,7 +638,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
|
||||
F src/resolve.c 37953a5f36c60bea413c3c04efcd433b6177009f508ef2ace0494728912fe2e9
|
||||
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
||||
F src/select.c 383b9dba12493c365ee2036bcadd73013b7c0f7d2afcda0c378317c335d60ac2
|
||||
F src/shell.c.in 5f07ea7ca4262872fcf07ce623a0be7c003f11834b80501874f039319aaf61b6
|
||||
F src/shell.c.in 10e9f46b1a9c335ba8fdb31f449ca562ac69c7edc667bd5483aba7a399d0ff51
|
||||
F src/sqlite.h.in 3076d78836b6dac53b3ab0875fc8fd15bca8077aad4d33c85336e05af6aef8c7
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h da473ce2b3d0ae407a6300c4a164589b9a6bfdbec9462688a8593ff16f3bb6e4
|
||||
@@ -2041,9 +2041,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 4943e8a1819e189747eefc414d02c0485e1620deff9cf92664295b21a8a9a83c c66ef2440e4e6c7aa17b50e5a29e543713ccab69aa0a415bac29b35b6116504a
|
||||
R 51bf89677ed17bae2e4a623d6d52a0c3
|
||||
T +closed c66ef2440e4e6c7aa17b50e5a29e543713ccab69aa0a415bac29b35b6116504a
|
||||
P a915f15a916af698e0cef46c8b3e7ed11bda19349179d2d414073cd39c4cce24
|
||||
R 0ff1aaf83c3a4b2103ba6e2bba60a2a8
|
||||
U drh
|
||||
Z 8ab32d51087d44c8fc250f900dd8d446
|
||||
Z f9cb0e945d7f18774016bacc44534d0c
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
a915f15a916af698e0cef46c8b3e7ed11bda19349179d2d414073cd39c4cce24
|
||||
669996a8ddcbf35f3de66cf466508fc1e6dd09ab269aba395ac86a11b2ec238c
|
||||
+43
-12
@@ -1207,6 +1207,42 @@ static char *shellFakeSchema(
|
||||
return s.z;
|
||||
}
|
||||
|
||||
/*
|
||||
** SQL function: strtod(X)
|
||||
**
|
||||
** Use the C-library strtod() function to convert string X into a double.
|
||||
** Used for comparing the accuracy of SQLite's internal text-to-float conversion
|
||||
** routines against the C-library.
|
||||
*/
|
||||
static void shellStrtod(
|
||||
sqlite3_context *pCtx,
|
||||
int nVal,
|
||||
sqlite3_value **apVal
|
||||
){
|
||||
char *z = (char*)sqlite3_value_text(apVal[0]);
|
||||
if( z==0 ) return;
|
||||
sqlite3_result_double(pCtx, strtod(z,0));
|
||||
}
|
||||
|
||||
/*
|
||||
** SQL function: dtostr(X)
|
||||
**
|
||||
** Use the C-library printf() function to convert real value X into a string.
|
||||
** Used for comparing the accuracy of SQLite's internal float-to-text conversion
|
||||
** routines against the C-library.
|
||||
*/
|
||||
static void shellDtostr(
|
||||
sqlite3_context *pCtx,
|
||||
int nVal,
|
||||
sqlite3_value **apVal
|
||||
){
|
||||
double r = sqlite3_value_double(apVal[0]);
|
||||
char z[200];
|
||||
sprintf(z, "%#+.70e", r);
|
||||
sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** SQL function: shell_module_schema(X)
|
||||
**
|
||||
@@ -5463,6 +5499,10 @@ static void open_db(ShellState *p, int openFlags){
|
||||
}
|
||||
#endif
|
||||
|
||||
sqlite3_create_function(p->db, "strtod", 1, SQLITE_UTF8, 0,
|
||||
shellStrtod, 0, 0);
|
||||
sqlite3_create_function(p->db, "dtostr", 1, SQLITE_UTF8, 0,
|
||||
shellDtostr, 0, 0);
|
||||
sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0,
|
||||
shellAddSchemaName, 0, 0);
|
||||
sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0,
|
||||
@@ -10805,7 +10845,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
static const struct {
|
||||
const char *zCtrlName; /* Name of a test-control option */
|
||||
int ctrlCode; /* Integer code for that option */
|
||||
int unSafe; /* Not valid for --safe mode */
|
||||
int unSafe; /* Not valid unless --unsafe-testing */
|
||||
const char *zUsage; /* Usage notes */
|
||||
} aCtrl[] = {
|
||||
{"always", SQLITE_TESTCTRL_ALWAYS, 1, "BOOLEAN" },
|
||||
@@ -10838,12 +10878,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
int i, n2;
|
||||
const char *zCmd = 0;
|
||||
|
||||
if( !ShellHasFlag(p,SHFLG_TestingMode) ){
|
||||
utf8_printf(stderr, ".%s unavailable without --unsafe-testing\n",
|
||||
"testctrl");
|
||||
rc = 1;
|
||||
goto meta_command_exit;
|
||||
}
|
||||
open_db(p, 0);
|
||||
zCmd = nArg>=2 ? azArg[1] : "help";
|
||||
|
||||
@@ -10857,6 +10891,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
if( cli_strcmp(zCmd,"help")==0 ){
|
||||
utf8_printf(p->out, "Available test-controls:\n");
|
||||
for(i=0; i<ArraySize(aCtrl); i++){
|
||||
if( aCtrl[i].unSafe && !ShellHasFlag(p,SHFLG_TestingMode) ) continue;
|
||||
utf8_printf(p->out, " .testctrl %s %s\n",
|
||||
aCtrl[i].zCtrlName, aCtrl[i].zUsage);
|
||||
}
|
||||
@@ -10868,6 +10903,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
** of the option name, or a numerical value. */
|
||||
n2 = strlen30(zCmd);
|
||||
for(i=0; i<ArraySize(aCtrl); i++){
|
||||
if( aCtrl[i].unSafe && !ShellHasFlag(p,SHFLG_TestingMode) ) continue;
|
||||
if( cli_strncmp(zCmd, aCtrl[i].zCtrlName, n2)==0 ){
|
||||
if( testctrl<0 ){
|
||||
testctrl = aCtrl[i].ctrlCode;
|
||||
@@ -10883,11 +10919,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
if( testctrl<0 ){
|
||||
utf8_printf(stderr,"Error: unknown test-control: %s\n"
|
||||
"Use \".testctrl --help\" for help\n", zCmd);
|
||||
}else if( aCtrl[iCtrl].unSafe && p->bSafeMode ){
|
||||
utf8_printf(stderr,
|
||||
"line %d: \".testctrl %s\" may not be used in safe mode\n",
|
||||
p->lineno, aCtrl[iCtrl].zCtrlName);
|
||||
exit(1);
|
||||
}else{
|
||||
switch(testctrl){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user