/ Check-in [0eb3f8b1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:More compact notation for the parse-tree view.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tree-explain
Files: files | file ages | folders
SHA1: 0eb3f8b1e3a196811fb54a5e2645debe6119610a
User & Date: drh 2011-12-07 15:33:14
Context
2011-12-07
22:49
Additional detail added to the tree-explain output for SELECT statements. check-in: 7b457ea4 user: drh tags: tree-explain
15:33
More compact notation for the parse-tree view. check-in: 0eb3f8b1 user: drh tags: tree-explain
01:47
Bug fix in sqlite3SelectDup(). Make sure the pNext pointer is valid. check-in: 7e5b56b1 user: drh tags: tree-explain
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  2952   2952     if( pExpr==0 ){
  2953   2953       op = TK_NULL;
  2954   2954     }else{
  2955   2955       op = pExpr->op;
  2956   2956     }
  2957   2957     switch( op ){
  2958   2958       case TK_AGG_COLUMN: {
  2959         -      sqlite3ExplainPrintf(pOut, "AGG_COLUMN(%s:%d:%d)",
  2960         -            pExpr->pTab->zName, pExpr->iTable, pExpr->iColumn);
         2959  +      sqlite3ExplainPrintf(pOut, "AGG{%d:%d}",
         2960  +            pExpr->iTable, pExpr->iColumn);
  2961   2961         break;
  2962   2962       }
  2963   2963       case TK_COLUMN: {
  2964   2964         if( pExpr->iTable<0 ){
  2965   2965           /* This only happens when coding check constraints */
  2966   2966           sqlite3ExplainPrintf(pOut, "COLUMN(%d)", pExpr->iColumn);
  2967   2967         }else{
  2968         -        sqlite3ExplainPrintf(pOut, "COLUMN(%s:%d:%d)",
  2969         -            pExpr->pTab->zName, pExpr->iTable, pExpr->iColumn);
         2968  +        sqlite3ExplainPrintf(pOut, "{%d:%d}",
         2969  +                             pExpr->iTable, pExpr->iColumn);
  2970   2970         }
  2971   2971         break;
  2972   2972       }
  2973   2973       case TK_INTEGER: {
  2974   2974         if( pExpr->flags & EP_IntValue ){
  2975         -        sqlite3ExplainPrintf(pOut, "INTEGER(%d)", pExpr->u.iValue);
         2975  +        sqlite3ExplainPrintf(pOut, "%d", pExpr->u.iValue);
  2976   2976         }else{
  2977         -        sqlite3ExplainPrintf(pOut, "INTEGER(%s)", pExpr->u.zToken);
         2977  +        sqlite3ExplainPrintf(pOut, "%s", pExpr->u.zToken);
  2978   2978         }
  2979   2979         break;
  2980   2980       }
  2981   2981   #ifndef SQLITE_OMIT_FLOATING_POINT
  2982   2982       case TK_FLOAT: {
  2983         -      sqlite3ExplainPrintf(pOut,"REAL(%s)", pExpr->u.zToken);
         2983  +      sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
  2984   2984         break;
  2985   2985       }
  2986   2986   #endif
  2987   2987       case TK_STRING: {
  2988         -      sqlite3ExplainPrintf(pOut,"STRING(%s)", pExpr->u.zToken);
         2988  +      sqlite3ExplainPrintf(pOut,"%Q", pExpr->u.zToken);
  2989   2989         break;
  2990   2990       }
  2991   2991       case TK_NULL: {
  2992   2992         sqlite3ExplainPrintf(pOut,"NULL");
  2993   2993         break;
  2994   2994       }
  2995   2995   #ifndef SQLITE_OMIT_BLOB_LITERAL
  2996   2996       case TK_BLOB: {
  2997         -      int n;
  2998         -      const char *z;
  2999         -      assert( !ExprHasProperty(pExpr, EP_IntValue) );
  3000         -      assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
  3001         -      assert( pExpr->u.zToken[1]=='\'' );
  3002         -      z = &pExpr->u.zToken[2];
  3003         -      n = sqlite3Strlen30(z) - 1;
  3004         -      assert( z[n]=='\'' );
  3005         -      sqlite3ExplainPrintf(pOut,"BLOB(%.*s)", n, z);
         2997  +      sqlite3ExplainPrintf(pOut,"%s", pExpr->u.zToken);
  3006   2998         break;
  3007   2999       }
  3008   3000   #endif
  3009   3001       case TK_VARIABLE: {
  3010   3002         sqlite3ExplainPrintf(pOut,"VARIABLE(%s,%d)",
  3011   3003                              pExpr->u.zToken, pExpr->iColumn);
  3012   3004         break;

Changes to src/select.c.

  4504   4504     sqlite3ExplainNL(pVdbe);
  4505   4505     if( p->pSrc && p->pSrc->nSrc ){
  4506   4506       int i;
  4507   4507       sqlite3ExplainPrintf(pVdbe, "FROM ");
  4508   4508       sqlite3ExplainPush(pVdbe);
  4509   4509       for(i=0; i<p->pSrc->nSrc; i++){
  4510   4510         struct SrcList_item *pItem = &p->pSrc->a[i];
  4511         -      sqlite3ExplainPrintf(pVdbe, "src[%d] = ", i);
         4511  +      sqlite3ExplainPrintf(pVdbe, "{%d,*} = ", pItem->iCursor);
  4512   4512         if( pItem->pSelect ){
  4513   4513           sqlite3ExplainSelect(pVdbe, pItem->pSelect);
         4514  +        if( pItem->pTab ){
         4515  +          sqlite3ExplainPrintf(pVdbe, " (tabname=%s)", pItem->pTab->zName);
         4516  +        }
  4514   4517         }else if( pItem->zName ){
  4515   4518           sqlite3ExplainPrintf(pVdbe, "%s", pItem->zName);
  4516   4519         }
  4517         -      if( pItem->pTab ){
  4518         -        sqlite3ExplainPrintf(pVdbe, " (name=%s:%d)",
  4519         -                             pItem->pTab->zName, pItem->iCursor);
         4520  +      if( pItem->zAlias ){
         4521  +        sqlite3ExplainPrintf(pVdbe, " (AS %s)", pItem->zAlias);
  4520   4522         }
  4521   4523         if( pItem->jointype & JT_LEFT ){
  4522   4524           sqlite3ExplainPrintf(pVdbe, " LEFT-JOIN");
  4523   4525         }
  4524         -      if( pItem->zAlias ){
  4525         -        sqlite3ExplainPrintf(pVdbe, " (AS %s)", pItem->zAlias);
  4526         -      }
  4527   4526         sqlite3ExplainNL(pVdbe);
  4528   4527       }
  4529   4528       sqlite3ExplainPop(pVdbe);
  4530   4529     }
  4531   4530     if( p->pWhere ){
  4532   4531       sqlite3ExplainPrintf(pVdbe, "WHERE ");
  4533   4532       sqlite3ExplainExpr(pVdbe, p->pWhere);