diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/delete.c | 6 | ||||
-rw-r--r-- | src/insert.c | 2 | ||||
-rw-r--r-- | src/sqliteInt.h | 5 | ||||
-rw-r--r-- | src/treeview.c | 118 | ||||
-rw-r--r-- | src/update.c | 7 |
5 files changed, 137 insertions, 1 deletions
diff --git a/src/delete.c b/src/delete.c index 7b769e6a1..8990e10a0 100644 --- a/src/delete.c +++ b/src/delete.c @@ -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 diff --git a/src/insert.c b/src/insert.c index 8a022df07..72d4b7df3 100644 --- a/src/insert.c +++ b/src/insert.c @@ -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); } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 9662508da..6d403f4f1 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -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); diff --git a/src/treeview.c b/src/treeview.c index a2ae32069..bb7187ee6 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -882,6 +882,54 @@ void sqlite3TreeViewUpsert( /* ** 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. */ void sqlite3TreeViewInsert( @@ -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 */ diff --git a/src/update.c b/src/update.c index a43d0eac5..49f361861 100644 --- a/src/update.c +++ b/src/update.c @@ -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); |