diff options
author | drh <> | 2022-04-29 17:13:52 +0000 |
---|---|---|
committer | drh <> | 2022-04-29 17:13:52 +0000 |
commit | 0c0d0526dceb2a1aab97539d041e777a0cadcd89 (patch) | |
tree | 02a4114b7c5ce94633ef94fa78b594f0289fb87e /src/treeview.c | |
parent | de7a820fd028aef290d8a0d4ffe0a2b080302acf (diff) | |
download | sqlite-0c0d0526dceb2a1aab97539d041e777a0cadcd89.tar.gz sqlite-0c0d0526dceb2a1aab97539d041e777a0cadcd89.zip |
Multiple enhancements to the TreeView output for SrcItem, cherrypicked from
the right-join experimental branch.
FossilOrigin-Name: 293afa81112e824eec2557d004a27319d484276f796936e16d64243fe24f6b68
Diffstat (limited to 'src/treeview.c')
-rw-r--r-- | src/treeview.c | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/src/treeview.c b/src/treeview.c index db73943f0..3aee7df67 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -87,6 +87,53 @@ static void sqlite3TreeViewItem(TreeView *p, const char *zLabel,u8 moreFollows){ } /* +** Show a list of Column objects in tree format. +*/ +void sqlite3TreeViewColumnList( + TreeView *pView, + const Column *aCol, + int nCol, + u8 moreToFollow +){ + int i; + sqlite3TreeViewPush(&pView, moreToFollow); + sqlite3TreeViewLine(pView, "COLUMNS"); + for(i=0; i<nCol; i++){ + u16 flg = aCol[i].colFlags; + int moreToFollow = i<(nCol - 1); + sqlite3TreeViewPush(&pView, moreToFollow); + sqlite3TreeViewLine(pView, 0); + printf(" %s", aCol[i].zCnName); + switch( aCol[i].eCType ){ + case COLTYPE_ANY: printf(" ANY"); break; + case COLTYPE_BLOB: printf(" BLOB"); break; + case COLTYPE_INT: printf(" INT"); break; + case COLTYPE_INTEGER: printf(" INTEGER"); break; + case COLTYPE_REAL: printf(" REAL"); break; + case COLTYPE_TEXT: printf(" TEXT"); break; + case COLTYPE_CUSTOM: { + if( flg & COLFLAG_HASTYPE ){ + const char *z = aCol[i].zCnName; + z += strlen(z)+1; + printf(" X-%s", z); + break; + } + } + } + if( flg & COLFLAG_PRIMKEY ) printf(" PRIMARY KEY"); + if( flg & COLFLAG_HIDDEN ) printf(" HIDDEN"); +#ifdef COLFLAG_NOEXPAND + if( flg & COLFLAG_NOEXPAND ) printf(" NO-EXPAND"); +#endif + if( flg ) printf(" flags=%04x", flg); + printf("\n"); + fflush(stdout); + sqlite3TreeViewPop(&pView); + } + sqlite3TreeViewPop(&pView); +} + +/* ** Generate a human-readable description of a WITH clause. */ void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 moreToFollow){ @@ -141,6 +188,7 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ for(i=0; i<pSrc->nSrc; i++){ const SrcItem *pItem = &pSrc->a[i]; StrAccum x; + int n = 0; char zLine[100]; sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); x.printfFlags |= SQLITE_PRINTF_INTERNAL; @@ -168,10 +216,22 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse); } sqlite3StrAccumFinish(&x); - sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); + sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); + n = 0; + if( pItem->pTab ) n++; + if( pItem->pSelect ) n++; + if( pItem->fg.isTabFunc ) n++; + if( pItem->fg.isUsing ) n++; + if( pItem->fg.isUsing ){ + sqlite3TreeViewIdList(pView, pItem->u3.pUsing, (--n)>0, "USING"); + } + if( pItem->pTab ){ + Table *pTab = pItem->pTab; + sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, (--n)>0); + } if( pItem->pSelect ){ assert( pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) ); - sqlite3TreeViewSelect(pView, pItem->pSelect, 0); + sqlite3TreeViewSelect(pView, pItem->pSelect, (--n)>0); } if( pItem->fg.isTabFunc ){ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); |