/ Check-in [7f3819f6]
Login

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

Overview
Comment:Shorten over-length source code lines in shell.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7f3819f6422badd344c1264b0cd2f2c7afe077df
User & Date: drh 2014-11-10 14:42:28
Context
2014-11-10
16:49
Add the eval() SQL function extension in ext/misc/eval.c. check-in: 27cf665b user: drh tags: trunk
14:42
Shorten over-length source code lines in shell.c. check-in: 7f3819f6 user: drh tags: trunk
2014-11-07
14:41
Add new test file e_blobopen.test, containing tests for sqlite3_blob_open(). check-in: ecbccd0e user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

   168    168   #include <windows.h>
   169    169   
   170    170   /* Saved resource information for the beginning of an operation */
   171    171   static HANDLE hProcess;
   172    172   static FILETIME ftKernelBegin;
   173    173   static FILETIME ftUserBegin;
   174    174   static sqlite3_int64 ftWallBegin;
   175         -typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
          175  +typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME,
          176  +                                    LPFILETIME, LPFILETIME);
   176    177   static GETPROCTIMES getProcessTimesAddr = NULL;
   177    178   
   178    179   /*
   179    180   ** Check to see if we have timer support.  Return 1 if necessary
   180    181   ** support found (or found previously).
   181    182   */
   182    183   static int hasTimer(void){
   183    184     if( getProcessTimesAddr ){
   184    185       return 1;
   185    186     } else {
   186         -    /* GetProcessTimes() isn't supported in WIN95 and some other Windows versions.
   187         -    ** See if the version we are running on has it, and if it does, save off
   188         -    ** a pointer to it and the current process handle.
          187  +    /* GetProcessTimes() isn't supported in WIN95 and some other Windows
          188  +    ** versions. See if the version we are running on has it, and if it
          189  +    ** does, save off a pointer to it and the current process handle.
   189    190       */
   190    191       hProcess = GetCurrentProcess();
   191    192       if( hProcess ){
   192    193         HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll"));
   193    194         if( NULL != hinstLib ){
   194         -        getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
          195  +        getProcessTimesAddr =
          196  +            (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
   195    197           if( NULL != getProcessTimesAddr ){
   196    198             return 1;
   197    199           }
   198    200           FreeLibrary(hinstLib); 
   199    201         }
   200    202       }
   201    203     }
................................................................................
   204    206   
   205    207   /*
   206    208   ** Begin timing an operation
   207    209   */
   208    210   static void beginTimer(void){
   209    211     if( enableTimer && getProcessTimesAddr ){
   210    212       FILETIME ftCreation, ftExit;
   211         -    getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin);
          213  +    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,
          214  +                        &ftKernelBegin,&ftUserBegin);
   212    215       ftWallBegin = timeOfDay();
   213    216     }
   214    217   }
   215    218   
   216    219   /* Return the difference of two FILETIME structs in seconds */
   217    220   static double timeDiff(FILETIME *pStart, FILETIME *pEnd){
   218    221     sqlite_int64 i64Start = *((sqlite_int64 *) pStart);
................................................................................
   223    226   /*
   224    227   ** Print the timing results.
   225    228   */
   226    229   static void endTimer(void){
   227    230     if( enableTimer && getProcessTimesAddr){
   228    231       FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
   229    232       sqlite3_int64 ftWallEnd = timeOfDay();
   230         -    getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd);
          233  +    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);
   231    234       printf("Run Time: real %.3f user %f sys %f\n",
   232    235          (ftWallEnd - ftWallBegin)*0.001,
   233    236          timeDiff(&ftUserBegin, &ftUserEnd),
   234    237          timeDiff(&ftKernelBegin, &ftKernelEnd));
   235    238     }
   236    239   }
   237    240   
