Fossil SCM

Use NULL rather than 0 for values in the MLINK table that are empty.

drh 2012-12-22 14:36 UTC trunk
Commit 19844445d0bd8fcb7330bd603cfd53687f367b36
2 files changed +5 +4 -3
+5
--- src/db.c
+++ src/db.c
@@ -332,10 +332,15 @@
332332
*/
333333
int db_bind_str(Stmt *pStmt, const char *zParamName, Blob *pBlob){
334334
return sqlite3_bind_text(pStmt->pStmt, paramIdx(pStmt, zParamName),
335335
blob_buffer(pBlob), blob_size(pBlob), SQLITE_STATIC);
336336
}
337
+
338
+/* Clear all bindings */
339
+int db_clear_bindings(Stmt *pStmt){
340
+ return sqlite3_clear_bindings(pStmt->pStmt);
341
+}
337342
338343
/*
339344
** Step the SQL statement. Return either SQLITE_ROW or an error code
340345
** or SQLITE_OK if the statement finishes successfully.
341346
*/
342347
--- src/db.c
+++ src/db.c
@@ -332,10 +332,15 @@
332 */
333 int db_bind_str(Stmt *pStmt, const char *zParamName, Blob *pBlob){
334 return sqlite3_bind_text(pStmt->pStmt, paramIdx(pStmt, zParamName),
335 blob_buffer(pBlob), blob_size(pBlob), SQLITE_STATIC);
336 }
 
 
 
 
 
337
338 /*
339 ** Step the SQL statement. Return either SQLITE_ROW or an error code
340 ** or SQLITE_OK if the statement finishes successfully.
341 */
342
--- src/db.c
+++ src/db.c
@@ -332,10 +332,15 @@
332 */
333 int db_bind_str(Stmt *pStmt, const char *zParamName, Blob *pBlob){
334 return sqlite3_bind_text(pStmt->pStmt, paramIdx(pStmt, zParamName),
335 blob_buffer(pBlob), blob_size(pBlob), SQLITE_STATIC);
336 }
337
338 /* Clear all bindings */
339 int db_clear_bindings(Stmt *pStmt){
340 return sqlite3_clear_bindings(pStmt->pStmt);
341 }
342
343 /*
344 ** Step the SQL statement. Return either SQLITE_ROW or an error code
345 ** or SQLITE_OK if the statement finishes successfully.
346 */
347
+4 -3
--- src/manifest.c
+++ src/manifest.c
@@ -1184,15 +1184,16 @@
11841184
}
11851185
db_static_prepare(&s1,
11861186
"INSERT INTO mlink(mid,pid,fid,fnid,pfnid,mperm)"
11871187
"VALUES(:m,:p,:f,:n,:pfn,:mp)"
11881188
);
1189
+ db_clear_bindings(&s1);
11891190
db_bind_int(&s1, ":m", mid);
1190
- db_bind_int(&s1, ":p", pid);
1191
- db_bind_int(&s1, ":f", fid);
1191
+ if( pid ) db_bind_int(&s1, ":p", pid);
1192
+ if( fid ) db_bind_int(&s1, ":f", fid);
11921193
db_bind_int(&s1, ":n", fnid);
1193
- db_bind_int(&s1, ":pfn", pfnid);
1194
+ if( pfnid) db_bind_int(&s1, ":pfn", pfnid);
11941195
db_bind_int(&s1, ":mp", mperm);
11951196
db_exec(&s1);
11961197
if( pid && fid ){
11971198
content_deltify(pid, fid, 0);
11981199
}
11991200
--- src/manifest.c
+++ src/manifest.c
@@ -1184,15 +1184,16 @@
1184 }
1185 db_static_prepare(&s1,
1186 "INSERT INTO mlink(mid,pid,fid,fnid,pfnid,mperm)"
1187 "VALUES(:m,:p,:f,:n,:pfn,:mp)"
1188 );
 
1189 db_bind_int(&s1, ":m", mid);
1190 db_bind_int(&s1, ":p", pid);
1191 db_bind_int(&s1, ":f", fid);
1192 db_bind_int(&s1, ":n", fnid);
1193 db_bind_int(&s1, ":pfn", pfnid);
1194 db_bind_int(&s1, ":mp", mperm);
1195 db_exec(&s1);
1196 if( pid && fid ){
1197 content_deltify(pid, fid, 0);
1198 }
1199
--- src/manifest.c
+++ src/manifest.c
@@ -1184,15 +1184,16 @@
1184 }
1185 db_static_prepare(&s1,
1186 "INSERT INTO mlink(mid,pid,fid,fnid,pfnid,mperm)"
1187 "VALUES(:m,:p,:f,:n,:pfn,:mp)"
1188 );
1189 db_clear_bindings(&s1);
1190 db_bind_int(&s1, ":m", mid);
1191 if( pid ) db_bind_int(&s1, ":p", pid);
1192 if( fid ) db_bind_int(&s1, ":f", fid);
1193 db_bind_int(&s1, ":n", fnid);
1194 if( pfnid) db_bind_int(&s1, ":pfn", pfnid);
1195 db_bind_int(&s1, ":mp", mperm);
1196 db_exec(&s1);
1197 if( pid && fid ){
1198 content_deltify(pid, fid, 0);
1199 }
1200

Keyboard Shortcuts

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