sqlite3 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -1,4 +1,17 @@
1
- === 1.3.3 / unreleased
1
+ === 1.3.4 / 2011-07-25
2
+
3
+ * Enhancements:
4
+ * Windows: build against SQLite 3.7.7.1
5
+ * Windows: build static binaries that do not depend on sqlite3.dll be
6
+ installed anymore
7
+
8
+ * Bugfixes
9
+ * Backup API is conditionaly required so that older libsqlite3 can be used.
10
+ Thanks Hongli Lai.
11
+ * Fixed segmentation fault when nil is passed to SQLite3::Statement.new
12
+ * Fix extconf's hardcoded path that affected installation on certain systems.
13
+
14
+ === 1.3.3 / 2010-01-16
2
15
 
3
16
  * Bugfixes
4
17
  * Abort on installation if sqlite3_backup_init is missing. Fixes #19
@@ -1,8 +1,6 @@
1
1
  = SQLite3/Ruby Interface
2
2
 
3
3
  * http://github.com/luislavena/sqlite3-ruby
4
- * http://rubyforge.org/projects/sqlite-ruby
5
- * http://sqlite-ruby.rubyforge.org
6
4
  * http://groups.google.com/group/sqlite3-ruby
7
5
 
8
6
  == DESCRIPTION
@@ -56,11 +54,11 @@ Then do the following:
56
54
  Alternatively, you can download and install the RubyGem package for
57
55
  SQLite3/Ruby (you must have RubyGems and SQLite3 installed, first):
58
56
 
59
- gem install sqlite3-ruby
57
+ gem install sqlite3
60
58
 
61
59
  If you have sqlite3 installed in a non-standard location, you can specify the location of the include and lib files by doing:
62
60
 
63
- gem install sqlite3-ruby -- --with-sqlite3-include=/opt/local/include \
61
+ gem install sqlite3 -- --with-sqlite3-include=/opt/local/include \
64
62
  --with-sqlite3-lib=/opt/local/lib
65
63
 
66
64
  = SUPPORT!!!
@@ -85,9 +83,9 @@ which can be found here:
85
83
  == Usage
86
84
 
87
85
  For help figuring out the SQLite3/Ruby interface, check out the