................................................................................
   722    725   }
   723    726   #endif
   724    727   
   725    728   /*
   726    729   ** This is the callback routine that the shell
   727    730   ** invokes for each row of a query result.
   728    731   */
   729         -static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int *aiType){
          732  +static int shell_callback(
          733  +  void *pArg,
          734  +  int nArg,        /* Number of result columns */
          735  +  char **azArg,    /* Text of each result column */
          736  +  char **azCol,    /* Column names */
          737  +  int *aiType      /* Column types */
          738  +){
   730    739     int i;
   731    740     ShellState *p = (ShellState*)pArg;
   732    741   
   733    742     switch( p->mode ){
   734    743       case MODE_Line: {
   735    744         int w = 5;
   736    745         if( azArg==0 ) break;
................................................................................
  1101   1110     int iCur;
  1102   1111     int iHiwtr;
  1103   1112   
  1104   1113     if( pArg && pArg->out ){
  1105   1114       
  1106   1115       iHiwtr = iCur = -1;
  1107   1116       sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
  1108         -    fprintf(pArg->out, "Memory Used:                         %d (max %d) bytes\n", iCur, iHiwtr);
         1117  +    fprintf(pArg->out,
         1118  +            "Memory Used:                         %d (max %d) bytes\n",
         1119  +            iCur, iHiwtr);
  1109   1120       iHiwtr = iCur = -1;
  1110   1121       sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
  1111         -    fprintf(pArg->out, "Number of Outstanding Allocations:   %d (max %d)\n", iCur, iHiwtr);
         1122  +    fprintf(pArg->out, "Number of Outstanding Allocations:   %d (max %d)\n",
         1123  +            iCur, iHiwtr);
  1112   1124       if( pArg->shellFlgs & SHFLG_Pagecache ){
  1113   1125         iHiwtr = iCur = -1;
  1114   1126         sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
  1115         -      fprintf(pArg->out, "Number of Pcache Pages Used:         %d (max %d) pages\n", iCur, iHiwtr);
         1127  +      fprintf(pArg->out,
         1128  +              "Number of Pcache Pages Used:         %d (max %d) pages\n",
         1129  +              iCur, iHiwtr);
  1116   1130       }
  1117   1131       iHiwtr = iCur = -1;
  1118   1132       sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
  1119         -    fprintf(pArg->out, "Number of Pcache Overflow Bytes:     %d (max %d) bytes\n", iCur, iHiwtr);
         1133  +    fprintf(pArg->out,
         1134  +            "Number of Pcache Overflow Bytes:     %d (max %d) bytes\n",
         1135  +            iCur, iHiwtr);
  1120   1136       if( pArg->shellFlgs & SHFLG_Scratch ){
  1121   1137         iHiwtr = iCur = -1;
  1122   1138         sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
  1123         -      fprintf(pArg->out, "Number of Scratch Allocations Used:  %d (max %d)\n", iCur, iHiwtr);
         1139  +      fprintf(pArg->out, "Number of Scratch Allocations Used:  %d (max %d)\n",
         1140  +              iCur, iHiwtr);
  1124   1141       }
  1125   1142       iHiwtr = iCur = -1;
  1126   1143       sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
  1127         -    fprintf(pArg->out, "Number of Scratch Overflow Bytes:    %d (max %d) bytes\n", iCur, iHiwtr);
         1144  +    fprintf(pArg->out,
         1145  +            "Number of Scratch Overflow Bytes:    %d (max %d) bytes\n",
         1146  +            iCur, iHiwtr);
  1128   1147       iHiwtr = iCur = -1;
  1129   1148       sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
  1130         -    fprintf(pArg->out, "Largest Allocation:                  %d bytes\n", iHiwtr);
         1149  +    fprintf(pArg->out, "Largest Allocation:                  %d bytes\n",
         1150  +            iHiwtr);
  1131   1151       iHiwtr = iCur = -1;
  1132   1152       sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
  1133         -    fprintf(pArg->out, "Largest Pcache Allocation:           %d bytes\n", iHiwtr);
         1153  +    fprintf(pArg->out, "Largest Pcache Allocation:           %d bytes\n",
         1154  +            iHiwtr);
  1134   1155       iHiwtr = iCur = -1;
  1135   1156       sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);
  1136         -    fprintf(pArg->out, "Largest Scratch Allocation:          %d bytes\n", iHiwtr);
         1157  +    fprintf(pArg->out, "Largest Scratch Allocation:          %d bytes\n",
         1158  +            iHiwtr);
  1137   1159   #ifdef YYTRACKMAXSTACKDEPTH
  1138   1160       iHiwtr = iCur = -1;
  1139   1161       sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset);
  1140         -    fprintf(pArg->out, "Deepest Parser Stack:                %d (max %d)\n", iCur, iHiwtr);
         1162  +    fprintf(pArg->out, "Deepest Parser Stack:                %d (max %d)\n",
         1163  +            iCur, iHiwtr);
  1141   1164   #endif
  1142   1165     }
  1143   1166   
  1144   1167     if( pArg && pArg->out && db ){
  1145   1168       if( pArg->shellFlgs & SHFLG_Lookaside ){
  1146   1169         iHiwtr = iCur = -1;
  1147         -      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
  1148         -      fprintf(pArg->out, "Lookaside Slots Used:                %d (max %d)\n", iCur, iHiwtr);
  1149         -      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);
         1170  +      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED,
         1171  +                        &iCur, &iHiwtr, bReset);
         1172  +      fprintf(pArg->out, "Lookaside Slots Used:                %d (max %d)\n",
         1173  +              iCur, iHiwtr);
         1174  +      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT,
         1175  +                        &iCur, &iHiwtr, bReset);
  1150   1176         fprintf(pArg->out, "Successful lookaside attempts:       %d\n", iHiwtr);
  1151         -      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);
         1177  +      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE,
         1178  +                        &iCur, &iHiwtr, bReset);
  1152   1179         fprintf(pArg->out, "Lookaside failures due to size:      %d\n", iHiwtr);
  1153         -      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);
         1180  +      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL,
         1181  +                        &iCur, &iHiwtr, bReset);
  1154   1182         fprintf(pArg->out, "Lookaside failures due to OOM:       %d\n", iHiwtr);
  1155   1183       }
  1156   1184       iHiwtr = iCur = -1;
  1157   1185       sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
  1158         -    fprintf(pArg->out, "Pager Heap Usage:                    %d bytes\n", iCur);    iHiwtr = iCur = -1;
         1186  +    fprintf(pArg->out, "Pager Heap Usage:                    %d bytes\n",iCur);
         1187  +    iHiwtr = iCur = -1;
  1159   1188       sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
  1160   1189       fprintf(pArg->out, "Page cache hits:                     %d\n", iCur);
  1161   1190       iHiwtr = iCur = -1;
  1162   1191       sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
  1163   1192       fprintf(pArg->out, "Page cache misses:                   %d\n", iCur); 
  1164   1193       iHiwtr = iCur = -1;
  1165   1194       sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
  1166   1195       fprintf(pArg->out, "Page cache writes:                   %d\n", iCur); 
  1167   1196       iHiwtr = iCur = -1;
  1168   1197       sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
  1169         -    fprintf(pArg->out, "Schema Heap Usage:                   %d bytes\n", iCur); 
         1198  +    fprintf(pArg->out, "Schema Heap Usage:                   %d bytes\n",iCur); 
  1170   1199       iHiwtr = iCur = -1;
  1171   1200       sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
  1172         -    fprintf(pArg->out, "Statement Heap/Lookaside Usage:      %d bytes\n", iCur); 
         1201  +    fprintf(pArg->out, "Statement Heap/Lookaside Usage:      %d bytes\n",iCur); 
  1173   1202     }
  1174   1203   
  1175   1204     if( pArg && pArg->out && db && pArg->pStmt ){
  1176         -    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset);
         1205  +    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
         1206  +                               bReset);
  1177   1207       fprintf(pArg->out, "Fullscan Steps:                      %d\n", iCur);
  1178   1208       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
  1179   1209       fprintf(pArg->out, "Sort Operations:                     %d\n", iCur);
  1180         -    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
         1210  +    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
  1181   1211       fprintf(pArg->out, "Autoindex Inserts:                   %d\n", iCur);
  1182   1212       iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
  1183   1213       fprintf(pArg->out, "Virtual Machine Steps:               %d\n", iCur);
  1184   1214     }
  1185   1215   
  1186   1216     return 0;
  1187   1217   }
