[glom/mysql: 14/21] Added some std::cerr hints



commit 024e484929cf9d4f1f55e3bc04a36bd107e87dff
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Jan 5 14:54:19 2013 +0100

    Added some std::cerr hints

 glom/libglom/db_utils.cc |   12 ++++++++++++
 glom/libglom/utils.cc    |    9 ++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 6684fe8..12280a9 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -1510,6 +1510,14 @@ static void recalculate_next_auto_increment_value(const Glib::ustring& table_nam
   {
     //Increment it:
     const Gnome::Gda::Value value_max = datamodel->get_value_at(0, 0); // A GdaNumeric.
+
+    //TODO: This happens with MySQL. Maybe it is OK, when there are no records or no values:
+    if(Glom::Conversions::value_is_empty(value_max))
+    {
+      std::cerr << G_STRFUNC << ": The MAX() value is null for query: " <<
+        Utils::sqlbuilder_get_full_query(builder) << std::endl;
+    }
+
     double num_max = Conversions::get_double_for_gda_value_numeric(value_max);
     ++num_max;
 
@@ -1617,7 +1625,11 @@ bool insert_example_data(Document* document, const Glib::ustring& table_name)
 
     insert_succeeded = query_execute(builder);
     if(!insert_succeeded)
+    {
+      std::cerr << G_STRFUNC << ": The INSERT query failed: " <<
+        Utils::sqlbuilder_get_full_query(builder) << std::endl;
       break;
+    }
   }
 
   for(Document::type_vec_fields::const_iterator iter = vec_fields.begin(); iter != vec_fields.end(); ++iter)
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index 2d97256..f85154e 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -1098,7 +1098,14 @@ std::string Utils::sqlbuilder_get_full_query(
     "ISO-8859-1", "UTF-8",
     (char*)"?",
     0, 0, 0));
-  return std::string(buf.get());
+
+  const Glib::ustring str = std::string(buf.get());
+  if(str.empty())
+  {
+    std::cerr << G_STRFUNC << ": Returning an empty string." << std::endl;
+  }
+
+  return str;
 }
 
 Gnome::Gda::SqlExpr Utils::get_find_where_clause_quick(const Document* document, const Glib::ustring& table_name, const Gnome::Gda::Value& quick_search)



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