88
- FAQ[http://sqlite-ruby.rubyforge.org/sqlite3/faq.html]. It includes examples of
86
+ SYNOPSIS as well as the RDoc. It includes examples of
89
87
  usage. If you have any questions that you feel should be address in the
90
- FAQ, please send them to jamis@37signals.com
88
+ FAQ, please send them to {the mailing list}[http://groups.google.com/group/sqlite3-ruby]
91
89
 
92
90
  == Source Code
93
91
 
@@ -95,9 +93,3 @@ The source repository is accessible via git:
95
93
 
96
94
  git clone git://github.com/luislavena/sqlite3-ruby.git
97
95
 
98
- == Contact Information
99
-
100
- The project page is http://rubyforge.org/projects/sqlite-ruby. There, you can
101
- find links to mailing lists and forums that you can use to discuss this
102
- library. Additionally, there are trackers for submitting bugs and feature
103
- requests. Feel free to use them!
@@ -1,3 +1,5 @@
1
+ #ifdef HAVE_SQLITE3_BACKUP_INIT
2
+
1
3
  #include <sqlite3_ruby.h>
2
4
 
3
5
  #define REQUIRE_OPEN_BACKUP(_ctxt) \
@@ -162,3 +164,5 @@ void init_sqlite3_backup()
162
164
  rb_define_method(cSqlite3Backup, "remaining", remaining, 0);
163
165
  rb_define_method(cSqlite3Backup, "pagecount", pagecount, 0);
164
166
  }
167
+
168
+ #endif
@@ -1,4 +1,4 @@
1
- #ifndef SQLITE3_BACKUP_RUBY
1
+ #if !defined(SQLITE3_BACKUP_RUBY) && defined(HAVE_SQLITE3_BACKUP_INIT)
2
2
  #define SQLITE3_BACKUP_RUBY
3
3
 
4
4
  #include <sqlite3_ruby.h>
@@ -6,14 +6,20 @@ require 'mkmf'
6
6
 
7
7
  RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
8
8
 
9
- sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/sw/local', '/usr'])
9
+ # --with-sqlite3-{dir,include,lib}
10
+ dir_config("sqlite3")
10
11
 
11
- if RUBY_PLATFORM =~ /mswin/
12
+ # prioritize local builds
13
+ if enable_config("local", false)
14
+ $LDFLAGS = ENV.fetch("LDFLAGS", nil)
15
+ end
16
+
17
+ if RbConfig::CONFIG["host_os"] =~ /mswin/
12
18
  $CFLAGS << ' -W3'
13
19
  end
14
20
 
15
21
  def asplode missing
16
- if RUBY_PLATFORM =~ /mswin/
22
+ if RUBY_PLATFORM =~ /mingw|mswin/
17
23
  abort "#{missing} is missing. Install SQLite3 from " +
18
24
  "http://www.sqlite.org/ first."
19
25
  else
@@ -31,15 +37,9 @@ asplode('sqlite3') unless find_library 'sqlite3', 'sqlite3_libversion_number'
31
37
  # Functions defined in 1.9 but not 1.8
32
38
  have_func('rb_proc_arity')
33
39
 
34
- unless %w{
35
- sqlite3_initialize
36
- sqlite3_next_stmt
37
- sqlite3_backup_init
38
- }.all? { |func| have_func func }
39
- abort "sqlite3-ruby only supports sqlite3 versions 3.6.16+, please upgrade!"
40
- end
41
-
42
40
  # These functions may not be defined
41
+ have_func('sqlite3_initialize')
42
+ have_func('sqlite3_backup_init')
43
43
  have_func('sqlite3_column_database_name')
44
44
  have_func('sqlite3_enable_load_extension')
45
45
  have_func('sqlite3_load_extension')
@@ -24,11 +24,15 @@ void Init_sqlite3_native()
24
24
  cSqlite3Blob = rb_define_class_under(mSqlite3, "Blob", rb_cString);
25
25
 
26
26
  /* Initialize the sqlite3 library */
27
+ #ifdef HAVE_SQLITE3_INITIALIZE
27
28
  sqlite3_initialize();
29
+ #endif
28
30
 
29
31
  init_sqlite3_database();
30
32
  init_sqlite3_statement();
33
+ #ifdef HAVE_SQLITE3_BACKUP_INIT
31
34
  init_sqlite3_backup();
35
+ #endif
32
36
 
33
37
  rb_define_singleton_method(mSqlite3, "libversion", libversion, 0);
34
38
  rb_define_const(mSqlite3, "SQLITE_VERSION", rb_str_new2(SQLITE_VERSION));
@@ -35,6 +35,8 @@ static VALUE initialize(VALUE self, VALUE db, VALUE sql)
35
35
  const char *tail = NULL;
36
36
  int status;
37
37
 
38
+ StringValue(sql);
39
+
38
40
  Data_Get_Struct(db, sqlite3Ruby, db_ctx);
39
41
  Data_Get_Struct(self, sqlite3StmtRuby, ctx);
40
42
 
@@ -43,10 +45,7 @@ static VALUE initialize(VALUE self, VALUE db, VALUE sql)
43
45
 
44
46
  #ifdef HAVE_RUBY_ENCODING_H
45
47
  if(!UTF8_P(sql)) {
46
- VALUE encoding = rb_funcall(db, rb_intern("encoding"), 0);
47
- rb_encoding * enc = NIL_P(encoding) ? rb_utf8_encoding() :
48
- rb_to_encoding(encoding);
49
- sql = rb_str_export_to_enc(sql, enc);
48
+ sql = rb_str_export_to_enc(sql, rb_utf8_encoding());
50
49
  }
51
50
  #endif
52
51
 
@@ -1,12 +1,12 @@
1
1
  module SQLite3
2
2
 
3
- VERSION = '1.3.3'
3
+ VERSION = '1.3.4'
4
4
 
5
5
  module VersionProxy
6
6
 
7
7
  MAJOR = 1
8
8
  MINOR = 3
9
- TINY = 1
9
+ TINY = 4
10
10
  BUILD = nil
11
11
 
12
12
  STRING = [ MAJOR, MINOR, TINY, BUILD ].compact.join( "." )
@@ -22,6 +22,7 @@ HOE = Hoe.spec 'sqlite3' do
22
22
  spec_extras[:extensions] = ["ext/sqlite3/extconf.rb"]
23
23
 
24
24
  extra_dev_deps << ['rake-compiler', "~> 0.7.0"]
25
+ extra_dev_deps << ["mini_portile", "~> 0.2.2"]
25
26
 
26
27
  clean_globs.push('**/test.db')
27
28
  end
@@ -4,8 +4,8 @@ require 'rake/extensiontask'
4
4
  # NOTE: version used by cross compilation of Windows native extension
5
5
  # It do not affect compilation under other operating systems
6
6
  # The version indicated is the minimum DLL suggested for correct functionality
7
- BINARY_VERSION = '3.7.3'
8
- URL_VERSION = BINARY_VERSION.gsub('.', '_')
7
+ BINARY_VERSION = '3.7.7.1'
8
+ URL_VERSION = BINARY_VERSION.tr(".", "0")
9
9
 
10
10
  # build sqlite3_native C extension
11
11
  Rake::ExtensionTask.new('sqlite3_native', HOE.spec) do |ext|
@@ -15,9 +15,6 @@ Rake::ExtensionTask.new('sqlite3_native', HOE.spec) do |ext|
15
15
  # where native extension will be copied (matches makefile)
16
16
  ext.lib_dir = "lib/sqlite3"
17
17
 
18
- # reference to the sqlite3 library
19
- sqlite3_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'sqlite3'))
20
-
21
18
  # clean binary folders always
