Fossil SCM
Inline uuid_to_rid and content_size. Saves one SQL statement per file in the checkout.
Commit
e0f5d4734ac825893e7feb963efd50574a17534b
Parent
4e77507e70d0a46…
1 file changed
+14
-4
+14
-4
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -75,12 +75,12 @@ | ||
| 75 | 75 | |
| 76 | 76 | /* |
| 77 | 77 | ** Build a catalog of all files in a checkin. |
| 78 | 78 | */ |
| 79 | 79 | void vfile_build(int vid){ |
| 80 | - int rid; | |
| 81 | - Stmt ins; | |
| 80 | + int rid, size; | |
| 81 | + Stmt ins, ridq; | |
| 82 | 82 | Manifest *p; |
| 83 | 83 | ManifestFile *pFile; |
| 84 | 84 | |
| 85 | 85 | db_begin_transaction(); |
| 86 | 86 | p = manifest_get(vid, CFTYPE_MANIFEST); |
| @@ -87,25 +87,35 @@ | ||
| 87 | 87 | if( p==0 ) return; |
| 88 | 88 | db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid); |
| 89 | 89 | db_prepare(&ins, |
| 90 | 90 | "INSERT INTO vfile(vid,isexe,rid,mrid,pathname) " |
| 91 | 91 | " VALUES(:vid,:isexe,:id,:id,:name)"); |
| 92 | + db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid"); | |
| 92 | 93 | db_bind_int(&ins, ":vid", vid); |
| 93 | 94 | manifest_file_rewind(p); |
| 94 | 95 | while( (pFile = manifest_file_next(p,0))!=0 ){ |
| 95 | 96 | if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue; |
| 96 | - rid = uuid_to_rid(pFile->zUuid, 0); | |
| 97 | - if( rid==0 || content_size(rid, -1)<0 ){ | |
| 97 | + db_bind_text(&ridq, ":uuid", pFile->zUuid); | |
| 98 | + if( db_step(&ridq)==SQLITE_ROW ){ | |
| 99 | + rid = db_column_int(&ridq, 0); | |
| 100 | + size = db_column_int(&ridq, 0); | |
| 101 | + }else{ | |
| 102 | + rid = 0; | |
| 103 | + size = 0; | |
| 104 | + } | |
| 105 | + db_reset(&ridq); | |
| 106 | + if( rid==0 || size<0 ){ | |
| 98 | 107 | fossil_warning("content missing for %s", pFile->zName); |
| 99 | 108 | continue; |
| 100 | 109 | } |
| 101 | 110 | db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile)); |
| 102 | 111 | db_bind_int(&ins, ":id", rid); |
| 103 | 112 | db_bind_text(&ins, ":name", pFile->zName); |
| 104 | 113 | db_step(&ins); |
| 105 | 114 | db_reset(&ins); |
| 106 | 115 | } |
| 116 | + db_finalize(&ridq); | |
| 107 | 117 | db_finalize(&ins); |
| 108 | 118 | manifest_destroy(p); |
| 109 | 119 | db_end_transaction(0); |
| 110 | 120 | } |
| 111 | 121 | |
| 112 | 122 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -75,12 +75,12 @@ | |
| 75 | |
| 76 | /* |
| 77 | ** Build a catalog of all files in a checkin. |
| 78 | */ |
| 79 | void vfile_build(int vid){ |
| 80 | int rid; |
| 81 | Stmt ins; |
| 82 | Manifest *p; |
| 83 | ManifestFile *pFile; |
| 84 | |
| 85 | db_begin_transaction(); |
| 86 | p = manifest_get(vid, CFTYPE_MANIFEST); |
| @@ -87,25 +87,35 @@ | |
| 87 | if( p==0 ) return; |
| 88 | db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid); |
| 89 | db_prepare(&ins, |
| 90 | "INSERT INTO vfile(vid,isexe,rid,mrid,pathname) " |
| 91 | " VALUES(:vid,:isexe,:id,:id,:name)"); |
| 92 | db_bind_int(&ins, ":vid", vid); |
| 93 | manifest_file_rewind(p); |
| 94 | while( (pFile = manifest_file_next(p,0))!=0 ){ |
| 95 | if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue; |
| 96 | rid = uuid_to_rid(pFile->zUuid, 0); |
| 97 | if( rid==0 || content_size(rid, -1)<0 ){ |
| 98 | fossil_warning("content missing for %s", pFile->zName); |
| 99 | continue; |
| 100 | } |
| 101 | db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile)); |
| 102 | db_bind_int(&ins, ":id", rid); |
| 103 | db_bind_text(&ins, ":name", pFile->zName); |
| 104 | db_step(&ins); |
| 105 | db_reset(&ins); |
| 106 | } |
| 107 | db_finalize(&ins); |
| 108 | manifest_destroy(p); |
| 109 | db_end_transaction(0); |
| 110 | } |
| 111 | |
| 112 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -75,12 +75,12 @@ | |
| 75 | |
| 76 | /* |
| 77 | ** Build a catalog of all files in a checkin. |
| 78 | */ |
| 79 | void vfile_build(int vid){ |
| 80 | int rid, size; |
| 81 | Stmt ins, ridq; |
| 82 | Manifest *p; |
| 83 | ManifestFile *pFile; |
| 84 | |
| 85 | db_begin_transaction(); |
| 86 | p = manifest_get(vid, CFTYPE_MANIFEST); |
| @@ -87,25 +87,35 @@ | |
| 87 | if( p==0 ) return; |
| 88 | db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid); |
| 89 | db_prepare(&ins, |
| 90 | "INSERT INTO vfile(vid,isexe,rid,mrid,pathname) " |
| 91 | " VALUES(:vid,:isexe,:id,:id,:name)"); |
| 92 | db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid"); |
| 93 | db_bind_int(&ins, ":vid", vid); |
| 94 | manifest_file_rewind(p); |
| 95 | while( (pFile = manifest_file_next(p,0))!=0 ){ |
| 96 | if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue; |
| 97 | db_bind_text(&ridq, ":uuid", pFile->zUuid); |
| 98 | if( db_step(&ridq)==SQLITE_ROW ){ |
| 99 | rid = db_column_int(&ridq, 0); |
| 100 | size = db_column_int(&ridq, 0); |
| 101 | }else{ |
| 102 | rid = 0; |
| 103 | size = 0; |
| 104 | } |
| 105 | db_reset(&ridq); |
| 106 | if( rid==0 || size<0 ){ |
| 107 | fossil_warning("content missing for %s", pFile->zName); |
| 108 | continue; |
| 109 | } |
| 110 | db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile)); |
| 111 | db_bind_int(&ins, ":id", rid); |
| 112 | db_bind_text(&ins, ":name", pFile->zName); |
| 113 | db_step(&ins); |
| 114 | db_reset(&ins); |
| 115 | } |
| 116 | db_finalize(&ridq); |
| 117 | db_finalize(&ins); |
| 118 | manifest_destroy(p); |
| 119 | db_end_transaction(0); |
| 120 | } |
| 121 | |
| 122 |