<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -594,18 +594,18 @@ int amalgalite_xProgress( void *pArg )
 VALUE am_sqlite3_database_progress_handler( VALUE self, VALUE op_count, VALUE handler )
 {
     am_sqlite3   *am_db;
-    int           op_codes = FIX2INT( op_count );
 
     Data_Get_Struct(self, am_sqlite3, am_db);
 
     /* Removing a progress handler, remove it from sqlite and then remove it
      * from the garbage collector if it existed */
     if ( Qnil == handler ) {
-        sqlite3_progress_handler( am_db-&gt;db, 0, NULL, (void*)NULL );
+        sqlite3_progress_handler( am_db-&gt;db, -1, NULL, (void*)NULL );
         if ( Qnil != am_db-&gt;progress_handler_obj ) {
             rb_gc_unregister_address( &amp;(am_db-&gt;progress_handler_obj) );
         }
     } else {
+        int  op_codes = FIX2INT( op_count );
         /* installing a progress handler
          * - register it with sqlite
          * - keep a reference for ourselves with our database handle</diff>
      <filename>ext/amalgalite3_database.c</filename>
    </modified>
    <modified>
      <diff>@@ -530,18 +530,27 @@ VALUE am_sqlite3_statement_sql(VALUE self)
  *    stmt.close -&gt; nil
  *
  * Closes the statement.  If there is a problem closing the statement then an
- * error is raised.
+ * error is raised.  Closing a statement when there is an existing error is
+ * perfectly fine.
+ *
  */
 VALUE am_sqlite3_statement_close( VALUE self )
 {
 
     am_sqlite3_stmt   *am_stmt;
-    int                rc;
+    int                rc, existing_errcode;
 
     Data_Get_Struct(self, am_sqlite3_stmt, am_stmt);
+
+    /* check the current error code to see if one exists, we could be
+     * closing a statement that has an error, and in that case we do not want to
+     * raise an additional error, we want to let the existing error stand
+     */
+    existing_errcode = sqlite3_errcode( sqlite3_db_handle( am_stmt-&gt;stmt ) );
     rc = sqlite3_finalize( am_stmt-&gt;stmt );
-    if ( SQLITE_OK != rc ) {
-        rb_raise(eAS_Error, &quot;Failure to close statment : [SQLITE_ERROR %d] : %s\n&quot;,
+
+    if ( (SQLITE_OK != rc) &amp;&amp; (rc != existing_errcode) ) {
+        rb_raise(eAS_Error, &quot;Failure to close statement : [SQLITE_ERROR %d] : %s\n&quot;,
                 rc, sqlite3_errmsg( sqlite3_db_handle( am_stmt-&gt;stmt) ));
     }
 
@@ -575,6 +584,8 @@ VALUE am_sqlite3_statement_alloc(VALUE klass)
     am_sqlite3_stmt  *wrapper = ALLOC(am_sqlite3_stmt);
     VALUE             obj     = (VALUE)NULL;
 
+    wrapper-&gt;remaining_sql = Qnil;
+
     obj = Data_Wrap_Struct(klass, NULL, am_sqlite3_statement_free, wrapper);
     return obj;
 }</diff>
      <filename>ext/amalgalite3_statement.c</filename>
    </modified>
    <modified>
      <diff>@@ -165,6 +165,7 @@ module Amalgalite
     def close
       if open? then
         @api.close
+        @open = false
       end
     end
 </diff>
      <filename>lib/amalgalite/database.rb</filename>
    </modified>
    <modified>
      <diff>@@ -35,6 +35,14 @@ module Amalgalite
       @blobs_to_write  = []
       @rowid_index     = nil
       @result_meta     = nil
+      @open            = true
+    end
+
+    ##
+    # is the statement open for business
+    #
+    def open?
+      @open
     end
 
     ##
@@ -288,8 +296,10 @@ module Amalgalite
         row = nil
         write_blobs
       else
-        raise Amalgalite::SQLite3::Error, 
-              &quot;SQLITE ERROR #{rc} (#{Amalgalite::SQLite3::Constants::ResultCode.name_from_value( rc )}) : #{@db.api.last_error_message}&quot;
+        self.close # must close so that the error message is guaranteed to be pushed into the database handler
+                   # and we can can call last_error_message on it
+        msg = &quot;SQLITE ERROR #{rc} (#{Amalgalite::SQLite3::Constants::ResultCode.name_from_value( rc )}) : #{@db.api.last_error_message}&quot;
+        raise Amalgalite::SQLite3::Error, msg
       end
       return row
     end
@@ -396,7 +406,10 @@ module Amalgalite
     # has been closed.
     #
     def close
-      @stmt_api.close
+      if open?
+        @stmt_api.close
+        @open = false
+      end
     end
   end
 end</diff>
      <filename>lib/amalgalite/statement.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,8 @@
 require 'rubygems'
 require 'spec'
 
-$: &lt;&lt; File.expand_path(File.join(File.dirname(__FILE__),&quot;..&quot;,&quot;lib&quot;))
+require File.expand_path( File.join( File.dirname( __FILE__ ), &quot;spec_helper.rb&quot; ) )
+
 require 'amalgalite'
 require 'amalgalite/database'
 </diff>
      <filename>spec/aggregate_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,8 @@
 require 'rubygems'
 require 'spec'
 
-$: &lt;&lt; File.expand_path(File.join(File.dirname(__FILE__),&quot;..&quot;,&quot;lib&quot;))
+require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper.rb' ) )
+
 require 'amalgalite'
 require 'amalgalite/database'
 </diff>
      <filename>spec/busy_handler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require 'rubygems'
 require 'spec'
+require File.expand_path( File.join( File.dirname( __FILE__ ), &quot;spec_helper.rb&quot; ) )
 
-$: &lt;&lt; File.expand_path(File.join(File.dirname(__FILE__),&quot;..&quot;,&quot;lib&quot;))
 require 'amalgalite'
 require 'amalgalite/database'
 class PH &lt; ::Amalgalite::ProgressHandler
@@ -82,6 +82,8 @@ describe &quot;Progress Handlers&quot; do
     qt.join
     ph.call_count.should eql(25)
     qt[:exception].should be_instance_of( ::Amalgalite::SQLite3::Error )
+    @iso_db.api.last_error_code.should == 9
+    @iso_db.api.last_error_message.should  =~ /interrupted/
     qt[:exception].message.should =~ /interrupted/
   end
 </diff>
      <filename>spec/progress_handler_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,8 @@ require 'rubygems'
 require 'spec'
 
 $: &lt;&lt; File.expand_path(File.join(File.dirname(__FILE__),&quot;..&quot;,&quot;lib&quot;))
+$: &lt;&lt; File.expand_path(File.join(File.dirname(__FILE__),&quot;..&quot;,&quot;ext&quot;))
+
 require 'amalgalite'
 
 class SpecInfo</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,8 @@
 require 'rubygems'
 require 'spec'
 
-$: &lt;&lt; File.expand_path(File.join(File.dirname(__FILE__),&quot;..&quot;,&quot;lib&quot;))
+require File.expand_path( File.join( File.dirname( __FILE__ ), &quot;spec_helper.rb&quot; ) )
+
 require 'amalgalite'
 
 describe Amalgalite::Statement do</diff>
      <filename>spec/statement_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -62,7 +62,7 @@ Configuration.for('test') {
   mode      &quot;spec&quot;
   files     Configuration.for(&quot;packaging&quot;).files.test
   options   %w[ --format progress --color ]
-  ruby_opts %w[ -w ]
+  ruby_opts %w[  ]
 }
 
 #-----------------------------------------------------------------------
@@ -72,7 +72,7 @@ Configuration.for('rcov') {
   output_dir  &quot;coverage&quot;
   libs        %w[ lib ]
   rcov_opts   %w[ --html ]
-  ruby_opts   %w[ -w ]
+  ruby_opts   %w[  ]
   test_files  Configuration.for('packaging').files.test
 }
 #</diff>
      <filename>tasks/config.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,7 @@ if spec_config = Configuration.for_if_exist?(&quot;test&quot;) then
                           Amalgalite::Paths.root_dir ]
         r.spec_files  = spec_config.files 
         r.spec_opts   = spec_config.options
-        r.warning     = true
+        #r.warning     = true
 
         if rcov_config = Configuration.for_if_exist?('rcov') then
           r.rcov      = true</diff>
      <filename>tasks/rspec.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b2edf7e056fd170efb8c8c291afe5680f01c7a0a</id>
    </parent>
    <parent>
      <id>39d2fb9147d3fdef32467ed1a35e81f39c5be9e0</id>
    </parent>
  </parents>
  <author>
    <name>Jeremy Hinegardner</name>
    <email>jeremy@hinegardner.org</email>
  </author>
  <url>http://github.com/copiousfreetime/amalgalite/commit/e4eeda66bbf77e71413070ee5ef0a5a56fd17294</url>
  <id>e4eeda66bbf77e71413070ee5ef0a5a56fd17294</id>
  <committed-date>2009-03-02T17:53:59-08:00</committed-date>
  <authored-date>2009-03-02T17:53:59-08:00</authored-date>
  <message>Merge branch 'master' of jeremy@hinegardner.org:/var/git/amalgalite</message>
  <tree>01473f3f91755eec0d363dd61dc56896ca9dea04</tree>
  <committer>
    <name>Jeremy Hinegardner</name>
    <email>jeremy@hinegardner.org</email>
  </committer>
</commit>
