| | @@ -98,11 +98,11 @@ |
| 98 | 98 | ** Rebuild cross-referencing information for the artifact |
| 99 | 99 | ** rid with content pBase and all of its descendants. This |
| 100 | 100 | ** routine clears the content buffer before returning. |
| 101 | 101 | */ |
| 102 | 102 | static void rebuild_step(int rid, int size, Blob *pBase){ |
| 103 | | - Stmt q1; |
| 103 | + static Stmt q1; |
| 104 | 104 | Bag children; |
| 105 | 105 | Blob copy; |
| 106 | 106 | Blob *pUse; |
| 107 | 107 | int nChild, i, cid; |
| 108 | 108 | |
| | @@ -112,20 +112,21 @@ |
| 112 | 112 | "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid |
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /* Find all children of artifact rid */ |
| 117 | | - db_prepare(&q1, "SELECT rid FROM delta WHERE srcid=%d", rid); |
| 117 | + db_static_prepare(&q1, "SELECT rid FROM delta WHERE srcid=:rid"); |
| 118 | + db_bind_int(&q1, ":rid", rid); |
| 118 | 119 | bag_init(&children); |
| 119 | 120 | while( db_step(&q1)==SQLITE_ROW ){ |
| 120 | 121 | int cid = db_column_int(&q1, 0); |
| 121 | 122 | if( !bag_find(&bagDone, cid) ){ |
| 122 | 123 | bag_insert(&children, cid); |
| 123 | 124 | } |
| 124 | 125 | } |
| 125 | 126 | nChild = bag_count(&children); |
| 126 | | - db_finalize(&q1); |
| 127 | + db_reset(&q1); |
| 127 | 128 | |
| 128 | 129 | /* Crosslink the artifact */ |
| 129 | 130 | if( nChild==0 ){ |
| 130 | 131 | pUse = pBase; |
| 131 | 132 | }else{ |
| | @@ -209,11 +210,11 @@ |
| 209 | 210 | fflush(stdout); |
| 210 | 211 | } |
| 211 | 212 | db_multi_exec(zSchemaUpdates); |
| 212 | 213 | for(;;){ |
| 213 | 214 | zTable = db_text(0, |
| 214 | | - "SELECT name FROM sqlite_master" |
| 215 | + "SELECT name FROM sqlite_master /*scan*/" |
| 215 | 216 | " WHERE type='table'" |
| 216 | 217 | " AND name NOT IN ('blob','delta','rcvfrom','user'," |
| 217 | 218 | "'config','shun','private','reportfmt'," |
| 218 | 219 | "'concealed')" |
| 219 | 220 | " AND name NOT GLOB 'sqlite_*'" |
| | @@ -237,11 +238,11 @@ |
| 237 | 238 | db_multi_exec( |
| 238 | 239 | "DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')" |
| 239 | 240 | ); |
| 240 | 241 | totalSize = db_int(0, "SELECT count(*) FROM blob"); |
| 241 | 242 | db_prepare(&s, |
| 242 | | - "SELECT rid, size FROM blob" |
| 243 | + "SELECT rid, size FROM blob /*scan*/" |
| 243 | 244 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 244 | 245 | " AND NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)" |
| 245 | 246 | ); |
| 246 | 247 | manifest_crosslink_begin(); |
| 247 | 248 | while( db_step(&s)==SQLITE_ROW ){ |
| 248 | 249 | |