Fossil SCM

Clarification of comments on the db_set_main_schemaname() routine.

drh 2016-08-19 09:14 omit-db_name
Commit 81184a02a56d714225535b0fe6b1c41b6cbb1b3c
1 file changed +18 -15
+18 -15
--- src/db.c
+++ src/db.c
@@ -963,35 +963,24 @@
963963
zDbName, zLabel, blob_str(&key));
964964
blob_reset(&key);
965965
}
966966
967967
/*
968
-** Change the schema name of the main database to from "main" to zLabel.
968
+** Change the schema name of the "main" database to zLabel.
969969
** zLabel must be a static string that is unchanged for the life of
970970
** the database connection.
971
+**
972
+** After calling this routine, db_database_slot(zLabel) should
973
+** return 0.
971974
*/
972975
void db_set_main_schemaname(sqlite3 *db, const char *zLabel){
973976
if( sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, zLabel) ){
974977
fossil_fatal("Fossil requires a version of SQLite that supports the "
975978
"SQLITE_DBCONFIG_MAINDBNAME interface.");
976979
}
977980
}
978981
979
-/*
980
-** zDbName is the name of a database file. If no other database
981
-** file is open, then open this one. If another database file is
982
-** already open, then attach zDbName using the name zLabel.
983
-*/
984
-void db_open_or_attach(const char *zDbName, const char *zLabel){
985
- if( !g.db ){
986
- g.db = db_open(zDbName);
987
- db_set_main_schemaname(g.db, zLabel);
988
- }else{
989
- db_attach(zDbName, zLabel);
990
- }
991
-}
992
-
993982
/*
994983
** Return the slot number for database zLabel. The first database
995984
** opened is slot 0. The "temp" database is slot 1. Attached databases
996985
** are slots 2 and higher.
997986
**
@@ -1008,10 +997,24 @@
1008997
}
1009998
}
1010999
db_finalize(&q);
10111000
return iSlot;
10121001
}
1002
+
1003
+/*
1004
+** zDbName is the name of a database file. If no other database
1005
+** file is open, then open this one. If another database file is
1006
+** already open, then attach zDbName using the name zLabel.
1007
+*/
1008
+void db_open_or_attach(const char *zDbName, const char *zLabel){
1009
+ if( !g.db ){
1010
+ g.db = db_open(zDbName);
1011
+ db_set_main_schemaname(g.db, zLabel);
1012
+ }else{
1013
+ db_attach(zDbName, zLabel);
1014
+ }
1015
+}
10131016
10141017
/*
10151018
** Close the per-user database file in ~/.fossil
10161019
*/
10171020
void db_close_config(){
10181021
--- src/db.c
+++ src/db.c
@@ -963,35 +963,24 @@
963 zDbName, zLabel, blob_str(&key));
964 blob_reset(&key);
965 }
966
967 /*
968 ** Change the schema name of the main database to from "main" to zLabel.
969 ** zLabel must be a static string that is unchanged for the life of
970 ** the database connection.
 
 
 
971 */
972 void db_set_main_schemaname(sqlite3 *db, const char *zLabel){
973 if( sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, zLabel) ){
974 fossil_fatal("Fossil requires a version of SQLite that supports the "
975 "SQLITE_DBCONFIG_MAINDBNAME interface.");
976 }
977 }
978
979 /*
980 ** zDbName is the name of a database file. If no other database
981 ** file is open, then open this one. If another database file is
982 ** already open, then attach zDbName using the name zLabel.
983 */
984 void db_open_or_attach(const char *zDbName, const char *zLabel){
985 if( !g.db ){
986 g.db = db_open(zDbName);
987 db_set_main_schemaname(g.db, zLabel);
988 }else{
989 db_attach(zDbName, zLabel);
990 }
991 }
992
993 /*
994 ** Return the slot number for database zLabel. The first database
995 ** opened is slot 0. The "temp" database is slot 1. Attached databases
996 ** are slots 2 and higher.
997 **
@@ -1008,10 +997,24 @@
1008 }
1009 }
1010 db_finalize(&q);
1011 return iSlot;
1012 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1013
1014 /*
1015 ** Close the per-user database file in ~/.fossil
1016 */
1017 void db_close_config(){
1018
--- src/db.c
+++ src/db.c
@@ -963,35 +963,24 @@
963 zDbName, zLabel, blob_str(&key));
964 blob_reset(&key);
965 }
966
967 /*
968 ** Change the schema name of the "main" database to zLabel.
969 ** zLabel must be a static string that is unchanged for the life of
970 ** the database connection.
971 **
972 ** After calling this routine, db_database_slot(zLabel) should
973 ** return 0.
974 */
975 void db_set_main_schemaname(sqlite3 *db, const char *zLabel){
976 if( sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, zLabel) ){
977 fossil_fatal("Fossil requires a version of SQLite that supports the "
978 "SQLITE_DBCONFIG_MAINDBNAME interface.");
979 }
980 }
981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
982 /*
983 ** Return the slot number for database zLabel. The first database
984 ** opened is slot 0. The "temp" database is slot 1. Attached databases
985 ** are slots 2 and higher.
986 **
@@ -1008,10 +997,24 @@
997 }
998 }
999 db_finalize(&q);
1000 return iSlot;
1001 }
1002
1003 /*
1004 ** zDbName is the name of a database file. If no other database
1005 ** file is open, then open this one. If another database file is
1006 ** already open, then attach zDbName using the name zLabel.
1007 */
1008 void db_open_or_attach(const char *zDbName, const char *zLabel){
1009 if( !g.db ){
1010 g.db = db_open(zDbName);
1011 db_set_main_schemaname(g.db, zLabel);
1012 }else{
1013 db_attach(zDbName, zLabel);
1014 }
1015 }
1016
1017 /*
1018 ** Close the per-user database file in ~/.fossil
1019 */
1020 void db_close_config(){
1021

Keyboard Shortcuts

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