[glom] Catch exceptions when updating the libgda metastore.



commit b5467a72ca165768b832831be7940cd69530fe0d
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Sep 1 06:34:32 2012 +0200

    Catch exceptions when updating the libgda metastore.
    
            * glom/libglom/connectionpool.cc:
            * glom/libglom/db_utils.cc: Put try/catch around
    	uses of Gda::Connection::update_meta_store_for_table()
    	because it is currently failing in test_selfhosting_new_then_change_columns
    	on my Fedora 17.

 ChangeLog                      |   10 ++++++++++
 glom/libglom/connectionpool.cc |   12 +++++++++++-
 glom/libglom/db_utils.cc       |   21 ++++++++++++++++-----
 3 files changed, 37 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1b4a958..d579431 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-08-31  Murray Cumming  <murrayc murrayc com>
+
+        Catch exceptions when updating the libgda metastore.
+
+        * glom/libglom/connectionpool.cc:
+        * glom/libglom/db_utils.cc: Put try/catch around 
+	uses of Gda::Connection::update_meta_store_for_table()
+	because it is currently failing in test_selfhosting_new_then_change_columns
+	on my Fedora 17.
+
 2012-04-19  Murray Cumming  <murrayc murrayc com>
 
 	Add some translatable strings for Online Glom
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 611a643..f06c3cf 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -762,7 +762,17 @@ bool ConnectionPool::change_columns(const Glib::ustring& table_name, const type_
     return false;
 
   const bool result = m_backend->change_columns(m_refGdaConnection, table_name, old_fields, new_fields);
-  m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name());
+
+  try
+  {
+    m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name());
+  }
+  catch(const Glib::Error& ex)
+  {
+    std::cerr << G_STRFUNC << ": update_meta_store_table() failed: " << ex.what() << std::endl;
+    return false;
+  }
+
   if(!result)
     return false;
 
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index bb5fa62..dcdc2b8 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -68,27 +68,37 @@ static Glib::RefPtr<Gnome::Gda::Connection> get_connection()
   * Call this whenever changing the table structure, for instance with an ALTER query.
   * This may take a few seconds to return.
   */
-static void update_gda_metastore_for_table(const Glib::ustring& table_name)
+static bool update_gda_metastore_for_table(const Glib::ustring& table_name)
 {
   Glib::RefPtr<Gnome::Gda::Connection> gda_connection = get_connection();
   if(!gda_connection)
   {
     std::cerr << G_STRFUNC << ": No gda_connection." << std::endl;
-    return;
+    return false;
   }
 
   if(table_name.empty())
   {
     std::cerr << G_STRFUNC << ": table_name is empty." << std::endl;
-    return;
+    return false;
   }
 
   //std::cout << "debug: " << G_STRFUNC << ": Calling Gda::Connection::update_meta_store_table(" << table_name << ") ..." << std::endl;
   //TODO: This doesn't seem to quite work yet:
-  gda_connection->update_meta_store_table(table_name);
+  try
+  {
+    gda_connection->update_meta_store_table(table_name);
+  }
+  catch(const Glib::Error& ex)
+  {
+    std::cerr << G_STRFUNC << ": update_meta_store_table() failed: " << ex.what() << std::endl;
+    return false;
+  }
 
   //This does work, though it takes ages: gda_connection->update_meta_store();
   //std::cout << "debug: " << G_STRFUNC << ": ... Finished calling Gda::Connection::update_meta_store_table()" << std::endl;
+
+  return true;
 }
 
 bool create_database(Document* document, const Glib::ustring& database_name, const Glib::ustring& title, const sigc::slot<void>& progress)
@@ -1271,7 +1281,8 @@ bool create_table(const sharedptr<const TableInfo>& table_info, const Document::
   {
     // Update the libgda meta store, so that get_fields_for_table_from_database()
     // returns the fields correctly for the new table.
-    update_gda_metastore_for_table(table_info->get_name());
+    if(!update_gda_metastore_for_table(table_info->get_name()))
+      return false;
 
     // TODO: Maybe we should create the table directly via libgda instead of
     // executing an SQL query ourselves, so that libgda has the chance to



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]