diff --git a/API_CHANGES.md b/API_CHANGES.md deleted file mode 100644 index 79044480..00000000 --- a/API_CHANGES.md +++ /dev/null @@ -1,49 +0,0 @@ -# API Changes - -* SQLite3::Database#execute only accepts an array for bind parameters. - -* SQLite3::ResultSet used to query the database for the first row, regardless - of whether the user asked for it or not. I have removed that so that rows - will not be returned until the user asks for them. This is a subtle but - sometimes important change in behavior. - - 83882d2208ed189361617d5ab8532a325aaf729d - -* SQLite3::Database#trace now takes either a block or an object that responds - to "call". The previous implementation passed around a VALUE that was cast - to a void *. This is dangerous because the value could get garbage collected - before the proc was called. If the user wants data passed around with the - block, they should use variables available to the closure or create an - object. - -* SQLite3::Statement#step automatically converts to ruby types, where before - all values were automatically yielded as strings. This will only be a - problem for people who were accessing information about the database that - wasn't previously passed through the pure ruby conversion code. - -* SQLite3::Database#errmsg no longer takes a parameter to return error - messages as UTF-16. Do people even use that? I opt for staying UTF-8 when - possible. See test_integration.rb test_errmsg_utf16 - -* SQLite3::Database#authorize same changes as trace - -* test/test_tc_database.rb was removed because we no longer use the Driver - design pattern. - -# Garbage Collection Strategy - -All statements keep pointers back to their respective database connections. -The @connection instance variable on the Statement handle keeps the database -connection alive. Memory allocated for a statement handler will be freed in -two cases: - -* close is called on the statement -* The SQLite3::Database object gets garbage collected - -We can't free the memory for the statement in the garbage collection function -for the statement handler. The reason is because there exists a race -condition. We cannot guarantee the order in which objects will be garbage -collected. So, it is possible that a connection and a statement are up for -garbage collection. If the database connection were to be free'd before the -statement, then boom. Instead we'll be conservative and free unclosed -statements when the connection is terminated. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d574d65e..97f06197 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,6 +5,28 @@ This doc is a short introduction on how to modify and maintain the sqlite3-ruby gem. +## Architecture notes + +### Garbage collection + +All statements keep pointers back to their respective database connections. +The `@connection` instance variable on the `Statement` handle keeps the database +connection alive. Memory allocated for a statement handler will be freed in +two cases: + +1. `#close` is called on the statement +2. The `SQLite3::Database` object gets garbage collected + +We can't free the memory for the statement in the garbage collection function +for the statement handler. The reason is because there exists a race +condition. We cannot guarantee the order in which objects will be garbage +collected. So, it is possible that a connection and a statement are up for +garbage collection. If the database connection were to be free'd before the +statement, then boom. Instead we'll be conservative and free unclosed +statements when the connection is terminated. + + + ## Building gems As a prerequisite please make sure you have `docker` correctly installed, so that you're able to cross-compile the native gems. diff --git a/ChangeLog.cvs b/ChangeLog.cvs deleted file mode 100644 index 6e9dd51d..00000000 --- a/ChangeLog.cvs +++ /dev/null @@ -1,88 +0,0 @@ -2005-01-05 09:40 minam - - * Rakefile, sqlite3-ruby-win32.gemspec, sqlite3-ruby.gemspec: Added - win32 gem. - -2005-01-05 07:31 minam - - * Rakefile, test/tc_integration.rb, test/tests.rb: Added - native-vs-dl benchmark to Rakefile. Added SQLITE3_DRIVERS - environment variable to integration test to specify which - driver(s) should be tested (defaults to "Native"). - -2005-01-04 14:26 minam - - * ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb, - lib/sqlite3/driver/native/driver.rb, test/tc_database.rb, - test/tc_integration.rb, test/tests.rb: Unit tests: done. Bugs: - fixed. - -2005-01-03 23:13 minam - - * ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb, - lib/sqlite3/driver/dl/driver.rb, - lib/sqlite3/driver/native/driver.rb, test/tc_integration.rb: - Custom functions (aggregate and otherwise) are supported by the - native driver now. Test cases for the same. - -2005-01-03 13:51 minam - - * ext/sqlite3_api/MANIFEST, ext/sqlite3_api/extconf.rb, - ext/sqlite3_api/post-clean.rb, ext/sqlite3_api/post-distclean.rb, - ext/sqlite3_api/sqlite3_api.i, lib/sqlite3/database.rb, - lib/sqlite3/resultset.rb, lib/sqlite3/version.rb, - lib/sqlite3/driver/dl/driver.rb, - lib/sqlite3/driver/native/driver.rb, test/native-vs-dl.rb, - test/tc_integration.rb: Added preliminary implementation of - native driver (swig-based), and integration tests. - -2004-12-29 19:37 minam - - * lib/sqlite3/driver/dl/driver.rb: Some fixes to allow the DL - driver to work with Ruby 1.8.1. - -2004-12-29 14:52 minam - - * lib/sqlite3/: database.rb, version.rb: Made #quote a class method - (again). Bumped version to 0.6. - -2004-12-25 22:59 minam - - * lib/sqlite3/driver/dl/api.rb: Added check for darwin in supported - platforms (thanks to bitsweat). - -2004-12-22 12:38 minam - - * Rakefile: Rakefile wasn't packaging the README file. - -2004-12-21 22:28 minam - - * Rakefile, sqlite3-ruby.gemspec, test/bm.rb: Packaging now works. - Added benchmarks. - -2004-12-21 21:45 minam - - * LICENSE, README, Rakefile, setup.rb, sqlite3-ruby.gemspec, - doc/faq/faq.rb, doc/faq/faq.yml, lib/sqlite3.rb, - lib/sqlite3/statement.rb, lib/sqlite3/constants.rb, - lib/sqlite3/database.rb, lib/sqlite3/resultset.rb, - lib/sqlite3/translator.rb, lib/sqlite3/value.rb, - lib/sqlite3/version.rb, lib/sqlite3/errors.rb, - lib/sqlite3/pragmas.rb, lib/sqlite3/driver/dl/api.rb, - lib/sqlite3/driver/dl/driver.rb, test/mocks.rb, - test/tc_database.rb, test/tests.rb, test/driver/dl/tc_driver.rb: - Initial import - -2004-12-21 21:45 minam - - * LICENSE, README, Rakefile, setup.rb, sqlite3-ruby.gemspec, - doc/faq/faq.rb, doc/faq/faq.yml, lib/sqlite3.rb, - lib/sqlite3/statement.rb, lib/sqlite3/constants.rb, - lib/sqlite3/database.rb, lib/sqlite3/resultset.rb, - lib/sqlite3/translator.rb, lib/sqlite3/value.rb, - lib/sqlite3/version.rb, lib/sqlite3/errors.rb, - lib/sqlite3/pragmas.rb, lib/sqlite3/driver/dl/api.rb, - lib/sqlite3/driver/dl/driver.rb, test/mocks.rb, - test/tc_database.rb, test/tests.rb, test/driver/dl/tc_driver.rb: - Initial revision - diff --git a/bin/test-gem-file-contents b/bin/test-gem-file-contents index cbe98c24..0eb5569b 100755 --- a/bin/test-gem-file-contents +++ b/bin/test-gem-file-contents @@ -94,7 +94,7 @@ describe File.basename(gemfile) do end describe "all platforms" do - ["lib", "test"].each do |dir| + ["lib"].each do |dir| it "contains every ruby file in #{dir}/" do expected = `git ls-files #{dir}`.split("\n").grep(/\.rb$/).sort skip "looks like this isn't a git repository" if expected.empty? @@ -102,6 +102,17 @@ describe File.basename(gemfile) do assert_equal(expected, actual) end end + + ["test"].each do |dir| + it "does not contain files from #{dir}/" do + actual = gemfile_contents.select { |f| f.start_with?("#{dir}/") }.grep(/\.rb$/) + assert_empty(actual) + end + end + + it "does not contain the Gemfile" do + refute_includes(gemfile_contents, "Gemfile") + end end if gemspec.platform == Gem::Platform::RUBY diff --git a/rakelib/check-manifest.rake b/rakelib/check-manifest.rake index a4935efd..813d7274 100644 --- a/rakelib/check-manifest.rake +++ b/rakelib/check-manifest.rake @@ -17,6 +17,7 @@ task :check_manifest do pkg ports rakelib + test tmp vendor [0-9]* @@ -26,7 +27,7 @@ task :check_manifest do .gitignore .rdoc_options .rubocop.yml - Gemfile?* + Gemfile* Rakefile [a-z]*.{log,out} [0-9]* diff --git a/sqlite3.gemspec b/sqlite3.gemspec index d0746454..7442b082 100644 --- a/sqlite3.gemspec +++ b/sqlite3.gemspec @@ -37,12 +37,9 @@ Gem::Specification.new do |s| s.files = [ ".gemtest", - "API_CHANGES.md", "CHANGELOG.md", "CONTRIBUTING.md", - "ChangeLog.cvs", "FAQ.md", - "Gemfile", "INSTALLATION.md", "LICENSE", "LICENSE-DEPENDENCIES", @@ -69,32 +66,10 @@ Gem::Specification.new do |s| "lib/sqlite3/resultset.rb", "lib/sqlite3/statement.rb", "lib/sqlite3/value.rb", - "lib/sqlite3/version.rb", - "test/helper.rb", - "test/test_backup.rb", - "test/test_collation.rb", - "test/test_database.rb", - "test/test_database_flags.rb", - "test/test_database_readonly.rb", - "test/test_database_readwrite.rb", - "test/test_deprecated.rb", - "test/test_encoding.rb", - "test/test_integration.rb", - "test/test_integration_aggregate.rb", - "test/test_integration_open_close.rb", - "test/test_integration_pending.rb", - "test/test_integration_resultset.rb", - "test/test_integration_statement.rb", - "test/test_pragmas.rb", - "test/test_resource_cleanup.rb", - "test/test_result_set.rb", - "test/test_sqlite3.rb", - "test/test_statement.rb", - "test/test_statement_execute.rb" + "lib/sqlite3/version.rb" ] s.extra_rdoc_files = [ - "API_CHANGES.md", "CHANGELOG.md", "README.md", "ext/sqlite3/aggregator.c",