Browse Source

[2180] Make the SQLITE_SETUP message a warning

Since creating new file is suspicious, the administrator may have
misspelled some file name. The message explains the problem and shows
the file name as well.

Also, removed a duplicate message, created a new instance for it.
Michal 'vorner' Vaner 12 years ago
parent
commit
fcde1f32cd

+ 12 - 2
src/lib/datasrc/datasrc_messages.mes

@@ -787,10 +787,20 @@ example.com). However, this name is not contained in any zone in the
 data source. This is an error since it indicates a problem in the earlier
 data source. This is an error since it indicates a problem in the earlier
 processing of the query.
 processing of the query.
 
 
-% DATASRC_SQLITE_SETUP setting up SQLite database
+% DATASRC_SQLITE_SETUP setting up new SQLite3 database in '%1'
 The database for SQLite data source was found empty. It is assumed this is the
 The database for SQLite data source was found empty. It is assumed this is the
 first run and it is being initialized with current schema.  It'll still contain
 first run and it is being initialized with current schema.  It'll still contain
-no data, but it will be ready for use.
+no data, but it will be ready for use. If this is indeed the first run of
+Bind10, it is to be expected and completely harmless. If you just configured
+a data source to point to an existing file and you see this, you may have
+misspelled the file name.
+
+% DATASRC_SQLITE_SETUP_OLD_API setting up new SQLite database
+The database for SQLite data source was found empty. It is assumed this is the
+first run and it is being initialized with current schema.  It'll still contain
+no data, but it will be ready for use. This is similar to DATASRC_SQLITE_SETUP
+message, but it is logged from the old API. You should never see it, since the
+API is deprecated.
 
 
 % DATASRC_STATIC_CLASS_NOT_CH static data source can handle CH class only
 % DATASRC_STATIC_CLASS_NOT_CH static data source can handle CH class only
 An error message indicating that a query requesting a RR for a class other
 An error message indicating that a query requesting a RR for a class other

+ 5 - 5
src/lib/datasrc/sqlite3_accessor.cc

@@ -474,8 +474,8 @@ private:
 
 
 // return db version
 // return db version
 pair<int, int>
 pair<int, int>
-createDatabase(sqlite3* db) {
-    logger.info(DATASRC_SQLITE_SETUP);
+createDatabase(sqlite3* db, const std::string& name) {
+    logger.warn(DATASRC_SQLITE_SETUP).arg(name);
 
 
     // try to get an exclusive lock. Once that is obtained, do the version
     // try to get an exclusive lock. Once that is obtained, do the version
     // check *again*, just in case this process was racing another
     // check *again*, just in case this process was racing another
@@ -501,12 +501,12 @@ createDatabase(sqlite3* db) {
 }
 }
 
 
 void
 void
-checkAndSetupSchema(Initializer* initializer) {
+checkAndSetupSchema(Initializer* initializer, const std::string& name) {
     sqlite3* const db = initializer->params_.db_;
     sqlite3* const db = initializer->params_.db_;
 
 
     pair<int, int> schema_version = checkSchemaVersion(db);
     pair<int, int> schema_version = checkSchemaVersion(db);
     if (schema_version.first == -1) {
     if (schema_version.first == -1) {
-        schema_version = createDatabase(db);
+        schema_version = createDatabase(db, name);
     } else if (schema_version.first != SQLITE_SCHEMA_MAJOR_VERSION) {
     } else if (schema_version.first != SQLITE_SCHEMA_MAJOR_VERSION) {
         LOG_ERROR(logger, DATASRC_SQLITE_INCOMPATIBLE_VERSION)
         LOG_ERROR(logger, DATASRC_SQLITE_INCOMPATIBLE_VERSION)
             .arg(schema_version.first).arg(schema_version.second)
             .arg(schema_version.first).arg(schema_version.second)
@@ -540,7 +540,7 @@ SQLite3Accessor::open(const std::string& name) {
         isc_throw(SQLite3Error, "Cannot open SQLite database file: " << name);
         isc_throw(SQLite3Error, "Cannot open SQLite database file: " << name);
     }
     }
 
 
-    checkAndSetupSchema(&initializer);
+    checkAndSetupSchema(&initializer, name);
     initializer.move(dbparameters_.get());
     initializer.move(dbparameters_.get());
 }
 }
 
 

+ 1 - 1
src/lib/datasrc/sqlite3_datasrc.cc

@@ -788,7 +788,7 @@ private:
 
 
 // return db version
 // return db version
 pair<int, int> create_database(sqlite3* db) {
 pair<int, int> create_database(sqlite3* db) {
-    logger.info(DATASRC_SQLITE_SETUP);
+    logger.info(DATASRC_SQLITE_SETUP_OLD_API);
 
 
     // try to get an exclusive lock. Once that is obtained, do the version
     // try to get an exclusive lock. Once that is obtained, do the version
     // check *again*, just in case this process was racing another
     // check *again*, just in case this process was racing another