................................................................................
  1217   1247         }
  1218   1248         n++;
  1219   1249         sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
  1220   1250         sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);
  1221   1251         sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);
  1222   1252         fprintf(pArg->out, "Loop %2d: %s\n", n, zExplain);
  1223   1253         rEstLoop *= rEst;
  1224         -      fprintf(pArg->out, "         nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
         1254  +      fprintf(pArg->out, 
         1255  +          "         nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
  1225   1256             nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst
  1226   1257         );
  1227   1258       }
  1228   1259     }
  1229   1260     fprintf(pArg->out, "---------------------------\n");
  1230   1261   #endif
  1231   1262   }
................................................................................
  1267   1298     const char *z;                  /* Used to check if this is an EXPLAIN */
  1268   1299     int *abYield = 0;               /* True if op is an OP_Yield */
  1269   1300     int nAlloc = 0;                 /* Allocated size of p->aiIndent[], abYield */
  1270   1301     int iOp;                        /* Index of operation in p->aiIndent[] */
  1271   1302   
  1272   1303     const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext",
  1273   1304                              "NextIfOpen", "PrevIfOpen", 0 };
  1274         -  const char *azYield[] = { "Yield", "SeekLT", "SeekGT", "RowSetRead", "Rewind", 0 };
         1305  +  const char *azYield[] = { "Yield", "SeekLT", "SeekGT", "RowSetRead",
         1306  +                            "Rewind", 0 };
  1275   1307     const char *azGoto[] = { "Goto", 0 };
  1276   1308   
  1277   1309     /* Try to figure out if this is really an EXPLAIN statement. If this
  1278   1310     ** cannot be verified, return early.  */
  1279   1311     zSql = sqlite3_sql(pSql);
  1280   1312     if( zSql==0 ) return;
  1281   1313     for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
