[glom] Added some std::cerr hints



commit ee9992a26df560efc007e1f81f2a8970b8c4ef02
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 d3abb2b..a46b5c5 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -1513,6 +1513,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;
 
@@ -1620,7 +1628,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]