[glom] Speedup initial meta store update by only fetching public tables



commit 087d27f48f080a3609142514ed5bf54ff0472ff2
Author: Armin Burgmeier <armin arbur net>
Date:   Wed May 20 23:14:43 2009 +0200

    Speedup initial meta store update by only fetching public tables
    
    	* glom/libglom/connectionpool_backends/backend.h:
    	* glom/libglom/connectionpool_backends/postgres.h:
    	* glom/libglom/connectionpool_backends/sqlite.h: Added
    	get_public_schema_name() virtual function and implementations for both
    	backends.
    
    	* glom/libglom/connectionpool.cc: Only update the meta store tables
    	for the public schema of the corresponding backend. This considerably
    	speeds up the initial meta store update. This requires latest libgdamm
    	from git.
---
 ChangeLog                                       |   13 +++++++++++++
 glom/libglom/connectionpool.cc                  |   14 +++++++-------
 glom/libglom/connectionpool_backends/backend.h  |    7 +++++++
 glom/libglom/connectionpool_backends/postgres.h |    1 +
 glom/libglom/connectionpool_backends/sqlite.h   |    1 +
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5e40619..a67bca0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-05-20  Armin Burgmeier  <armin openismus com>
+
+	* glom/libglom/connectionpool_backends/backend.h:
+	* glom/libglom/connectionpool_backends/postgres.h:
+	* glom/libglom/connectionpool_backends/sqlite.h: Added
+	get_public_schema_name() virtual function and implementations for both
+	backends.
+
+	* glom/libglom/connectionpool.cc: Only update the meta store tables
+	for the public schema of the corresponding backend. This considerably
+	speeds up the initial meta store update. This requires latest libgdamm
+	from git.
+
 2009-05-10  Murray Cumming  <murrayc murrayc-x61>
 
 	Disables the Open button next to ID fields if the field is empty.
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 480805d..5b63c5c 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -386,7 +386,7 @@ sharedptr<SharedConnection> ConnectionPool::connect(std::auto_ptr<ExceptionConne
         {
           //update_meta_store_table_names() has been known to throw an exception.
           //Glom is mostly unusable when it fails, but that's still better than a crash.
-          m_refGdaConnection->update_meta_store_table_names();
+          m_refGdaConnection->update_meta_store_table_names(m_backend->get_public_schema_name());
         }
         catch(const Glib::Error& ex)
         {
@@ -700,11 +700,11 @@ bool ConnectionPool::add_column(const Glib::ustring& table_name, const sharedptr
   const bool result = m_backend->add_column(m_refGdaConnection, table_name, field, error);
   if(error.get()) throw *error;
 
-  m_refGdaConnection->update_meta_store_table(table_name);
+  m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name());
 #else
   const bool result = m_backend->add_column(m_refGdaConnection, table_name, field, error);
   if(result)
-    result = m_refGdaConnection->update_meta_store_table(table_name, error);
+    result = m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name(), error);
 #endif
 
   return result;
@@ -737,11 +737,11 @@ bool ConnectionPool::drop_column(const Glib::ustring& table_name, const Glib::us
   const bool result = m_backend->drop_column(m_refGdaConnection, table_name, field_name, error);
   if(error.get()) throw *error;
 
-  m_refGdaConnection->update_meta_store_table(table_name);
+  m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name());
 #else
   const bool result = m_backend->drop_column(m_refGdaConnection, table_name, field_name, error);
   if(result)
-    result = m_refGdaConnection->update_meta_store_table(table_name, error);
+    result = m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name(), error);
 #endif
 
   return result;
@@ -790,11 +790,11 @@ bool ConnectionPool::change_columns(const Glib::ustring& table_name, const type_
   const bool result = m_backend->change_columns(m_refGdaConnection, table_name, old_fields, new_fields, error);
   if(error.get()) throw *error;
 
-  m_refGdaConnection->update_meta_store_table(table_name);
+  m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name());
 #else
   const bool result = m_backend->change_columns(m_refGdaConnection, table_name, old_fields, new_fields, error);
   if(result)
-    result = m_refGdaConnection->update_meta_store_table(table_name, error);
+    result = m_refGdaConnection->update_meta_store_table(table_name, m_backend->get_public_schema_name(), error);
 #endif
 
   return result;
diff --git a/glom/libglom/connectionpool_backends/backend.h b/glom/libglom/connectionpool_backends/backend.h
index 19e12a8..847f043 100644
--- a/glom/libglom/connectionpool_backends/backend.h
+++ b/glom/libglom/connectionpool_backends/backend.h
@@ -109,6 +109,13 @@ protected:
    */
   virtual Glib::ustring get_string_find_operator() const = 0;
 
+  /** This specifies the database schema which contains the non-internal
+   * tables. This is used to speedup the libgda meta store update by only
+   * updating the non-internal tables. libgda might later be able to do this
+   * without us specifying it explicitely. See #575235.
+   */
+  virtual const char* get_public_schema_name() const = 0;
+
   /** This callback should show UI to indicate that work is still happening.
    * For instance, a pulsing ProgressBar.
    */
diff --git a/glom/libglom/connectionpool_backends/postgres.h b/glom/libglom/connectionpool_backends/postgres.h
index fa4a165..1fbdd2c 100644
--- a/glom/libglom/connectionpool_backends/postgres.h
+++ b/glom/libglom/connectionpool_backends/postgres.h
@@ -60,6 +60,7 @@ private:
   virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_POSTGRES; }
   virtual bool supports_remote_access() const { return true; }
   virtual Glib::ustring get_string_find_operator() const { return "ILIKE"; } // ILIKE is a postgres extension for locale-dependent case-insensitive matches.
+  virtual const char* get_public_schema_name() const { return "public"; }
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   virtual bool change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connection, const Glib::ustring& table_name, const type_vec_const_fields& old_fields, const type_vec_const_fields& new_fields, std::auto_ptr<Glib::Error>& error);
diff --git a/glom/libglom/connectionpool_backends/sqlite.h b/glom/libglom/connectionpool_backends/sqlite.h
index bc2d4b3..bb1c84b 100644
--- a/glom/libglom/connectionpool_backends/sqlite.h
+++ b/glom/libglom/connectionpool_backends/sqlite.h
@@ -48,6 +48,7 @@ private:
   virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_SQLITE; }
   virtual bool supports_remote_access() const { return false; }
   virtual Glib::ustring get_string_find_operator() const { return "LIKE"; }
+  virtual const char* get_public_schema_name() const { return "main"; }
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   bool add_column_to_server_operation(const Glib::RefPtr<Gnome::Gda::ServerOperation>& operation, GdaMetaTableColumn* column, unsigned int i, std::auto_ptr<Glib::Error>& error);



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