22
19
  CLEAN.include("#{ext.lib_dir}/?.?")
23
20
 
@@ -26,32 +23,11 @@ Rake::ExtensionTask.new('sqlite3_native', HOE.spec) do |ext|
26
23
  # define target for extension (supporting fat binaries)
27
24
  RUBY_VERSION =~ /(\d+\.\d+)/
28
25
  ext.lib_dir = "lib/sqlite3/#{$1}"
29
- ext.config_options << "--with-sqlite3-dir=#{sqlite3_lib}"
26
+ ext.config_options << "--enable-local"
30
27
  else
31
28
  ext.cross_compile = true
32
29
  ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32']
33
- ext.cross_config_options << "--with-sqlite3-dir=#{sqlite3_lib}"
34
- ext.cross_compiling do |gemspec|
35
- gemspec.post_install_message = <<-POST_INSTALL_MESSAGE
36
-
37
- =============================================================================
38
-
39
- You've installed the binary version of #{gemspec.name}.
40
- It was built using SQLite3 version #{BINARY_VERSION}.
41
- It's recommended to use the exact same version to avoid potential issues.
42
-
43
- At the time of building this gem, the necessary DLL files where available
44
- in the following download:
45
-
46
- http://www.sqlite.org/sqlitedll-#{URL_VERSION}.zip
47
-
48
- You can put the sqlite3.dll available in this package in your Ruby bin
49
- directory, for example C:\\Ruby\\bin
50
-
51
- =============================================================================
52
-
53
- POST_INSTALL_MESSAGE
54
- end
30
+ ext.cross_config_options << "--enable-local"
55
31
  end
56
32
  end
57
33
 
