Add extra debugging code for sqlite3_stmt_scanstatus_v2() to test1.c.

FossilOrigin-Name: f936f101406069b29218c89a36581b4497226fb61906782ea368f12d943c901c
This commit is contained in:
dan 2023-06-30 16:16:51 +00:00
parent 48114d08cf
commit 1bfe92a691
3 changed files with 52 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Completely\sunwind\sthe\senhanced\sprecision\ssum()\sfrom\s[a915f15a916af698]\sso\nas\snot\sto\soffend\sUBSAN\sand\sOSS-Fuzz.
D 2023-06-30T14:01:09.017
C Add\sextra\sdebugging\scode\sfor\ssqlite3_stmt_scanstatus_v2()\sto\stest1.c.
D 2023-06-30T16:16:51.838
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -647,7 +647,7 @@ F src/sqliteLimit.h 33b1c9baba578d34efe7dfdb43193b366111cdf41476b1e82699e14c11ee
F src/status.c 160c445d7d28c984a0eae38c144f6419311ed3eace59b44ac6dafc20db4af749
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/tclsqlite.c ecbc3c99c0d0c3ed122a913f143026c26d38d57f33e06bb71185dd5c1efe37cd
F src/test1.c e6ab4a00671f052366a01bcb7fdf2e2f6bb4aa884cd01e738c5590dcf47a99ca
F src/test1.c 64b8462099618a6243f63ba701eea8913046cd7377a7a77a7e3a0ada42219275
F src/test2.c 827446e259a3b7ab949da1542953edda7b5117982576d3e6f1c24a0dd20a5cef
F src/test3.c e5178558c41ff53236ae0271e9acb3d6885a94981d2eb939536ee6474598840e
F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664
@ -2041,8 +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 625820e8ebfdcf513c81b1b632bbe2aa882a8fbba52001113dc6f56270fa5ceb
R 1a82418c3ef4ddd94ec77caee044b5a7
U drh
Z aca079c870f1ae7b8c8d668c5fe69525
P 85be05b66ef975f02a3e7b2984bcab97d9280c7f3b6ee1e16718de549f240d46
R 433a85e7cf1b4578b68ff0f431f95f42
U dan
Z 30a28df351ab36975e3c1ccdb855302c
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
85be05b66ef975f02a3e7b2984bcab97d9280c7f3b6ee1e16718de549f240d46
f936f101406069b29218c89a36581b4497226fb61906782ea368f12d943c901c

View File

@ -2216,6 +2216,7 @@ static int SQLITE_TCLAPI test_stmt_scanstatus(
int flags = 0;
int iSelectId = 0;
int iParentId = 0;
int bDebug = 0;
if( objc==5 ){
struct Flag {
@ -2223,6 +2224,7 @@ static int SQLITE_TCLAPI test_stmt_scanstatus(
int flag;
} aTbl[] = {
{"complex", SQLITE_SCANSTAT_COMPLEX},
{"debug", -1},
{0, 0}
};
@ -2239,7 +2241,11 @@ static int SQLITE_TCLAPI test_stmt_scanstatus(
interp, aFlag[ii], aTbl, sizeof(aTbl[0]), "flag", 0, &iVal
);
if( res ) return TCL_ERROR;
flags |= aTbl[iVal].flag;
if( aTbl[iVal].flag==-1 ){
bDebug = 1;
}else{
flags |= aTbl[iVal].flag;
}
}
}
@ -2253,6 +2259,13 @@ static int SQLITE_TCLAPI test_stmt_scanstatus(
return TCL_ERROR;
}
if( bDebug && 0==(flags & SQLITE_SCANSTAT_COMPLEX) ){
Tcl_SetObjResult(interp,
Tcl_NewStringObj("may not specify debug without complex", -1)
);
return TCL_ERROR;
}
if( idx<0 ){
Tcl_Obj *pRet = Tcl_NewObj();
res = sqlite3_stmt_scanstatus_v2(
@ -2299,6 +2312,36 @@ static int SQLITE_TCLAPI test_stmt_scanstatus(
pStmt, idx, SQLITE_SCANSTAT_NCYCLE, flags, (void*)&nCycle);
Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj("nCycle", -1));
Tcl_ListObjAppendElement(0, pRet, Tcl_NewWideIntObj(nCycle));
if( bDebug ){
int ii;
ScanStatus *pScan = &((Vdbe*)pStmt)->aScan[idx];
Tcl_Obj *pRange = Tcl_NewObj();
Tcl_Obj *pCsr = Tcl_NewObj();
Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj("debug_loop", -1));
Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(pScan->addrLoop));
Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj("debug_visit", -1));
Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(pScan->addrVisit));
Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj("debug_explain",-1));
Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(pScan->addrExplain));
for(ii=0; ii<ArraySize(pScan->aAddrRange)/2; ii++){
int iStart = pScan->aAddrRange[ii*2];
int iEnd = pScan->aAddrRange[ii*2+1];
if( iStart>0 ){
Tcl_ListObjAppendElement(0, pRange, Tcl_NewIntObj(iStart));
Tcl_ListObjAppendElement(0, pRange, Tcl_NewIntObj(iEnd));
}else if( iStart<0 ){
Tcl_ListObjAppendElement(0, pCsr, Tcl_NewIntObj(iEnd));
}
}
Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj("debug_range", -1));
Tcl_ListObjAppendElement(0, pRet, pRange);
Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj("debug_csr", -1));
Tcl_ListObjAppendElement(0, pRet, pCsr);
}
Tcl_SetObjResult(interp, pRet);
}else{
Tcl_ResetResult(interp);