? .deps
? .libs
? Makefile
? Makefile.in
? gsqlitebackend.lo
? libgsqlitebackend.la
? ssqlite.lo
Index: ssqlite.cc
===================================================================
RCS file: /var/cvsroot/pdns/modules/gsqlitebackend/ssqlite.cc,v
retrieving revision 1.5
diff -u -B -b -r1.5 ssqlite.cc
--- ssqlite.cc	17 Dec 2003 19:55:44 -0000	1.5
+++ ssqlite.cc	11 Jul 2004 13:43:40 -0000
@@ -8,6 +8,7 @@
 #include <string>
 #include "ssqlite.hh"
 #include <iostream>
+#include <unistd.h>
 
 #ifdef WIN32
 # include <io.h>
@@ -42,6 +43,37 @@
 }
 
 
+// Performs a command.
+int SSQLite::doCommand( const std::string & query )
+{   
+  int rc;
+
+  // Execute the query.
+  char *pError = NULL;
+  do
+  {
+    rc = sqlite_exec( m_pDB, query.c_str(), NULL, NULL, &pError );
+    if ( rc == SQLITE_BUSY )
+      Utility::usleep( 250 ); // FIXME: Should this be increased, decreased, or is it Just Right? :)
+    else
+      break;
+  } while ( true );
+
+  if ( rc != SQLITE_OK )
+  {
+    std::string report( "Unable to exec SQLite statement" );
+    
+    if( pError ) 
+    {
+      report += string( ": " ) + pError;
+      sqlite_freemem( pError );
+    }
+    
+    sPerrorException( report );
+  }
+  return 0;
+}
+
 // Performs a query.
 int SSQLite::doQuery( const std::string & query, result_t & result )
 {
@@ -90,6 +121,8 @@
   const char **ppData;
   const char **ppColumnNames;
 
+  row.clear();
+  
   do
   {
     rc = sqlite_step( m_pVM, &numCols, &ppData, &ppColumnNames );
@@ -115,19 +148,25 @@
     return true;
   }
   
-  if ( rc == SQLITE_DONE )
+  std::string report( "Error while retrieving SQLite query results" );
+  
+  if ( rc == SQLITE_DONE || rc == SQLITE_ERROR )
   {
     // We're done, clean up.
-    sqlite_finalize( m_pVM, NULL );
+    char *pError = NULL;
+    sqlite_finalize( m_pVM, &pError );
     m_pVM = NULL;
     
-    return false;
+    if ( rc == SQLITE_ERROR && pError )
+      report += string( ": " ) + pError;
+
+    if ( pError )
+      sqlite_freemem( pError ); 
   }
   
-  // Something went wrong, complain.
-  throw sPerrorException( "Error while retrieving SQLite query results" );
+  if ( rc != SQLITE_DONE )  // Something went wrong, complain.
+    throw sPerrorException( report );
   
-  // Prevent some compilers from complaining.
   return false;
 }
 
Index: ssqlite.hh
===================================================================
RCS file: /var/cvsroot/pdns/modules/gsqlitebackend/ssqlite.hh,v
retrieving revision 1.2
diff -u -B -b -r1.2 ssqlite.hh
--- ssqlite.hh	11 Oct 2003 19:57:19 -0000	1.2
+++ ssqlite.hh	11 Jul 2004 13:43:40 -0000
@@ -34,11 +34,7 @@
   int doQuery( const std::string & query );
 
   //! Performs a command that does not return rows
-  int doCommand( const std::string & query )
-  {
-    return doQuery(query);
-  }
-
+  int doCommand( const std::string & query );
   
   //! Returns a row from a result set.
   bool getRow( row_t & row );
