Overview
SHA1 Hash: | 5b74febbccab50c65bb9d38a6192834927ebb8f9 |
---|---|
Date: | 2008-05-16 17:05:05 |
User: | drh |
Comment: | The rebuild command corrects any errors seen in the blob.size field. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/rebuild.c from [048501db14] to [468a623847].
@@ -50,10 +50,20 @@ @ owner text, -- Owner of this report format (not used) @ title text, -- Title of this report @ cols text, -- A color-key specification @ sqlcode text -- An SQL SELECT statement for this report @ ); +@ +@ -- A cache for mapping baseline artifact ID + filename into file +@ -- artifact ID. Used by the /doc method. +@ -- +@ CREATE TABLE IF NOT EXISTS vcache( +@ vid integer, -- Baseline artifact ID +@ fname text, -- Filename +@ rid integer, -- File artifact ID +@ UNIQUE(vid,fname,rid) +@ ); ; /* ** Variables used for progress information */ @@ -75,16 +85,23 @@ /* ** Rebuild cross-referencing information for the artifact ** rid with content pBase and all of its descendants. This ** routine clears the content buffer before returning. */ -static void rebuild_step(int rid, Blob *pBase){ +static void rebuild_step(int rid, int size, Blob *pBase){ Stmt q1; Bag children; Blob copy; Blob *pUse; int nChild, i, cid; + + /* Fix up the "blob.size" field if needed. */ + if( size!=blob_size(pBase) ){ + db_multi_exec( + "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid + ); + } /* Find all children of artifact rid */ db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid); bag_init(&children); while( db_step(&q1)==SQLITE_ROW ){ @@ -119,11 +136,11 @@ db_ephemeral_blob(&q2, 0, &delta); blob_uncompress(&delta, &delta); blob_delta_apply(pUse, &delta, pUse); blob_reset(&delta); db_finalize(&q2); - rebuild_step(cid, pUse); + rebuild_step(cid, sz, pUse); }else{ db_finalize(&q2); blob_reset(pUse); } } @@ -181,11 +198,11 @@ int rid = db_column_int(&s, 0); int size = db_column_int(&s, 1); if( size>=0 ){ Blob content; content_get(rid, &content); - rebuild_step(rid, &content); + rebuild_step(rid, size, &content); }else{ db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); rebuild_step_done(); } }