@@ -1,104 +1,41 @@
1
- require 'rake/clean'
2
- require 'rake/extensioncompiler'
1
+ require "rake/clean"
2
+ require "rake/extensioncompiler"
3
+ require "mini_portile"
3
4
 
4
- # download sqlite3 library and headers
5
+ $recipes = {}
5
6
 
6
- # only on Windows or cross platform compilation
7
- def dlltool(dllname, deffile, libfile)
8
- # define if we are using GCC or not
9
- if Rake::ExtensionCompiler.mingw_gcc_executable then
10
- dir = File.dirname(Rake::ExtensionCompiler.mingw_gcc_executable)
11
- tool = case RUBY_PLATFORM
12
- when /mingw/
13
- File.join(dir, 'dlltool.exe')
14
- when /linux|darwin/
15
- File.join(dir, "#{Rake::ExtensionCompiler.mingw_host}-dlltool")
16
- end
17
- return "#{tool} --dllname #{dllname} --def #{deffile} --output-lib #{libfile}"
18
- else
19
- if RUBY_PLATFORM =~ /mswin/ then
20
- tool = 'lib.exe'
21
- else
22
- fail "Unsupported platform for cross-compilation (please, contribute some patches)."
23
- end
24
- return "#{tool} /DEF:#{deffile} /OUT:#{libfile}"
25
- end
26
- end
7
+ $recipes[:sqlite3] = MiniPortile.new "sqlite3", BINARY_VERSION
8
+ $recipes[:sqlite3].files << "http://sqlite.org/sqlite-autoconf-#{URL_VERSION}.tar.gz"
27
9
 
28
- # required folder structure for --with-sqlite3-dir (include + lib)
29
- directory "vendor/sqlite3/lib"
30
- directory "vendor/sqlite3/include"
10
+ namespace :ports do
11
+ directory "ports"
31
12
 
32
- # download amalgamation version (for include files)
33
- file "vendor/sqlite-amalgamation-#{URL_VERSION}.zip" => ['vendor'] do |t|
34
- url = "http://www.sqlite.org/#{File.basename(t.name)}"
35
- when_writing "downloading #{t.name}" do
36
- cd File.dirname(t.name) do
37
- system "wget -c #{url} || curl -C - -O #{url}"
38
- end
39
- end
40
- end
13
+ desc "Install port sqlite3 #{$recipes[:sqlite3].version}"
14
+ task :sqlite3 => ["ports"] do |t|
15
+ recipe = $recipes[:sqlite3]
16
+ checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
41
17
 
42
- # download dll binaries
43
- file "vendor/sqlitedll-#{URL_VERSION}.zip" => ['vendor'] do |t|
44
- url = "http://www.sqlite.org/#{File.basename(t.name)}"
45
- when_writing "downloading #{t.name}" do
46
- cd File.dirname(t.name) do
47
- system "wget -c #{url} || curl -C - -O #{url}"
18
+ unless File.exist?(checkpoint)
19
+ recipe.cook
20
+ touch checkpoint
48
21
  end
49
- end
50
- end
51
22
 
52
- # extract header files into include folder
53
- file "vendor/sqlite3/include/sqlite3.h" => ['vendor/sqlite3/include', "vendor/sqlite-amalgamation-#{URL_VERSION}.zip"] do |t|
54
- full_file = File.expand_path(t.prerequisites.last)
55
- when_writing "creating #{t.name}" do
56
- cd File.dirname(t.name) do
57
- sh "unzip #{full_file}"
58
- # update file timestamp to avoid Rake perform this extraction again.
59
- touch File.basename(t.name)
60
- end
23
+ recipe.activate
61
24
  end
62
25
  end
63
26
 
