/ Check-in [b91d819b]
Login

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

Overview
Comment:Add comments and fix formatting issues in new code in shell.c.in.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dbdata
Files: files | file ages | folders
SHA3-256: b91d819bd16de43fc99e379da0ba9c915b0c5afc68e804a50c3c1662c1f9a740
User & Date: dan 2019-04-27 19:36:49
Context
2019-04-27
20:15
Fix building the shell with SQLITE_OMIT_VIRTUAL_TABLE. And without SQLITE_ENABLE_DBPAGE_VTAB. Closed-Leaf check-in: 425d708c user: dan tags: dbdata
19:36
Add comments and fix formatting issues in new code in shell.c.in. check-in: b91d819b user: dan tags: dbdata
18:47
Add the "--lost-and-found" option to the ".recover" command. For setting the name of the orphaned rows table. check-in: 67bb88e2 user: dan tags: dbdata
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

  6381   6381     if( rc!=SQLITE_OK ){
  6382   6382       recoverFreeTable(pTab);
  6383   6383       pTab = 0;
  6384   6384     }
  6385   6385     return pTab;
  6386   6386   }
  6387   6387   
         6388  +/*
         6389  +** This function is called to search the schema recovered from the
         6390  +** sqlite_master table of the (possibly) corrupt database as part
         6391  +** of a ".recover" command. Specifically, for a table with root page
         6392  +** iRoot and at least nCol columns. Additionally, if bIntkey is 0, the
         6393  +** table must be a WITHOUT ROWID table, or if non-zero, not one of
         6394  +** those.
         6395  +**
         6396  +** If a table is found, a (RecoverTable*) object is returned. Or, if
         6397  +** no such table is found, but bIntkey is false and iRoot is the 
         6398  +** root page of an index in the recovered schema, then (*pbNoop) is
         6399  +** set to true and NULL returned. Or, if there is no such table or
         6400  +** index, NULL is returned and (*pbNoop) set to 0, indicating that
         6401  +** the caller should write data to the orphans table.
         6402  +*/
  6388   6403   static RecoverTable *recoverFindTable(
  6389         -  ShellState *pState, 
  6390         -  int *pRc,
  6391         -  int iRoot,
  6392         -  int bIntkey,
  6393         -  int nCol,
  6394         -  int *pbNoop
         6404  +  ShellState *pState,             /* Shell state object */
         6405  +  int *pRc,                       /* IN/OUT: Error code */
         6406  +  int iRoot,                      /* Root page of table */
         6407  +  int bIntkey,                    /* True for an intkey table */
         6408  +  int nCol,                       /* Number of columns in table */
         6409  +  int *pbNoop                     /* OUT: True if iRoot is root of index */
  6395   6410   ){
  6396   6411     sqlite3_stmt *pStmt = 0;
  6397   6412     RecoverTable *pRet = 0;
  6398   6413     int bNoop = 0;
  6399   6414     const char *zSql = 0;
  6400   6415     const char *zName = 0;
  6401   6416   
................................................................................
  6418   6433     }
  6419   6434   
  6420   6435     shellFinalize(pRc, pStmt);
  6421   6436     *pbNoop = bNoop;
  6422   6437     return pRet;
  6423   6438   }
  6424   6439   
         6440  +/*
         6441  +** Return a RecoverTable object representing the orphans table.
         6442  +*/
  6425   6443   static RecoverTable *recoverOrphanTable(
  6426         -  ShellState *pState, 
  6427         -  int *pRc, 
  6428         -  const char *zLostAndFound,
  6429         -  int nCol
         6444  +  ShellState *pState,             /* Shell state object */
         6445  +  int *pRc,                       /* IN/OUT: Error code */
         6446  +  const char *zLostAndFound,      /* Base name for orphans table */
         6447  +  int nCol                        /* Number of user data columns */
  6430   6448   ){
  6431   6449     RecoverTable *pTab = 0;
  6432   6450     if( nCol>=0 && *pRc==SQLITE_OK ){
  6433   6451       int i;
  6434   6452   
  6435   6453       /* This block determines the name of the orphan table. The prefered
  6436   6454       ** name is zLostAndFound. But if that clashes with another name