Fossil SCM

Provide better error messages to the client when the server database schema is out-of-date.

drh 2011-03-08 17:00 trunk
Commit 0ca36443675b13ce66dd78d0c5af776bd2104820
3 files changed +11 -3 +5 -1 +4
+11 -3
--- src/db.c
+++ src/db.c
@@ -903,25 +903,33 @@
903903
|| strcmp(zDb,"configdb")==0
904904
|| strcmp(zDb,"repository")==0 );
905905
if( strcmp(zDb, g.zMainDbType)==0 ) zDb = "main";
906906
return zDb;
907907
}
908
+
909
+/*
910
+** Return TRUE if the schema is out-of-date
911
+*/
912
+int db_schema_is_outofdate(void){
913
+ return db_exists("SELECT 1 FROM config"
914
+ " WHERE name='aux-schema'"
915
+ " AND value<>'%s'", AUX_SCHEMA);
916
+}
908917
909918
/*
910919
** Verify that the repository schema is correct. If it is not correct,
911920
** issue a fatal error and die.
912921
*/
913922
void db_verify_schema(void){
914
- if( db_exists("SELECT 1 FROM config"
915
- " WHERE name='aux-schema'"
916
- " AND value<>'%s'", AUX_SCHEMA) ){
923
+ if( db_schema_is_outofdate() ){
917924
fossil_warning("incorrect repository schema version");
918925
fossil_warning("you have version \"%s\" but you need version \"%s\"",
919926
db_get("aux-schema",0), AUX_SCHEMA);
920927
fossil_fatal("run \"fossil rebuild\" to fix this problem");
921928
}
922929
}
930
+
923931
924932
/*
925933
** COMMAND: test-move-repository
926934
**
927935
** Usage: %fossil test-move-repository PATHNAME
928936
--- src/db.c
+++ src/db.c
@@ -903,25 +903,33 @@
903 || strcmp(zDb,"configdb")==0
904 || strcmp(zDb,"repository")==0 );
905 if( strcmp(zDb, g.zMainDbType)==0 ) zDb = "main";
906 return zDb;
907 }
 
 
 
 
 
 
 
 
 
908
909 /*
910 ** Verify that the repository schema is correct. If it is not correct,
911 ** issue a fatal error and die.
912 */
913 void db_verify_schema(void){
914 if( db_exists("SELECT 1 FROM config"
915 " WHERE name='aux-schema'"
916 " AND value<>'%s'", AUX_SCHEMA) ){
917 fossil_warning("incorrect repository schema version");
918 fossil_warning("you have version \"%s\" but you need version \"%s\"",
919 db_get("aux-schema",0), AUX_SCHEMA);
920 fossil_fatal("run \"fossil rebuild\" to fix this problem");
921 }
922 }
 
923
924 /*
925 ** COMMAND: test-move-repository
926 **
927 ** Usage: %fossil test-move-repository PATHNAME
928
--- src/db.c
+++ src/db.c
@@ -903,25 +903,33 @@
903 || strcmp(zDb,"configdb")==0
904 || strcmp(zDb,"repository")==0 );
905 if( strcmp(zDb, g.zMainDbType)==0 ) zDb = "main";
906 return zDb;
907 }
908
909 /*
910 ** Return TRUE if the schema is out-of-date
911 */
912 int db_schema_is_outofdate(void){
913 return db_exists("SELECT 1 FROM config"
914 " WHERE name='aux-schema'"
915 " AND value<>'%s'", AUX_SCHEMA);
916 }
917
918 /*
919 ** Verify that the repository schema is correct. If it is not correct,
920 ** issue a fatal error and die.
921 */
922 void db_verify_schema(void){
923 if( db_schema_is_outofdate() ){
 
 
924 fossil_warning("incorrect repository schema version");
925 fossil_warning("you have version \"%s\" but you need version \"%s\"",
926 db_get("aux-schema",0), AUX_SCHEMA);
927 fossil_fatal("run \"fossil rebuild\" to fix this problem");
928 }
929 }
930
931
932 /*
933 ** COMMAND: test-move-repository
934 **
935 ** Usage: %fossil test-move-repository PATHNAME
936
+5 -1
--- src/main.c
+++ src/main.c
@@ -962,19 +962,23 @@
962962
** will use g.zExtra directly.
963963
*/
964964
dehttpize(g.zExtra);
965965
cgi_set_parameter_nocopy("name", g.zExtra);
966966
}
967
-
967
+
968968
/* Locate the method specified by the path and execute the function
969969
** that implements that method.
970970
*/
971971
if( name_search(g.zPath, aWebpage, count(aWebpage), &idx) &&
972972
name_search("not_found", aWebpage, count(aWebpage), &idx) ){
973973
cgi_set_status(404,"Not Found");
974974
@ <h1>Not Found</h1>
975975
@ <p>Page not found: %h(g.zPath)</p>
976
+ }else if( aWebpage[idx].xFunc!=page_xfer && db_schema_is_outofdate() ){
977
+ @ <h1>Server Configuration Error</h1>
978
+ @ <p>The database schema on the server is out-of-date. Please ask
979
+ @ the administrator to run <b>fossil rebuild</b>.</p>
976980
}else{
977981
aWebpage[idx].xFunc();
978982
}
979983
980984
/* Return the result.
981985
--- src/main.c
+++ src/main.c
@@ -962,19 +962,23 @@
962 ** will use g.zExtra directly.
963 */
964 dehttpize(g.zExtra);
965 cgi_set_parameter_nocopy("name", g.zExtra);
966 }
967
968 /* Locate the method specified by the path and execute the function
969 ** that implements that method.
970 */
971 if( name_search(g.zPath, aWebpage, count(aWebpage), &idx) &&
972 name_search("not_found", aWebpage, count(aWebpage), &idx) ){
973 cgi_set_status(404,"Not Found");
974 @ <h1>Not Found</h1>
975 @ <p>Page not found: %h(g.zPath)</p>
 
 
 
 
976 }else{
977 aWebpage[idx].xFunc();
978 }
979
980 /* Return the result.
981
--- src/main.c
+++ src/main.c
@@ -962,19 +962,23 @@
962 ** will use g.zExtra directly.
963 */
964 dehttpize(g.zExtra);
965 cgi_set_parameter_nocopy("name", g.zExtra);
966 }
967
968 /* Locate the method specified by the path and execute the function
969 ** that implements that method.
970 */
971 if( name_search(g.zPath, aWebpage, count(aWebpage), &idx) &&
972 name_search("not_found", aWebpage, count(aWebpage), &idx) ){
973 cgi_set_status(404,"Not Found");
974 @ <h1>Not Found</h1>
975 @ <p>Page not found: %h(g.zPath)</p>
976 }else if( aWebpage[idx].xFunc!=page_xfer && db_schema_is_outofdate() ){
977 @ <h1>Server Configuration Error</h1>
978 @ <p>The database schema on the server is out-of-date. Please ask
979 @ the administrator to run <b>fossil rebuild</b>.</p>
980 }else{
981 aWebpage[idx].xFunc();
982 }
983
984 /* Return the result.
985
+4
--- src/xfer.c
+++ src/xfer.c
@@ -810,10 +810,14 @@
810810
g.zLogin = "anonymous";
811811
login_set_anon_nobody_capabilities();
812812
memset(&xfer, 0, sizeof(xfer));
813813
blobarray_zero(xfer.aToken, count(xfer.aToken));
814814
cgi_set_content_type(g.zContentType);
815
+ if( db_schema_is_outofdate() ){
816
+ @ error database\sschema\sis\out-of-date\son\sthe\sserver.
817
+ return;
818
+ }
815819
blob_zero(&xfer.err);
816820
xfer.pIn = &g.cgiIn;
817821
xfer.pOut = cgi_output_blob();
818822
xfer.mxSend = db_get_int("max-download", 5000000);
819823
g.xferPanic = 1;
820824
--- src/xfer.c
+++ src/xfer.c
@@ -810,10 +810,14 @@
810 g.zLogin = "anonymous";
811 login_set_anon_nobody_capabilities();
812 memset(&xfer, 0, sizeof(xfer));
813 blobarray_zero(xfer.aToken, count(xfer.aToken));
814 cgi_set_content_type(g.zContentType);
 
 
 
 
815 blob_zero(&xfer.err);
816 xfer.pIn = &g.cgiIn;
817 xfer.pOut = cgi_output_blob();
818 xfer.mxSend = db_get_int("max-download", 5000000);
819 g.xferPanic = 1;
820
--- src/xfer.c
+++ src/xfer.c
@@ -810,10 +810,14 @@
810 g.zLogin = "anonymous";
811 login_set_anon_nobody_capabilities();
812 memset(&xfer, 0, sizeof(xfer));
813 blobarray_zero(xfer.aToken, count(xfer.aToken));
814 cgi_set_content_type(g.zContentType);
815 if( db_schema_is_outofdate() ){
816 @ error database\sschema\sis\out-of-date\son\sthe\sserver.
817 return;
818 }
819 blob_zero(&xfer.err);
820 xfer.pIn = &g.cgiIn;
821 xfer.pOut = cgi_output_blob();
822 xfer.mxSend = db_get_int("max-download", 5000000);
823 g.xferPanic = 1;
824

Keyboard Shortcuts

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