Fossil SCM

The rebuild command corrects any errors seen in the blob.size field.

drh 2008-05-16 17:05 trunk
Commit 5b74febbccab50c65bb9d38a6192834927ebb8f9
1 file changed +20 -3
+20 -3
--- src/rebuild.c
+++ src/rebuild.c
@@ -50,10 +50,20 @@
5050
@ owner text, -- Owner of this report format (not used)
5151
@ title text, -- Title of this report
5252
@ cols text, -- A color-key specification
5353
@ sqlcode text -- An SQL SELECT statement for this report
5454
@ );
55
+@
56
+@ -- A cache for mapping baseline artifact ID + filename into file
57
+@ -- artifact ID. Used by the /doc method.
58
+@ --
59
+@ CREATE TABLE IF NOT EXISTS vcache(
60
+@ vid integer, -- Baseline artifact ID
61
+@ fname text, -- Filename
62
+@ rid integer, -- File artifact ID
63
+@ UNIQUE(vid,fname,rid)
64
+@ );
5565
;
5666
5767
/*
5868
** Variables used for progress information
5969
*/
@@ -75,16 +85,23 @@
7585
/*
7686
** Rebuild cross-referencing information for the artifact
7787
** rid with content pBase and all of its descendants. This
7888
** routine clears the content buffer before returning.
7989
*/
80
-static void rebuild_step(int rid, Blob *pBase){
90
+static void rebuild_step(int rid, int size, Blob *pBase){
8191
Stmt q1;
8292
Bag children;
8393
Blob copy;
8494
Blob *pUse;
8595
int nChild, i, cid;
96
+
97
+ /* Fix up the "blob.size" field if needed. */
98
+ if( size!=blob_size(pBase) ){
99
+ db_multi_exec(
100
+ "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid
101
+ );
102
+ }
86103
87104
/* Find all children of artifact rid */
88105
db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid);
89106
bag_init(&children);
90107
while( db_step(&q1)==SQLITE_ROW ){
@@ -119,11 +136,11 @@
119136
db_ephemeral_blob(&q2, 0, &delta);
120137
blob_uncompress(&delta, &delta);
121138
blob_delta_apply(pUse, &delta, pUse);
122139
blob_reset(&delta);
123140
db_finalize(&q2);
124
- rebuild_step(cid, pUse);
141
+ rebuild_step(cid, sz, pUse);
125142
}else{
126143
db_finalize(&q2);
127144
blob_reset(pUse);
128145
}
129146
}
@@ -181,11 +198,11 @@
181198
int rid = db_column_int(&s, 0);
182199
int size = db_column_int(&s, 1);
183200
if( size>=0 ){
184201
Blob content;
185202
content_get(rid, &content);
186
- rebuild_step(rid, &content);
203
+ rebuild_step(rid, size, &content);
187204
}else{
188205
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
189206
rebuild_step_done();
190207
}
191208
}
192209
--- src/rebuild.c
+++ src/rebuild.c
@@ -50,10 +50,20 @@
50 @ owner text, -- Owner of this report format (not used)
51 @ title text, -- Title of this report
52 @ cols text, -- A color-key specification
53 @ sqlcode text -- An SQL SELECT statement for this report
54 @ );
 
 
 
 
 
 
 
 
 
 
55 ;
56
57 /*
58 ** Variables used for progress information
59 */
@@ -75,16 +85,23 @@
75 /*
76 ** Rebuild cross-referencing information for the artifact
77 ** rid with content pBase and all of its descendants. This
78 ** routine clears the content buffer before returning.
79 */
80 static void rebuild_step(int rid, Blob *pBase){
81 Stmt q1;
82 Bag children;
83 Blob copy;
84 Blob *pUse;
85 int nChild, i, cid;
 
 
 
 
 
 
 
86
87 /* Find all children of artifact rid */
88 db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid);
89 bag_init(&children);
90 while( db_step(&q1)==SQLITE_ROW ){
@@ -119,11 +136,11 @@
119 db_ephemeral_blob(&q2, 0, &delta);
120 blob_uncompress(&delta, &delta);
121 blob_delta_apply(pUse, &delta, pUse);
122 blob_reset(&delta);
123 db_finalize(&q2);
124 rebuild_step(cid, pUse);
125 }else{
126 db_finalize(&q2);
127 blob_reset(pUse);
128 }
129 }
@@ -181,11 +198,11 @@
181 int rid = db_column_int(&s, 0);
182 int size = db_column_int(&s, 1);
183 if( size>=0 ){
184 Blob content;
185 content_get(rid, &content);
186 rebuild_step(rid, &content);
187 }else{
188 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
189 rebuild_step_done();
190 }
191 }
192
--- src/rebuild.c
+++ src/rebuild.c
@@ -50,10 +50,20 @@
50 @ owner text, -- Owner of this report format (not used)
51 @ title text, -- Title of this report
52 @ cols text, -- A color-key specification
53 @ sqlcode text -- An SQL SELECT statement for this report
54 @ );
55 @
56 @ -- A cache for mapping baseline artifact ID + filename into file
57 @ -- artifact ID. Used by the /doc method.
58 @ --
59 @ CREATE TABLE IF NOT EXISTS vcache(
60 @ vid integer, -- Baseline artifact ID
61 @ fname text, -- Filename
62 @ rid integer, -- File artifact ID
63 @ UNIQUE(vid,fname,rid)
64 @ );
65 ;
66
67 /*
68 ** Variables used for progress information
69 */
@@ -75,16 +85,23 @@
85 /*
86 ** Rebuild cross-referencing information for the artifact
87 ** rid with content pBase and all of its descendants. This
88 ** routine clears the content buffer before returning.
89 */
90 static void rebuild_step(int rid, int size, Blob *pBase){
91 Stmt q1;
92 Bag children;
93 Blob copy;
94 Blob *pUse;
95 int nChild, i, cid;
96
97 /* Fix up the "blob.size" field if needed. */
98 if( size!=blob_size(pBase) ){
99 db_multi_exec(
100 "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid
101 );
102 }
103
104 /* Find all children of artifact rid */
105 db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid);
106 bag_init(&children);
107 while( db_step(&q1)==SQLITE_ROW ){
@@ -119,11 +136,11 @@
136 db_ephemeral_blob(&q2, 0, &delta);
137 blob_uncompress(&delta, &delta);
138 blob_delta_apply(pUse, &delta, pUse);
139 blob_reset(&delta);
140 db_finalize(&q2);
141 rebuild_step(cid, sz, pUse);
142 }else{
143 db_finalize(&q2);
144 blob_reset(pUse);
145 }
146 }
@@ -181,11 +198,11 @@
198 int rid = db_column_int(&s, 0);
199 int size = db_column_int(&s, 1);
200 if( size>=0 ){
201 Blob content;
202 content_get(rid, &content);
203 rebuild_step(rid, size, &content);
204 }else{
205 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
206 rebuild_step_done();
207 }
208 }
209

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button