Fossil SCM

Fix the use of uninitialized static variables for DB statements: whenever such variable is declared initialize it with a predefined empty value.<br> Because otherwize it looks like a bug.<br> It is unclear why it did work before. Also add a few code comments for further consideration.

george 2026-06-09 01:20 UTC trunk
Commit 76e735502f02e4e53d9211133a538dd99e1aeec54b34ce99102d199c91fc10cf
+1 -1
--- src/branch.c
+++ src/branch.c
@@ -54,11 +54,11 @@
5454
** Space to hold the returned value is obtained from fossil_malloc()
5555
** and should be freed by the caller.
5656
*/
5757
char *branch_of_rid(int rid){
5858
char *zBr = 0;
59
- static Stmt q;
59
+ static Stmt q = empty_Stmt_m;
6060
db_static_prepare(&q,
6161
"SELECT value FROM tagxref"
6262
" WHERE rid=$rid AND tagid=%d"
6363
" AND tagtype>0", TAG_BRANCH);
6464
db_bind_int(&q, "$rid", rid);
6565
--- src/branch.c
+++ src/branch.c
@@ -54,11 +54,11 @@
54 ** Space to hold the returned value is obtained from fossil_malloc()
55 ** and should be freed by the caller.
56 */
57 char *branch_of_rid(int rid){
58 char *zBr = 0;
59 static Stmt q;
60 db_static_prepare(&q,
61 "SELECT value FROM tagxref"
62 " WHERE rid=$rid AND tagid=%d"
63 " AND tagtype>0", TAG_BRANCH);
64 db_bind_int(&q, "$rid", rid);
65
--- src/branch.c
+++ src/branch.c
@@ -54,11 +54,11 @@
54 ** Space to hold the returned value is obtained from fossil_malloc()
55 ** and should be freed by the caller.
56 */
57 char *branch_of_rid(int rid){
58 char *zBr = 0;
59 static Stmt q = empty_Stmt_m;
60 db_static_prepare(&q,
61 "SELECT value FROM tagxref"
62 " WHERE rid=$rid AND tagid=%d"
63 " AND tagtype>0", TAG_BRANCH);
64 db_bind_int(&q, "$rid", rid);
65
+1 -1
--- src/checkout.c
+++ src/checkout.c
@@ -118,11 +118,11 @@
118118
119119
/*
120120
** Set or clear the vfile.isexe flag for a file.
121121
*/
122122
static void set_or_clear_isexe(const char *zFilename, int vid, int onoff){
123
- static Stmt s;
123
+ static Stmt s = empty_Stmt_m;
124124
db_static_prepare(&s,
125125
"UPDATE vfile SET isexe=:isexe"
126126
" WHERE vid=:vid AND pathname=:path AND isexe!=:isexe"
127127
);
128128
db_bind_int(&s, ":isexe", onoff);
129129
--- src/checkout.c
+++ src/checkout.c
@@ -118,11 +118,11 @@
118
119 /*
120 ** Set or clear the vfile.isexe flag for a file.
121 */
122 static void set_or_clear_isexe(const char *zFilename, int vid, int onoff){
123 static Stmt s;
124 db_static_prepare(&s,
125 "UPDATE vfile SET isexe=:isexe"
126 " WHERE vid=:vid AND pathname=:path AND isexe!=:isexe"
127 );
128 db_bind_int(&s, ":isexe", onoff);
129
--- src/checkout.c
+++ src/checkout.c
@@ -118,11 +118,11 @@
118
119 /*
120 ** Set or clear the vfile.isexe flag for a file.
121 */
122 static void set_or_clear_isexe(const char *zFilename, int vid, int onoff){
123 static Stmt s = empty_Stmt_m;
124 db_static_prepare(&s,
125 "UPDATE vfile SET isexe=:isexe"
126 " WHERE vid=:vid AND pathname=:path AND isexe!=:isexe"
127 );
128 db_bind_int(&s, ":isexe", onoff);
129
+8 -8
--- src/content.c
+++ src/content.c
@@ -125,11 +125,11 @@
125125
/*
126126
** Return the srcid associated with rid. Or return 0 if rid is
127127
** original content and not a delta.
128128
*/
129129
int delta_source_rid(int rid){
130
- static Stmt q;
130
+ static Stmt q = empty_Stmt_m;
131131
int srcid;
132132
db_static_prepare(&q, "SELECT srcid FROM delta WHERE rid=:rid");
133133
db_bind_int(&q, ":rid", rid);
134134
if( db_step(&q)==SQLITE_ROW ){
135135
srcid = db_column_int(&q, 0);
@@ -142,11 +142,11 @@
142142
143143
/*
144144
** Return the blob.size field given blob.rid
145145
*/
146146
int content_size(int rid, int dflt){
147
- static Stmt q;
147
+ static Stmt q = empty_Stmt_m;
148148
int sz = dflt;
149149
db_static_prepare(&q, "SELECT size FROM blob WHERE rid=:r");
150150
db_bind_int(&q, ":r", rid);
151151
if( db_step(&q)==SQLITE_ROW ){
152152
sz = db_column_int(&q, 0);
@@ -190,11 +190,11 @@
190190
** show that everything that was formerly unavailable because rid
191191
** was missing is now available.
192192
*/
193193
static void content_mark_available(int rid){
194194
Bag pending;
195
- static Stmt q;
195
+ static Stmt q = empty_Stmt_m;
196196
if( bag_find(&contentCache.available, rid) ) return;
197197
bag_init(&pending);
198198
bag_insert(&pending, rid);
199199
while( (rid = bag_first(&pending))!=0 ){
200200
bag_remove(&pending, rid);
@@ -214,11 +214,11 @@
214214
/*
215215
** Get the blob.content value for blob.rid=rid. Return 1 on success or
216216
** 0 on failure.
217217
*/
218218
static int content_of_blob(int rid, Blob *pBlob){
219
- static Stmt q;
219
+ static Stmt q = empty_Stmt_m;
220220
int rc = 0;
221221
db_static_prepare(&q, "SELECT content FROM blob WHERE rid=:rid AND size>=0");
222222
db_bind_int(&q, ":rid", rid);
223223
if( db_step(&q)==SQLITE_ROW ){
224224
db_ephemeral_blob(&q, 0, pBlob);
@@ -784,11 +784,11 @@
784784
785785
/*
786786
** Return true if the given RID is marked as PRIVATE.
787787
*/
788788
int content_is_private(int rid){
789
- static Stmt s1;
789
+ static Stmt s1 = empty_Stmt_m;
790790
int rc;
791791
db_static_prepare(&s1,
792792
"SELECT 1 FROM private WHERE rid=:rid"
793793
);
794794
db_bind_int(&s1, ":rid", rid);
@@ -799,11 +799,11 @@
799799
800800
/*
801801
** Make sure an artifact is public.
802802
*/
803803
void content_make_public(int rid){
804
- static Stmt s1;
804
+ static Stmt s1 = empty_Stmt_m;
805805
db_static_prepare(&s1,
806806
"DELETE FROM private WHERE rid=:rid"
807807
);
808808
db_bind_int(&s1, ":rid", rid);
809809
db_exec(&s1);
@@ -811,11 +811,11 @@
811811
812812
/*
813813
** Make sure an artifact is private
814814
*/
815815
void content_make_private(int rid){
816
- static Stmt s1;
816
+ static Stmt s1 = empty_Stmt_m;
817817
db_static_prepare(&s1,
818818
"INSERT OR IGNORE INTO private(rid) VALUES(:rid)"
819819
);
820820
db_bind_int(&s1, ":rid", rid);
821821
db_exec(&s1);
@@ -1164,11 +1164,11 @@
11641164
unsigned flags, /* Flags */
11651165
Manifest *p, /* The control artifact that references zUuid */
11661166
const char *zRole, /* Role of zUuid in p */
11671167
const char *zDetail /* Additional information, such as a filename */
11681168
){
1169
- static Stmt q;
1169
+ static Stmt q = empty_Stmt_m;
11701170
int rc = 0;
11711171
11721172
db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=:uuid");
11731173
if( zUuid==0 || zUuid[0]==0 ) return 0;
11741174
db_bind_text(&q, ":uuid", zUuid);
11751175
--- src/content.c
+++ src/content.c
@@ -125,11 +125,11 @@
125 /*
126 ** Return the srcid associated with rid. Or return 0 if rid is
127 ** original content and not a delta.
128 */
129 int delta_source_rid(int rid){
130 static Stmt q;
131 int srcid;
132 db_static_prepare(&q, "SELECT srcid FROM delta WHERE rid=:rid");
133 db_bind_int(&q, ":rid", rid);
134 if( db_step(&q)==SQLITE_ROW ){
135 srcid = db_column_int(&q, 0);
@@ -142,11 +142,11 @@
142
143 /*
144 ** Return the blob.size field given blob.rid
145 */
146 int content_size(int rid, int dflt){
147 static Stmt q;
148 int sz = dflt;
149 db_static_prepare(&q, "SELECT size FROM blob WHERE rid=:r");
150 db_bind_int(&q, ":r", rid);
151 if( db_step(&q)==SQLITE_ROW ){
152 sz = db_column_int(&q, 0);
@@ -190,11 +190,11 @@
190 ** show that everything that was formerly unavailable because rid
191 ** was missing is now available.
192 */
193 static void content_mark_available(int rid){
194 Bag pending;
195 static Stmt q;
196 if( bag_find(&contentCache.available, rid) ) return;
197 bag_init(&pending);
198 bag_insert(&pending, rid);
199 while( (rid = bag_first(&pending))!=0 ){
200 bag_remove(&pending, rid);
@@ -214,11 +214,11 @@
214 /*
215 ** Get the blob.content value for blob.rid=rid. Return 1 on success or
216 ** 0 on failure.
217 */
218 static int content_of_blob(int rid, Blob *pBlob){
219 static Stmt q;
220 int rc = 0;
221 db_static_prepare(&q, "SELECT content FROM blob WHERE rid=:rid AND size>=0");
222 db_bind_int(&q, ":rid", rid);
223 if( db_step(&q)==SQLITE_ROW ){
224 db_ephemeral_blob(&q, 0, pBlob);
@@ -784,11 +784,11 @@
784
785 /*
786 ** Return true if the given RID is marked as PRIVATE.
787 */
788 int content_is_private(int rid){
789 static Stmt s1;
790 int rc;
791 db_static_prepare(&s1,
792 "SELECT 1 FROM private WHERE rid=:rid"
793 );
794 db_bind_int(&s1, ":rid", rid);
@@ -799,11 +799,11 @@
799
800 /*
801 ** Make sure an artifact is public.
802 */
803 void content_make_public(int rid){
804 static Stmt s1;
805 db_static_prepare(&s1,
806 "DELETE FROM private WHERE rid=:rid"
807 );
808 db_bind_int(&s1, ":rid", rid);
809 db_exec(&s1);
@@ -811,11 +811,11 @@
811
812 /*
813 ** Make sure an artifact is private
814 */
815 void content_make_private(int rid){
816 static Stmt s1;
817 db_static_prepare(&s1,
818 "INSERT OR IGNORE INTO private(rid) VALUES(:rid)"
819 );
820 db_bind_int(&s1, ":rid", rid);
821 db_exec(&s1);
@@ -1164,11 +1164,11 @@
1164 unsigned flags, /* Flags */
1165 Manifest *p, /* The control artifact that references zUuid */
1166 const char *zRole, /* Role of zUuid in p */
1167 const char *zDetail /* Additional information, such as a filename */
1168 ){
1169 static Stmt q;
1170 int rc = 0;
1171
1172 db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=:uuid");
1173 if( zUuid==0 || zUuid[0]==0 ) return 0;
1174 db_bind_text(&q, ":uuid", zUuid);
1175
--- src/content.c
+++ src/content.c
@@ -125,11 +125,11 @@
125 /*
126 ** Return the srcid associated with rid. Or return 0 if rid is
127 ** original content and not a delta.
128 */
129 int delta_source_rid(int rid){
130 static Stmt q = empty_Stmt_m;
131 int srcid;
132 db_static_prepare(&q, "SELECT srcid FROM delta WHERE rid=:rid");
133 db_bind_int(&q, ":rid", rid);
134 if( db_step(&q)==SQLITE_ROW ){
135 srcid = db_column_int(&q, 0);
@@ -142,11 +142,11 @@
142
143 /*
144 ** Return the blob.size field given blob.rid
145 */
146 int content_size(int rid, int dflt){
147 static Stmt q = empty_Stmt_m;
148 int sz = dflt;
149 db_static_prepare(&q, "SELECT size FROM blob WHERE rid=:r");
150 db_bind_int(&q, ":r", rid);
151 if( db_step(&q)==SQLITE_ROW ){
152 sz = db_column_int(&q, 0);
@@ -190,11 +190,11 @@
190 ** show that everything that was formerly unavailable because rid
191 ** was missing is now available.
192 */
193 static void content_mark_available(int rid){
194 Bag pending;
195 static Stmt q = empty_Stmt_m;
196 if( bag_find(&contentCache.available, rid) ) return;
197 bag_init(&pending);
198 bag_insert(&pending, rid);
199 while( (rid = bag_first(&pending))!=0 ){
200 bag_remove(&pending, rid);
@@ -214,11 +214,11 @@
214 /*
215 ** Get the blob.content value for blob.rid=rid. Return 1 on success or
216 ** 0 on failure.
217 */
218 static int content_of_blob(int rid, Blob *pBlob){
219 static Stmt q = empty_Stmt_m;
220 int rc = 0;
221 db_static_prepare(&q, "SELECT content FROM blob WHERE rid=:rid AND size>=0");
222 db_bind_int(&q, ":rid", rid);
223 if( db_step(&q)==SQLITE_ROW ){
224 db_ephemeral_blob(&q, 0, pBlob);
@@ -784,11 +784,11 @@
784
785 /*
786 ** Return true if the given RID is marked as PRIVATE.
787 */
788 int content_is_private(int rid){
789 static Stmt s1 = empty_Stmt_m;
790 int rc;
791 db_static_prepare(&s1,
792 "SELECT 1 FROM private WHERE rid=:rid"
793 );
794 db_bind_int(&s1, ":rid", rid);
@@ -799,11 +799,11 @@
799
800 /*
801 ** Make sure an artifact is public.
802 */
803 void content_make_public(int rid){
804 static Stmt s1 = empty_Stmt_m;
805 db_static_prepare(&s1,
806 "DELETE FROM private WHERE rid=:rid"
807 );
808 db_bind_int(&s1, ":rid", rid);
809 db_exec(&s1);
@@ -811,11 +811,11 @@
811
812 /*
813 ** Make sure an artifact is private
814 */
815 void content_make_private(int rid){
816 static Stmt s1 = empty_Stmt_m;
817 db_static_prepare(&s1,
818 "INSERT OR IGNORE INTO private(rid) VALUES(:rid)"
819 );
820 db_bind_int(&s1, ":rid", rid);
821 db_exec(&s1);
@@ -1164,11 +1164,11 @@
1164 unsigned flags, /* Flags */
1165 Manifest *p, /* The control artifact that references zUuid */
1166 const char *zRole, /* Role of zUuid in p */
1167 const char *zDetail /* Additional information, such as a filename */
1168 ){
1169 static Stmt q = empty_Stmt_m;
1170 int rc = 0;
1171
1172 db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=:uuid");
1173 if( zUuid==0 || zUuid[0]==0 ) return 0;
1174 db_bind_text(&q, ":uuid", zUuid);
1175
+4 -4
--- src/db.c
+++ src/db.c
@@ -3780,21 +3780,21 @@
37803780
*/
37813781
char *db_get(const char *zName, const char *zDefault){
37823782
char *z = 0;
37833783
const Setting *pSetting = db_find_setting(zName, 0);
37843784
if( g.repositoryOpen ){
3785
- static Stmt q1;
3785
+ static Stmt q1 = empty_Stmt_m;
37863786
const char *zRes;
37873787
db_static_prepare(&q1, "SELECT value FROM config WHERE name=$n");
37883788
db_bind_text(&q1, "$n", zName);
37893789
if( db_step(&q1)==SQLITE_ROW && (zRes = db_column_text(&q1,0))!=0 ){
37903790
z = fossil_strdup(zRes);
37913791
}
37923792
db_reset(&q1);
37933793
}
37943794
if( z==0 && g.zConfigDbName ){
3795
- static Stmt q2;
3795
+ static Stmt q2 = empty_Stmt_m;
37963796
const char *zRes;
37973797
db_swap_connections();
37983798
db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n");
37993799
db_swap_connections();
38003800
db_bind_text(&q2, "$n", zName);
@@ -3890,11 +3890,11 @@
38903890
}
38913891
int db_get_int(const char *zName, int dflt){
38923892
int v = dflt;
38933893
int rc;
38943894
if( g.repositoryOpen ){
3895
- static Stmt q;
3895
+ static Stmt q = empty_Stmt_m;
38963896
db_static_prepare(&q, "SELECT value FROM config WHERE name=$n");
38973897
db_bind_text(&q, "$n", zName);
38983898
rc = db_step(&q);
38993899
if( rc==SQLITE_ROW ){
39003900
v = db_column_int(&q, 0);
@@ -3902,11 +3902,11 @@
39023902
db_reset(&q);
39033903
}else{
39043904
rc = SQLITE_DONE;
39053905
}
39063906
if( rc==SQLITE_DONE && g.zConfigDbName ){
3907
- static Stmt q2;
3907
+ static Stmt q2 = empty_Stmt_m;
39083908
db_swap_connections();
39093909
db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n");
39103910
db_swap_connections();
39113911
db_bind_text(&q2, "$n", zName);
39123912
if( db_step(&q2)==SQLITE_ROW ){
39133913
--- src/db.c
+++ src/db.c
@@ -3780,21 +3780,21 @@
3780 */
3781 char *db_get(const char *zName, const char *zDefault){
3782 char *z = 0;
3783 const Setting *pSetting = db_find_setting(zName, 0);
3784 if( g.repositoryOpen ){
3785 static Stmt q1;
3786 const char *zRes;
3787 db_static_prepare(&q1, "SELECT value FROM config WHERE name=$n");
3788 db_bind_text(&q1, "$n", zName);
3789 if( db_step(&q1)==SQLITE_ROW && (zRes = db_column_text(&q1,0))!=0 ){
3790 z = fossil_strdup(zRes);
3791 }
3792 db_reset(&q1);
3793 }
3794 if( z==0 && g.zConfigDbName ){
3795 static Stmt q2;
3796 const char *zRes;
3797 db_swap_connections();
3798 db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n");
3799 db_swap_connections();
3800 db_bind_text(&q2, "$n", zName);
@@ -3890,11 +3890,11 @@
3890 }
3891 int db_get_int(const char *zName, int dflt){
3892 int v = dflt;
3893 int rc;
3894 if( g.repositoryOpen ){
3895 static Stmt q;
3896 db_static_prepare(&q, "SELECT value FROM config WHERE name=$n");
3897 db_bind_text(&q, "$n", zName);
3898 rc = db_step(&q);
3899 if( rc==SQLITE_ROW ){
3900 v = db_column_int(&q, 0);
@@ -3902,11 +3902,11 @@
3902 db_reset(&q);
3903 }else{
3904 rc = SQLITE_DONE;
3905 }
3906 if( rc==SQLITE_DONE && g.zConfigDbName ){
3907 static Stmt q2;
3908 db_swap_connections();
3909 db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n");
3910 db_swap_connections();
3911 db_bind_text(&q2, "$n", zName);
3912 if( db_step(&q2)==SQLITE_ROW ){
3913
--- src/db.c
+++ src/db.c
@@ -3780,21 +3780,21 @@
3780 */
3781 char *db_get(const char *zName, const char *zDefault){
3782 char *z = 0;
3783 const Setting *pSetting = db_find_setting(zName, 0);
3784 if( g.repositoryOpen ){
3785 static Stmt q1 = empty_Stmt_m;
3786 const char *zRes;
3787 db_static_prepare(&q1, "SELECT value FROM config WHERE name=$n");
3788 db_bind_text(&q1, "$n", zName);
3789 if( db_step(&q1)==SQLITE_ROW && (zRes = db_column_text(&q1,0))!=0 ){
3790 z = fossil_strdup(zRes);
3791 }
3792 db_reset(&q1);
3793 }
3794 if( z==0 && g.zConfigDbName ){
3795 static Stmt q2 = empty_Stmt_m;
3796 const char *zRes;
3797 db_swap_connections();
3798 db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n");
3799 db_swap_connections();
3800 db_bind_text(&q2, "$n", zName);
@@ -3890,11 +3890,11 @@
3890 }
3891 int db_get_int(const char *zName, int dflt){
3892 int v = dflt;
3893 int rc;
3894 if( g.repositoryOpen ){
3895 static Stmt q = empty_Stmt_m;
3896 db_static_prepare(&q, "SELECT value FROM config WHERE name=$n");
3897 db_bind_text(&q, "$n", zName);
3898 rc = db_step(&q);
3899 if( rc==SQLITE_ROW ){
3900 v = db_column_int(&q, 0);
@@ -3902,11 +3902,11 @@
3902 db_reset(&q);
3903 }else{
3904 rc = SQLITE_DONE;
3905 }
3906 if( rc==SQLITE_DONE && g.zConfigDbName ){
3907 static Stmt q2 = empty_Stmt_m;
3908 db_swap_connections();
3909 db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n");
3910 db_swap_connections();
3911 db_bind_text(&q2, "$n", zName);
3912 if( db_step(&q2)==SQLITE_ROW ){
3913
--- src/descendants.c
+++ src/descendants.c
@@ -162,11 +162,11 @@
162162
/*
163163
** If RID refers to a check-in, return the mtime of that check-in - the
164164
** Julian day number of when the check-in occurred.
165165
*/
166166
double mtime_of_rid(int rid, double mtime){
167
- static Stmt q;
167
+ static Stmt q = empty_Stmt_m;
168168
db_static_prepare(&q,"SELECT mtime FROM event WHERE objid=:rid");
169169
db_bind_int(&q, ":rid", rid);
170170
if( db_step(&q)==SQLITE_ROW ){
171171
mtime = db_column_double(&q,0);
172172
}
@@ -302,11 +302,11 @@
302302
int vid, /* The check-in that contains fid */
303303
int fid, /* The id of the file whose check-in time is sought */
304304
i64 *pMTime /* Write result here */
305305
){
306306
static int prevVid = -1;
307
- static Stmt q;
307
+ static Stmt q = empty_Stmt_m;
308308
309309
if( prevVid!=vid ){
310310
prevVid = vid;
311311
db_multi_exec("CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
312312
"DELETE FROM ok;");
313313
--- src/descendants.c
+++ src/descendants.c
@@ -162,11 +162,11 @@
162 /*
163 ** If RID refers to a check-in, return the mtime of that check-in - the
164 ** Julian day number of when the check-in occurred.
165 */
166 double mtime_of_rid(int rid, double mtime){
167 static Stmt q;
168 db_static_prepare(&q,"SELECT mtime FROM event WHERE objid=:rid");
169 db_bind_int(&q, ":rid", rid);
170 if( db_step(&q)==SQLITE_ROW ){
171 mtime = db_column_double(&q,0);
172 }
@@ -302,11 +302,11 @@
302 int vid, /* The check-in that contains fid */
303 int fid, /* The id of the file whose check-in time is sought */
304 i64 *pMTime /* Write result here */
305 ){
306 static int prevVid = -1;
307 static Stmt q;
308
309 if( prevVid!=vid ){
310 prevVid = vid;
311 db_multi_exec("CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
312 "DELETE FROM ok;");
313
--- src/descendants.c
+++ src/descendants.c
@@ -162,11 +162,11 @@
162 /*
163 ** If RID refers to a check-in, return the mtime of that check-in - the
164 ** Julian day number of when the check-in occurred.
165 */
166 double mtime_of_rid(int rid, double mtime){
167 static Stmt q = empty_Stmt_m;
168 db_static_prepare(&q,"SELECT mtime FROM event WHERE objid=:rid");
169 db_bind_int(&q, ":rid", rid);
170 if( db_step(&q)==SQLITE_ROW ){
171 mtime = db_column_double(&q,0);
172 }
@@ -302,11 +302,11 @@
302 int vid, /* The check-in that contains fid */
303 int fid, /* The id of the file whose check-in time is sought */
304 i64 *pMTime /* Write result here */
305 ){
306 static int prevVid = -1;
307 static Stmt q = empty_Stmt_m;
308
309 if( prevVid!=vid ){
310 prevVid = vid;
311 db_multi_exec("CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
312 "DELETE FROM ok;");
313
+1 -1
--- src/export.c
+++ src/export.c
@@ -43,11 +43,11 @@
4343
/*
4444
** Output a "committer" record for the given user.
4545
** NOTE: the given user name may be an email itself.
4646
*/
4747
static void print_person(const char *zUser){
48
- static Stmt q;
48
+ static Stmt q = empty_Stmt_m;
4949
const char *zContact;
5050
char *zName;
5151
char *zEmail;
5252
int i, j;
5353
int isBracketed, atEmailFirst, atEmailLast;
5454
--- src/export.c
+++ src/export.c
@@ -43,11 +43,11 @@
43 /*
44 ** Output a "committer" record for the given user.
45 ** NOTE: the given user name may be an email itself.
46 */
47 static void print_person(const char *zUser){
48 static Stmt q;
49 const char *zContact;
50 char *zName;
51 char *zEmail;
52 int i, j;
53 int isBracketed, atEmailFirst, atEmailLast;
54
--- src/export.c
+++ src/export.c
@@ -43,11 +43,11 @@
43 /*
44 ** Output a "committer" record for the given user.
45 ** NOTE: the given user name may be an email itself.
46 */
47 static void print_person(const char *zUser){
48 static Stmt q = empty_Stmt_m;
49 const char *zContact;
50 char *zName;
51 char *zEmail;
52 int i, j;
53 int isBracketed, atEmailFirst, atEmailLast;
54
+4 -4
--- src/forum.c
+++ src/forum.c
@@ -188,11 +188,11 @@
188188
/*
189189
** Return true if the forum post with the given rid has been
190190
** subsequently edited.
191191
*/
192192
int forum_rid_has_been_edited(int rid){
193
- static Stmt q;
193
+ static Stmt q = empty_Stmt_m;
194194
int res;
195195
db_static_prepare(&q,
196196
"SELECT 1 FROM forumpost A, forumpost B"
197197
" WHERE A.fpid=$rid AND B.froot=A.froot AND B.fprev=$rid"
198198
);
@@ -244,11 +244,11 @@
244244
** matches the event.(euser,user) field for a formpost entry with the
245245
** matching RID. Returns false if no match is found. If zUserName is
246246
** 0 then login_name() is used.
247247
*/
248248
int forumpost_is_owner(int rid, const char *zUserName){
249
- static Stmt q;
249
+ static Stmt q = empty_Stmt_m;
250250
int rc;
251251
if( !q.pStmt ){
252252
db_static_prepare(
253253
&q, "SELECT 1 FROM event"
254254
" WHERE type='f' AND objid=$rid"
@@ -991,11 +991,11 @@
991991
**
992992
** HTML markup within the reply has been property escaped. Hyperlinks
993993
** may have been added. The result is safe for use with %s.
994994
*/
995995
static char *display_name_from_login(const char *zLogin){
996
- static Stmt q;
996
+ static Stmt q = empty_Stmt_m;
997997
char *zResult;
998998
db_static_prepare(&q,
999999
"SELECT display_name(info) FROM user WHERE login=$login"
10001000
);
10011001
db_bind_text(&q, "$login", zLogin);
@@ -2426,11 +2426,11 @@
24262426
static void forum_status_match(
24272427
sqlite3_context *context,
24282428
int argc,
24292429
sqlite3_value **argv
24302430
){
2431
- static Stmt q;
2431
+ static Stmt q = empty_Stmt_m;
24322432
ForumStatusMatch *pMData = sqlite3_user_data(context);
24332433
int i;
24342434
24352435
if( pMData==0 ){
24362436
sqlite3_result_int(context, 1);
24372437
--- src/forum.c
+++ src/forum.c
@@ -188,11 +188,11 @@
188 /*
189 ** Return true if the forum post with the given rid has been
190 ** subsequently edited.
191 */
192 int forum_rid_has_been_edited(int rid){
193 static Stmt q;
194 int res;
195 db_static_prepare(&q,
196 "SELECT 1 FROM forumpost A, forumpost B"
197 " WHERE A.fpid=$rid AND B.froot=A.froot AND B.fprev=$rid"
198 );
@@ -244,11 +244,11 @@
244 ** matches the event.(euser,user) field for a formpost entry with the
245 ** matching RID. Returns false if no match is found. If zUserName is
246 ** 0 then login_name() is used.
247 */
248 int forumpost_is_owner(int rid, const char *zUserName){
249 static Stmt q;
250 int rc;
251 if( !q.pStmt ){
252 db_static_prepare(
253 &q, "SELECT 1 FROM event"
254 " WHERE type='f' AND objid=$rid"
@@ -991,11 +991,11 @@
991 **
992 ** HTML markup within the reply has been property escaped. Hyperlinks
993 ** may have been added. The result is safe for use with %s.
994 */
995 static char *display_name_from_login(const char *zLogin){
996 static Stmt q;
997 char *zResult;
998 db_static_prepare(&q,
999 "SELECT display_name(info) FROM user WHERE login=$login"
1000 );
1001 db_bind_text(&q, "$login", zLogin);
@@ -2426,11 +2426,11 @@
2426 static void forum_status_match(
2427 sqlite3_context *context,
2428 int argc,
2429 sqlite3_value **argv
2430 ){
2431 static Stmt q;
2432 ForumStatusMatch *pMData = sqlite3_user_data(context);
2433 int i;
2434
2435 if( pMData==0 ){
2436 sqlite3_result_int(context, 1);
2437
--- src/forum.c
+++ src/forum.c
@@ -188,11 +188,11 @@
188 /*
189 ** Return true if the forum post with the given rid has been
190 ** subsequently edited.
191 */
192 int forum_rid_has_been_edited(int rid){
193 static Stmt q = empty_Stmt_m;
194 int res;
195 db_static_prepare(&q,
196 "SELECT 1 FROM forumpost A, forumpost B"
197 " WHERE A.fpid=$rid AND B.froot=A.froot AND B.fprev=$rid"
198 );
@@ -244,11 +244,11 @@
244 ** matches the event.(euser,user) field for a formpost entry with the
245 ** matching RID. Returns false if no match is found. If zUserName is
246 ** 0 then login_name() is used.
247 */
248 int forumpost_is_owner(int rid, const char *zUserName){
249 static Stmt q = empty_Stmt_m;
250 int rc;
251 if( !q.pStmt ){
252 db_static_prepare(
253 &q, "SELECT 1 FROM event"
254 " WHERE type='f' AND objid=$rid"
@@ -991,11 +991,11 @@
991 **
992 ** HTML markup within the reply has been property escaped. Hyperlinks
993 ** may have been added. The result is safe for use with %s.
994 */
995 static char *display_name_from_login(const char *zLogin){
996 static Stmt q = empty_Stmt_m;
997 char *zResult;
998 db_static_prepare(&q,
999 "SELECT display_name(info) FROM user WHERE login=$login"
1000 );
1001 db_bind_text(&q, "$login", zLogin);
@@ -2426,11 +2426,11 @@
2426 static void forum_status_match(
2427 sqlite3_context *context,
2428 int argc,
2429 sqlite3_value **argv
2430 ){
2431 static Stmt q = empty_Stmt_m;
2432 ForumStatusMatch *pMData = sqlite3_user_data(context);
2433 int i;
2434
2435 if( pMData==0 ){
2436 sqlite3_result_int(context, 1);
2437
+1 -1
--- src/fusefs.c
+++ src/fusefs.c
@@ -149,11 +149,11 @@
149149
fusefs_load_rid(rid, fusefs.az[1]);
150150
if( fusefs.pMan==0 ) return -ENOENT;
151151
stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
152152
pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 0);
153153
if( pFile ){
154
- static Stmt q;
154
+ static Stmt q = empty_Stmt_m;
155155
stbuf->st_mode = S_IFREG |
156156
(manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
157157
stbuf->st_nlink = 1;
158158
db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
159159
db_bind_text(&q, "$uuid", pFile->zUuid);
160160
--- src/fusefs.c
+++ src/fusefs.c
@@ -149,11 +149,11 @@
149 fusefs_load_rid(rid, fusefs.az[1]);
150 if( fusefs.pMan==0 ) return -ENOENT;
151 stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
152 pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 0);
153 if( pFile ){
154 static Stmt q;
155 stbuf->st_mode = S_IFREG |
156 (manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
157 stbuf->st_nlink = 1;
158 db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
159 db_bind_text(&q, "$uuid", pFile->zUuid);
160
--- src/fusefs.c
+++ src/fusefs.c
@@ -149,11 +149,11 @@
149 fusefs_load_rid(rid, fusefs.az[1]);
150 if( fusefs.pMan==0 ) return -ENOENT;
151 stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
152 pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 0);
153 if( pFile ){
154 static Stmt q = empty_Stmt_m;
155 stbuf->st_mode = S_IFREG |
156 (manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
157 stbuf->st_nlink = 1;
158 db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
159 db_bind_text(&q, "$uuid", pFile->zUuid);
160
+4 -4
--- src/import.c
+++ src/import.c
@@ -139,11 +139,11 @@
139139
int rid;
140140
141141
hname_hash(pContent, 0, &hash);
142142
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &hash);
143143
if( rid==0 ){
144
- static Stmt ins;
144
+ static Stmt ins = empty_Stmt_m;
145145
assert( g.rcvid>0 );
146146
db_static_prepare(&ins,
147147
"INSERT INTO blob(uuid, size, rcvid, content)"
148148
"VALUES(:uuid, :size, %d, :content)", g.rcvid
149149
);
@@ -1024,13 +1024,13 @@
10241024
10251025
#define MAX_INT_32 (0x7FFFFFFFL)
10261026
10271027
static void svn_finish_revision(){
10281028
Blob manifest;
1029
- static Stmt getChanges;
1030
- static Stmt getFiles;
1031
- static Stmt setRid;
1029
+ static Stmt getChanges = empty_Stmt_m;
1030
+ static Stmt getFiles = empty_Stmt_m;
1031
+ static Stmt setRid = empty_Stmt_m;
10321032
Blob mcksum;
10331033
10341034
blob_zero(&manifest);
10351035
db_static_prepare(&getChanges, "SELECT tid, tname, ttype, tparent"
10361036
" FROM xrevisions, xbranches ON (tbranch=tid)"
10371037
--- src/import.c
+++ src/import.c
@@ -139,11 +139,11 @@
139 int rid;
140
141 hname_hash(pContent, 0, &hash);
142 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &hash);
143 if( rid==0 ){
144 static Stmt ins;
145 assert( g.rcvid>0 );
146 db_static_prepare(&ins,
147 "INSERT INTO blob(uuid, size, rcvid, content)"
148 "VALUES(:uuid, :size, %d, :content)", g.rcvid
149 );
@@ -1024,13 +1024,13 @@
1024
1025 #define MAX_INT_32 (0x7FFFFFFFL)
1026
1027 static void svn_finish_revision(){
1028 Blob manifest;
1029 static Stmt getChanges;
1030 static Stmt getFiles;
1031 static Stmt setRid;
1032 Blob mcksum;
1033
1034 blob_zero(&manifest);
1035 db_static_prepare(&getChanges, "SELECT tid, tname, ttype, tparent"
1036 " FROM xrevisions, xbranches ON (tbranch=tid)"
1037
--- src/import.c
+++ src/import.c
@@ -139,11 +139,11 @@
139 int rid;
140
141 hname_hash(pContent, 0, &hash);
142 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &hash);
143 if( rid==0 ){
144 static Stmt ins = empty_Stmt_m;
145 assert( g.rcvid>0 );
146 db_static_prepare(&ins,
147 "INSERT INTO blob(uuid, size, rcvid, content)"
148 "VALUES(:uuid, :size, %d, :content)", g.rcvid
149 );
@@ -1024,13 +1024,13 @@
1024
1025 #define MAX_INT_32 (0x7FFFFFFFL)
1026
1027 static void svn_finish_revision(){
1028 Blob manifest;
1029 static Stmt getChanges = empty_Stmt_m;
1030 static Stmt getFiles = empty_Stmt_m;
1031 static Stmt setRid = empty_Stmt_m;
1032 Blob mcksum;
1033
1034 blob_zero(&manifest);
1035 db_static_prepare(&getChanges, "SELECT tid, tname, ttype, tparent"
1036 " FROM xrevisions, xbranches ON (tbranch=tid)"
1037
+1 -1
--- src/interwiki.c
+++ src/interwiki.c
@@ -75,11 +75,11 @@
7575
int i;
7676
const char *zPage;
7777
int nPage;
7878
char *zUrl = 0;
7979
char *zName;
80
- static Stmt q;
80
+ static Stmt q = empty_Stmt_m;
8181
for(i=0; fossil_isalnum(zTarget[i]); i++){}
8282
if( zTarget[i]!=':' ) return 0;
8383
nCode = i;
8484
if( nCode==4 && strncmp(zTarget,"wiki",4)==0 ) return 0;
8585
zPage = zTarget + nCode + 1;
8686
--- src/interwiki.c
+++ src/interwiki.c
@@ -75,11 +75,11 @@
75 int i;
76 const char *zPage;
77 int nPage;
78 char *zUrl = 0;
79 char *zName;
80 static Stmt q;
81 for(i=0; fossil_isalnum(zTarget[i]); i++){}
82 if( zTarget[i]!=':' ) return 0;
83 nCode = i;
84 if( nCode==4 && strncmp(zTarget,"wiki",4)==0 ) return 0;
85 zPage = zTarget + nCode + 1;
86
--- src/interwiki.c
+++ src/interwiki.c
@@ -75,11 +75,11 @@
75 int i;
76 const char *zPage;
77 int nPage;
78 char *zUrl = 0;
79 char *zName;
80 static Stmt q = empty_Stmt_m;
81 for(i=0; fossil_isalnum(zTarget[i]); i++){}
82 if( zTarget[i]!=':' ) return 0;
83 nCode = i;
84 if( nCode==4 && strncmp(zTarget,"wiki",4)==0 ) return 0;
85 zPage = zTarget + nCode + 1;
86
+5 -5
--- src/leaf.c
+++ src/leaf.c
@@ -55,11 +55,11 @@
5555
**
5656
** A non-branch child is one which is on the same branch as the parent.
5757
*/
5858
int count_nonbranch_children(int pid){
5959
int nNonBranch = 0;
60
- static Stmt q;
60
+ static Stmt q = empty_Stmt_m;
6161
static const char zSql[] =
6262
@ SELECT count(*) FROM plink
6363
@ WHERE pid=:pid AND isprim
6464
@ AND coalesce((SELECT value FROM tagxref
6565
@ WHERE tagid=%d AND rid=plink.pid), 'trunk')
@@ -105,13 +105,13 @@
105105
/*
106106
** Check to see if check-in "rid" is a leaf and either add it to the LEAF
107107
** table if it is, or remove it if it is not.
108108
*/
109109
void leaf_check(int rid){
110
- static Stmt checkIfLeaf;
111
- static Stmt addLeaf;
112
- static Stmt removeLeaf;
110
+ static Stmt checkIfLeaf = empty_Stmt_m;
111
+ static Stmt addLeaf = empty_Stmt_m;
112
+ static Stmt removeLeaf = empty_Stmt_m;
113113
int rc;
114114
115115
db_static_prepare(&checkIfLeaf,
116116
"SELECT 1 FROM plink"
117117
" WHERE pid=:rid"
@@ -168,11 +168,11 @@
168168
169169
/*
170170
** Schedule a leaf check for "rid" and its parents.
171171
*/
172172
void leaf_eventually_check(int rid){
173
- static Stmt parentsOf;
173
+ static Stmt parentsOf = empty_Stmt_m;
174174
175175
db_static_prepare(&parentsOf,
176176
"SELECT pid FROM plink WHERE cid=:rid AND pid>0"
177177
);
178178
db_bind_int(&parentsOf, ":rid", rid);
179179
--- src/leaf.c
+++ src/leaf.c
@@ -55,11 +55,11 @@
55 **
56 ** A non-branch child is one which is on the same branch as the parent.
57 */
58 int count_nonbranch_children(int pid){
59 int nNonBranch = 0;
60 static Stmt q;
61 static const char zSql[] =
62 @ SELECT count(*) FROM plink
63 @ WHERE pid=:pid AND isprim
64 @ AND coalesce((SELECT value FROM tagxref
65 @ WHERE tagid=%d AND rid=plink.pid), 'trunk')
@@ -105,13 +105,13 @@
105 /*
106 ** Check to see if check-in "rid" is a leaf and either add it to the LEAF
107 ** table if it is, or remove it if it is not.
108 */
109 void leaf_check(int rid){
110 static Stmt checkIfLeaf;
111 static Stmt addLeaf;
112 static Stmt removeLeaf;
113 int rc;
114
115 db_static_prepare(&checkIfLeaf,
116 "SELECT 1 FROM plink"
117 " WHERE pid=:rid"
@@ -168,11 +168,11 @@
168
169 /*
170 ** Schedule a leaf check for "rid" and its parents.
171 */
172 void leaf_eventually_check(int rid){
173 static Stmt parentsOf;
174
175 db_static_prepare(&parentsOf,
176 "SELECT pid FROM plink WHERE cid=:rid AND pid>0"
177 );
178 db_bind_int(&parentsOf, ":rid", rid);
179
--- src/leaf.c
+++ src/leaf.c
@@ -55,11 +55,11 @@
55 **
56 ** A non-branch child is one which is on the same branch as the parent.
57 */
58 int count_nonbranch_children(int pid){
59 int nNonBranch = 0;
60 static Stmt q = empty_Stmt_m;
61 static const char zSql[] =
62 @ SELECT count(*) FROM plink
63 @ WHERE pid=:pid AND isprim
64 @ AND coalesce((SELECT value FROM tagxref
65 @ WHERE tagid=%d AND rid=plink.pid), 'trunk')
@@ -105,13 +105,13 @@
105 /*
106 ** Check to see if check-in "rid" is a leaf and either add it to the LEAF
107 ** table if it is, or remove it if it is not.
108 */
109 void leaf_check(int rid){
110 static Stmt checkIfLeaf = empty_Stmt_m;
111 static Stmt addLeaf = empty_Stmt_m;
112 static Stmt removeLeaf = empty_Stmt_m;
113 int rc;
114
115 db_static_prepare(&checkIfLeaf,
116 "SELECT 1 FROM plink"
117 " WHERE pid=:rid"
@@ -168,11 +168,11 @@
168
169 /*
170 ** Schedule a leaf check for "rid" and its parents.
171 */
172 void leaf_eventually_check(int rid){
173 static Stmt parentsOf = empty_Stmt_m;
174
175 db_static_prepare(&parentsOf,
176 "SELECT pid FROM plink WHERE cid=:rid AND pid>0"
177 );
178 db_bind_int(&parentsOf, ":rid", rid);
179
+2 -2
--- src/manifest.c
+++ src/manifest.c
@@ -1699,11 +1699,11 @@
16991699
Blob otherContent;
17001700
int otherRid;
17011701
int i, rc;
17021702
ManifestFile *pChildFile, *pParentFile;
17031703
Manifest **ppOther;
1704
- static Stmt eq;
1704
+ static Stmt eq = empty_Stmt_m;
17051705
int isPublic; /* True if pChild is non-private */
17061706
17071707
/* If mlink table entires are already exist for the pmid-to-mid transition,
17081708
** then abort early doing no work.
17091709
*/
@@ -2427,11 +2427,11 @@
24272427
}
24282428
}
24292429
}
24302430
}
24312431
if( p->type==CFTYPE_CLUSTER ){
2432
- static Stmt del1;
2432
+ static Stmt del1 = empty_Stmt_m;
24332433
tag_insert("cluster", 1, 0, rid, p->rDate, rid);
24342434
db_static_prepare(&del1, "DELETE FROM unclustered WHERE rid=:rid");
24352435
for(i=0; i<p->nCChild; i++){
24362436
int mid;
24372437
mid = uuid_to_rid(p->azCChild[i], 1);
24382438
--- src/manifest.c
+++ src/manifest.c
@@ -1699,11 +1699,11 @@
1699 Blob otherContent;
1700 int otherRid;
1701 int i, rc;
1702 ManifestFile *pChildFile, *pParentFile;
1703 Manifest **ppOther;
1704 static Stmt eq;
1705 int isPublic; /* True if pChild is non-private */
1706
1707 /* If mlink table entires are already exist for the pmid-to-mid transition,
1708 ** then abort early doing no work.
1709 */
@@ -2427,11 +2427,11 @@
2427 }
2428 }
2429 }
2430 }
2431 if( p->type==CFTYPE_CLUSTER ){
2432 static Stmt del1;
2433 tag_insert("cluster", 1, 0, rid, p->rDate, rid);
2434 db_static_prepare(&del1, "DELETE FROM unclustered WHERE rid=:rid");
2435 for(i=0; i<p->nCChild; i++){
2436 int mid;
2437 mid = uuid_to_rid(p->azCChild[i], 1);
2438
--- src/manifest.c
+++ src/manifest.c
@@ -1699,11 +1699,11 @@
1699 Blob otherContent;
1700 int otherRid;
1701 int i, rc;
1702 ManifestFile *pChildFile, *pParentFile;
1703 Manifest **ppOther;
1704 static Stmt eq = empty_Stmt_m;
1705 int isPublic; /* True if pChild is non-private */
1706
1707 /* If mlink table entires are already exist for the pmid-to-mid transition,
1708 ** then abort early doing no work.
1709 */
@@ -2427,11 +2427,11 @@
2427 }
2428 }
2429 }
2430 }
2431 if( p->type==CFTYPE_CLUSTER ){
2432 static Stmt del1 = empty_Stmt_m;
2433 tag_insert("cluster", 1, 0, rid, p->rDate, rid);
2434 db_static_prepare(&del1, "DELETE FROM unclustered WHERE rid=:rid");
2435 for(i=0; i<p->nCChild; i++){
2436 int mid;
2437 mid = uuid_to_rid(p->azCChild[i], 1);
2438
+1 -1
--- src/merge.c
+++ src/merge.c
@@ -546,11 +546,11 @@
546546
/*
547547
** Check content that was received with rcvid and return true if any
548548
** fork was created.
549549
*/
550550
int fossil_any_has_fork(int rcvid){
551
- static Stmt q;
551
+ static Stmt q = empty_Stmt_m;
552552
int fForkSeen = 0;
553553
554554
if( rcvid==0 ) return 0;
555555
db_static_prepare(&q,
556556
" SELECT pid FROM plink WHERE pid>0 AND isprim"
557557
--- src/merge.c
+++ src/merge.c
@@ -546,11 +546,11 @@
546 /*
547 ** Check content that was received with rcvid and return true if any
548 ** fork was created.
549 */
550 int fossil_any_has_fork(int rcvid){
551 static Stmt q;
552 int fForkSeen = 0;
553
554 if( rcvid==0 ) return 0;
555 db_static_prepare(&q,
556 " SELECT pid FROM plink WHERE pid>0 AND isprim"
557
--- src/merge.c
+++ src/merge.c
@@ -546,11 +546,11 @@
546 /*
547 ** Check content that was received with rcvid and return true if any
548 ** fork was created.
549 */
550 int fossil_any_has_fork(int rcvid){
551 static Stmt q = empty_Stmt_m;
552 int fForkSeen = 0;
553
554 if( rcvid==0 ) return 0;
555 db_static_prepare(&q,
556 " SELECT pid FROM plink WHERE pid>0 AND isprim"
557
+3 -3
--- src/moderate.c
+++ src/moderate.c
@@ -45,11 +45,11 @@
4545
4646
/*
4747
** Return TRUE if the object specified is being held for moderation.
4848
*/
4949
int moderation_pending(int rid){
50
- static Stmt q;
50
+ static Stmt q = empty_Stmt_m;
5151
int rc;
5252
if( rid==0 || !moderation_table_exists() ) return 0;
5353
db_static_prepare(&q, "SELECT 1 FROM modreq WHERE objid=:objid");
5454
db_bind_int(&q, ":objid", rid);
5555
rc = db_step(&q)==SQLITE_ROW;
@@ -283,14 +283,14 @@
283283
** return true for admins because that check skips looking at the
284284
** db.
285285
**
286286
*/
287287
int moderation_user_could(int rid, int bMayDeny, const char *zWho){
288
- static Stmt q;
288
+ static Stmt q = empty_Stmt_m;
289289
int rc = 0;
290290
if( g.perm.Admin ) return g.perm.Admin;
291
- if( !q.pStmt ){
291
+ if( !q.pStmt ){ /* FIXME: this if(..) looks redundant here */
292292
db_static_prepare(
293293
&q,
294294
"SELECT coalesce(euser,user)=:user, type FROM event "
295295
"WHERE objid=:rid"
296296
);
297297
--- src/moderate.c
+++ src/moderate.c
@@ -45,11 +45,11 @@
45
46 /*
47 ** Return TRUE if the object specified is being held for moderation.
48 */
49 int moderation_pending(int rid){
50 static Stmt q;
51 int rc;
52 if( rid==0 || !moderation_table_exists() ) return 0;
53 db_static_prepare(&q, "SELECT 1 FROM modreq WHERE objid=:objid");
54 db_bind_int(&q, ":objid", rid);
55 rc = db_step(&q)==SQLITE_ROW;
@@ -283,14 +283,14 @@
283 ** return true for admins because that check skips looking at the
284 ** db.
285 **
286 */
287 int moderation_user_could(int rid, int bMayDeny, const char *zWho){
288 static Stmt q;
289 int rc = 0;
290 if( g.perm.Admin ) return g.perm.Admin;
291 if( !q.pStmt ){
292 db_static_prepare(
293 &q,
294 "SELECT coalesce(euser,user)=:user, type FROM event "
295 "WHERE objid=:rid"
296 );
297
--- src/moderate.c
+++ src/moderate.c
@@ -45,11 +45,11 @@
45
46 /*
47 ** Return TRUE if the object specified is being held for moderation.
48 */
49 int moderation_pending(int rid){
50 static Stmt q = empty_Stmt_m;
51 int rc;
52 if( rid==0 || !moderation_table_exists() ) return 0;
53 db_static_prepare(&q, "SELECT 1 FROM modreq WHERE objid=:objid");
54 db_bind_int(&q, ":objid", rid);
55 rc = db_step(&q)==SQLITE_ROW;
@@ -283,14 +283,14 @@
283 ** return true for admins because that check skips looking at the
284 ** db.
285 **
286 */
287 int moderation_user_could(int rid, int bMayDeny, const char *zWho){
288 static Stmt q = empty_Stmt_m;
289 int rc = 0;
290 if( g.perm.Admin ) return g.perm.Admin;
291 if( !q.pStmt ){ /* FIXME: this if(..) looks redundant here */
292 db_static_prepare(
293 &q,
294 "SELECT coalesce(euser,user)=:user, type FROM event "
295 "WHERE objid=:rid"
296 );
297
+1 -1
--- src/path.c
+++ src/path.c
@@ -78,11 +78,11 @@
7878
** Given a RID, return the ISO date/time string and branch for the
7979
** corresponding check-in. Memory is held locally and is overwritten
8080
** with each call.
8181
*/
8282
char *path_rid_desc(int rid){
83
- static Stmt q;
83
+ static Stmt q = empty_Stmt_m;
8484
static char *zDesc = 0;
8585
db_static_prepare(&q,
8686
"SELECT concat(strftime('%%Y%%m%%d%%H%%M',event.mtime),'/',value)"
8787
" FROM event, tagxref"
8888
" WHERE event.objid=:rid"
8989
--- src/path.c
+++ src/path.c
@@ -78,11 +78,11 @@
78 ** Given a RID, return the ISO date/time string and branch for the
79 ** corresponding check-in. Memory is held locally and is overwritten
80 ** with each call.
81 */
82 char *path_rid_desc(int rid){
83 static Stmt q;
84 static char *zDesc = 0;
85 db_static_prepare(&q,
86 "SELECT concat(strftime('%%Y%%m%%d%%H%%M',event.mtime),'/',value)"
87 " FROM event, tagxref"
88 " WHERE event.objid=:rid"
89
--- src/path.c
+++ src/path.c
@@ -78,11 +78,11 @@
78 ** Given a RID, return the ISO date/time string and branch for the
79 ** corresponding check-in. Memory is held locally and is overwritten
80 ** with each call.
81 */
82 char *path_rid_desc(int rid){
83 static Stmt q = empty_Stmt_m;
84 static char *zDesc = 0;
85 db_static_prepare(&q,
86 "SELECT concat(strftime('%%Y%%m%%d%%H%%M',event.mtime),'/',value)"
87 " FROM event, tagxref"
88 " WHERE event.objid=:rid"
89
+2 -2
--- src/rebuild.c
+++ src/rebuild.c
@@ -252,11 +252,11 @@
252252
** other artifacts that are deltas off of the current artifact.
253253
** This is the most efficient way to extract all of the original
254254
** artifact content from the Fossil repository.
255255
*/
256256
static void rebuild_step(int rid, int size, Blob *pBase){
257
- static Stmt q1;
257
+ static Stmt q1 = empty_Stmt_m;
258258
Bag children;
259259
Blob copy;
260260
Blob *pUse;
261261
int nChild, i, cid;
262262
@@ -317,11 +317,11 @@
317317
rebuild_step_done(rid);
318318
319319
/* Call all children recursively */
320320
rid = 0;
321321
for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){
322
- static Stmt q2;
322
+ static Stmt q2 = empty_Stmt_m;
323323
int sz;
324324
db_static_prepare(&q2, "SELECT content, size FROM blob WHERE rid=:rid");
325325
db_bind_int(&q2, ":rid", cid);
326326
if( db_step(&q2)==SQLITE_ROW && (sz = db_column_int(&q2,1))>=0 ){
327327
Blob delta, next;
328328
--- src/rebuild.c
+++ src/rebuild.c
@@ -252,11 +252,11 @@
252 ** other artifacts that are deltas off of the current artifact.
253 ** This is the most efficient way to extract all of the original
254 ** artifact content from the Fossil repository.
255 */
256 static void rebuild_step(int rid, int size, Blob *pBase){
257 static Stmt q1;
258 Bag children;
259 Blob copy;
260 Blob *pUse;
261 int nChild, i, cid;
262
@@ -317,11 +317,11 @@
317 rebuild_step_done(rid);
318
319 /* Call all children recursively */
320 rid = 0;
321 for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){
322 static Stmt q2;
323 int sz;
324 db_static_prepare(&q2, "SELECT content, size FROM blob WHERE rid=:rid");
325 db_bind_int(&q2, ":rid", cid);
326 if( db_step(&q2)==SQLITE_ROW && (sz = db_column_int(&q2,1))>=0 ){
327 Blob delta, next;
328
--- src/rebuild.c
+++ src/rebuild.c
@@ -252,11 +252,11 @@
252 ** other artifacts that are deltas off of the current artifact.
253 ** This is the most efficient way to extract all of the original
254 ** artifact content from the Fossil repository.
255 */
256 static void rebuild_step(int rid, int size, Blob *pBase){
257 static Stmt q1 = empty_Stmt_m;
258 Bag children;
259 Blob copy;
260 Blob *pUse;
261 int nChild, i, cid;
262
@@ -317,11 +317,11 @@
317 rebuild_step_done(rid);
318
319 /* Call all children recursively */
320 rid = 0;
321 for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){
322 static Stmt q2 = empty_Stmt_m;
323 int sz;
324 db_static_prepare(&q2, "SELECT content, size FROM blob WHERE rid=:rid");
325 db_bind_int(&q2, ":rid", cid);
326 if( db_step(&q2)==SQLITE_ROW && (sz = db_column_int(&q2,1))>=0 ){
327 Blob delta, next;
328
+3 -3
--- src/search.c
+++ src/search.c
@@ -1587,11 +1587,11 @@
15871587
blob_reset(&wiki);
15881588
manifest_destroy(pWiki);
15891589
break;
15901590
}
15911591
case 'c': { /* Check-in Comments */
1592
- static Stmt q;
1592
+ static Stmt q = empty_Stmt_m;
15931593
static int isPlainText = -1;
15941594
db_static_prepare(&q,
15951595
"SELECT coalesce(ecomment,comment)"
15961596
" ||' (user: '||coalesce(euser,user,'?')"
15971597
" ||', tags: '||"
@@ -1619,11 +1619,11 @@
16191619
}
16201620
db_reset(&q);
16211621
break;
16221622
}
16231623
case 't': { /* Tickets */
1624
- static Stmt q1;
1624
+ static Stmt q1 = empty_Stmt_m;
16251625
static int iTitle = -1;
16261626
db_static_prepare(&q1, "SELECT * FROM ticket WHERE tkt_id=:rid");
16271627
db_bind_int(&q1, ":rid", rid);
16281628
if( db_step(&q1)==SQLITE_ROW ){
16291629
if( iTitle<0 ){
@@ -1634,11 +1634,11 @@
16341634
}
16351635
append_all_ticket_fields(pOut, &q1, iTitle);
16361636
}
16371637
db_reset(&q1);
16381638
if( db_table_exists("repository","ticketchng") ){
1639
- static Stmt q2;
1639
+ static Stmt q2 = empty_Stmt_m;
16401640
db_static_prepare(&q2, "SELECT * FROM ticketchng WHERE tkt_id=:rid"
16411641
" ORDER BY tkt_mtime");
16421642
db_bind_int(&q2, ":rid", rid);
16431643
while( db_step(&q2)==SQLITE_ROW ){
16441644
append_all_ticket_fields(pOut, &q2, -1);
16451645
--- src/search.c
+++ src/search.c
@@ -1587,11 +1587,11 @@
1587 blob_reset(&wiki);
1588 manifest_destroy(pWiki);
1589 break;
1590 }
1591 case 'c': { /* Check-in Comments */
1592 static Stmt q;
1593 static int isPlainText = -1;
1594 db_static_prepare(&q,
1595 "SELECT coalesce(ecomment,comment)"
1596 " ||' (user: '||coalesce(euser,user,'?')"
1597 " ||', tags: '||"
@@ -1619,11 +1619,11 @@
1619 }
1620 db_reset(&q);
1621 break;
1622 }
1623 case 't': { /* Tickets */
1624 static Stmt q1;
1625 static int iTitle = -1;
1626 db_static_prepare(&q1, "SELECT * FROM ticket WHERE tkt_id=:rid");
1627 db_bind_int(&q1, ":rid", rid);
1628 if( db_step(&q1)==SQLITE_ROW ){
1629 if( iTitle<0 ){
@@ -1634,11 +1634,11 @@
1634 }
1635 append_all_ticket_fields(pOut, &q1, iTitle);
1636 }
1637 db_reset(&q1);
1638 if( db_table_exists("repository","ticketchng") ){
1639 static Stmt q2;
1640 db_static_prepare(&q2, "SELECT * FROM ticketchng WHERE tkt_id=:rid"
1641 " ORDER BY tkt_mtime");
1642 db_bind_int(&q2, ":rid", rid);
1643 while( db_step(&q2)==SQLITE_ROW ){
1644 append_all_ticket_fields(pOut, &q2, -1);
1645
--- src/search.c
+++ src/search.c
@@ -1587,11 +1587,11 @@
1587 blob_reset(&wiki);
1588 manifest_destroy(pWiki);
1589 break;
1590 }
1591 case 'c': { /* Check-in Comments */
1592 static Stmt q = empty_Stmt_m;
1593 static int isPlainText = -1;
1594 db_static_prepare(&q,
1595 "SELECT coalesce(ecomment,comment)"
1596 " ||' (user: '||coalesce(euser,user,'?')"
1597 " ||', tags: '||"
@@ -1619,11 +1619,11 @@
1619 }
1620 db_reset(&q);
1621 break;
1622 }
1623 case 't': { /* Tickets */
1624 static Stmt q1 = empty_Stmt_m;
1625 static int iTitle = -1;
1626 db_static_prepare(&q1, "SELECT * FROM ticket WHERE tkt_id=:rid");
1627 db_bind_int(&q1, ":rid", rid);
1628 if( db_step(&q1)==SQLITE_ROW ){
1629 if( iTitle<0 ){
@@ -1634,11 +1634,11 @@
1634 }
1635 append_all_ticket_fields(pOut, &q1, iTitle);
1636 }
1637 db_reset(&q1);
1638 if( db_table_exists("repository","ticketchng") ){
1639 static Stmt q2 = empty_Stmt_m;
1640 db_static_prepare(&q2, "SELECT * FROM ticketchng WHERE tkt_id=:rid"
1641 " ORDER BY tkt_mtime");
1642 db_bind_int(&q2, ":rid", rid);
1643 while( db_step(&q2)==SQLITE_ROW ){
1644 append_all_ticket_fields(pOut, &q2, -1);
1645
+1 -1
--- src/shun.c
+++ src/shun.c
@@ -23,11 +23,11 @@
2323
2424
/*
2525
** Return true if the given artifact ID should be shunned.
2626
*/
2727
int uuid_is_shunned(const char *zUuid){
28
- static Stmt q;
28
+ static Stmt q = empty_Stmt_m;
2929
int rc;
3030
if( zUuid==0 || zUuid[0]==0 ) return 0;
3131
if( g.eHashPolicy==HPOLICY_SHUN_SHA1 && zUuid[HNAME_LEN_SHA1]==0 ) return 1;
3232
db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid");
3333
db_bind_text(&q, ":uuid", zUuid);
3434
--- src/shun.c
+++ src/shun.c
@@ -23,11 +23,11 @@
23
24 /*
25 ** Return true if the given artifact ID should be shunned.
26 */
27 int uuid_is_shunned(const char *zUuid){
28 static Stmt q;
29 int rc;
30 if( zUuid==0 || zUuid[0]==0 ) return 0;
31 if( g.eHashPolicy==HPOLICY_SHUN_SHA1 && zUuid[HNAME_LEN_SHA1]==0 ) return 1;
32 db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid");
33 db_bind_text(&q, ":uuid", zUuid);
34
--- src/shun.c
+++ src/shun.c
@@ -23,11 +23,11 @@
23
24 /*
25 ** Return true if the given artifact ID should be shunned.
26 */
27 int uuid_is_shunned(const char *zUuid){
28 static Stmt q = empty_Stmt_m;
29 int rc;
30 if( zUuid==0 || zUuid[0]==0 ) return 0;
31 if( g.eHashPolicy==HPOLICY_SHUN_SHA1 && zUuid[HNAME_LEN_SHA1]==0 ) return 1;
32 db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid");
33 db_bind_text(&q, ":uuid", zUuid);
34
+2 -1
--- src/tag.c
+++ src/tag.c
@@ -1014,12 +1014,13 @@
10141014
**
10151015
** Ownership of *pOut is transfered to the caller, who must eventually
10161016
** fossil_free() it.
10171017
*/
10181018
int rid_has_tag2(int rid, const char *zTag, char **pOut){
1019
- static Stmt q;
1019
+ static Stmt q = empty_Stmt_m;
10201020
int rc = 0;
1021
+ /* FIXME: db_static_prepare() without if(..) looks more suitable here */
10211022
if( !q.pStmt ){
10221023
db_prepare(
10231024
&q, "SELECT t.tagid, x.value"
10241025
" FROM tagxref x, tag t"
10251026
" WHERE x.rid=:rid"
10261027
--- src/tag.c
+++ src/tag.c
@@ -1014,12 +1014,13 @@
1014 **
1015 ** Ownership of *pOut is transfered to the caller, who must eventually
1016 ** fossil_free() it.
1017 */
1018 int rid_has_tag2(int rid, const char *zTag, char **pOut){
1019 static Stmt q;
1020 int rc = 0;
 
1021 if( !q.pStmt ){
1022 db_prepare(
1023 &q, "SELECT t.tagid, x.value"
1024 " FROM tagxref x, tag t"
1025 " WHERE x.rid=:rid"
1026
--- src/tag.c
+++ src/tag.c
@@ -1014,12 +1014,13 @@
1014 **
1015 ** Ownership of *pOut is transfered to the caller, who must eventually
1016 ** fossil_free() it.
1017 */
1018 int rid_has_tag2(int rid, const char *zTag, char **pOut){
1019 static Stmt q = empty_Stmt_m;
1020 int rc = 0;
1021 /* FIXME: db_static_prepare() without if(..) looks more suitable here */
1022 if( !q.pStmt ){
1023 db_prepare(
1024 &q, "SELECT t.tagid, x.value"
1025 " FROM tagxref x, tag t"
1026 " WHERE x.rid=:rid"
1027
+5 -5
--- src/timeline.c
+++ src/timeline.c
@@ -143,11 +143,11 @@
143143
/*
144144
** Return true if the checking identified by "rid" has a valid "closed"
145145
** tag.
146146
*/
147147
static int has_closed_tag(int rid){
148
- static Stmt q;
148
+ static Stmt q = empty_Stmt_m;
149149
int res = 0;
150150
db_static_prepare(&q,
151151
"SELECT 1 FROM tagxref WHERE rid=$rid AND tagid=%d AND tagtype>0",
152152
TAG_CLOSED);
153153
db_bind_int(&q, "$rid", rid);
@@ -583,11 +583,11 @@
583583
if( tmFlags & TIMELINE_UCOLOR ){
584584
zBgClr = zUser ? user_color(zUser) : 0;
585585
}else if( tmFlags & TIMELINE_NOCOLOR ){
586586
zBgClr = 0;
587587
}else if( zType[0]=='c' ){
588
- static Stmt qdelta;
588
+ static Stmt qdelta = empty_Stmt_m;
589589
db_static_prepare(&qdelta, "SELECT baseid IS NULL FROM plink"
590590
" WHERE cid=:rid");
591591
db_bind_int(&qdelta, ":rid", rid);
592592
if( db_step(&qdelta)!=SQLITE_ROW ){
593593
zBgClr = 0; /* Not a check-in */
@@ -619,11 +619,11 @@
619619
}
620620
if( zType[0]=='c' && pGraph ){
621621
int nParent = 0;
622622
int nCherrypick = 0;
623623
GraphRowId aParent[GR_MAX_RAIL];
624
- static Stmt qparent;
624
+ static Stmt qparent = empty_Stmt_m;
625625
if( tmFlags & TIMELINE_GRAPH ){
626626
db_static_prepare(&qparent,
627627
"SELECT pid FROM plink"
628628
" WHERE cid=:rid AND pid NOT IN phantom"
629629
" ORDER BY isprim DESC /*sort*/"
@@ -632,11 +632,11 @@
632632
while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){
633633
aParent[nParent++] = db_column_int(&qparent, 0);
634634
}
635635
db_reset(&qparent);
636636
if( (tmFlags & TIMELINE_CHPICK)!=0 && nParent>0 ){
637
- static Stmt qcherrypick;
637
+ static Stmt qcherrypick = empty_Stmt_m;
638638
db_static_prepare(&qcherrypick,
639639
"SELECT parentid FROM cherrypick"
640640
" WHERE childid=:rid AND parentid NOT IN phantom"
641641
);
642642
db_bind_int(&qcherrypick, ":rid", rid);
@@ -674,11 +674,11 @@
674674
}
675675
if( modPending ){
676676
@ <span class="modpending">(Awaiting Moderator Approval)</span>
677677
}
678678
if( (tmFlags & TIMELINE_BISECT)!=0 && zType[0]=='c' ){
679
- static Stmt bisectQuery;
679
+ static Stmt bisectQuery = empty_Stmt_m;
680680
db_static_prepare(&bisectQuery,
681681
"SELECT seq, stat FROM bilog WHERE rid=:rid AND seq");
682682
db_bind_int(&bisectQuery, ":rid", rid);
683683
if( db_step(&bisectQuery)==SQLITE_ROW ){
684684
@ <b>%s(db_column_text(&bisectQuery,1))</b>
685685
--- src/timeline.c
+++ src/timeline.c
@@ -143,11 +143,11 @@
143 /*
144 ** Return true if the checking identified by "rid" has a valid "closed"
145 ** tag.
146 */
147 static int has_closed_tag(int rid){
148 static Stmt q;
149 int res = 0;
150 db_static_prepare(&q,
151 "SELECT 1 FROM tagxref WHERE rid=$rid AND tagid=%d AND tagtype>0",
152 TAG_CLOSED);
153 db_bind_int(&q, "$rid", rid);
@@ -583,11 +583,11 @@
583 if( tmFlags & TIMELINE_UCOLOR ){
584 zBgClr = zUser ? user_color(zUser) : 0;
585 }else if( tmFlags & TIMELINE_NOCOLOR ){
586 zBgClr = 0;
587 }else if( zType[0]=='c' ){
588 static Stmt qdelta;
589 db_static_prepare(&qdelta, "SELECT baseid IS NULL FROM plink"
590 " WHERE cid=:rid");
591 db_bind_int(&qdelta, ":rid", rid);
592 if( db_step(&qdelta)!=SQLITE_ROW ){
593 zBgClr = 0; /* Not a check-in */
@@ -619,11 +619,11 @@
619 }
620 if( zType[0]=='c' && pGraph ){
621 int nParent = 0;
622 int nCherrypick = 0;
623 GraphRowId aParent[GR_MAX_RAIL];
624 static Stmt qparent;
625 if( tmFlags & TIMELINE_GRAPH ){
626 db_static_prepare(&qparent,
627 "SELECT pid FROM plink"
628 " WHERE cid=:rid AND pid NOT IN phantom"
629 " ORDER BY isprim DESC /*sort*/"
@@ -632,11 +632,11 @@
632 while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){
633 aParent[nParent++] = db_column_int(&qparent, 0);
634 }
635 db_reset(&qparent);
636 if( (tmFlags & TIMELINE_CHPICK)!=0 && nParent>0 ){
637 static Stmt qcherrypick;
638 db_static_prepare(&qcherrypick,
639 "SELECT parentid FROM cherrypick"
640 " WHERE childid=:rid AND parentid NOT IN phantom"
641 );
642 db_bind_int(&qcherrypick, ":rid", rid);
@@ -674,11 +674,11 @@
674 }
675 if( modPending ){
676 @ <span class="modpending">(Awaiting Moderator Approval)</span>
677 }
678 if( (tmFlags & TIMELINE_BISECT)!=0 && zType[0]=='c' ){
679 static Stmt bisectQuery;
680 db_static_prepare(&bisectQuery,
681 "SELECT seq, stat FROM bilog WHERE rid=:rid AND seq");
682 db_bind_int(&bisectQuery, ":rid", rid);
683 if( db_step(&bisectQuery)==SQLITE_ROW ){
684 @ <b>%s(db_column_text(&bisectQuery,1))</b>
685
--- src/timeline.c
+++ src/timeline.c
@@ -143,11 +143,11 @@
143 /*
144 ** Return true if the checking identified by "rid" has a valid "closed"
145 ** tag.
146 */
147 static int has_closed_tag(int rid){
148 static Stmt q = empty_Stmt_m;
149 int res = 0;
150 db_static_prepare(&q,
151 "SELECT 1 FROM tagxref WHERE rid=$rid AND tagid=%d AND tagtype>0",
152 TAG_CLOSED);
153 db_bind_int(&q, "$rid", rid);
@@ -583,11 +583,11 @@
583 if( tmFlags & TIMELINE_UCOLOR ){
584 zBgClr = zUser ? user_color(zUser) : 0;
585 }else if( tmFlags & TIMELINE_NOCOLOR ){
586 zBgClr = 0;
587 }else if( zType[0]=='c' ){
588 static Stmt qdelta = empty_Stmt_m;
589 db_static_prepare(&qdelta, "SELECT baseid IS NULL FROM plink"
590 " WHERE cid=:rid");
591 db_bind_int(&qdelta, ":rid", rid);
592 if( db_step(&qdelta)!=SQLITE_ROW ){
593 zBgClr = 0; /* Not a check-in */
@@ -619,11 +619,11 @@
619 }
620 if( zType[0]=='c' && pGraph ){
621 int nParent = 0;
622 int nCherrypick = 0;
623 GraphRowId aParent[GR_MAX_RAIL];
624 static Stmt qparent = empty_Stmt_m;
625 if( tmFlags & TIMELINE_GRAPH ){
626 db_static_prepare(&qparent,
627 "SELECT pid FROM plink"
628 " WHERE cid=:rid AND pid NOT IN phantom"
629 " ORDER BY isprim DESC /*sort*/"
@@ -632,11 +632,11 @@
632 while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){
633 aParent[nParent++] = db_column_int(&qparent, 0);
634 }
635 db_reset(&qparent);
636 if( (tmFlags & TIMELINE_CHPICK)!=0 && nParent>0 ){
637 static Stmt qcherrypick = empty_Stmt_m;
638 db_static_prepare(&qcherrypick,
639 "SELECT parentid FROM cherrypick"
640 " WHERE childid=:rid AND parentid NOT IN phantom"
641 );
642 db_bind_int(&qcherrypick, ":rid", rid);
@@ -674,11 +674,11 @@
674 }
675 if( modPending ){
676 @ <span class="modpending">(Awaiting Moderator Approval)</span>
677 }
678 if( (tmFlags & TIMELINE_BISECT)!=0 && zType[0]=='c' ){
679 static Stmt bisectQuery = empty_Stmt_m;
680 db_static_prepare(&bisectQuery,
681 "SELECT seq, stat FROM bilog WHERE rid=:rid AND seq");
682 db_bind_int(&bisectQuery, ":rid", rid);
683 if( db_step(&bisectQuery)==SQLITE_ROW ){
684 @ <b>%s(db_column_text(&bisectQuery,1))</b>
685
+1 -1
--- src/utf8.c
+++ src/utf8.c
@@ -58,11 +58,11 @@
5858
int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0);
5959
char *zUtf = fossil_malloc( nByte );
6060
WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
6161
return zUtf;
6262
#else
63
- static Stmt q;
63
+ static Stmt q = empty_Stmt_m;
6464
char *zUtf8;
6565
db_static_prepare(&q, "SELECT :utf8");
6666
db_bind_text16(&q, ":utf8", zUnicode);
6767
db_step(&q);
6868
zUtf8 = fossil_strdup(db_column_text(&q, 0));
6969
--- src/utf8.c
+++ src/utf8.c
@@ -58,11 +58,11 @@
58 int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0);
59 char *zUtf = fossil_malloc( nByte );
60 WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
61 return zUtf;
62 #else
63 static Stmt q;
64 char *zUtf8;
65 db_static_prepare(&q, "SELECT :utf8");
66 db_bind_text16(&q, ":utf8", zUnicode);
67 db_step(&q);
68 zUtf8 = fossil_strdup(db_column_text(&q, 0));
69
--- src/utf8.c
+++ src/utf8.c
@@ -58,11 +58,11 @@
58 int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0);
59 char *zUtf = fossil_malloc( nByte );
60 WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
61 return zUtf;
62 #else
63 static Stmt q = empty_Stmt_m;
64 char *zUtf8;
65 db_static_prepare(&q, "SELECT :utf8");
66 db_bind_text16(&q, ":utf8", zUnicode);
67 db_step(&q);
68 zUtf8 = fossil_strdup(db_column_text(&q, 0));
69
+5 -4
--- src/vfile.c
+++ src/vfile.c
@@ -25,11 +25,11 @@
2525
/*
2626
** The input is guaranteed to be a 40- or 64-character well-formed
2727
** artifact hash. Find its rid.
2828
*/
2929
int fast_uuid_to_rid(const char *zUuid){
30
- static Stmt q;
30
+ static Stmt q = empty_Stmt_m;
3131
int rid;
3232
db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
3333
db_bind_text(&q, ":uuid", zUuid);
3434
if( db_step(&q)==SQLITE_ROW ){
3535
rid = db_column_int(&q, 0);
@@ -468,11 +468,11 @@
468468
){
469469
DIR *d;
470470
int origSize;
471471
struct dirent *pEntry;
472472
int skipAll = 0;
473
- static Stmt ins;
473
+ static Stmt ins = empty_Stmt_m;
474474
static int depth = 0;
475475
void *zNative;
476476
477477
origSize = blob_size(pPath);
478478
if( pIgnore1 || pIgnore2 ){
@@ -599,12 +599,12 @@
599599
int result = 0;
600600
DIR *d;
601601
int origSize;
602602
struct dirent *pEntry;
603603
int skipAll = 0;
604
- static Stmt ins;
605
- static Stmt upd;
604
+ static Stmt ins = empty_Stmt_m;
605
+ static Stmt upd = empty_Stmt_m;
606606
static int depth = 0;
607607
void *zNative;
608608
609609
origSize = blob_size(pPath);
610610
if( pIgnore1 || pIgnore2 ){
@@ -618,10 +618,11 @@
618618
if( depth==0 ){
619619
db_multi_exec("DROP TABLE IF EXISTS dscan_temp;"
620620
"CREATE TEMP TABLE dscan_temp("
621621
" x TEXT PRIMARY KEY %s, y INTEGER)",
622622
filename_collation());
623
+ /* FIXME: maybe db_static_prepare() is more suitable here? */
623624
db_prepare(&ins,
624625
"INSERT OR IGNORE INTO dscan_temp(x, y) SELECT :file, :count"
625626
" WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE"
626627
" pathname GLOB :file || '/*' %s)", filename_collation()
627628
);
628629
--- src/vfile.c
+++ src/vfile.c
@@ -25,11 +25,11 @@
25 /*
26 ** The input is guaranteed to be a 40- or 64-character well-formed
27 ** artifact hash. Find its rid.
28 */
29 int fast_uuid_to_rid(const char *zUuid){
30 static Stmt q;
31 int rid;
32 db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
33 db_bind_text(&q, ":uuid", zUuid);
34 if( db_step(&q)==SQLITE_ROW ){
35 rid = db_column_int(&q, 0);
@@ -468,11 +468,11 @@
468 ){
469 DIR *d;
470 int origSize;
471 struct dirent *pEntry;
472 int skipAll = 0;
473 static Stmt ins;
474 static int depth = 0;
475 void *zNative;
476
477 origSize = blob_size(pPath);
478 if( pIgnore1 || pIgnore2 ){
@@ -599,12 +599,12 @@
599 int result = 0;
600 DIR *d;
601 int origSize;
602 struct dirent *pEntry;
603 int skipAll = 0;
604 static Stmt ins;
605 static Stmt upd;
606 static int depth = 0;
607 void *zNative;
608
609 origSize = blob_size(pPath);
610 if( pIgnore1 || pIgnore2 ){
@@ -618,10 +618,11 @@
618 if( depth==0 ){
619 db_multi_exec("DROP TABLE IF EXISTS dscan_temp;"
620 "CREATE TEMP TABLE dscan_temp("
621 " x TEXT PRIMARY KEY %s, y INTEGER)",
622 filename_collation());
 
623 db_prepare(&ins,
624 "INSERT OR IGNORE INTO dscan_temp(x, y) SELECT :file, :count"
625 " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE"
626 " pathname GLOB :file || '/*' %s)", filename_collation()
627 );
628
--- src/vfile.c
+++ src/vfile.c
@@ -25,11 +25,11 @@
25 /*
26 ** The input is guaranteed to be a 40- or 64-character well-formed
27 ** artifact hash. Find its rid.
28 */
29 int fast_uuid_to_rid(const char *zUuid){
30 static Stmt q = empty_Stmt_m;
31 int rid;
32 db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
33 db_bind_text(&q, ":uuid", zUuid);
34 if( db_step(&q)==SQLITE_ROW ){
35 rid = db_column_int(&q, 0);
@@ -468,11 +468,11 @@
468 ){
469 DIR *d;
470 int origSize;
471 struct dirent *pEntry;
472 int skipAll = 0;
473 static Stmt ins = empty_Stmt_m;
474 static int depth = 0;
475 void *zNative;
476
477 origSize = blob_size(pPath);
478 if( pIgnore1 || pIgnore2 ){
@@ -599,12 +599,12 @@
599 int result = 0;
600 DIR *d;
601 int origSize;
602 struct dirent *pEntry;
603 int skipAll = 0;
604 static Stmt ins = empty_Stmt_m;
605 static Stmt upd = empty_Stmt_m;
606 static int depth = 0;
607 void *zNative;
608
609 origSize = blob_size(pPath);
610 if( pIgnore1 || pIgnore2 ){
@@ -618,10 +618,11 @@
618 if( depth==0 ){
619 db_multi_exec("DROP TABLE IF EXISTS dscan_temp;"
620 "CREATE TEMP TABLE dscan_temp("
621 " x TEXT PRIMARY KEY %s, y INTEGER)",
622 filename_collation());
623 /* FIXME: maybe db_static_prepare() is more suitable here? */
624 db_prepare(&ins,
625 "INSERT OR IGNORE INTO dscan_temp(x, y) SELECT :file, :count"
626 " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE"
627 " pathname GLOB :file || '/*' %s)", filename_collation()
628 );
629
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1146,11 +1146,11 @@
11461146
/*
11471147
** Return TRUE if a hash name corresponds to an artifact in this
11481148
** repository.
11491149
*/
11501150
static int in_this_repo(const char *zUuid){
1151
- static Stmt q;
1151
+ static Stmt q = empty_Stmt_m;
11521152
int rc;
11531153
int n;
11541154
char zU2[HNAME_MAX+1];
11551155
db_static_prepare(&q,
11561156
"SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2"
@@ -1175,11 +1175,11 @@
11751175
*/
11761176
int is_ticket(
11771177
const char *zTarget, /* Ticket UUID */
11781178
int *pClosed /* True if the ticket is closed */
11791179
){
1180
- static Stmt q;
1180
+ static Stmt q = empty_Stmt_m;
11811181
int n;
11821182
int rc;
11831183
char zLower[HNAME_MAX+1];
11841184
char zUpper[HNAME_MAX+1];
11851185
n = strlen(zTarget);
11861186
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1146,11 +1146,11 @@
1146 /*
1147 ** Return TRUE if a hash name corresponds to an artifact in this
1148 ** repository.
1149 */
1150 static int in_this_repo(const char *zUuid){
1151 static Stmt q;
1152 int rc;
1153 int n;
1154 char zU2[HNAME_MAX+1];
1155 db_static_prepare(&q,
1156 "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2"
@@ -1175,11 +1175,11 @@
1175 */
1176 int is_ticket(
1177 const char *zTarget, /* Ticket UUID */
1178 int *pClosed /* True if the ticket is closed */
1179 ){
1180 static Stmt q;
1181 int n;
1182 int rc;
1183 char zLower[HNAME_MAX+1];
1184 char zUpper[HNAME_MAX+1];
1185 n = strlen(zTarget);
1186
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1146,11 +1146,11 @@
1146 /*
1147 ** Return TRUE if a hash name corresponds to an artifact in this
1148 ** repository.
1149 */
1150 static int in_this_repo(const char *zUuid){
1151 static Stmt q = empty_Stmt_m;
1152 int rc;
1153 int n;
1154 char zU2[HNAME_MAX+1];
1155 db_static_prepare(&q,
1156 "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2"
@@ -1175,11 +1175,11 @@
1175 */
1176 int is_ticket(
1177 const char *zTarget, /* Ticket UUID */
1178 int *pClosed /* True if the ticket is closed */
1179 ){
1180 static Stmt q = empty_Stmt_m;
1181 int n;
1182 int rc;
1183 char zLower[HNAME_MAX+1];
1184 char zUpper[HNAME_MAX+1];
1185 n = strlen(zTarget);
1186
+4 -4
--- src/xfer.c
+++ src/xfer.c
@@ -66,11 +66,11 @@
6666
**
6767
** Compare to uuid_to_rid(). This routine takes a blob argument
6868
** and does less error checking.
6969
*/
7070
static int rid_from_uuid(Blob *pUuid, int phantomize, int isPrivate){
71
- static Stmt q;
71
+ static Stmt q = empty_Stmt_m;
7272
int rid;
7373
7474
db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
7575
db_bind_str(&q, ":uuid", pUuid);
7676
if( db_step(&q)==SQLITE_ROW ){
@@ -89,11 +89,11 @@
8989
** Remember that the other side of the connection already has a copy
9090
** of the file rid.
9191
*/
9292
static void remote_has(int rid){
9393
if( rid ){
94
- static Stmt q;
94
+ static Stmt q = empty_Stmt_m;
9595
db_static_prepare(&q, "INSERT OR IGNORE INTO onremote VALUES(:r)");
9696
db_bind_int(&q, ":r", rid);
9797
db_step(&q);
9898
db_reset(&q);
9999
}
@@ -102,11 +102,11 @@
102102
/*
103103
** Remember that the other side of the connection lacks a copy of
104104
** the artifact with the given hash.
105105
*/
106106
static void remote_unk(Blob *pHash){
107
- static Stmt q;
107
+ static Stmt q = empty_Stmt_m;
108108
db_static_prepare(&q, "INSERT OR IGNORE INTO unk VALUES(:h)");
109109
db_bind_text(&q, ":h", blob_str(pHash));
110110
db_step(&q);
111111
db_reset(&q);
112112
}
@@ -634,11 +634,11 @@
634634
int szU;
635635
int szC;
636636
int rc;
637637
int isPrivate;
638638
int srcIsPrivate;
639
- static Stmt q1;
639
+ static Stmt q1 = empty_Stmt_m;
640640
Blob fullContent;
641641
642642
isPrivate = content_is_private(rid);
643643
if( isPrivate && pXfer->syncPrivate==0 ) return;
644644
db_static_prepare(&q1,
645645
--- src/xfer.c
+++ src/xfer.c
@@ -66,11 +66,11 @@
66 **
67 ** Compare to uuid_to_rid(). This routine takes a blob argument
68 ** and does less error checking.
69 */
70 static int rid_from_uuid(Blob *pUuid, int phantomize, int isPrivate){
71 static Stmt q;
72 int rid;
73
74 db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
75 db_bind_str(&q, ":uuid", pUuid);
76 if( db_step(&q)==SQLITE_ROW ){
@@ -89,11 +89,11 @@
89 ** Remember that the other side of the connection already has a copy
90 ** of the file rid.
91 */
92 static void remote_has(int rid){
93 if( rid ){
94 static Stmt q;
95 db_static_prepare(&q, "INSERT OR IGNORE INTO onremote VALUES(:r)");
96 db_bind_int(&q, ":r", rid);
97 db_step(&q);
98 db_reset(&q);
99 }
@@ -102,11 +102,11 @@
102 /*
103 ** Remember that the other side of the connection lacks a copy of
104 ** the artifact with the given hash.
105 */
106 static void remote_unk(Blob *pHash){
107 static Stmt q;
108 db_static_prepare(&q, "INSERT OR IGNORE INTO unk VALUES(:h)");
109 db_bind_text(&q, ":h", blob_str(pHash));
110 db_step(&q);
111 db_reset(&q);
112 }
@@ -634,11 +634,11 @@
634 int szU;
635 int szC;
636 int rc;
637 int isPrivate;
638 int srcIsPrivate;
639 static Stmt q1;
640 Blob fullContent;
641
642 isPrivate = content_is_private(rid);
643 if( isPrivate && pXfer->syncPrivate==0 ) return;
644 db_static_prepare(&q1,
645
--- src/xfer.c
+++ src/xfer.c
@@ -66,11 +66,11 @@
66 **
67 ** Compare to uuid_to_rid(). This routine takes a blob argument
68 ** and does less error checking.
69 */
70 static int rid_from_uuid(Blob *pUuid, int phantomize, int isPrivate){
71 static Stmt q = empty_Stmt_m;
72 int rid;
73
74 db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
75 db_bind_str(&q, ":uuid", pUuid);
76 if( db_step(&q)==SQLITE_ROW ){
@@ -89,11 +89,11 @@
89 ** Remember that the other side of the connection already has a copy
90 ** of the file rid.
91 */
92 static void remote_has(int rid){
93 if( rid ){
94 static Stmt q = empty_Stmt_m;
95 db_static_prepare(&q, "INSERT OR IGNORE INTO onremote VALUES(:r)");
96 db_bind_int(&q, ":r", rid);
97 db_step(&q);
98 db_reset(&q);
99 }
@@ -102,11 +102,11 @@
102 /*
103 ** Remember that the other side of the connection lacks a copy of
104 ** the artifact with the given hash.
105 */
106 static void remote_unk(Blob *pHash){
107 static Stmt q = empty_Stmt_m;
108 db_static_prepare(&q, "INSERT OR IGNORE INTO unk VALUES(:h)");
109 db_bind_text(&q, ":h", blob_str(pHash));
110 db_step(&q);
111 db_reset(&q);
112 }
@@ -634,11 +634,11 @@
634 int szU;
635 int szC;
636 int rc;
637 int isPrivate;
638 int srcIsPrivate;
639 static Stmt q1 = empty_Stmt_m;
640 Blob fullContent;
641
642 isPrivate = content_is_private(rid);
643 if( isPrivate && pXfer->syncPrivate==0 ) return;
644 db_static_prepare(&q1,
645

Keyboard Shortcuts

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