Fossil

Check-in [e166ea6aeb]
Login

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

Overview
Comment:Add --vacuum, --wal, and --pagesize options to the "rebuild" command.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e166ea6aebffd12f904e3ab97fd896f580a218ed
User & Date: drh 2011-02-25 14:49:57.579
Context
2011-02-25
16:20
Track file permission changes in the mlink table. Updating through this check-in requires a rebuild. ... (check-in: 7f11789bf1 user: drh tags: trunk)
14:49
Add --vacuum, --wal, and --pagesize options to the "rebuild" command. ... (check-in: e166ea6aeb user: drh tags: trunk)
14:20
Comment and documentation updates on the tagging mechanism. No substantive code changes. ... (check-in: 80f89e3feb user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/rebuild.c.
353
354
355
356
357
358
359



360
361
362
363
364
365
366




367
368
369
370
371











372
373
374
375
376
377
378
**
** Options:
**
**   --noverify    Skip the verification of changes to the BLOB table
**   --force       Force the rebuild to complete even if errors are seen
**   --randomize   Scan artifacts in a random order
**   --cluster     Compute clusters for unclustered artifacts



*/
void rebuild_database(void){
  int forceFlag;
  int randomizeFlag;
  int errCnt;
  int omitVerify;
  int doClustering;





  omitVerify = find_option("noverify",0,0)!=0;
  forceFlag = find_option("force","f",0)!=0;
  randomizeFlag = find_option("randomize", 0, 0)!=0;
  doClustering = find_option("cluster", 0, 0)!=0;











  if( g.argc==3 ){
    db_open_repository(g.argv[2]);
  }else{
    db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
    if( g.argc!=2 ){
      usage("?REPOSITORY-FILENAME?");
    }







>
>
>







>
>
>
>





>
>
>
>
>
>
>
>
>
>
>







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
**
** Options:
**
**   --noverify    Skip the verification of changes to the BLOB table
**   --force       Force the rebuild to complete even if errors are seen
**   --randomize   Scan artifacts in a random order
**   --cluster     Compute clusters for unclustered artifacts
**   --pagesize N  Set the database pagesize to N. (512..65536 and power of 2)
**   --wal         Set Write-Ahead-Log journalling mode on the database
**   --vacuum      Run VACUUM on the database after rebuilding
*/
void rebuild_database(void){
  int forceFlag;
  int randomizeFlag;
  int errCnt;
  int omitVerify;
  int doClustering;
  const char *zPagesize;
  int newPagesize = 0;
  int activateWal;
  int runVacuum;

  omitVerify = find_option("noverify",0,0)!=0;
  forceFlag = find_option("force","f",0)!=0;
  randomizeFlag = find_option("randomize", 0, 0)!=0;
  doClustering = find_option("cluster", 0, 0)!=0;
  runVacuum = find_option("vacuum",0,0)!=0;
  zPagesize = find_option("pagesize",0,1);
  if( zPagesize ){
    newPagesize = atoi(zPagesize);
    if( newPagesize<512 || newPagesize>65536
        || (newPagesize&(newPagesize-1))!=0
    ){
      fossil_fatal("page size must be a power of two between 512 and 65536");
    }
  }
  activateWal = find_option("wal",0,0)!=0;
  if( g.argc==3 ){
    db_open_repository(g.argv[2]);
  }else{
    db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
    if( g.argc!=2 ){
      usage("?REPOSITORY-FILENAME?");
    }
390
391
392
393
394
395
396














397
398
399
400
401
402
403
  if( errCnt && !forceFlag ){
    printf("%d errors. Rolling back changes. Use --force to force a commit.\n",
            errCnt);
    db_end_transaction(1);
  }else{
    if( omitVerify ) verify_cancel();
    db_end_transaction(0);














  }
}

/*
** COMMAND:  test-detach  ?REPOSITORY?
**
** Change the project-code and make other changes in order to prevent







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







408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
  if( errCnt && !forceFlag ){
    printf("%d errors. Rolling back changes. Use --force to force a commit.\n",
            errCnt);
    db_end_transaction(1);
  }else{
    if( omitVerify ) verify_cancel();
    db_end_transaction(0);
    db_close(0);
    db_open_repository(g.zRepositoryName);
    if( newPagesize ){
      db_multi_exec("PRAGMA page_size=%d", newPagesize);
      runVacuum = 1;
    }
    if( runVacuum ){
      printf("Vacuuming the database... "); fflush(stdout);
      db_multi_exec("VACUUM");
      printf("done\n");
    }
    if( activateWal ){
      db_multi_exec("PRAGMA journal_mode=WAL;");
    }
  }
}

/*
** COMMAND:  test-detach  ?REPOSITORY?
**
** Change the project-code and make other changes in order to prevent