[libgdamm] Added a schema_name parameter for the meta store update methods



commit 12a7d30cdb3b74d5fd41f79941014c6ef5ad9442
Author: Armin Burgmeier <armin arbur net>
Date:   Wed May 20 23:11:33 2009 +0200

    Added a schema_name parameter for the meta store update methods
    
    	* libgda/src/connection.hg:
    	* libgda/src/connection.ccg: Added a schema_name parameter for
    	update_meta_store_table_names() and update_meta_store_table().
---
 ChangeLog                 |    6 ++++++
 libgda/src/connection.ccg |   32 +++++++++++++++++++++++---------
 libgda/src/connection.hg  |   17 +++++++++++++----
 3 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dd6bf15..a368929 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-20  Armin Burgmeier  <armin openismus com>
+
+	* libgda/src/connection.hg:
+	* libgda/src/connection.ccg: Added a schema_name parameter for
+	update_meta_store_table_names() and update_meta_store_table().
+
 2009-05-18  Murray Cumming  <murrayc murrayc com>
 
 	* libgda/src/dataproxy.ccg: get_values(): Actually return the result, 
diff --git a/libgda/src/connection.ccg b/libgda/src/connection.ccg
index f47c38b..5200366 100644
--- a/libgda/src/connection.ccg
+++ b/libgda/src/connection.ccg
@@ -364,23 +364,28 @@ Glib::RefPtr<DataModel> Connection::get_meta_store_data(ConnectionMetaType meta_
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-bool Connection::update_meta_store_table(const Glib::ustring& table_name)
+bool Connection::update_meta_store_table(const Glib::ustring& table_name, const Glib::ustring& schema_name)
 #else
-bool Connection::update_meta_store_table(const Glib::ustring& table_name, std::auto_ptr<Glib::Error>& err)
+bool Connection::update_meta_store_table(const Glib::ustring& table_name, const Glib::ustring& schema_name, std::auto_ptr<Glib::Error>& err)
 #endif
 {
   GValue table_name_value = { 0 };
   g_value_init(&table_name_value, G_TYPE_STRING);
   g_value_set_static_string(&table_name_value, table_name.c_str());
 
-  gchar* column_names[] = { (gchar*)"table_name" };
-  GValue* column_values[] = { &table_name_value };
+  GValue table_schema_value = { 0 };
+  g_value_init(&table_schema_value, G_TYPE_STRING);
+  g_value_set_static_string(&table_schema_value, schema_name.c_str());
 
-  GdaMetaContext mcontext = {(gchar*)"_tables", 1, column_names, column_values };
+  gchar* column_names[] = { (gchar*)"table_name" , (gchar*)"table_schema"};
+  GValue* column_values[] = { &table_name_value, &table_schema_value };
+
+  GdaMetaContext mcontext = {(gchar*)"_tables", schema_name.empty() ? 1 : 2, column_names, column_values };
   GError* gerror = 0;
   const bool retval = gda_connection_update_meta_store(gobj(), &mcontext, &gerror);
 
   g_value_unset(&table_name_value);
+  g_value_unset(&table_schema_value);
   
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
@@ -394,15 +399,24 @@ bool Connection::update_meta_store_table(const Glib::ustring& table_name, std::a
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-bool Connection::update_meta_store_table_names()
+bool Connection::update_meta_store_table_names(const Glib::ustring& schema_name)
 #else
-bool Connection::update_meta_store_table_names(std::auto_ptr<Glib::Error>& err)
+bool Connection::update_meta_store_table_names(const Glib::ustring& schema_name, std::auto_ptr<Glib::Error>& err)
 #endif
 {
-  GdaMetaContext mcontext = {(gchar*)"_tables", 0, 0, 0 };
+  GValue table_schema_value = { 0 };
+  g_value_init(&table_schema_value, G_TYPE_STRING);
+  g_value_set_static_string(&table_schema_value, schema_name.c_str());
+
+  gchar* column_names[] = { (gchar*)"table_schema"};
+  GValue* column_values[] = { &table_schema_value };
+
+  GdaMetaContext mcontext = {(gchar*)"_tables", schema_name.empty() ? 0 : 1, column_names, column_values };
   GError* gerror = 0;
   const bool retval = gda_connection_update_meta_store(gobj(), &mcontext, &gerror);
-  
+
+  g_value_unset(&table_schema_value);
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
diff --git a/libgda/src/connection.hg b/libgda/src/connection.hg
index fb9c953..d9e6921 100644
--- a/libgda/src/connection.hg
+++ b/libgda/src/connection.hg
@@ -240,11 +240,13 @@ public:
    * This can speed up the update of the meta store if you only need the information
    * for a specific table
    * @param table_name Name of the table where the information is needed
+   * @param schema_name Name of the schema @table_name is in, or "" to update
+   * all tables with the given name.
    * @return <tt>true</tt> if no error occurred.
    */
-  bool update_meta_store_table(const Glib::ustring& table_name);
+  bool update_meta_store_table(const Glib::ustring& table_name, const Glib::ustring& schema_name = Glib::ustring());
 #else
-  bool update_meta_store_table(const Glib::ustring& table_name, std::auto_ptr<Glib::Error>& err);
+  bool update_meta_store_table(const Glib::ustring& table_name, const Glib::ustring& schema_name, std::auto_ptr<Glib::Error>& err);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -252,11 +254,18 @@ public:
    * 
    * This can speed up the update of the meta store if you only need the list of table names.
    *
+   * @param schema_name Name of the schema whose tables to update, or "" to
+   * update all tables. For example, for postgresql this function takes a
+   * considerable amount of time when doing this. If you don't need
+   * information about internal postgresql tables, then you can speed up the
+   * process by only updating the tables for the "public" schema.
+   * Unfortunately, schema names are not common between different database
+   * systems.
    * @return <tt>true</tt> if no error occurred.
    */
-  bool update_meta_store_table_names();
+  bool update_meta_store_table_names(const Glib::ustring& schema_name = Glib::ustring());
 #else
-  bool update_meta_store_table_names(std::auto_ptr<Glib::Error>& err);
+  bool update_meta_store_table_names(const Glib::ustring& schema_name, std::auto_ptr<Glib::Error>& err);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED



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