Add additional tree display routines for DELETE and UPDATE. No changes

to deliverable code.

FossilOrigin-Name: fbd288ff3d4ea47cd324b5952e7754a465901844f2d950f0860d4488d5b6eb9f
This commit is contained in:
drh
2022-04-06 10:37:44 +00:00
parent 7d2c1d24b0
commit f8ef2dbd7b
7 changed files with 148 additions and 12 deletions
+6
View File
@@ -300,6 +300,12 @@ void sqlite3DeleteFrom(
assert( db->mallocFailed==0 );
assert( pTabList->nSrc==1 );
#if SELECTTRACE_ENABLED
if( sqlite3SelectTrace & 0x10000 ){
sqlite3TreeViewDelete(0, pParse->pWith, pTabList, pWhere,
pOrderBy, pLimit);
}
#endif
/* Locate the table which we want to delete. This table has to be
** put in an SrcList structure because some of the subroutines we
+1 -1
View File
@@ -723,7 +723,7 @@ void sqlite3Insert(
dest.iSDParm = 0; /* Suppress a harmless compiler warning */
#if SELECTTRACE_ENABLED
if( sqlite3SelectTrace & 0x100 ){
if( sqlite3SelectTrace & 0x10000 ){
sqlite3TreeViewInsert(0, pParse->pWith, pTabList, pColumn, pSelect,
onError, pUpsert);
}
+5
View File
@@ -4421,9 +4421,14 @@ char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
void sqlite3TreeViewWith(TreeView*, const With*, u8);
void sqlite3TreeViewUpsert(TreeView*, const Upsert*, u8);
void sqlite3TreeViewDelete(TreeView*, const With*, const SrcList*,
const Expr*,const ExprList*,const Expr*);
void sqlite3TreeViewInsert(TreeView*, const With*, const SrcList*,
const IdList*, const Select*, int,
const Upsert*);
void sqlite3TreeViewUpdate(TreeView*, const With*, const SrcList*,
const ExprList*, const Expr*, int,
const ExprList*, const Expr*, const Upsert*);
#ifndef SQLITE_OMIT_WINDOWFUNC
void sqlite3TreeViewWindow(TreeView*, const Window*, u8);
void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
+118
View File
@@ -880,6 +880,54 @@ void sqlite3TreeViewUpsert(
sqlite3TreeViewPop(pView);
}
/*
** Generate a human-readable diagram of the data structure that go
** into generating an DELETE statement.
*/
void sqlite3TreeViewDelete(
TreeView *pView,
const With *pWith,
const SrcList *pTabList,
const Expr *pWhere,
const ExprList *pOrderBy,
const Expr *pLimit
){
int n = 0;
sqlite3TreeViewLine(pView, "DELETE");
pView = sqlite3TreeViewPush(pView, 0);
if( pWith ) n++;
if( pTabList ) n++;
if( pWhere ) n++;
if( pOrderBy ) n++;
if( pLimit ) n++;
if( pWith ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewWith(pView, pWith, 0);
sqlite3TreeViewPop(pView);
}
if( pTabList ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewLine(pView, "FROM");
sqlite3TreeViewSrcList(pView, pTabList);
sqlite3TreeViewPop(pView);
}
if( pWhere ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewLine(pView, "WHERE");
sqlite3TreeViewExpr(pView, pWhere, 0);
sqlite3TreeViewPop(pView);
}
if( pOrderBy ){
sqlite3TreeViewExprList(pView, pOrderBy, (--n)>0, "ORDER-BY");
}
if( pLimit ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewLine(pView, "LIMIT");
sqlite3TreeViewExpr(pView, pLimit, 0);
sqlite3TreeViewPop(pView);
}
}
/*
** Generate a human-readable diagram of the data structure that go
** into generating an INSERT statement.
@@ -937,4 +985,74 @@ void sqlite3TreeViewInsert(
}
}
/*
** Generate a human-readable diagram of the data structure that go
** into generating an UPDATE statement.
*/
void sqlite3TreeViewUpdate(
TreeView *pView,
const With *pWith,
const SrcList *pTabList,
const ExprList *pChanges,
const Expr *pWhere,
int onError,
const ExprList *pOrderBy,
const Expr *pLimit,
const Upsert *pUpsert
){
int n = 0;
const char *zLabel = "UPDATE";
switch( onError ){
case OE_Replace: zLabel = "UPDATE OR REPLACE"; break;
case OE_Ignore: zLabel = "UPDATE OR IGNORE"; break;
case OE_Rollback: zLabel = "UPDATE OR ROLLBACK"; break;
case OE_Abort: zLabel = "UPDATE OR ABORT"; break;
case OE_Fail: zLabel = "UPDATE OR FAIL"; break;
}
sqlite3TreeViewLine(pView, zLabel);
pView = sqlite3TreeViewPush(pView, 0);
if( pWith ) n++;
if( pTabList ) n++;
if( pChanges ) n++;
if( pWhere ) n++;
if( pOrderBy ) n++;
if( pLimit ) n++;
if( pUpsert ) n++;
if( pWith ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewWith(pView, pWith, 0);
sqlite3TreeViewPop(pView);
}
if( pTabList ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewLine(pView, "FROM");
sqlite3TreeViewSrcList(pView, pTabList);
sqlite3TreeViewPop(pView);
}
if( pChanges ){
sqlite3TreeViewExprList(pView, pChanges, (--n)>0, "SET");
}
if( pWhere ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewLine(pView, "WHERE");
sqlite3TreeViewExpr(pView, pWhere, 0);
sqlite3TreeViewPop(pView);
}
if( pOrderBy ){
sqlite3TreeViewExprList(pView, pOrderBy, (--n)>0, "ORDER-BY");
}
if( pLimit ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewLine(pView, "LIMIT");
sqlite3TreeViewExpr(pView, pLimit, 0);
sqlite3TreeViewPop(pView);
}
if( pUpsert ){
pView = sqlite3TreeViewPush(pView, (--n)>0);
sqlite3TreeViewLine(pView, "UPSERT");
sqlite3TreeViewUpsert(pView, pUpsert, 0);
sqlite3TreeViewPop(pView);
}
}
#endif /* SQLITE_DEBUG */
+7
View File
@@ -353,6 +353,13 @@ void sqlite3Update(
}
assert( db->mallocFailed==0 );
#if SELECTTRACE_ENABLED
if( sqlite3SelectTrace & 0x10000 ){
sqlite3TreeViewUpdate(0, pParse->pWith, pTabList, pChanges, pWhere,
onError, pOrderBy, pLimit, pUpsert);
}
#endif
/* Locate the table which we want to update.
*/
pTab = sqlite3SrcListLookup(pParse, pTabList);