/ Check-in [b91d819b]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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 Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

6381
6382
6383
6384
6385
6386
6387















6388
6389
6390
6391
6392
6393
6394





6395
6396
6397
6398
6399
6400
6401
....
6418
6419
6420
6421
6422
6423
6424



6425
6426
6427

6428
6429

6430
6431
6432
6433
6434
6435
6436
  if( rc!=SQLITE_OK ){
    recoverFreeTable(pTab);
    pTab = 0;
  }
  return pTab;
}
















static RecoverTable *recoverFindTable(
  ShellState *pState, 
  int *pRc,
  int iRoot,
  int bIntkey,
  int nCol,
  int *pbNoop





){
  sqlite3_stmt *pStmt = 0;
  RecoverTable *pRet = 0;
  int bNoop = 0;
  const char *zSql = 0;
  const char *zName = 0;

................................................................................
  }

  shellFinalize(pRc, pStmt);
  *pbNoop = bNoop;
  return pRet;
}




static RecoverTable *recoverOrphanTable(
  ShellState *pState, 
  int *pRc, 

  const char *zLostAndFound,
  int nCol

){
  RecoverTable *pTab = 0;
  if( nCol>=0 && *pRc==SQLITE_OK ){
    int i;

    /* This block determines the name of the orphan table. The prefered
    ** name is zLostAndFound. But if that clashes with another name







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
<
<
<
<
<
>
>
>
>
>







 







>
>
>

|
<
>
|
<
>







6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404





6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
....
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444

6445
6446

6447
6448
6449
6450
6451
6452
6453
6454
  if( rc!=SQLITE_OK ){
    recoverFreeTable(pTab);
    pTab = 0;
  }
  return pTab;
}

/*
** This function is called to search the schema recovered from the
** sqlite_master table of the (possibly) corrupt database as part
** of a ".recover" command. Specifically, for a table with root page
** iRoot and at least nCol columns. Additionally, if bIntkey is 0, the
** table must be a WITHOUT ROWID table, or if non-zero, not one of
** those.
**
** If a table is found, a (RecoverTable*) object is returned. Or, if
** no such table is found, but bIntkey is false and iRoot is the 
** root page of an index in the recovered schema, then (*pbNoop) is
** set to true and NULL returned. Or, if there is no such table or
** index, NULL is returned and (*pbNoop) set to 0, indicating that
** the caller should write data to the orphans table.
*/
static RecoverTable *recoverFindTable(
  ShellState *pState,             /* Shell state object */





  int *pRc,                       /* IN/OUT: Error code */
  int iRoot,                      /* Root page of table */
  int bIntkey,                    /* True for an intkey table */
  int nCol,                       /* Number of columns in table */
  int *pbNoop                     /* OUT: True if iRoot is root of index */
){
  sqlite3_stmt *pStmt = 0;
  RecoverTable *pRet = 0;
  int bNoop = 0;
  const char *zSql = 0;
  const char *zName = 0;

................................................................................
  }

  shellFinalize(pRc, pStmt);
  *pbNoop = bNoop;
  return pRet;
}

/*
** Return a RecoverTable object representing the orphans table.
*/
static RecoverTable *recoverOrphanTable(
  ShellState *pState,             /* Shell state object */

  int *pRc,                       /* IN/OUT: Error code */
  const char *zLostAndFound,      /* Base name for orphans table */

  int nCol                        /* Number of user data columns */
){
  RecoverTable *pTab = 0;
  if( nCol>=0 && *pRc==SQLITE_OK ){
    int i;

    /* This block determines the name of the orphan table. The prefered
    ** name is zLostAndFound. But if that clashes with another name