/ Check-in [fa80c64c]
Login

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

Overview
Comment:Improvements to the ".fullschema" command in the command-line shell.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fa80c64caa573297bf43cb5b11d9e7db58567200
User & Date: drh 2014-07-18 14:43:29
Context
2014-07-18
17:39
SQLite has long accepted some unadvertised and non-standard join syntax. Add a test to ensure that future versions continue to accept this non-standard syntax, to avoid breaking legacy applications that use the undefined syntax. check-in: 824dde7f user: drh tags: trunk
14:43
Improvements to the ".fullschema" command in the command-line shell. check-in: fa80c64c user: drh tags: trunk
2014-07-07
18:03
Fix harmless compiler warnings in the fts3view utility program that can occur with MSVC. check-in: 1cec1e03 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  2412   2412         memcpy(p->colWidth,p->explainPrev.colWidth,sizeof(p->colWidth));
  2413   2413       }
  2414   2414     }else
  2415   2415   
  2416   2416     if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
  2417   2417       struct callback_data data;
  2418   2418       char *zErrMsg = 0;
         2419  +    int doStats = 0;
  2419   2420       if( nArg!=1 ){
  2420   2421         fprintf(stderr, "Usage: .fullschema\n");
  2421   2422         rc = 1;
  2422   2423         goto meta_command_exit;
  2423   2424       }
  2424   2425       open_db(p, 0);
  2425   2426       memcpy(&data, p, sizeof(data));
................................................................................
  2430   2431          "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
  2431   2432          "     FROM sqlite_master UNION ALL"
  2432   2433          "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
  2433   2434          "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'"
  2434   2435          "ORDER BY rowid",
  2435   2436          callback, &data, &zErrMsg
  2436   2437       );
  2437         -    sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master;'",
  2438         -                 callback, &data, &zErrMsg);
  2439         -    data.mode = MODE_Insert;
  2440         -    data.zDestTable = "sqlite_stat1";
  2441         -    shell_exec(p->db, "SELECT * FROM sqlite_stat1",
  2442         -               shell_callback, &data,&zErrMsg);
  2443         -    data.zDestTable = "sqlite_stat3";
  2444         -    shell_exec(p->db, "SELECT * FROM sqlite_stat3",
  2445         -               shell_callback, &data,&zErrMsg);
  2446         -    data.zDestTable = "sqlite_stat4";
  2447         -    shell_exec(p->db, "SELECT * FROM sqlite_stat4",
  2448         -               shell_callback, &data, &zErrMsg);
  2449         -    data.mode = MODE_Semi;
  2450         -    shell_exec(p->db, "SELECT 'ANALYZE sqlite_master;'",
  2451         -               shell_callback, &data, &zErrMsg);
         2438  +    if( rc==SQLITE_OK ){
         2439  +      sqlite3_stmt *pStmt;
         2440  +      rc = sqlite3_prepare_v2(p->db,
         2441  +               "SELECT rowid FROM sqlite_master"
         2442  +               " WHERE name GLOB 'sqlite_stat[134]'",
         2443  +               -1, &pStmt, 0);
         2444  +      doStats = sqlite3_step(pStmt)==SQLITE_ROW;
         2445  +      sqlite3_finalize(pStmt);
         2446  +    }
         2447  +    if( doStats==0 ){
         2448  +      fprintf(p->out, "/* No STAT tables available */\n");
         2449  +    }else{
         2450  +      fprintf(p->out, "ANALYZE sqlite_master;\n");
         2451  +      sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master'",
         2452  +                   callback, &data, &zErrMsg);
         2453  +      data.mode = MODE_Insert;
         2454  +      data.zDestTable = "sqlite_stat1";
         2455  +      shell_exec(p->db, "SELECT * FROM sqlite_stat1",
         2456  +                 shell_callback, &data,&zErrMsg);
         2457  +      data.zDestTable = "sqlite_stat3";
         2458  +      shell_exec(p->db, "SELECT * FROM sqlite_stat3",
         2459  +                 shell_callback, &data,&zErrMsg);
         2460  +      data.zDestTable = "sqlite_stat4";
         2461  +      shell_exec(p->db, "SELECT * FROM sqlite_stat4",
         2462  +                 shell_callback, &data, &zErrMsg);
         2463  +      fprintf(p->out, "ANALYZE sqlite_master;\n");
         2464  +    }
  2452   2465     }else
  2453   2466   
  2454   2467     if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){
  2455   2468       if( nArg==2 ){
  2456   2469         p->showHeader = booleanValue(azArg[1]);
  2457   2470       }else{
  2458   2471         fprintf(stderr, "Usage: .headers on|off\n");