Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ext/sqlite3/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ sqlite3_rb_close(VALUE self)

close_or_discard_db(ctx);

rb_iv_set(self, "-aggregators", Qnil);

return self;
}

Expand All @@ -212,8 +210,6 @@ sqlite3_rb_discard(VALUE self)

discard_db(ctx);

rb_iv_set(self, "-aggregators", Qnil);

return self;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/sqlite3/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ def create_function name, arity, text_rep = Constants::TextRep::UTF8, &block
# function invocation. It should invoke FunctionProxy#result= to
# store the result of the function.
#
# A reference to the block will be kept for the lifetime of the database object.
#
# Example:
#
# db.create_aggregate( "lengths", 1 ) do
Expand Down
11 changes: 11 additions & 0 deletions test/test_integration_aggregate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,15 @@ def test_define_aggregator_with_two_different_arities
assert_equal 33, values[0]
assert_equal 2145, values[1]
end

def test_step_on_statement_whose_database_was_closed_does_not_use_freed_aggregator
@db.define_aggregator("accumulate", AccumulateAggregator.new)
stmt = @db.prepare("select accumulate(c) from foo")

@db.close
GC.start(full_mark: true, immediate_sweep: true)

values = stmt.step
assert_equal 33, values[0]
end
Comment on lines +374 to +376
end
Loading