64
- # extract dll files into lib folder
65
- file "vendor/sqlite3/lib/sqlite3.dll" => ['vendor/sqlite3/lib', "vendor/sqlitedll-#{URL_VERSION}.zip"] do |t|
66
- full_file = File.expand_path(t.prerequisites.last)
67
- when_writing "creating #{t.name}" do
68
- cd File.dirname(t.name) do
69
- sh "unzip #{full_file}"
70
- # update file timestamp to avoid Rake perform this extraction again.
71
- touch File.basename(t.name)
72
- end
73
- end
27
+ if RUBY_PLATFORM =~ /mingw/
28
+ Rake::Task['compile'].prerequisites.unshift "ports:sqlite3"
74
29
  end
75
30
 
76
- # generate import library from definition and dll file
77
- file "vendor/sqlite3/lib/sqlite3.lib" => ["vendor/sqlite3/lib/sqlite3.dll"] do |t|
78
- libfile = t.name
79
- dllname = libfile.ext('dll')
80
- deffile = libfile.ext('def')
81
-
82
- when_writing "creating #{t.name}" do
83
- sh dlltool(dllname, deffile, libfile)
31
+ task :cross do
32
+ host = ENV.fetch("HOST", Rake::ExtensionCompiler.mingw_host)
33
+ $recipes.each do |_, recipe|
34
+ recipe.host = host
84
35
  end
85
- end
86
-
87
- # clean and clobber actions
88
- # All the uncompressed files must be removed at clean
89
- CLEAN.include('vendor/sqlite3')
90
36
 
91
- # clobber vendored packages
92
- CLOBBER.include('vendor')
93
-
94
- # vendor:sqlite3
95
- task 'vendor:sqlite3' => ["vendor/sqlite3/lib/sqlite3.lib", "vendor/sqlite3/include/sqlite3.h"]
96
-
97
- # hook into cross compilation vendored sqlite3 dependency
98
- if RUBY_PLATFORM =~ /mingw|mswin/ then
99
- Rake::Task['compile'].prerequisites.unshift 'vendor:sqlite3'
100
- else
101
- if Rake::Task.task_defined?(:cross)
102
- Rake::Task['cross'].prerequisites.unshift 'vendor:sqlite3'
103
- end
37
+ # hook compile task with dependencies
38
+ Rake::Task["compile"].prerequisites.unshift "ports:sqlite3"
104
39
  end
40
+
41
+ CLOBBER.include("ports")
@@ -29,5 +29,5 @@ module SQLite3
29
29
  b.finish
30
30
  assert_equal(@data.length, @ddb.execute('SELECT * FROM foo;').length)
31
31
  end
32
- end
32
+ end if defined?(SQLite3::Backup)
33
33
  end
@@ -1,5 +1,4 @@
1
1
  require 'helper'
2
- require 'iconv'
3
2
 
4
3
  module SQLite3
5
4
  class TestDatabase < Test::Unit::TestCase
@@ -7,6 +6,13 @@ module SQLite3
7
6
  @db = SQLite3::Database.new(':memory:')
8
7
  end
9
8
 
9
+ def test_blob
10
+ @db.execute("CREATE TABLE blobs ( id INTEGER, hash BLOB(10) )")
11
+ str = "\0foo"
12
+ @db.execute("INSERT INTO blobs VALUES (0, ?)", [str])
13
+ assert_equal [[0, str]], @db.execute("SELECT * FROM blobs")
14
+ end
15
+
10
16
  def test_get_first_row
11
17
  assert_equal [1], @db.get_first_row('SELECT 1')
12
18
  end
@@ -291,7 +297,7 @@ module SQLite3
291
297
  end
292
298
 
293
299
  def test_close_with_open_statements
294
- stmt = @db.prepare("select 'foo'")
300
+ @db.prepare("select 'foo'")
295
301
  assert_raises(SQLite3::BusyException) do
296
302
  @db.close
297
303
  end
@@ -7,6 +7,12 @@ module SQLite3
7
7
  @stmt = SQLite3::Statement.new(@db, "select 'foo'")
8
8
  end
