Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Clarification of comments on the db_set_main_schemaname() routine. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | omit-db_name |
| Files: | files | file ages | folders |
| SHA1: |
81184a02a56d714225535b0fe6b1c41b |
| User & Date: | drh 2016-08-19 09:14:36.335 |
Context
|
2016-08-19
| ||
| 15:25 | Incorporate the version of SQLite that allows VACUUM on attached databases. check-in: 80d0df0508 user: drh tags: omit-db_name | |
| 09:14 | Clarification of comments on the db_set_main_schemaname() routine. check-in: 81184a02a5 user: drh tags: omit-db_name | |
| 00:13 | Use the new SQLITE_DBCONFIG_MAINDBNAME feature of SQLite to eliminate the need for the db_name() hack. check-in: d858f3da52 user: drh tags: omit-db_name | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
961 962 963 964 965 966 967 |
db_encryption_key(zDbName, &key);
db_multi_exec("ATTACH DATABASE %Q AS %Q KEY %Q",
zDbName, zLabel, blob_str(&key));
blob_reset(&key);
}
/*
| | > > > < < < < < < < < < < < < < < > > > > > > > > > > > > > > | 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
db_encryption_key(zDbName, &key);
db_multi_exec("ATTACH DATABASE %Q AS %Q KEY %Q",
zDbName, zLabel, blob_str(&key));
blob_reset(&key);
}
/*
** Change the schema name of the "main" database to zLabel.
** zLabel must be a static string that is unchanged for the life of
** the database connection.
**
** After calling this routine, db_database_slot(zLabel) should
** return 0.
*/
void db_set_main_schemaname(sqlite3 *db, const char *zLabel){
if( sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, zLabel) ){
fossil_fatal("Fossil requires a version of SQLite that supports the "
"SQLITE_DBCONFIG_MAINDBNAME interface.");
}
}
/*
** Return the slot number for database zLabel. The first database
** opened is slot 0. The "temp" database is slot 1. Attached databases
** are slots 2 and higher.
**
** Return -1 if zLabel does not match any open database.
*/
int db_database_slot(const char *zLabel){
int iSlot = -1;
Stmt q;
db_prepare(&q, "PRAGMA database_list");
while( db_step(&q)==SQLITE_ROW ){
if( fossil_strcmp(db_column_text(&q,1),zLabel)==0 ){
iSlot = db_column_int(&q, 0);
break;
}
}
db_finalize(&q);
return iSlot;
}
/*
** zDbName is the name of a database file. If no other database
** file is open, then open this one. If another database file is
** already open, then attach zDbName using the name zLabel.
*/
void db_open_or_attach(const char *zDbName, const char *zLabel){
if( !g.db ){
g.db = db_open(zDbName);
db_set_main_schemaname(g.db, zLabel);
}else{
db_attach(zDbName, zLabel);
}
}
/*
** Close the per-user database file in ~/.fossil
*/
void db_close_config(){
int iSlot = db_database_slot("configdb");
if( iSlot>0 ){
|
| ︙ | ︙ |