................................................................................
  1380   1412           const char *zStmtSql = sqlite3_sql(pStmt);
  1381   1413           fprintf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
  1382   1414         }
  1383   1415   
  1384   1416         /* Show the EXPLAIN QUERY PLAN if .eqp is on */
  1385   1417         if( pArg && pArg->autoEQP ){
  1386   1418           sqlite3_stmt *pExplain;
  1387         -        char *zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", sqlite3_sql(pStmt));
         1419  +        char *zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s",
         1420  +                                     sqlite3_sql(pStmt));
  1388   1421           rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
  1389   1422           if( rc==SQLITE_OK ){
  1390   1423             while( sqlite3_step(pExplain)==SQLITE_ROW ){
  1391   1424               fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0));
  1392   1425               fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1));
  1393   1426               fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2));
  1394   1427               fprintf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
................................................................................
  3331   3364         }
  3332   3365         nPrintCol = 80/(maxlen+2);
  3333   3366         if( nPrintCol<1 ) nPrintCol = 1;
  3334   3367         nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
  3335   3368         for(i=0; i<nPrintRow; i++){
  3336   3369           for(j=i; j<nRow; j+=nPrintRow){
  3337   3370             char *zSp = j<nPrintRow ? "" : "  ";
  3338         -          fprintf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : "");
         3371  +          fprintf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:"");
  3339   3372           }
  3340   3373           fprintf(p->out, "\n");
  3341   3374         }
  3342   3375       }
  3343   3376       for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);
  3344   3377       sqlite3_free(azResult);
  3345   3378     }else
................................................................................
  3801   3834   ** Return a pathname which is the user's home directory.  A
  3802   3835   ** 0 return indicates an error of some kind.
  3803   3836   */
  3804   3837   static char *find_home_dir(void){
  3805   3838     static char *home_dir = NULL;
  3806   3839     if( home_dir ) return home_dir;
  3807   3840   
  3808         -#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL)
         3841  +#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
         3842  +     && !defined(__RTP__) && !defined(_WRS_KERNEL)
  3809   3843     {
  3810   3844       struct passwd *pwent;
  3811   3845       uid_t uid = getuid();
  3812   3846       if( (pwent=getpwuid(uid)) != NULL) {
  3813   3847         home_dir = pwent->pw_dir;
  3814   3848       }
  3815   3849     }