Fossil SCM
Do not complain about unfinalized SQL statements when exiting on a fatal error. Fix comments and indentation on the vfile_verify_not_phantom() function.
Commit
c2f5dbe65527d18339a570088f67022a8a29a890
Parent
7aaa2aa4179966c…
8 files changed
+1
-1
+2
-2
+21
-5
+5
-5
+2
-2
+1
-1
+1
-1
+3
-2
+1
-1
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -290,8 +290,8 @@ | ||
| 290 | 290 | db_must_be_within_tree(); |
| 291 | 291 | if( !forceFlag && unsaved_changes()==1 ){ |
| 292 | 292 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 293 | 293 | } |
| 294 | 294 | unlink_local_database(1); |
| 295 | - db_close(); | |
| 295 | + db_close(1); | |
| 296 | 296 | unlink_local_database(0); |
| 297 | 297 | } |
| 298 | 298 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -290,8 +290,8 @@ | |
| 290 | db_must_be_within_tree(); |
| 291 | if( !forceFlag && unsaved_changes()==1 ){ |
| 292 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 293 | } |
| 294 | unlink_local_database(1); |
| 295 | db_close(); |
| 296 | unlink_local_database(0); |
| 297 | } |
| 298 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -290,8 +290,8 @@ | |
| 290 | db_must_be_within_tree(); |
| 291 | if( !forceFlag && unsaved_changes()==1 ){ |
| 292 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 293 | } |
| 294 | unlink_local_database(1); |
| 295 | db_close(1); |
| 296 | unlink_local_database(0); |
| 297 | } |
| 298 |
+2
-2
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -57,11 +57,11 @@ | ||
| 57 | 57 | zDefaultUser = find_option("admin-user","A",1); |
| 58 | 58 | |
| 59 | 59 | url_parse(g.argv[2]); |
| 60 | 60 | if( g.urlIsFile ){ |
| 61 | 61 | file_copy(g.urlName, g.argv[3]); |
| 62 | - db_close(); | |
| 62 | + db_close(1); | |
| 63 | 63 | db_open_repository(g.argv[3]); |
| 64 | 64 | db_record_repository_filename(g.argv[3]); |
| 65 | 65 | db_multi_exec( |
| 66 | 66 | "REPLACE INTO config(name,value)" |
| 67 | 67 | " VALUES('server-code', lower(hex(randomblob(20))));" |
| @@ -98,11 +98,11 @@ | ||
| 98 | 98 | g.xlinkClusterOnly = 1; |
| 99 | 99 | nErr = client_sync(0,0,1,CONFIGSET_ALL,0); |
| 100 | 100 | g.xlinkClusterOnly = 0; |
| 101 | 101 | verify_cancel(); |
| 102 | 102 | db_end_transaction(0); |
| 103 | - db_close(); | |
| 103 | + db_close(1); | |
| 104 | 104 | if( nErr ){ |
| 105 | 105 | unlink(g.argv[3]); |
| 106 | 106 | fossil_fatal("server returned an error - clone aborted"); |
| 107 | 107 | } |
| 108 | 108 | db_open_repository(g.argv[3]); |
| 109 | 109 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -57,11 +57,11 @@ | |
| 57 | zDefaultUser = find_option("admin-user","A",1); |
| 58 | |
| 59 | url_parse(g.argv[2]); |
| 60 | if( g.urlIsFile ){ |
| 61 | file_copy(g.urlName, g.argv[3]); |
| 62 | db_close(); |
| 63 | db_open_repository(g.argv[3]); |
| 64 | db_record_repository_filename(g.argv[3]); |
| 65 | db_multi_exec( |
| 66 | "REPLACE INTO config(name,value)" |
| 67 | " VALUES('server-code', lower(hex(randomblob(20))));" |
| @@ -98,11 +98,11 @@ | |
| 98 | g.xlinkClusterOnly = 1; |
| 99 | nErr = client_sync(0,0,1,CONFIGSET_ALL,0); |
| 100 | g.xlinkClusterOnly = 0; |
| 101 | verify_cancel(); |
| 102 | db_end_transaction(0); |
| 103 | db_close(); |
| 104 | if( nErr ){ |
| 105 | unlink(g.argv[3]); |
| 106 | fossil_fatal("server returned an error - clone aborted"); |
| 107 | } |
| 108 | db_open_repository(g.argv[3]); |
| 109 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -57,11 +57,11 @@ | |
| 57 | zDefaultUser = find_option("admin-user","A",1); |
| 58 | |
| 59 | url_parse(g.argv[2]); |
| 60 | if( g.urlIsFile ){ |
| 61 | file_copy(g.urlName, g.argv[3]); |
| 62 | db_close(1); |
| 63 | db_open_repository(g.argv[3]); |
| 64 | db_record_repository_filename(g.argv[3]); |
| 65 | db_multi_exec( |
| 66 | "REPLACE INTO config(name,value)" |
| 67 | " VALUES('server-code', lower(hex(randomblob(20))));" |
| @@ -98,11 +98,11 @@ | |
| 98 | g.xlinkClusterOnly = 1; |
| 99 | nErr = client_sync(0,0,1,CONFIGSET_ALL,0); |
| 100 | g.xlinkClusterOnly = 0; |
| 101 | verify_cancel(); |
| 102 | db_end_transaction(0); |
| 103 | db_close(1); |
| 104 | if( nErr ){ |
| 105 | unlink(g.argv[3]); |
| 106 | fossil_fatal("server returned an error - clone aborted"); |
| 107 | } |
| 108 | db_open_repository(g.argv[3]); |
| 109 |
M
src/db.c
+21
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -126,28 +126,39 @@ | ||
| 126 | 126 | if( nBegin==0 ){ |
| 127 | 127 | int i; |
| 128 | 128 | for(i=0; doRollback==0 && i<nCommitHook; i++){ |
| 129 | 129 | doRollback |= aHook[i].xHook(); |
| 130 | 130 | } |
| 131 | + while( pAllStmt ){ | |
| 132 | + db_finalize(pAllStmt); | |
| 133 | + } | |
| 131 | 134 | db_multi_exec(doRollback ? "ROLLBACK" : "COMMIT"); |
| 132 | 135 | doRollback = 0; |
| 133 | 136 | } |
| 134 | 137 | } |
| 138 | + | |
| 139 | +/* | |
| 140 | +** Force a rollback and shutdown the database | |
| 141 | +*/ | |
| 135 | 142 | void db_force_rollback(void){ |
| 136 | 143 | static int busy = 0; |
| 137 | 144 | if( busy || g.db==0 ) return; |
| 138 | 145 | busy = 1; |
| 139 | 146 | undo_rollback(); |
| 147 | + while( pAllStmt ){ | |
| 148 | + db_finalize(pAllStmt); | |
| 149 | + } | |
| 140 | 150 | if( nBegin ){ |
| 141 | 151 | sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); |
| 142 | 152 | nBegin = 0; |
| 143 | 153 | if( isNewRepo ){ |
| 144 | - db_close(); | |
| 154 | + db_close(0); | |
| 145 | 155 | unlink(g.zRepositoryName); |
| 146 | 156 | } |
| 147 | 157 | } |
| 148 | 158 | busy = 0; |
| 159 | + db_close(0); | |
| 149 | 160 | } |
| 150 | 161 | |
| 151 | 162 | /* |
| 152 | 163 | ** Install a commit hook. Hooks are installed in sequence order. |
| 153 | 164 | ** It is an error to install the same commit hook more than once. |
| @@ -920,11 +931,11 @@ | ||
| 920 | 931 | if( access(zRepo, 0) ){ |
| 921 | 932 | fossil_fatal("no such file: %s", zRepo); |
| 922 | 933 | } |
| 923 | 934 | db_open_or_attach(zRepo, "test_repo"); |
| 924 | 935 | db_lset("repository", blob_str(&repo)); |
| 925 | - db_close(); | |
| 936 | + db_close(1); | |
| 926 | 937 | } |
| 927 | 938 | |
| 928 | 939 | |
| 929 | 940 | /* |
| 930 | 941 | ** Open the local database. If unable, exit with an error. |
| @@ -937,12 +948,15 @@ | ||
| 937 | 948 | db_verify_schema(); |
| 938 | 949 | } |
| 939 | 950 | |
| 940 | 951 | /* |
| 941 | 952 | ** Close the database connection. |
| 953 | +** | |
| 954 | +** Check for unfinalized statements and report errors if the reportErrors | |
| 955 | +** argument is true. Ignore unfinalized statements when false. | |
| 942 | 956 | */ |
| 943 | -void db_close(void){ | |
| 957 | +void db_close(int reportErrors){ | |
| 944 | 958 | sqlite3_stmt *pStmt; |
| 945 | 959 | if( g.db==0 ) return; |
| 946 | 960 | if( g.fSqlTrace ){ |
| 947 | 961 | int cur, hiwtr; |
| 948 | 962 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0); |
| @@ -971,12 +985,14 @@ | ||
| 971 | 985 | while( pAllStmt ){ |
| 972 | 986 | db_finalize(pAllStmt); |
| 973 | 987 | } |
| 974 | 988 | db_end_transaction(1); |
| 975 | 989 | pStmt = 0; |
| 976 | - while( (pStmt = sqlite3_next_stmt(g.db, pStmt))!=0 ){ | |
| 977 | - fossil_warning("unfinalized SQL statement: [%s]", sqlite3_sql(pStmt)); | |
| 990 | + if( reportErrors ){ | |
| 991 | + while( (pStmt = sqlite3_next_stmt(g.db, pStmt))!=0 ){ | |
| 992 | + fossil_warning("unfinalized SQL statement: [%s]", sqlite3_sql(pStmt)); | |
| 993 | + } | |
| 978 | 994 | } |
| 979 | 995 | g.repositoryOpen = 0; |
| 980 | 996 | g.localOpen = 0; |
| 981 | 997 | g.configOpen = 0; |
| 982 | 998 | sqlite3_wal_checkpoint(g.db, 0); |
| 983 | 999 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -126,28 +126,39 @@ | |
| 126 | if( nBegin==0 ){ |
| 127 | int i; |
| 128 | for(i=0; doRollback==0 && i<nCommitHook; i++){ |
| 129 | doRollback |= aHook[i].xHook(); |
| 130 | } |
| 131 | db_multi_exec(doRollback ? "ROLLBACK" : "COMMIT"); |
| 132 | doRollback = 0; |
| 133 | } |
| 134 | } |
| 135 | void db_force_rollback(void){ |
| 136 | static int busy = 0; |
| 137 | if( busy || g.db==0 ) return; |
| 138 | busy = 1; |
| 139 | undo_rollback(); |
| 140 | if( nBegin ){ |
| 141 | sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); |
| 142 | nBegin = 0; |
| 143 | if( isNewRepo ){ |
| 144 | db_close(); |
| 145 | unlink(g.zRepositoryName); |
| 146 | } |
| 147 | } |
| 148 | busy = 0; |
| 149 | } |
| 150 | |
| 151 | /* |
| 152 | ** Install a commit hook. Hooks are installed in sequence order. |
| 153 | ** It is an error to install the same commit hook more than once. |
| @@ -920,11 +931,11 @@ | |
| 920 | if( access(zRepo, 0) ){ |
| 921 | fossil_fatal("no such file: %s", zRepo); |
| 922 | } |
| 923 | db_open_or_attach(zRepo, "test_repo"); |
| 924 | db_lset("repository", blob_str(&repo)); |
| 925 | db_close(); |
| 926 | } |
| 927 | |
| 928 | |
| 929 | /* |
| 930 | ** Open the local database. If unable, exit with an error. |
| @@ -937,12 +948,15 @@ | |
| 937 | db_verify_schema(); |
| 938 | } |
| 939 | |
| 940 | /* |
| 941 | ** Close the database connection. |
| 942 | */ |
| 943 | void db_close(void){ |
| 944 | sqlite3_stmt *pStmt; |
| 945 | if( g.db==0 ) return; |
| 946 | if( g.fSqlTrace ){ |
| 947 | int cur, hiwtr; |
| 948 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0); |
| @@ -971,12 +985,14 @@ | |
| 971 | while( pAllStmt ){ |
| 972 | db_finalize(pAllStmt); |
| 973 | } |
| 974 | db_end_transaction(1); |
| 975 | pStmt = 0; |
| 976 | while( (pStmt = sqlite3_next_stmt(g.db, pStmt))!=0 ){ |
| 977 | fossil_warning("unfinalized SQL statement: [%s]", sqlite3_sql(pStmt)); |
| 978 | } |
| 979 | g.repositoryOpen = 0; |
| 980 | g.localOpen = 0; |
| 981 | g.configOpen = 0; |
| 982 | sqlite3_wal_checkpoint(g.db, 0); |
| 983 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -126,28 +126,39 @@ | |
| 126 | if( nBegin==0 ){ |
| 127 | int i; |
| 128 | for(i=0; doRollback==0 && i<nCommitHook; i++){ |
| 129 | doRollback |= aHook[i].xHook(); |
| 130 | } |
| 131 | while( pAllStmt ){ |
| 132 | db_finalize(pAllStmt); |
| 133 | } |
| 134 | db_multi_exec(doRollback ? "ROLLBACK" : "COMMIT"); |
| 135 | doRollback = 0; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | ** Force a rollback and shutdown the database |
| 141 | */ |
| 142 | void db_force_rollback(void){ |
| 143 | static int busy = 0; |
| 144 | if( busy || g.db==0 ) return; |
| 145 | busy = 1; |
| 146 | undo_rollback(); |
| 147 | while( pAllStmt ){ |
| 148 | db_finalize(pAllStmt); |
| 149 | } |
| 150 | if( nBegin ){ |
| 151 | sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); |
| 152 | nBegin = 0; |
| 153 | if( isNewRepo ){ |
| 154 | db_close(0); |
| 155 | unlink(g.zRepositoryName); |
| 156 | } |
| 157 | } |
| 158 | busy = 0; |
| 159 | db_close(0); |
| 160 | } |
| 161 | |
| 162 | /* |
| 163 | ** Install a commit hook. Hooks are installed in sequence order. |
| 164 | ** It is an error to install the same commit hook more than once. |
| @@ -920,11 +931,11 @@ | |
| 931 | if( access(zRepo, 0) ){ |
| 932 | fossil_fatal("no such file: %s", zRepo); |
| 933 | } |
| 934 | db_open_or_attach(zRepo, "test_repo"); |
| 935 | db_lset("repository", blob_str(&repo)); |
| 936 | db_close(1); |
| 937 | } |
| 938 | |
| 939 | |
| 940 | /* |
| 941 | ** Open the local database. If unable, exit with an error. |
| @@ -937,12 +948,15 @@ | |
| 948 | db_verify_schema(); |
| 949 | } |
| 950 | |
| 951 | /* |
| 952 | ** Close the database connection. |
| 953 | ** |
| 954 | ** Check for unfinalized statements and report errors if the reportErrors |
| 955 | ** argument is true. Ignore unfinalized statements when false. |
| 956 | */ |
| 957 | void db_close(int reportErrors){ |
| 958 | sqlite3_stmt *pStmt; |
| 959 | if( g.db==0 ) return; |
| 960 | if( g.fSqlTrace ){ |
| 961 | int cur, hiwtr; |
| 962 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0); |
| @@ -971,12 +985,14 @@ | |
| 985 | while( pAllStmt ){ |
| 986 | db_finalize(pAllStmt); |
| 987 | } |
| 988 | db_end_transaction(1); |
| 989 | pStmt = 0; |
| 990 | if( reportErrors ){ |
| 991 | while( (pStmt = sqlite3_next_stmt(g.db, pStmt))!=0 ){ |
| 992 | fossil_warning("unfinalized SQL statement: [%s]", sqlite3_sql(pStmt)); |
| 993 | } |
| 994 | } |
| 995 | g.repositoryOpen = 0; |
| 996 | g.localOpen = 0; |
| 997 | g.configOpen = 0; |
| 998 | sqlite3_wal_checkpoint(g.db, 0); |
| 999 |
+5
-5
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -294,11 +294,11 @@ | ||
| 294 | 294 | |
| 295 | 295 | /* |
| 296 | 296 | ** Exit. Take care to close the database first. |
| 297 | 297 | */ |
| 298 | 298 | void fossil_exit(int rc){ |
| 299 | - db_close(); | |
| 299 | + db_close(1); | |
| 300 | 300 | exit(rc); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /* |
| 304 | 304 | ** Print an error message, rollback all databases, and quit. These |
| @@ -837,11 +837,11 @@ | ||
| 837 | 837 | fossil_fatal("cannot stat() repository: %s", zRepo); |
| 838 | 838 | } |
| 839 | 839 | setgid(sStat.st_gid); |
| 840 | 840 | setuid(sStat.st_uid); |
| 841 | 841 | if( g.db!=0 ){ |
| 842 | - db_close(); | |
| 842 | + db_close(1); | |
| 843 | 843 | db_open_repository(zRepo); |
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | #endif |
| 847 | 847 | return zRepo; |
| @@ -1019,11 +1019,11 @@ | ||
| 1019 | 1019 | db_open_repository(blob_str(&value)); |
| 1020 | 1020 | blob_reset(&value); |
| 1021 | 1021 | continue; |
| 1022 | 1022 | } |
| 1023 | 1023 | if( blob_eq(&key, "directory:") && blob_token(&line, &value) ){ |
| 1024 | - db_close(); | |
| 1024 | + db_close(1); | |
| 1025 | 1025 | g.zRepositoryName = mprintf("%s", blob_str(&value)); |
| 1026 | 1026 | blob_reset(&value); |
| 1027 | 1027 | continue; |
| 1028 | 1028 | } |
| 1029 | 1029 | if( blob_eq(&key, "notfound:") && blob_token(&line, &value) ){ |
| @@ -1228,11 +1228,11 @@ | ||
| 1228 | 1228 | #else |
| 1229 | 1229 | zBrowser = db_get("web-browser", "open"); |
| 1230 | 1230 | #endif |
| 1231 | 1231 | zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 1232 | 1232 | } |
| 1233 | - db_close(); | |
| 1233 | + db_close(1); | |
| 1234 | 1234 | if( cgi_http_server(iPort, mxPort, zBrowserCmd, flags) ){ |
| 1235 | 1235 | fossil_fatal("unable to listen on TCP socket %d", iPort); |
| 1236 | 1236 | } |
| 1237 | 1237 | g.httpIn = stdin; |
| 1238 | 1238 | g.httpOut = stdout; |
| @@ -1248,9 +1248,9 @@ | ||
| 1248 | 1248 | /* Win32 implementation */ |
| 1249 | 1249 | if( isUiCmd ){ |
| 1250 | 1250 | zBrowser = db_get("web-browser", "start"); |
| 1251 | 1251 | zBrowserCmd = mprintf("%s http://127.0.0.1:%%d/", zBrowser); |
| 1252 | 1252 | } |
| 1253 | - db_close(); | |
| 1253 | + db_close(1); | |
| 1254 | 1254 | win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile, zNotFound, flags); |
| 1255 | 1255 | #endif |
| 1256 | 1256 | } |
| 1257 | 1257 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -294,11 +294,11 @@ | |
| 294 | |
| 295 | /* |
| 296 | ** Exit. Take care to close the database first. |
| 297 | */ |
| 298 | void fossil_exit(int rc){ |
| 299 | db_close(); |
| 300 | exit(rc); |
| 301 | } |
| 302 | |
| 303 | /* |
| 304 | ** Print an error message, rollback all databases, and quit. These |
| @@ -837,11 +837,11 @@ | |
| 837 | fossil_fatal("cannot stat() repository: %s", zRepo); |
| 838 | } |
| 839 | setgid(sStat.st_gid); |
| 840 | setuid(sStat.st_uid); |
| 841 | if( g.db!=0 ){ |
| 842 | db_close(); |
| 843 | db_open_repository(zRepo); |
| 844 | } |
| 845 | } |
| 846 | #endif |
| 847 | return zRepo; |
| @@ -1019,11 +1019,11 @@ | |
| 1019 | db_open_repository(blob_str(&value)); |
| 1020 | blob_reset(&value); |
| 1021 | continue; |
| 1022 | } |
| 1023 | if( blob_eq(&key, "directory:") && blob_token(&line, &value) ){ |
| 1024 | db_close(); |
| 1025 | g.zRepositoryName = mprintf("%s", blob_str(&value)); |
| 1026 | blob_reset(&value); |
| 1027 | continue; |
| 1028 | } |
| 1029 | if( blob_eq(&key, "notfound:") && blob_token(&line, &value) ){ |
| @@ -1228,11 +1228,11 @@ | |
| 1228 | #else |
| 1229 | zBrowser = db_get("web-browser", "open"); |
| 1230 | #endif |
| 1231 | zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 1232 | } |
| 1233 | db_close(); |
| 1234 | if( cgi_http_server(iPort, mxPort, zBrowserCmd, flags) ){ |
| 1235 | fossil_fatal("unable to listen on TCP socket %d", iPort); |
| 1236 | } |
| 1237 | g.httpIn = stdin; |
| 1238 | g.httpOut = stdout; |
| @@ -1248,9 +1248,9 @@ | |
| 1248 | /* Win32 implementation */ |
| 1249 | if( isUiCmd ){ |
| 1250 | zBrowser = db_get("web-browser", "start"); |
| 1251 | zBrowserCmd = mprintf("%s http://127.0.0.1:%%d/", zBrowser); |
| 1252 | } |
| 1253 | db_close(); |
| 1254 | win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile, zNotFound, flags); |
| 1255 | #endif |
| 1256 | } |
| 1257 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -294,11 +294,11 @@ | |
| 294 | |
| 295 | /* |
| 296 | ** Exit. Take care to close the database first. |
| 297 | */ |
| 298 | void fossil_exit(int rc){ |
| 299 | db_close(1); |
| 300 | exit(rc); |
| 301 | } |
| 302 | |
| 303 | /* |
| 304 | ** Print an error message, rollback all databases, and quit. These |
| @@ -837,11 +837,11 @@ | |
| 837 | fossil_fatal("cannot stat() repository: %s", zRepo); |
| 838 | } |
| 839 | setgid(sStat.st_gid); |
| 840 | setuid(sStat.st_uid); |
| 841 | if( g.db!=0 ){ |
| 842 | db_close(1); |
| 843 | db_open_repository(zRepo); |
| 844 | } |
| 845 | } |
| 846 | #endif |
| 847 | return zRepo; |
| @@ -1019,11 +1019,11 @@ | |
| 1019 | db_open_repository(blob_str(&value)); |
| 1020 | blob_reset(&value); |
| 1021 | continue; |
| 1022 | } |
| 1023 | if( blob_eq(&key, "directory:") && blob_token(&line, &value) ){ |
| 1024 | db_close(1); |
| 1025 | g.zRepositoryName = mprintf("%s", blob_str(&value)); |
| 1026 | blob_reset(&value); |
| 1027 | continue; |
| 1028 | } |
| 1029 | if( blob_eq(&key, "notfound:") && blob_token(&line, &value) ){ |
| @@ -1228,11 +1228,11 @@ | |
| 1228 | #else |
| 1229 | zBrowser = db_get("web-browser", "open"); |
| 1230 | #endif |
| 1231 | zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 1232 | } |
| 1233 | db_close(1); |
| 1234 | if( cgi_http_server(iPort, mxPort, zBrowserCmd, flags) ){ |
| 1235 | fossil_fatal("unable to listen on TCP socket %d", iPort); |
| 1236 | } |
| 1237 | g.httpIn = stdin; |
| 1238 | g.httpOut = stdout; |
| @@ -1248,9 +1248,9 @@ | |
| 1248 | /* Win32 implementation */ |
| 1249 | if( isUiCmd ){ |
| 1250 | zBrowser = db_get("web-browser", "start"); |
| 1251 | zBrowserCmd = mprintf("%s http://127.0.0.1:%%d/", zBrowser); |
| 1252 | } |
| 1253 | db_close(1); |
| 1254 | win32_http_server(iPort, mxPort, zBrowserCmd, zStopperFile, zNotFound, flags); |
| 1255 | #endif |
| 1256 | } |
| 1257 |
+2
-2
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -364,11 +364,11 @@ | ||
| 364 | 364 | }else{ |
| 365 | 365 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 366 | 366 | if( g.argc!=2 ){ |
| 367 | 367 | usage("?REPOSITORY-FILENAME?"); |
| 368 | 368 | } |
| 369 | - db_close(); | |
| 369 | + db_close(1); | |
| 370 | 370 | db_open_repository(g.zRepositoryName); |
| 371 | 371 | } |
| 372 | 372 | db_begin_transaction(); |
| 373 | 373 | ttyOutput = 1; |
| 374 | 374 | errCnt = rebuild_db(randomizeFlag, 1); |
| @@ -420,11 +420,11 @@ | ||
| 420 | 420 | }else{ |
| 421 | 421 | db_find_and_open_repository(0, 0); |
| 422 | 422 | if( g.argc!=2 ){ |
| 423 | 423 | usage("?REPOSITORY-FILENAME?"); |
| 424 | 424 | } |
| 425 | - db_close(); | |
| 425 | + db_close(1); | |
| 426 | 426 | db_open_repository(g.zRepositoryName); |
| 427 | 427 | } |
| 428 | 428 | db_begin_transaction(); |
| 429 | 429 | create_cluster(); |
| 430 | 430 | db_end_transaction(0); |
| 431 | 431 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -364,11 +364,11 @@ | |
| 364 | }else{ |
| 365 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 366 | if( g.argc!=2 ){ |
| 367 | usage("?REPOSITORY-FILENAME?"); |
| 368 | } |
| 369 | db_close(); |
| 370 | db_open_repository(g.zRepositoryName); |
| 371 | } |
| 372 | db_begin_transaction(); |
| 373 | ttyOutput = 1; |
| 374 | errCnt = rebuild_db(randomizeFlag, 1); |
| @@ -420,11 +420,11 @@ | |
| 420 | }else{ |
| 421 | db_find_and_open_repository(0, 0); |
| 422 | if( g.argc!=2 ){ |
| 423 | usage("?REPOSITORY-FILENAME?"); |
| 424 | } |
| 425 | db_close(); |
| 426 | db_open_repository(g.zRepositoryName); |
| 427 | } |
| 428 | db_begin_transaction(); |
| 429 | create_cluster(); |
| 430 | db_end_transaction(0); |
| 431 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -364,11 +364,11 @@ | |
| 364 | }else{ |
| 365 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 366 | if( g.argc!=2 ){ |
| 367 | usage("?REPOSITORY-FILENAME?"); |
| 368 | } |
| 369 | db_close(1); |
| 370 | db_open_repository(g.zRepositoryName); |
| 371 | } |
| 372 | db_begin_transaction(); |
| 373 | ttyOutput = 1; |
| 374 | errCnt = rebuild_db(randomizeFlag, 1); |
| @@ -420,11 +420,11 @@ | |
| 420 | }else{ |
| 421 | db_find_and_open_repository(0, 0); |
| 422 | if( g.argc!=2 ){ |
| 423 | usage("?REPOSITORY-FILENAME?"); |
| 424 | } |
| 425 | db_close(1); |
| 426 | db_open_repository(g.zRepositoryName); |
| 427 | } |
| 428 | db_begin_transaction(); |
| 429 | create_cluster(); |
| 430 | db_end_transaction(0); |
| 431 |
+1
-1
| --- src/shun.c | ||
| +++ src/shun.c | ||
| @@ -48,11 +48,11 @@ | ||
| 48 | 48 | login_check_credentials(); |
| 49 | 49 | if( !g.okAdmin ){ |
| 50 | 50 | login_needed(); |
| 51 | 51 | } |
| 52 | 52 | if( P("rebuild") ){ |
| 53 | - db_close(); | |
| 53 | + db_close(1); | |
| 54 | 54 | db_open_repository(g.zRepositoryName); |
| 55 | 55 | db_begin_transaction(); |
| 56 | 56 | rebuild_db(0,0); |
| 57 | 57 | db_end_transaction(0); |
| 58 | 58 | } |
| 59 | 59 |
| --- src/shun.c | |
| +++ src/shun.c | |
| @@ -48,11 +48,11 @@ | |
| 48 | login_check_credentials(); |
| 49 | if( !g.okAdmin ){ |
| 50 | login_needed(); |
| 51 | } |
| 52 | if( P("rebuild") ){ |
| 53 | db_close(); |
| 54 | db_open_repository(g.zRepositoryName); |
| 55 | db_begin_transaction(); |
| 56 | rebuild_db(0,0); |
| 57 | db_end_transaction(0); |
| 58 | } |
| 59 |
| --- src/shun.c | |
| +++ src/shun.c | |
| @@ -48,11 +48,11 @@ | |
| 48 | login_check_credentials(); |
| 49 | if( !g.okAdmin ){ |
| 50 | login_needed(); |
| 51 | } |
| 52 | if( P("rebuild") ){ |
| 53 | db_close(1); |
| 54 | db_open_repository(g.zRepositoryName); |
| 55 | db_begin_transaction(); |
| 56 | rebuild_db(0,0); |
| 57 | db_end_transaction(0); |
| 58 | } |
| 59 |
+1
-1
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -79,11 +79,11 @@ | ||
| 79 | 79 | ** running any SQL commands that modifies the repository database. |
| 80 | 80 | */ |
| 81 | 81 | void sqlite3_cmd(void){ |
| 82 | 82 | extern int sqlite3_shell(int, char**); |
| 83 | 83 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 84 | - db_close(); | |
| 84 | + db_close(1); | |
| 85 | 85 | sqlite3_shutdown(); |
| 86 | 86 | sqlite3_shell(g.argc-1, g.argv+1); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /* |
| 90 | 90 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -79,11 +79,11 @@ | |
| 79 | ** running any SQL commands that modifies the repository database. |
| 80 | */ |
| 81 | void sqlite3_cmd(void){ |
| 82 | extern int sqlite3_shell(int, char**); |
| 83 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 84 | db_close(); |
| 85 | sqlite3_shutdown(); |
| 86 | sqlite3_shell(g.argc-1, g.argv+1); |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -79,11 +79,11 @@ | |
| 79 | ** running any SQL commands that modifies the repository database. |
| 80 | */ |
| 81 | void sqlite3_cmd(void){ |
| 82 | extern int sqlite3_shell(int, char**); |
| 83 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 84 | db_close(1); |
| 85 | sqlite3_shutdown(); |
| 86 | sqlite3_shell(g.argc-1, g.argv+1); |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 |
+3
-2
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -72,19 +72,20 @@ | ||
| 72 | 72 | return rid; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /* |
| 76 | 76 | ** Verify that an object is not a phantom. If the object is |
| 77 | -** a phantom, output an error message and quick. | |
| 77 | +** a phantom, output an error message and quit. | |
| 78 | 78 | */ |
| 79 | 79 | static void vfile_verify_not_phantom( |
| 80 | 80 | int rid, /* The RID to verify */ |
| 81 | 81 | const char *zFilename, /* Filename. Might be NULL */ |
| 82 | 82 | const char *zUuid /* UUID. Might be NULL */ |
| 83 | 83 | ){ |
| 84 | 84 | if( db_int(-1, "SELECT size FROM blob WHERE rid=%d", rid)<0 |
| 85 | - && (zUuid==0 || !db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid)) ){ | |
| 85 | + && (zUuid==0 || !db_exists("SELECT 1 FROM shun WHERE uuid='%s'",zUuid)) | |
| 86 | + ){ | |
| 86 | 87 | if( zFilename ){ |
| 87 | 88 | fossil_fatal("content missing for %s", zFilename); |
| 88 | 89 | }else{ |
| 89 | 90 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 90 | 91 | if( zUuid ){ |
| 91 | 92 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -72,19 +72,20 @@ | |
| 72 | return rid; |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | ** Verify that an object is not a phantom. If the object is |
| 77 | ** a phantom, output an error message and quick. |
| 78 | */ |
| 79 | static void vfile_verify_not_phantom( |
| 80 | int rid, /* The RID to verify */ |
| 81 | const char *zFilename, /* Filename. Might be NULL */ |
| 82 | const char *zUuid /* UUID. Might be NULL */ |
| 83 | ){ |
| 84 | if( db_int(-1, "SELECT size FROM blob WHERE rid=%d", rid)<0 |
| 85 | && (zUuid==0 || !db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid)) ){ |
| 86 | if( zFilename ){ |
| 87 | fossil_fatal("content missing for %s", zFilename); |
| 88 | }else{ |
| 89 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 90 | if( zUuid ){ |
| 91 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -72,19 +72,20 @@ | |
| 72 | return rid; |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | ** Verify that an object is not a phantom. If the object is |
| 77 | ** a phantom, output an error message and quit. |
| 78 | */ |
| 79 | static void vfile_verify_not_phantom( |
| 80 | int rid, /* The RID to verify */ |
| 81 | const char *zFilename, /* Filename. Might be NULL */ |
| 82 | const char *zUuid /* UUID. Might be NULL */ |
| 83 | ){ |
| 84 | if( db_int(-1, "SELECT size FROM blob WHERE rid=%d", rid)<0 |
| 85 | && (zUuid==0 || !db_exists("SELECT 1 FROM shun WHERE uuid='%s'",zUuid)) |
| 86 | ){ |
| 87 | if( zFilename ){ |
| 88 | fossil_fatal("content missing for %s", zFilename); |
| 89 | }else{ |
| 90 | char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 91 | if( zUuid ){ |
| 92 |