Fossil SCM

Inline uuid_to_rid and content_size. Saves one SQL statement per file in the checkout.

joerg 2011-03-09 00:09 trunk
Commit e0f5d4734ac825893e7feb963efd50574a17534b
1 file changed +14 -4
+14 -4
--- src/vfile.c
+++ src/vfile.c
@@ -75,12 +75,12 @@
7575
7676
/*
7777
** Build a catalog of all files in a checkin.
7878
*/
7979
void vfile_build(int vid){
80
- int rid;
81
- Stmt ins;
80
+ int rid, size;
81
+ Stmt ins, ridq;
8282
Manifest *p;
8383
ManifestFile *pFile;
8484
8585
db_begin_transaction();
8686
p = manifest_get(vid, CFTYPE_MANIFEST);
@@ -87,25 +87,35 @@
8787
if( p==0 ) return;
8888
db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
8989
db_prepare(&ins,
9090
"INSERT INTO vfile(vid,isexe,rid,mrid,pathname) "
9191
" VALUES(:vid,:isexe,:id,:id,:name)");
92
+ db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid");
9293
db_bind_int(&ins, ":vid", vid);
9394
manifest_file_rewind(p);
9495
while( (pFile = manifest_file_next(p,0))!=0 ){
9596
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 ){
98107
fossil_warning("content missing for %s", pFile->zName);
99108
continue;
100109
}
101110
db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile));
102111
db_bind_int(&ins, ":id", rid);
103112
db_bind_text(&ins, ":name", pFile->zName);
104113
db_step(&ins);
105114
db_reset(&ins);
106115
}
116
+ db_finalize(&ridq);
107117
db_finalize(&ins);
108118
manifest_destroy(p);
109119
db_end_transaction(0);
110120
}
111121
112122
--- 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

Keyboard Shortcuts

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