9
9
 
10
+ def test_raises_type_error
11
+ assert_raises(TypeError) do
12
+ SQLite3::Statement.new( @db, nil )
13
+ end
14
+ end
15
+
10
16
  ###
11
17
  # This method may not exist depending on how sqlite3 was compiled
12
18
  def test_database_name
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 3
10
- version: 1.3.3
9
+ - 4
10
+ version: 1.3.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jamis Buck
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-01-16 00:00:00 -08:00
20
+ date: 2011-07-25 00:00:00 -03:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -37,21 +37,36 @@ dependencies:
37
37
  type: :development
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency
40
- name: hoe
40
+ name: mini_portile
41
41
  prerelease: false
42
42
  requirement: &id002 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
- - - ">="
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- hash: 47
47
+ hash: 19
48
48
  segments:
49
- - 2
50
- - 8
51
49
  - 0
52
- version: 2.8.0
50
+ - 2
51
+ - 2
52
+ version: 0.2.2
53
53
  type: :development
54
54
  version_requirements: *id002
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ prerelease: false
58
+ requirement: &id003 !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ hash: 23
64
+ segments:
65
+ - 2
66
+ - 10
67
+ version: "2.10"
68
+ type: :development
69
+ version_requirements: *id003
55
70
  description: |-
56
71
  This module allows Ruby programs to interface with the SQLite3
57
72
  database engine (http://www.sqlite.org). You must have the
@@ -68,14 +83,14 @@ extensions:
68
83
  - ext/sqlite3/extconf.rb
69
84
  extra_rdoc_files:
70
85
  - Manifest.txt
71
- - API_CHANGES.rdoc
72
- - CHANGELOG.rdoc
73
86
  - README.rdoc
87
+ - CHANGELOG.rdoc
88
+ - API_CHANGES.rdoc
89
+ - ext/sqlite3/sqlite3.c
74
90
  - ext/sqlite3/backup.c
91
+ - ext/sqlite3/statement.c
75
92
  - ext/sqlite3/database.c
76
93
  - ext/sqlite3/exception.c
77
- - ext/sqlite3/sqlite3.c
78
- - ext/sqlite3/statement.c
79
94
  files:
80
95
  - API_CHANGES.rdoc
81
96
  - CHANGELOG.rdoc
@@ -127,6 +142,7 @@ files:
127
142
  - test/test_sqlite3.rb
128
143
  - test/test_statement.rb
129
144
  - test/test_statement_execute.rb
145
+ - .gemtest
130
146
  has_rdoc: true
131
147
  homepage: http://github.com/luislavena/sqlite3-ruby
132
148
  licenses: []
@@ -162,22 +178,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
178
  requirements: []
163
179
 
164
180
  rubyforge_project: sqlite3
165
- rubygems_version: 1.3.7
181
+ rubygems_version: 1.6.2
166
182
  signing_key:
167
183
  specification_version: 3
168
184
  summary: This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org)
169
185
  test_files:
170
- - test/test_backup.rb
171
- - test/test_collation.rb
172
186
  - test/test_database.rb
187
+ - test/test_integration_open_close.rb
173
188
  - test/test_database_readonly.rb
189
+ - test/test_statement.rb
190
+ - test/test_integration_resultset.rb
174
191
  - test/test_deprecated.rb
192
+ - test/test_backup.rb
175
193
  - test/test_encoding.rb
176
- - test/test_integration.rb
177
- - test/test_integration_open_close.rb
178
- - test/test_integration_pending.rb
179
- - test/test_integration_resultset.rb
180
- - test/test_integration_statement.rb
181
194
  - test/test_sqlite3.rb
182
- - test/test_statement.rb
195
+ - test/test_collation.rb
196
+ - test/test_integration.rb
183
197
  - test/test_statement_execute.rb
198
+ - test/test_integration_statement.rb
199
+ - test/test_integration_pending.rb