[glom] Fix previous broken commit to fix the build.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Fix previous broken commit to fix the build.
- Date: Thu, 20 Oct 2011 11:15:20 +0000 (UTC)
commit bcfd63c23e1dacd34ec07a41292b91d532be69de
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Oct 20 13:14:53 2011 +0200
Fix previous broken commit to fix the build.
glom/libglom/db_utils.cc | 67 ----------------------------------------------
1 files changed, 0 insertions(+), 67 deletions(-)
---
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index cd4528a..cc194e4 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -1880,73 +1880,6 @@ int count_rows_returned_by(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& sql
return result;
}
-/** Build a SQL query to discover how many rows a SQL query would return if it was run.
- *
- * This uses a COUNT * on a the @a sql_query as a sub-statement.
- * Be careful not to include ORDER BY clauses in the supplied SQL query, because that would make it unnecessarily slow.
- *
- * @sql_query A SQL query.
- * @result The number of rows.
- */
-static Glib::RefPtr<Gnome::Gda::SqlBuilder> build_sql_select_count_rows(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& sql_query)
-{
- Glib::RefPtr<Gnome::Gda::SqlBuilder> result;
-
- if(!sql_query)
- {
- std::cerr << G_STRFUNC << ": sql_query was null." << std::endl;
- return result;
- }
-
- result = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
-
- //Note that the alias is just because the SQL syntax requires it - we get an error if we don't use it.
- //Be careful not to include ORDER BY clauses in this, because that would make it unnecessarily slow:
- const guint target_id = result->add_sub_select( sql_query->get_sql_statement() );
- result->select_add_target_id(target_id, "glomarbitraryalias");
-
- const Gnome::Gda::SqlBuilder::Id id_function = result->add_function("COUNT", result->add_id("*"));
- result->add_field_value_id(id_function);
-
- return result;
-}
-
-int count_rows_returned_by(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& sql_query)
-{
- if(!sql_query)
- {
- std::cerr << G_STRFUNC << ": sql_query was null." << std::endl;
- return 0;
- }
-
- const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder =
- build_sql_select_count_rows(sql_query);
-
- int result = 0;
-
- Glib::RefPtr<Gnome::Gda::DataModel> datamodel = DbUtils::query_execute_select(builder);
- if(datamodel && datamodel->get_n_rows() && datamodel->get_n_columns())
- {
- const Gnome::Gda::Value value = datamodel->get_value_at(0, 0);
- //This showed me that this contains a gint64: std::cerr << "DEBUG: value type=" << G_VALUE_TYPE_NAME(value.gobj()) << std::endl;
- //For sqlite, this is an integer
- if(value.get_value_type() == G_TYPE_INT64) //With the PostgreSQL backend.
- result = (int)value.get_int64();
- else if(value.get_value_type() == G_TYPE_INT) //With the PostgreSQL backend.
- {
- result = value.get_int(); //With the SQLite backend.
- }
- else
- {
- std::cerr << G_STRFUNC << ": The COUNT query returned an unexpected value type: " << g_type_name(value.get_value_type()) << std::endl;
- result = -1;
- }
- }
-
- //std::cout << "debug: " << G_STRFUNC << ": Returning " << result << std::endl;
- return result;
-}
-
} //namespace DbUtils
} //namespace Glom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]