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.
Commit
76e735502f02e4e53d9211133a538dd99e1aeec54b34ce99102d199c91fc10cf
Parent
59985724d71229b…
24 files changed
+1
-1
+1
-1
+8
-8
+4
-4
+2
-2
+1
-1
+4
-4
+1
-1
+4
-4
+1
-1
+5
-5
+2
-2
+1
-1
+3
-3
+1
-1
+2
-2
+3
-3
+1
-1
+2
-1
+5
-5
+1
-1
+5
-4
+2
-2
+4
-4
~
src/branch.c
~
src/checkout.c
~
src/content.c
~
src/db.c
~
src/descendants.c
~
src/export.c
~
src/forum.c
~
src/fusefs.c
~
src/import.c
~
src/interwiki.c
~
src/leaf.c
~
src/manifest.c
~
src/merge.c
~
src/moderate.c
~
src/path.c
~
src/rebuild.c
~
src/search.c
~
src/shun.c
~
src/tag.c
~
src/timeline.c
~
src/utf8.c
~
src/vfile.c
~
src/wikiformat.c
~
src/xfer.c
+1
-1
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -54,11 +54,11 @@ | ||
| 54 | 54 | ** Space to hold the returned value is obtained from fossil_malloc() |
| 55 | 55 | ** and should be freed by the caller. |
| 56 | 56 | */ |
| 57 | 57 | char *branch_of_rid(int rid){ |
| 58 | 58 | char *zBr = 0; |
| 59 | - static Stmt q; | |
| 59 | + static Stmt q = empty_Stmt_m; | |
| 60 | 60 | db_static_prepare(&q, |
| 61 | 61 | "SELECT value FROM tagxref" |
| 62 | 62 | " WHERE rid=$rid AND tagid=%d" |
| 63 | 63 | " AND tagtype>0", TAG_BRANCH); |
| 64 | 64 | db_bind_int(&q, "$rid", rid); |
| 65 | 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; |
| 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 @@ | ||
| 118 | 118 | |
| 119 | 119 | /* |
| 120 | 120 | ** Set or clear the vfile.isexe flag for a file. |
| 121 | 121 | */ |
| 122 | 122 | static void set_or_clear_isexe(const char *zFilename, int vid, int onoff){ |
| 123 | - static Stmt s; | |
| 123 | + static Stmt s = empty_Stmt_m; | |
| 124 | 124 | db_static_prepare(&s, |
| 125 | 125 | "UPDATE vfile SET isexe=:isexe" |
| 126 | 126 | " WHERE vid=:vid AND pathname=:path AND isexe!=:isexe" |
| 127 | 127 | ); |
| 128 | 128 | db_bind_int(&s, ":isexe", onoff); |
| 129 | 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; |
| 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 @@ | ||
| 125 | 125 | /* |
| 126 | 126 | ** Return the srcid associated with rid. Or return 0 if rid is |
| 127 | 127 | ** original content and not a delta. |
| 128 | 128 | */ |
| 129 | 129 | int delta_source_rid(int rid){ |
| 130 | - static Stmt q; | |
| 130 | + static Stmt q = empty_Stmt_m; | |
| 131 | 131 | int srcid; |
| 132 | 132 | db_static_prepare(&q, "SELECT srcid FROM delta WHERE rid=:rid"); |
| 133 | 133 | db_bind_int(&q, ":rid", rid); |
| 134 | 134 | if( db_step(&q)==SQLITE_ROW ){ |
| 135 | 135 | srcid = db_column_int(&q, 0); |
| @@ -142,11 +142,11 @@ | ||
| 142 | 142 | |
| 143 | 143 | /* |
| 144 | 144 | ** Return the blob.size field given blob.rid |
| 145 | 145 | */ |
| 146 | 146 | int content_size(int rid, int dflt){ |
| 147 | - static Stmt q; | |
| 147 | + static Stmt q = empty_Stmt_m; | |
| 148 | 148 | int sz = dflt; |
| 149 | 149 | db_static_prepare(&q, "SELECT size FROM blob WHERE rid=:r"); |
| 150 | 150 | db_bind_int(&q, ":r", rid); |
| 151 | 151 | if( db_step(&q)==SQLITE_ROW ){ |
| 152 | 152 | sz = db_column_int(&q, 0); |
| @@ -190,11 +190,11 @@ | ||
| 190 | 190 | ** show that everything that was formerly unavailable because rid |
| 191 | 191 | ** was missing is now available. |
| 192 | 192 | */ |
| 193 | 193 | static void content_mark_available(int rid){ |
| 194 | 194 | Bag pending; |
| 195 | - static Stmt q; | |
| 195 | + static Stmt q = empty_Stmt_m; | |
| 196 | 196 | if( bag_find(&contentCache.available, rid) ) return; |
| 197 | 197 | bag_init(&pending); |
| 198 | 198 | bag_insert(&pending, rid); |
| 199 | 199 | while( (rid = bag_first(&pending))!=0 ){ |
| 200 | 200 | bag_remove(&pending, rid); |
| @@ -214,11 +214,11 @@ | ||
| 214 | 214 | /* |
| 215 | 215 | ** Get the blob.content value for blob.rid=rid. Return 1 on success or |
| 216 | 216 | ** 0 on failure. |
| 217 | 217 | */ |
| 218 | 218 | static int content_of_blob(int rid, Blob *pBlob){ |
| 219 | - static Stmt q; | |
| 219 | + static Stmt q = empty_Stmt_m; | |
| 220 | 220 | int rc = 0; |
| 221 | 221 | db_static_prepare(&q, "SELECT content FROM blob WHERE rid=:rid AND size>=0"); |
| 222 | 222 | db_bind_int(&q, ":rid", rid); |
| 223 | 223 | if( db_step(&q)==SQLITE_ROW ){ |
| 224 | 224 | db_ephemeral_blob(&q, 0, pBlob); |
| @@ -784,11 +784,11 @@ | ||
| 784 | 784 | |
| 785 | 785 | /* |
| 786 | 786 | ** Return true if the given RID is marked as PRIVATE. |
| 787 | 787 | */ |
| 788 | 788 | int content_is_private(int rid){ |
| 789 | - static Stmt s1; | |
| 789 | + static Stmt s1 = empty_Stmt_m; | |
| 790 | 790 | int rc; |
| 791 | 791 | db_static_prepare(&s1, |
| 792 | 792 | "SELECT 1 FROM private WHERE rid=:rid" |
| 793 | 793 | ); |
| 794 | 794 | db_bind_int(&s1, ":rid", rid); |
| @@ -799,11 +799,11 @@ | ||
| 799 | 799 | |
| 800 | 800 | /* |
| 801 | 801 | ** Make sure an artifact is public. |
| 802 | 802 | */ |
| 803 | 803 | void content_make_public(int rid){ |
| 804 | - static Stmt s1; | |
| 804 | + static Stmt s1 = empty_Stmt_m; | |
| 805 | 805 | db_static_prepare(&s1, |
| 806 | 806 | "DELETE FROM private WHERE rid=:rid" |
| 807 | 807 | ); |
| 808 | 808 | db_bind_int(&s1, ":rid", rid); |
| 809 | 809 | db_exec(&s1); |
| @@ -811,11 +811,11 @@ | ||
| 811 | 811 | |
| 812 | 812 | /* |
| 813 | 813 | ** Make sure an artifact is private |
| 814 | 814 | */ |
| 815 | 815 | void content_make_private(int rid){ |
| 816 | - static Stmt s1; | |
| 816 | + static Stmt s1 = empty_Stmt_m; | |
| 817 | 817 | db_static_prepare(&s1, |
| 818 | 818 | "INSERT OR IGNORE INTO private(rid) VALUES(:rid)" |
| 819 | 819 | ); |
| 820 | 820 | db_bind_int(&s1, ":rid", rid); |
| 821 | 821 | db_exec(&s1); |
| @@ -1164,11 +1164,11 @@ | ||
| 1164 | 1164 | unsigned flags, /* Flags */ |
| 1165 | 1165 | Manifest *p, /* The control artifact that references zUuid */ |
| 1166 | 1166 | const char *zRole, /* Role of zUuid in p */ |
| 1167 | 1167 | const char *zDetail /* Additional information, such as a filename */ |
| 1168 | 1168 | ){ |
| 1169 | - static Stmt q; | |
| 1169 | + static Stmt q = empty_Stmt_m; | |
| 1170 | 1170 | int rc = 0; |
| 1171 | 1171 | |
| 1172 | 1172 | db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=:uuid"); |
| 1173 | 1173 | if( zUuid==0 || zUuid[0]==0 ) return 0; |
| 1174 | 1174 | db_bind_text(&q, ":uuid", zUuid); |
| 1175 | 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; |
| 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 |
M
src/db.c
+4
-4
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -3780,21 +3780,21 @@ | ||
| 3780 | 3780 | */ |
| 3781 | 3781 | char *db_get(const char *zName, const char *zDefault){ |
| 3782 | 3782 | char *z = 0; |
| 3783 | 3783 | const Setting *pSetting = db_find_setting(zName, 0); |
| 3784 | 3784 | if( g.repositoryOpen ){ |
| 3785 | - static Stmt q1; | |
| 3785 | + static Stmt q1 = empty_Stmt_m; | |
| 3786 | 3786 | const char *zRes; |
| 3787 | 3787 | db_static_prepare(&q1, "SELECT value FROM config WHERE name=$n"); |
| 3788 | 3788 | db_bind_text(&q1, "$n", zName); |
| 3789 | 3789 | if( db_step(&q1)==SQLITE_ROW && (zRes = db_column_text(&q1,0))!=0 ){ |
| 3790 | 3790 | z = fossil_strdup(zRes); |
| 3791 | 3791 | } |
| 3792 | 3792 | db_reset(&q1); |
| 3793 | 3793 | } |
| 3794 | 3794 | if( z==0 && g.zConfigDbName ){ |
| 3795 | - static Stmt q2; | |
| 3795 | + static Stmt q2 = empty_Stmt_m; | |
| 3796 | 3796 | const char *zRes; |
| 3797 | 3797 | db_swap_connections(); |
| 3798 | 3798 | db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n"); |
| 3799 | 3799 | db_swap_connections(); |
| 3800 | 3800 | db_bind_text(&q2, "$n", zName); |
| @@ -3890,11 +3890,11 @@ | ||
| 3890 | 3890 | } |
| 3891 | 3891 | int db_get_int(const char *zName, int dflt){ |
| 3892 | 3892 | int v = dflt; |
| 3893 | 3893 | int rc; |
| 3894 | 3894 | if( g.repositoryOpen ){ |
| 3895 | - static Stmt q; | |
| 3895 | + static Stmt q = empty_Stmt_m; | |
| 3896 | 3896 | db_static_prepare(&q, "SELECT value FROM config WHERE name=$n"); |
| 3897 | 3897 | db_bind_text(&q, "$n", zName); |
| 3898 | 3898 | rc = db_step(&q); |
| 3899 | 3899 | if( rc==SQLITE_ROW ){ |
| 3900 | 3900 | v = db_column_int(&q, 0); |
| @@ -3902,11 +3902,11 @@ | ||
| 3902 | 3902 | db_reset(&q); |
| 3903 | 3903 | }else{ |
| 3904 | 3904 | rc = SQLITE_DONE; |
| 3905 | 3905 | } |
| 3906 | 3906 | if( rc==SQLITE_DONE && g.zConfigDbName ){ |
| 3907 | - static Stmt q2; | |
| 3907 | + static Stmt q2 = empty_Stmt_m; | |
| 3908 | 3908 | db_swap_connections(); |
| 3909 | 3909 | db_static_prepare(&q2, "SELECT value FROM global_config WHERE name=$n"); |
| 3910 | 3910 | db_swap_connections(); |
| 3911 | 3911 | db_bind_text(&q2, "$n", zName); |
| 3912 | 3912 | if( db_step(&q2)==SQLITE_ROW ){ |
| 3913 | 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; |
| 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 |
+2
-2
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -162,11 +162,11 @@ | ||
| 162 | 162 | /* |
| 163 | 163 | ** If RID refers to a check-in, return the mtime of that check-in - the |
| 164 | 164 | ** Julian day number of when the check-in occurred. |
| 165 | 165 | */ |
| 166 | 166 | double mtime_of_rid(int rid, double mtime){ |
| 167 | - static Stmt q; | |
| 167 | + static Stmt q = empty_Stmt_m; | |
| 168 | 168 | db_static_prepare(&q,"SELECT mtime FROM event WHERE objid=:rid"); |
| 169 | 169 | db_bind_int(&q, ":rid", rid); |
| 170 | 170 | if( db_step(&q)==SQLITE_ROW ){ |
| 171 | 171 | mtime = db_column_double(&q,0); |
| 172 | 172 | } |
| @@ -302,11 +302,11 @@ | ||
| 302 | 302 | int vid, /* The check-in that contains fid */ |
| 303 | 303 | int fid, /* The id of the file whose check-in time is sought */ |
| 304 | 304 | i64 *pMTime /* Write result here */ |
| 305 | 305 | ){ |
| 306 | 306 | static int prevVid = -1; |
| 307 | - static Stmt q; | |
| 307 | + static Stmt q = empty_Stmt_m; | |
| 308 | 308 | |
| 309 | 309 | if( prevVid!=vid ){ |
| 310 | 310 | prevVid = vid; |
| 311 | 311 | db_multi_exec("CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);" |
| 312 | 312 | "DELETE FROM ok;"); |
| 313 | 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; |
| 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 @@ | ||
| 43 | 43 | /* |
| 44 | 44 | ** Output a "committer" record for the given user. |
| 45 | 45 | ** NOTE: the given user name may be an email itself. |
| 46 | 46 | */ |
| 47 | 47 | static void print_person(const char *zUser){ |
| 48 | - static Stmt q; | |
| 48 | + static Stmt q = empty_Stmt_m; | |
| 49 | 49 | const char *zContact; |
| 50 | 50 | char *zName; |
| 51 | 51 | char *zEmail; |
| 52 | 52 | int i, j; |
| 53 | 53 | int isBracketed, atEmailFirst, atEmailLast; |
| 54 | 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; |
| 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 @@ | ||
| 188 | 188 | /* |
| 189 | 189 | ** Return true if the forum post with the given rid has been |
| 190 | 190 | ** subsequently edited. |
| 191 | 191 | */ |
| 192 | 192 | int forum_rid_has_been_edited(int rid){ |
| 193 | - static Stmt q; | |
| 193 | + static Stmt q = empty_Stmt_m; | |
| 194 | 194 | int res; |
| 195 | 195 | db_static_prepare(&q, |
| 196 | 196 | "SELECT 1 FROM forumpost A, forumpost B" |
| 197 | 197 | " WHERE A.fpid=$rid AND B.froot=A.froot AND B.fprev=$rid" |
| 198 | 198 | ); |
| @@ -244,11 +244,11 @@ | ||
| 244 | 244 | ** matches the event.(euser,user) field for a formpost entry with the |
| 245 | 245 | ** matching RID. Returns false if no match is found. If zUserName is |
| 246 | 246 | ** 0 then login_name() is used. |
| 247 | 247 | */ |
| 248 | 248 | int forumpost_is_owner(int rid, const char *zUserName){ |
| 249 | - static Stmt q; | |
| 249 | + static Stmt q = empty_Stmt_m; | |
| 250 | 250 | int rc; |
| 251 | 251 | if( !q.pStmt ){ |
| 252 | 252 | db_static_prepare( |
| 253 | 253 | &q, "SELECT 1 FROM event" |
| 254 | 254 | " WHERE type='f' AND objid=$rid" |
| @@ -991,11 +991,11 @@ | ||
| 991 | 991 | ** |
| 992 | 992 | ** HTML markup within the reply has been property escaped. Hyperlinks |
| 993 | 993 | ** may have been added. The result is safe for use with %s. |
| 994 | 994 | */ |
| 995 | 995 | static char *display_name_from_login(const char *zLogin){ |
| 996 | - static Stmt q; | |
| 996 | + static Stmt q = empty_Stmt_m; | |
| 997 | 997 | char *zResult; |
| 998 | 998 | db_static_prepare(&q, |
| 999 | 999 | "SELECT display_name(info) FROM user WHERE login=$login" |
| 1000 | 1000 | ); |
| 1001 | 1001 | db_bind_text(&q, "$login", zLogin); |
| @@ -2426,11 +2426,11 @@ | ||
| 2426 | 2426 | static void forum_status_match( |
| 2427 | 2427 | sqlite3_context *context, |
| 2428 | 2428 | int argc, |
| 2429 | 2429 | sqlite3_value **argv |
| 2430 | 2430 | ){ |
| 2431 | - static Stmt q; | |
| 2431 | + static Stmt q = empty_Stmt_m; | |
| 2432 | 2432 | ForumStatusMatch *pMData = sqlite3_user_data(context); |
| 2433 | 2433 | int i; |
| 2434 | 2434 | |
| 2435 | 2435 | if( pMData==0 ){ |
| 2436 | 2436 | sqlite3_result_int(context, 1); |
| 2437 | 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; |
| 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 @@ | ||
| 149 | 149 | fusefs_load_rid(rid, fusefs.az[1]); |
| 150 | 150 | if( fusefs.pMan==0 ) return -ENOENT; |
| 151 | 151 | stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0; |
| 152 | 152 | pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 0); |
| 153 | 153 | if( pFile ){ |
| 154 | - static Stmt q; | |
| 154 | + static Stmt q = empty_Stmt_m; | |
| 155 | 155 | stbuf->st_mode = S_IFREG | |
| 156 | 156 | (manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444); |
| 157 | 157 | stbuf->st_nlink = 1; |
| 158 | 158 | db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid"); |
| 159 | 159 | db_bind_text(&q, "$uuid", pFile->zUuid); |
| 160 | 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; |
| 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 @@ | ||
| 139 | 139 | int rid; |
| 140 | 140 | |
| 141 | 141 | hname_hash(pContent, 0, &hash); |
| 142 | 142 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &hash); |
| 143 | 143 | if( rid==0 ){ |
| 144 | - static Stmt ins; | |
| 144 | + static Stmt ins = empty_Stmt_m; | |
| 145 | 145 | assert( g.rcvid>0 ); |
| 146 | 146 | db_static_prepare(&ins, |
| 147 | 147 | "INSERT INTO blob(uuid, size, rcvid, content)" |
| 148 | 148 | "VALUES(:uuid, :size, %d, :content)", g.rcvid |
| 149 | 149 | ); |
| @@ -1024,13 +1024,13 @@ | ||
| 1024 | 1024 | |
| 1025 | 1025 | #define MAX_INT_32 (0x7FFFFFFFL) |
| 1026 | 1026 | |
| 1027 | 1027 | static void svn_finish_revision(){ |
| 1028 | 1028 | 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; | |
| 1032 | 1032 | Blob mcksum; |
| 1033 | 1033 | |
| 1034 | 1034 | blob_zero(&manifest); |
| 1035 | 1035 | db_static_prepare(&getChanges, "SELECT tid, tname, ttype, tparent" |
| 1036 | 1036 | " FROM xrevisions, xbranches ON (tbranch=tid)" |
| 1037 | 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; |
| 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 @@ | ||
| 75 | 75 | int i; |
| 76 | 76 | const char *zPage; |
| 77 | 77 | int nPage; |
| 78 | 78 | char *zUrl = 0; |
| 79 | 79 | char *zName; |
| 80 | - static Stmt q; | |
| 80 | + static Stmt q = empty_Stmt_m; | |
| 81 | 81 | for(i=0; fossil_isalnum(zTarget[i]); i++){} |
| 82 | 82 | if( zTarget[i]!=':' ) return 0; |
| 83 | 83 | nCode = i; |
| 84 | 84 | if( nCode==4 && strncmp(zTarget,"wiki",4)==0 ) return 0; |
| 85 | 85 | zPage = zTarget + nCode + 1; |
| 86 | 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; |
| 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 @@ | ||
| 55 | 55 | ** |
| 56 | 56 | ** A non-branch child is one which is on the same branch as the parent. |
| 57 | 57 | */ |
| 58 | 58 | int count_nonbranch_children(int pid){ |
| 59 | 59 | int nNonBranch = 0; |
| 60 | - static Stmt q; | |
| 60 | + static Stmt q = empty_Stmt_m; | |
| 61 | 61 | static const char zSql[] = |
| 62 | 62 | @ SELECT count(*) FROM plink |
| 63 | 63 | @ WHERE pid=:pid AND isprim |
| 64 | 64 | @ AND coalesce((SELECT value FROM tagxref |
| 65 | 65 | @ WHERE tagid=%d AND rid=plink.pid), 'trunk') |
| @@ -105,13 +105,13 @@ | ||
| 105 | 105 | /* |
| 106 | 106 | ** Check to see if check-in "rid" is a leaf and either add it to the LEAF |
| 107 | 107 | ** table if it is, or remove it if it is not. |
| 108 | 108 | */ |
| 109 | 109 | 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; | |
| 113 | 113 | int rc; |
| 114 | 114 | |
| 115 | 115 | db_static_prepare(&checkIfLeaf, |
| 116 | 116 | "SELECT 1 FROM plink" |
| 117 | 117 | " WHERE pid=:rid" |
| @@ -168,11 +168,11 @@ | ||
| 168 | 168 | |
| 169 | 169 | /* |
| 170 | 170 | ** Schedule a leaf check for "rid" and its parents. |
| 171 | 171 | */ |
| 172 | 172 | void leaf_eventually_check(int rid){ |
| 173 | - static Stmt parentsOf; | |
| 173 | + static Stmt parentsOf = empty_Stmt_m; | |
| 174 | 174 | |
| 175 | 175 | db_static_prepare(&parentsOf, |
| 176 | 176 | "SELECT pid FROM plink WHERE cid=:rid AND pid>0" |
| 177 | 177 | ); |
| 178 | 178 | db_bind_int(&parentsOf, ":rid", rid); |
| 179 | 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; |
| 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 @@ | ||
| 1699 | 1699 | Blob otherContent; |
| 1700 | 1700 | int otherRid; |
| 1701 | 1701 | int i, rc; |
| 1702 | 1702 | ManifestFile *pChildFile, *pParentFile; |
| 1703 | 1703 | Manifest **ppOther; |
| 1704 | - static Stmt eq; | |
| 1704 | + static Stmt eq = empty_Stmt_m; | |
| 1705 | 1705 | int isPublic; /* True if pChild is non-private */ |
| 1706 | 1706 | |
| 1707 | 1707 | /* If mlink table entires are already exist for the pmid-to-mid transition, |
| 1708 | 1708 | ** then abort early doing no work. |
| 1709 | 1709 | */ |
| @@ -2427,11 +2427,11 @@ | ||
| 2427 | 2427 | } |
| 2428 | 2428 | } |
| 2429 | 2429 | } |
| 2430 | 2430 | } |
| 2431 | 2431 | if( p->type==CFTYPE_CLUSTER ){ |
| 2432 | - static Stmt del1; | |
| 2432 | + static Stmt del1 = empty_Stmt_m; | |
| 2433 | 2433 | tag_insert("cluster", 1, 0, rid, p->rDate, rid); |
| 2434 | 2434 | db_static_prepare(&del1, "DELETE FROM unclustered WHERE rid=:rid"); |
| 2435 | 2435 | for(i=0; i<p->nCChild; i++){ |
| 2436 | 2436 | int mid; |
| 2437 | 2437 | mid = uuid_to_rid(p->azCChild[i], 1); |
| 2438 | 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; |
| 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 @@ | ||
| 546 | 546 | /* |
| 547 | 547 | ** Check content that was received with rcvid and return true if any |
| 548 | 548 | ** fork was created. |
| 549 | 549 | */ |
| 550 | 550 | int fossil_any_has_fork(int rcvid){ |
| 551 | - static Stmt q; | |
| 551 | + static Stmt q = empty_Stmt_m; | |
| 552 | 552 | int fForkSeen = 0; |
| 553 | 553 | |
| 554 | 554 | if( rcvid==0 ) return 0; |
| 555 | 555 | db_static_prepare(&q, |
| 556 | 556 | " SELECT pid FROM plink WHERE pid>0 AND isprim" |
| 557 | 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; |
| 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 @@ | ||
| 45 | 45 | |
| 46 | 46 | /* |
| 47 | 47 | ** Return TRUE if the object specified is being held for moderation. |
| 48 | 48 | */ |
| 49 | 49 | int moderation_pending(int rid){ |
| 50 | - static Stmt q; | |
| 50 | + static Stmt q = empty_Stmt_m; | |
| 51 | 51 | int rc; |
| 52 | 52 | if( rid==0 || !moderation_table_exists() ) return 0; |
| 53 | 53 | db_static_prepare(&q, "SELECT 1 FROM modreq WHERE objid=:objid"); |
| 54 | 54 | db_bind_int(&q, ":objid", rid); |
| 55 | 55 | rc = db_step(&q)==SQLITE_ROW; |
| @@ -283,14 +283,14 @@ | ||
| 283 | 283 | ** return true for admins because that check skips looking at the |
| 284 | 284 | ** db. |
| 285 | 285 | ** |
| 286 | 286 | */ |
| 287 | 287 | int moderation_user_could(int rid, int bMayDeny, const char *zWho){ |
| 288 | - static Stmt q; | |
| 288 | + static Stmt q = empty_Stmt_m; | |
| 289 | 289 | int rc = 0; |
| 290 | 290 | if( g.perm.Admin ) return g.perm.Admin; |
| 291 | - if( !q.pStmt ){ | |
| 291 | + if( !q.pStmt ){ /* FIXME: this if(..) looks redundant here */ | |
| 292 | 292 | db_static_prepare( |
| 293 | 293 | &q, |
| 294 | 294 | "SELECT coalesce(euser,user)=:user, type FROM event " |
| 295 | 295 | "WHERE objid=:rid" |
| 296 | 296 | ); |
| 297 | 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; |
| 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 @@ | ||
| 78 | 78 | ** Given a RID, return the ISO date/time string and branch for the |
| 79 | 79 | ** corresponding check-in. Memory is held locally and is overwritten |
| 80 | 80 | ** with each call. |
| 81 | 81 | */ |
| 82 | 82 | char *path_rid_desc(int rid){ |
| 83 | - static Stmt q; | |
| 83 | + static Stmt q = empty_Stmt_m; | |
| 84 | 84 | static char *zDesc = 0; |
| 85 | 85 | db_static_prepare(&q, |
| 86 | 86 | "SELECT concat(strftime('%%Y%%m%%d%%H%%M',event.mtime),'/',value)" |
| 87 | 87 | " FROM event, tagxref" |
| 88 | 88 | " WHERE event.objid=:rid" |
| 89 | 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; |
| 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 @@ | ||
| 252 | 252 | ** other artifacts that are deltas off of the current artifact. |
| 253 | 253 | ** This is the most efficient way to extract all of the original |
| 254 | 254 | ** artifact content from the Fossil repository. |
| 255 | 255 | */ |
| 256 | 256 | static void rebuild_step(int rid, int size, Blob *pBase){ |
| 257 | - static Stmt q1; | |
| 257 | + static Stmt q1 = empty_Stmt_m; | |
| 258 | 258 | Bag children; |
| 259 | 259 | Blob copy; |
| 260 | 260 | Blob *pUse; |
| 261 | 261 | int nChild, i, cid; |
| 262 | 262 | |
| @@ -317,11 +317,11 @@ | ||
| 317 | 317 | rebuild_step_done(rid); |
| 318 | 318 | |
| 319 | 319 | /* Call all children recursively */ |
| 320 | 320 | rid = 0; |
| 321 | 321 | 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; | |
| 323 | 323 | int sz; |
| 324 | 324 | db_static_prepare(&q2, "SELECT content, size FROM blob WHERE rid=:rid"); |
| 325 | 325 | db_bind_int(&q2, ":rid", cid); |
| 326 | 326 | if( db_step(&q2)==SQLITE_ROW && (sz = db_column_int(&q2,1))>=0 ){ |
| 327 | 327 | Blob delta, next; |
| 328 | 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; |
| 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 @@ | ||
| 1587 | 1587 | blob_reset(&wiki); |
| 1588 | 1588 | manifest_destroy(pWiki); |
| 1589 | 1589 | break; |
| 1590 | 1590 | } |
| 1591 | 1591 | case 'c': { /* Check-in Comments */ |
| 1592 | - static Stmt q; | |
| 1592 | + static Stmt q = empty_Stmt_m; | |
| 1593 | 1593 | static int isPlainText = -1; |
| 1594 | 1594 | db_static_prepare(&q, |
| 1595 | 1595 | "SELECT coalesce(ecomment,comment)" |
| 1596 | 1596 | " ||' (user: '||coalesce(euser,user,'?')" |
| 1597 | 1597 | " ||', tags: '||" |
| @@ -1619,11 +1619,11 @@ | ||
| 1619 | 1619 | } |
| 1620 | 1620 | db_reset(&q); |
| 1621 | 1621 | break; |
| 1622 | 1622 | } |
| 1623 | 1623 | case 't': { /* Tickets */ |
| 1624 | - static Stmt q1; | |
| 1624 | + static Stmt q1 = empty_Stmt_m; | |
| 1625 | 1625 | static int iTitle = -1; |
| 1626 | 1626 | db_static_prepare(&q1, "SELECT * FROM ticket WHERE tkt_id=:rid"); |
| 1627 | 1627 | db_bind_int(&q1, ":rid", rid); |
| 1628 | 1628 | if( db_step(&q1)==SQLITE_ROW ){ |
| 1629 | 1629 | if( iTitle<0 ){ |
| @@ -1634,11 +1634,11 @@ | ||
| 1634 | 1634 | } |
| 1635 | 1635 | append_all_ticket_fields(pOut, &q1, iTitle); |
| 1636 | 1636 | } |
| 1637 | 1637 | db_reset(&q1); |
| 1638 | 1638 | if( db_table_exists("repository","ticketchng") ){ |
| 1639 | - static Stmt q2; | |
| 1639 | + static Stmt q2 = empty_Stmt_m; | |
| 1640 | 1640 | db_static_prepare(&q2, "SELECT * FROM ticketchng WHERE tkt_id=:rid" |
| 1641 | 1641 | " ORDER BY tkt_mtime"); |
| 1642 | 1642 | db_bind_int(&q2, ":rid", rid); |
| 1643 | 1643 | while( db_step(&q2)==SQLITE_ROW ){ |
| 1644 | 1644 | append_all_ticket_fields(pOut, &q2, -1); |
| 1645 | 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; |
| 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 @@ | ||
| 23 | 23 | |
| 24 | 24 | /* |
| 25 | 25 | ** Return true if the given artifact ID should be shunned. |
| 26 | 26 | */ |
| 27 | 27 | int uuid_is_shunned(const char *zUuid){ |
| 28 | - static Stmt q; | |
| 28 | + static Stmt q = empty_Stmt_m; | |
| 29 | 29 | int rc; |
| 30 | 30 | if( zUuid==0 || zUuid[0]==0 ) return 0; |
| 31 | 31 | if( g.eHashPolicy==HPOLICY_SHUN_SHA1 && zUuid[HNAME_LEN_SHA1]==0 ) return 1; |
| 32 | 32 | db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid"); |
| 33 | 33 | db_bind_text(&q, ":uuid", zUuid); |
| 34 | 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; |
| 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 @@ | ||
| 1014 | 1014 | ** |
| 1015 | 1015 | ** Ownership of *pOut is transfered to the caller, who must eventually |
| 1016 | 1016 | ** fossil_free() it. |
| 1017 | 1017 | */ |
| 1018 | 1018 | int rid_has_tag2(int rid, const char *zTag, char **pOut){ |
| 1019 | - static Stmt q; | |
| 1019 | + static Stmt q = empty_Stmt_m; | |
| 1020 | 1020 | int rc = 0; |
| 1021 | + /* FIXME: db_static_prepare() without if(..) looks more suitable here */ | |
| 1021 | 1022 | if( !q.pStmt ){ |
| 1022 | 1023 | db_prepare( |
| 1023 | 1024 | &q, "SELECT t.tagid, x.value" |
| 1024 | 1025 | " FROM tagxref x, tag t" |
| 1025 | 1026 | " WHERE x.rid=:rid" |
| 1026 | 1027 |
| --- 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 @@ | ||
| 143 | 143 | /* |
| 144 | 144 | ** Return true if the checking identified by "rid" has a valid "closed" |
| 145 | 145 | ** tag. |
| 146 | 146 | */ |
| 147 | 147 | static int has_closed_tag(int rid){ |
| 148 | - static Stmt q; | |
| 148 | + static Stmt q = empty_Stmt_m; | |
| 149 | 149 | int res = 0; |
| 150 | 150 | db_static_prepare(&q, |
| 151 | 151 | "SELECT 1 FROM tagxref WHERE rid=$rid AND tagid=%d AND tagtype>0", |
| 152 | 152 | TAG_CLOSED); |
| 153 | 153 | db_bind_int(&q, "$rid", rid); |
| @@ -583,11 +583,11 @@ | ||
| 583 | 583 | if( tmFlags & TIMELINE_UCOLOR ){ |
| 584 | 584 | zBgClr = zUser ? user_color(zUser) : 0; |
| 585 | 585 | }else if( tmFlags & TIMELINE_NOCOLOR ){ |
| 586 | 586 | zBgClr = 0; |
| 587 | 587 | }else if( zType[0]=='c' ){ |
| 588 | - static Stmt qdelta; | |
| 588 | + static Stmt qdelta = empty_Stmt_m; | |
| 589 | 589 | db_static_prepare(&qdelta, "SELECT baseid IS NULL FROM plink" |
| 590 | 590 | " WHERE cid=:rid"); |
| 591 | 591 | db_bind_int(&qdelta, ":rid", rid); |
| 592 | 592 | if( db_step(&qdelta)!=SQLITE_ROW ){ |
| 593 | 593 | zBgClr = 0; /* Not a check-in */ |
| @@ -619,11 +619,11 @@ | ||
| 619 | 619 | } |
| 620 | 620 | if( zType[0]=='c' && pGraph ){ |
| 621 | 621 | int nParent = 0; |
| 622 | 622 | int nCherrypick = 0; |
| 623 | 623 | GraphRowId aParent[GR_MAX_RAIL]; |
| 624 | - static Stmt qparent; | |
| 624 | + static Stmt qparent = empty_Stmt_m; | |
| 625 | 625 | if( tmFlags & TIMELINE_GRAPH ){ |
| 626 | 626 | db_static_prepare(&qparent, |
| 627 | 627 | "SELECT pid FROM plink" |
| 628 | 628 | " WHERE cid=:rid AND pid NOT IN phantom" |
| 629 | 629 | " ORDER BY isprim DESC /*sort*/" |
| @@ -632,11 +632,11 @@ | ||
| 632 | 632 | while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){ |
| 633 | 633 | aParent[nParent++] = db_column_int(&qparent, 0); |
| 634 | 634 | } |
| 635 | 635 | db_reset(&qparent); |
| 636 | 636 | if( (tmFlags & TIMELINE_CHPICK)!=0 && nParent>0 ){ |
| 637 | - static Stmt qcherrypick; | |
| 637 | + static Stmt qcherrypick = empty_Stmt_m; | |
| 638 | 638 | db_static_prepare(&qcherrypick, |
| 639 | 639 | "SELECT parentid FROM cherrypick" |
| 640 | 640 | " WHERE childid=:rid AND parentid NOT IN phantom" |
| 641 | 641 | ); |
| 642 | 642 | db_bind_int(&qcherrypick, ":rid", rid); |
| @@ -674,11 +674,11 @@ | ||
| 674 | 674 | } |
| 675 | 675 | if( modPending ){ |
| 676 | 676 | @ <span class="modpending">(Awaiting Moderator Approval)</span> |
| 677 | 677 | } |
| 678 | 678 | if( (tmFlags & TIMELINE_BISECT)!=0 && zType[0]=='c' ){ |
| 679 | - static Stmt bisectQuery; | |
| 679 | + static Stmt bisectQuery = empty_Stmt_m; | |
| 680 | 680 | db_static_prepare(&bisectQuery, |
| 681 | 681 | "SELECT seq, stat FROM bilog WHERE rid=:rid AND seq"); |
| 682 | 682 | db_bind_int(&bisectQuery, ":rid", rid); |
| 683 | 683 | if( db_step(&bisectQuery)==SQLITE_ROW ){ |
| 684 | 684 | @ <b>%s(db_column_text(&bisectQuery,1))</b> |
| 685 | 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; |
| 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 @@ | ||
| 58 | 58 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0); |
| 59 | 59 | char *zUtf = fossil_malloc( nByte ); |
| 60 | 60 | WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0); |
| 61 | 61 | return zUtf; |
| 62 | 62 | #else |
| 63 | - static Stmt q; | |
| 63 | + static Stmt q = empty_Stmt_m; | |
| 64 | 64 | char *zUtf8; |
| 65 | 65 | db_static_prepare(&q, "SELECT :utf8"); |
| 66 | 66 | db_bind_text16(&q, ":utf8", zUnicode); |
| 67 | 67 | db_step(&q); |
| 68 | 68 | zUtf8 = fossil_strdup(db_column_text(&q, 0)); |
| 69 | 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; |
| 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 @@ | ||
| 25 | 25 | /* |
| 26 | 26 | ** The input is guaranteed to be a 40- or 64-character well-formed |
| 27 | 27 | ** artifact hash. Find its rid. |
| 28 | 28 | */ |
| 29 | 29 | int fast_uuid_to_rid(const char *zUuid){ |
| 30 | - static Stmt q; | |
| 30 | + static Stmt q = empty_Stmt_m; | |
| 31 | 31 | int rid; |
| 32 | 32 | db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid"); |
| 33 | 33 | db_bind_text(&q, ":uuid", zUuid); |
| 34 | 34 | if( db_step(&q)==SQLITE_ROW ){ |
| 35 | 35 | rid = db_column_int(&q, 0); |
| @@ -468,11 +468,11 @@ | ||
| 468 | 468 | ){ |
| 469 | 469 | DIR *d; |
| 470 | 470 | int origSize; |
| 471 | 471 | struct dirent *pEntry; |
| 472 | 472 | int skipAll = 0; |
| 473 | - static Stmt ins; | |
| 473 | + static Stmt ins = empty_Stmt_m; | |
| 474 | 474 | static int depth = 0; |
| 475 | 475 | void *zNative; |
| 476 | 476 | |
| 477 | 477 | origSize = blob_size(pPath); |
| 478 | 478 | if( pIgnore1 || pIgnore2 ){ |
| @@ -599,12 +599,12 @@ | ||
| 599 | 599 | int result = 0; |
| 600 | 600 | DIR *d; |
| 601 | 601 | int origSize; |
| 602 | 602 | struct dirent *pEntry; |
| 603 | 603 | 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; | |
| 606 | 606 | static int depth = 0; |
| 607 | 607 | void *zNative; |
| 608 | 608 | |
| 609 | 609 | origSize = blob_size(pPath); |
| 610 | 610 | if( pIgnore1 || pIgnore2 ){ |
| @@ -618,10 +618,11 @@ | ||
| 618 | 618 | if( depth==0 ){ |
| 619 | 619 | db_multi_exec("DROP TABLE IF EXISTS dscan_temp;" |
| 620 | 620 | "CREATE TEMP TABLE dscan_temp(" |
| 621 | 621 | " x TEXT PRIMARY KEY %s, y INTEGER)", |
| 622 | 622 | filename_collation()); |
| 623 | + /* FIXME: maybe db_static_prepare() is more suitable here? */ | |
| 623 | 624 | db_prepare(&ins, |
| 624 | 625 | "INSERT OR IGNORE INTO dscan_temp(x, y) SELECT :file, :count" |
| 625 | 626 | " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE" |
| 626 | 627 | " pathname GLOB :file || '/*' %s)", filename_collation() |
| 627 | 628 | ); |
| 628 | 629 |
| --- 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 |
+2
-2
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -1146,11 +1146,11 @@ | ||
| 1146 | 1146 | /* |
| 1147 | 1147 | ** Return TRUE if a hash name corresponds to an artifact in this |
| 1148 | 1148 | ** repository. |
| 1149 | 1149 | */ |
| 1150 | 1150 | static int in_this_repo(const char *zUuid){ |
| 1151 | - static Stmt q; | |
| 1151 | + static Stmt q = empty_Stmt_m; | |
| 1152 | 1152 | int rc; |
| 1153 | 1153 | int n; |
| 1154 | 1154 | char zU2[HNAME_MAX+1]; |
| 1155 | 1155 | db_static_prepare(&q, |
| 1156 | 1156 | "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2" |
| @@ -1175,11 +1175,11 @@ | ||
| 1175 | 1175 | */ |
| 1176 | 1176 | int is_ticket( |
| 1177 | 1177 | const char *zTarget, /* Ticket UUID */ |
| 1178 | 1178 | int *pClosed /* True if the ticket is closed */ |
| 1179 | 1179 | ){ |
| 1180 | - static Stmt q; | |
| 1180 | + static Stmt q = empty_Stmt_m; | |
| 1181 | 1181 | int n; |
| 1182 | 1182 | int rc; |
| 1183 | 1183 | char zLower[HNAME_MAX+1]; |
| 1184 | 1184 | char zUpper[HNAME_MAX+1]; |
| 1185 | 1185 | n = strlen(zTarget); |
| 1186 | 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; |
| 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 @@ | ||
| 66 | 66 | ** |
| 67 | 67 | ** Compare to uuid_to_rid(). This routine takes a blob argument |
| 68 | 68 | ** and does less error checking. |
| 69 | 69 | */ |
| 70 | 70 | static int rid_from_uuid(Blob *pUuid, int phantomize, int isPrivate){ |
| 71 | - static Stmt q; | |
| 71 | + static Stmt q = empty_Stmt_m; | |
| 72 | 72 | int rid; |
| 73 | 73 | |
| 74 | 74 | db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid"); |
| 75 | 75 | db_bind_str(&q, ":uuid", pUuid); |
| 76 | 76 | if( db_step(&q)==SQLITE_ROW ){ |
| @@ -89,11 +89,11 @@ | ||
| 89 | 89 | ** Remember that the other side of the connection already has a copy |
| 90 | 90 | ** of the file rid. |
| 91 | 91 | */ |
| 92 | 92 | static void remote_has(int rid){ |
| 93 | 93 | if( rid ){ |
| 94 | - static Stmt q; | |
| 94 | + static Stmt q = empty_Stmt_m; | |
| 95 | 95 | db_static_prepare(&q, "INSERT OR IGNORE INTO onremote VALUES(:r)"); |
| 96 | 96 | db_bind_int(&q, ":r", rid); |
| 97 | 97 | db_step(&q); |
| 98 | 98 | db_reset(&q); |
| 99 | 99 | } |
| @@ -102,11 +102,11 @@ | ||
| 102 | 102 | /* |
| 103 | 103 | ** Remember that the other side of the connection lacks a copy of |
| 104 | 104 | ** the artifact with the given hash. |
| 105 | 105 | */ |
| 106 | 106 | static void remote_unk(Blob *pHash){ |
| 107 | - static Stmt q; | |
| 107 | + static Stmt q = empty_Stmt_m; | |
| 108 | 108 | db_static_prepare(&q, "INSERT OR IGNORE INTO unk VALUES(:h)"); |
| 109 | 109 | db_bind_text(&q, ":h", blob_str(pHash)); |
| 110 | 110 | db_step(&q); |
| 111 | 111 | db_reset(&q); |
| 112 | 112 | } |
| @@ -634,11 +634,11 @@ | ||
| 634 | 634 | int szU; |
| 635 | 635 | int szC; |
| 636 | 636 | int rc; |
| 637 | 637 | int isPrivate; |
| 638 | 638 | int srcIsPrivate; |
| 639 | - static Stmt q1; | |
| 639 | + static Stmt q1 = empty_Stmt_m; | |
| 640 | 640 | Blob fullContent; |
| 641 | 641 | |
| 642 | 642 | isPrivate = content_is_private(rid); |
| 643 | 643 | if( isPrivate && pXfer->syncPrivate==0 ) return; |
| 644 | 644 | db_static_prepare(&q1, |
| 645 | 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; |
| 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 |