Fossil SCM

Fix the "files_of_checkin" virtual table so that it works correctly with delta manifests.

drh 2014-12-15 18:17 UTC fileage-enhancement
Commit 0fba2272faaba6c69938351d2eaaa59a4ad22870
1 file changed +10 -6
+10 -6
--- src/foci.c
+++ src/foci.c
@@ -46,11 +46,12 @@
4646
sqlite3_vtab base; /* Base class - must be first */
4747
};
4848
struct FociCursor {
4949
sqlite3_vtab_cursor base; /* Base class - must be first */
5050
Manifest *pMan; /* Current manifest */
51
- int iFile; /* Index of current file */
51
+ ManifestFile *pFile; /* Current file */
52
+ int iFile; /* File index */
5253
};
5354
#endif /* INTERFACE */
5455
5556
5657
/*
@@ -127,17 +128,18 @@
127128
/*
128129
** Move a focivfs cursor to the next entry in the file.
129130
*/
130131
static int fociNext(sqlite3_vtab_cursor *pCursor){
131132
FociCursor *pCsr = (FociCursor *)pCursor;
133
+ pCsr->pFile = manifest_file_next(pCsr->pMan, 0);
132134
pCsr->iFile++;
133135
return SQLITE_OK;
134136
}
135137
136138
static int fociEof(sqlite3_vtab_cursor *pCursor){
137139
FociCursor *pCsr = (FociCursor *)pCursor;
138
- return pCsr->pMan==0 || pCsr->iFile>=pCsr->pMan->nFile;
140
+ return pCsr->pFile==0;
139141
}
140142
141143
static int fociFilter(
142144
sqlite3_vtab_cursor *pCursor,
143145
int idxNum, const char *idxStr,
@@ -146,10 +148,12 @@
146148
FociCursor *pCur = (FociCursor *)pCursor;
147149
manifest_destroy(pCur->pMan);
148150
if( idxNum ){
149151
pCur->pMan = manifest_get(sqlite3_value_int(argv[0]), CFTYPE_MANIFEST, 0);
150152
pCur->iFile = 0;
153
+ manifest_file_rewind(pCur->pMan);
154
+ pCur->pFile = manifest_file_next(pCur->pMan, 0);
151155
}else{
152156
pCur->pMan = 0;
153157
pCur->iFile = 0;
154158
}
155159
return SQLITE_OK;
@@ -164,23 +168,23 @@
164168
switch( i ){
165169
case 0: /* checkinID */
166170
sqlite3_result_int(ctx, pCsr->pMan->rid);
167171
break;
168172
case 1: /* filename */
169
- sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zName, -1,
173
+ sqlite3_result_text(ctx, pCsr->pFile->zName, -1,
170174
SQLITE_TRANSIENT);
171175
break;
172176
case 2: /* uuid */
173
- sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zUuid, -1,
177
+ sqlite3_result_text(ctx, pCsr->pFile->zUuid, -1,
174178
SQLITE_TRANSIENT);
175179
break;
176180
case 3: /* previousName */
177
- sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zPrior, -1,
181
+ sqlite3_result_text(ctx, pCsr->pFile->zPrior, -1,
178182
SQLITE_TRANSIENT);
179183
break;
180184
case 4: /* perm */
181
- sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zPerm, -1,
185
+ sqlite3_result_text(ctx, pCsr->pFile->zPerm, -1,
182186
SQLITE_TRANSIENT);
183187
break;
184188
}
185189
return SQLITE_OK;
186190
}
187191
--- src/foci.c
+++ src/foci.c
@@ -46,11 +46,12 @@
46 sqlite3_vtab base; /* Base class - must be first */
47 };
48 struct FociCursor {
49 sqlite3_vtab_cursor base; /* Base class - must be first */
50 Manifest *pMan; /* Current manifest */
51 int iFile; /* Index of current file */
 
52 };
53 #endif /* INTERFACE */
54
55
56 /*
@@ -127,17 +128,18 @@
127 /*
128 ** Move a focivfs cursor to the next entry in the file.
129 */
130 static int fociNext(sqlite3_vtab_cursor *pCursor){
131 FociCursor *pCsr = (FociCursor *)pCursor;
 
132 pCsr->iFile++;
133 return SQLITE_OK;
134 }
135
136 static int fociEof(sqlite3_vtab_cursor *pCursor){
137 FociCursor *pCsr = (FociCursor *)pCursor;
138 return pCsr->pMan==0 || pCsr->iFile>=pCsr->pMan->nFile;
139 }
140
141 static int fociFilter(
142 sqlite3_vtab_cursor *pCursor,
143 int idxNum, const char *idxStr,
@@ -146,10 +148,12 @@
146 FociCursor *pCur = (FociCursor *)pCursor;
147 manifest_destroy(pCur->pMan);
148 if( idxNum ){
149 pCur->pMan = manifest_get(sqlite3_value_int(argv[0]), CFTYPE_MANIFEST, 0);
150 pCur->iFile = 0;
 
 
151 }else{
152 pCur->pMan = 0;
153 pCur->iFile = 0;
154 }
155 return SQLITE_OK;
@@ -164,23 +168,23 @@
164 switch( i ){
165 case 0: /* checkinID */
166 sqlite3_result_int(ctx, pCsr->pMan->rid);
167 break;
168 case 1: /* filename */
169 sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zName, -1,
170 SQLITE_TRANSIENT);
171 break;
172 case 2: /* uuid */
173 sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zUuid, -1,
174 SQLITE_TRANSIENT);
175 break;
176 case 3: /* previousName */
177 sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zPrior, -1,
178 SQLITE_TRANSIENT);
179 break;
180 case 4: /* perm */
181 sqlite3_result_text(ctx, pCsr->pMan->aFile[pCsr->iFile].zPerm, -1,
182 SQLITE_TRANSIENT);
183 break;
184 }
185 return SQLITE_OK;
186 }
187
--- src/foci.c
+++ src/foci.c
@@ -46,11 +46,12 @@
46 sqlite3_vtab base; /* Base class - must be first */
47 };
48 struct FociCursor {
49 sqlite3_vtab_cursor base; /* Base class - must be first */
50 Manifest *pMan; /* Current manifest */
51 ManifestFile *pFile; /* Current file */
52 int iFile; /* File index */
53 };
54 #endif /* INTERFACE */
55
56
57 /*
@@ -127,17 +128,18 @@
128 /*
129 ** Move a focivfs cursor to the next entry in the file.
130 */
131 static int fociNext(sqlite3_vtab_cursor *pCursor){
132 FociCursor *pCsr = (FociCursor *)pCursor;
133 pCsr->pFile = manifest_file_next(pCsr->pMan, 0);
134 pCsr->iFile++;
135 return SQLITE_OK;
136 }
137
138 static int fociEof(sqlite3_vtab_cursor *pCursor){
139 FociCursor *pCsr = (FociCursor *)pCursor;
140 return pCsr->pFile==0;
141 }
142
143 static int fociFilter(
144 sqlite3_vtab_cursor *pCursor,
145 int idxNum, const char *idxStr,
@@ -146,10 +148,12 @@
148 FociCursor *pCur = (FociCursor *)pCursor;
149 manifest_destroy(pCur->pMan);
150 if( idxNum ){
151 pCur->pMan = manifest_get(sqlite3_value_int(argv[0]), CFTYPE_MANIFEST, 0);
152 pCur->iFile = 0;
153 manifest_file_rewind(pCur->pMan);
154 pCur->pFile = manifest_file_next(pCur->pMan, 0);
155 }else{
156 pCur->pMan = 0;
157 pCur->iFile = 0;
158 }
159 return SQLITE_OK;
@@ -164,23 +168,23 @@
168 switch( i ){
169 case 0: /* checkinID */
170 sqlite3_result_int(ctx, pCsr->pMan->rid);
171 break;
172 case 1: /* filename */
173 sqlite3_result_text(ctx, pCsr->pFile->zName, -1,
174 SQLITE_TRANSIENT);
175 break;
176 case 2: /* uuid */
177 sqlite3_result_text(ctx, pCsr->pFile->zUuid, -1,
178 SQLITE_TRANSIENT);
179 break;
180 case 3: /* previousName */
181 sqlite3_result_text(ctx, pCsr->pFile->zPrior, -1,
182 SQLITE_TRANSIENT);
183 break;
184 case 4: /* perm */
185 sqlite3_result_text(ctx, pCsr->pFile->zPerm, -1,
186 SQLITE_TRANSIENT);
187 break;
188 }
189 return SQLITE_OK;
190 }
191

Keyboard Shortcuts

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