/ Check-in [ebec4892]
Login

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

Overview
Comment:Add the .fullschema command to the sqlite3.exe utility. This command shows the schema and the content of the sqlite_stat tables, all in one go. Useful when reporting problems with the query planner.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ebec48921c092e20c9d7608242b63db40b40be5e
User & Date: drh 2014-06-23 23:28:13
Context
2014-06-24
00:59
Add the showstat4.exe utility program for decoding and displaying the content of the sqlite_stat4 table in a database. check-in: b4d9f605 user: drh tags: trunk
2014-06-23
23:28
Add the .fullschema command to the sqlite3.exe utility. This command shows the schema and the content of the sqlite_stat tables, all in one go. Useful when reporting problems with the query planner. check-in: ebec4892 user: drh tags: trunk
10:18
Fix a problem with SQLITE_OMIT_WSD builds. check-in: 07dda49c user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1579   1579     "                         If TABLE specified, only dump tables matching\n"
  1580   1580     "                         LIKE pattern TABLE.\n"
  1581   1581     ".echo on|off           Turn command echo on or off\n"
  1582   1582     ".eqp on|off            Enable or disable automatic EXPLAIN QUERY PLAN\n"
  1583   1583     ".exit                  Exit this program\n"
  1584   1584     ".explain ?on|off?      Turn output mode suitable for EXPLAIN on or off.\n"
  1585   1585     "                         With no args, it turns EXPLAIN on.\n"
         1586  +  ".fullschema            Show schema and the content of sqlite_stat tables\n"
  1586   1587     ".headers on|off        Turn display of headers on or off\n"
  1587   1588     ".help                  Show this message\n"
  1588   1589     ".import FILE TABLE     Import data from FILE into TABLE\n"
  1589   1590     ".indices ?TABLE?       Show names of all indices\n"
  1590   1591     "                         If TABLE specified, only show indices for tables\n"
  1591   1592     "                         matching LIKE pattern TABLE.\n"
  1592   1593   #ifdef SQLITE_ENABLE_IOTRACE
................................................................................
  2407   2408       }else if (p->explainPrev.valid) {
  2408   2409         p->explainPrev.valid = 0;
  2409   2410         p->mode = p->explainPrev.mode;
  2410   2411         p->showHeader = p->explainPrev.showHeader;
  2411   2412         memcpy(p->colWidth,p->explainPrev.colWidth,sizeof(p->colWidth));
  2412   2413       }
  2413   2414     }else
         2415  +
         2416  +  if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
         2417  +    struct callback_data data;
         2418  +    char *zErrMsg = 0;
         2419  +    if( nArg!=1 ){
         2420  +      fprintf(stderr, "Usage: .fullschema\n");
         2421  +      rc = 1;
         2422  +      goto meta_command_exit;
         2423  +    }
         2424  +    open_db(p, 0);
         2425  +    memcpy(&data, p, sizeof(data));
         2426  +    data.showHeader = 0;
         2427  +    data.mode = MODE_Semi;
         2428  +    rc = sqlite3_exec(p->db,
         2429  +       "SELECT sql FROM"
         2430  +       "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
         2431  +       "     FROM sqlite_master UNION ALL"
         2432  +       "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
         2433  +       "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'"
         2434  +       "ORDER BY rowid",
         2435  +       callback, &data, &zErrMsg
         2436  +    );
         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);
         2452  +  }else
  2414   2453   
  2415   2454     if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){
  2416   2455       if( nArg==2 ){
  2417   2456         p->showHeader = booleanValue(azArg[1]);
  2418   2457       }else{
  2419   2458         fprintf(stderr, "Usage: .headers on|off\n");
  2420   2459         rc = 1;