Update SQLite3 Drivers

Update bundled drivers to version 1.2.4.
This commit is contained in:
Jacques Distler 2008-12-15 14:45:15 -06:00
parent 14561d998d
commit 65c08e1090
37 changed files with 7364 additions and 521 deletions

View file

@ -51,7 +51,6 @@ Rails::Initializer.run do |config|
# (enables use of different database adapters for development and test environments) # (enables use of different database adapters for development and test environments)
config.active_record.schema_format = :sql config.active_record.schema_format = :sql
config.load_paths << "#{RAILS_ROOT}/vendor/plugins/sqlite3-ruby"
File.umask(0026) File.umask(0026)
end end

View file

@ -0,0 +1,49 @@
=== 1.2.4 / 27 Aug 2008
* Package the updated C file for source builds. [Jamis Buck]
=== 1.2.3 / 26 Aug 2008
* Fix incorrect permissions on database.rb and translator.rb [Various]
* Avoid using Object#extend for greater speedups [Erik Veenstra]
* Ruby 1.9 compatibility tweaks for Array#zip [jimmy88@gmail.com]
* Fix linking against Ruby 1.8.5 [Rob Holland <rob@inversepath.com>]
=== 1.2.2 / 31 May 2008
* Make the table_info method adjust the returned default value for the rows
so that the sqlite3 change in 3.3.8 and greater can be handled
transparently [Jamis Buck <jamis@37signals.com>]
* Ruby 1.9 compatibility tweaks [Roman Le Negrate <roman2k@free.fr>]
* Various performance enhancements [thanks Erik Veenstra]
* Correct busy_handler documentation [Rob Holland <rob@inversepath.com>]
* Use int_bind64 on Fixnum values larger than a 32bit C int can take. [Rob Holland <rob@inversepath.com>]
* Work around a quirk in SQLite's error reporting by calling sqlite3_reset
to produce a more informative error code upon a failure from
sqlite3_step. [Rob Holland <rob@inversepath.com>]
* Various documentation, test, and style tweaks [Rob Holland <rob@inversepath.com>]
* Be more granular with time/data translation [Rob Holland <rob@inversepath.com>]
* Use Date directly for parsing rather than going via Time [Rob Holland <rob@inversepath.com>]
* Check for the rt library and fdatasync so we link against that when
needed [Rob Holland <rob@inversepath.com>]
* Rename data structures to avoid collision on win32. based on patch
by: Luis Lavena [Rob Holland <rob@inversepath.com>]
* Add test for defaults [Daniel Rodríguez Troitiño]
* Correctly unquote double-quoted pragma defaults [Łukasz Dargiewicz <lukasz.dargiewicz@gmail.com>]

27
vendor/plugins/sqlite3-ruby/LICENSE vendored Normal file
View file

@ -0,0 +1,27 @@
Copyright (c) 2004, Jamis Buck (jamis@jamisbuck.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

51
vendor/plugins/sqlite3-ruby/README.rdoc vendored Normal file
View file

@ -0,0 +1,51 @@
= SQLite3/Ruby Interface
This module allows Ruby programs to interface with the SQLite3
database engine (http://www.sqlite.org). You must have the
SQLite engine installed in order to build this module.
Note that this module is NOT compatible with SQLite 2.x.
== Compilation and Installation
Simply do the following, after installing SQLite3:
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
Alternatively, you can download and install the RubyGem package for
SQLite3/Ruby (you must have RubyGems and SQLite3 installed, first):
gem install sqlite3-ruby
If you have sqlite3 installed in a non-standard location, you can specify the location of the include and lib files by doing:
gem install sqlite3-ruby -- --with-sqlite3-include=/opt/local/include \
--with-sqlite3-lib=/opt/local/lib
Also, the gem ships with the C source-code pre-built, so (as of version 1.1.1)
you no longer need to have SWIG installed. However, if you have SWIG installed
and you want to generate the C file yourself, you can specify the
<code>--with-swig</code> option.
== Usage
For help figuring out the SQLite3/Ruby interface, check out the
FAQ[http://sqlite-ruby.rubyforge.org/sqlite3/faq.html]. It includes examples of
usage. If you have any questions that you feel should be address in the
FAQ, please send them to jamis@37signals.com
== Source Code
The source repository is accessible via git:
git clone git://github.com/jamis/sqlite3-ruby.git
== Contact Information
The project page is http://rubyforge.org/projects/sqlite-ruby. There, you can
find links to mailing lists and forums that you can use to discuss this
library. Additionally, there are trackers for submitting bugs and feature
requests. Feel free to use them!

192
vendor/plugins/sqlite3-ruby/Rakefile vendored Normal file
View file

@ -0,0 +1,192 @@
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/contrib/sshpublisher'
require "./lib/sqlite3/version"
PACKAGE_NAME = "sqlite3-ruby"
PACKAGE_VERSION = SQLite3::Version::STRING
puts "name : #{PACKAGE_NAME}"
puts "version: #{PACKAGE_VERSION}"
SOURCE_FILES = FileList.new do |fl|
[ "ext", "lib", "test" ].each do |dir|
fl.include "#{dir}/**/*"
end
fl.include "Rakefile"
end
PACKAGE_FILES = FileList.new do |fl|
[ "api", "doc" ].each do |dir|
fl.include "#{dir}/**/*"
end
fl.include "CHANGELOG.rdoc", "README.rdoc", "LICENSE", "#{PACKAGE_NAME}.gemspec", "setup.rb"
fl.include SOURCE_FILES
end
Gem.manage_gems
def can_require( file )
begin
require file
return true
rescue LoadError
return false
end
end
desc "Default task"
task :default => [ :test ]
desc "Clean generated files"
task :clean do
rm_rf "ChangeLog"
rm_rf "pkg"
rm_rf "api"
rm_f "doc/faq/faq.html"
native_files = [ "Makefile", "mkmf.log", "sqlite3_api.so",
"sqlite3_api.bundle", "sqlite3_api_wrap.o" ]
native_files.each { |f| rm_f "ext/sqlite3_api/#{f}" }
end
desc "Run benchmarks vs. sqlite-ruby"
task :benchmark do
ruby "test/bm.rb"
end
desc "Run benchmarks dl vs. native"
task :benchmark2 do
ruby "test/native-vs-dl.rb"
end
desc "Generate the FAQ document"
task :faq => "doc/faq/faq.html"
file "doc/faq/faq.html" => [ "doc/faq/faq.rb", "doc/faq/faq.yml" ] do
cd( "doc/faq" ) { ruby "faq.rb > faq.html" }
end
Rake::TestTask.new do |t|
t.test_files = [ "test/tests.rb" ]
t.verbose = true
end
desc "Build all packages"
task :package
package_name = "#{PACKAGE_NAME}-#{PACKAGE_VERSION}"
package_dir = "pkg"
package_dir_path = "#{package_dir}/#{package_name}"
gz_file = "#{package_name}.tar.gz"
bz2_file = "#{package_name}.tar.bz2"
zip_file = "#{package_name}.zip"
gem_file = "#{package_name}.gem"
task :gzip => SOURCE_FILES + [ :faq, :rdoc, "#{package_dir}/#{gz_file}" ]
task :bzip => SOURCE_FILES + [ :faq, :rdoc, "#{package_dir}/#{bz2_file}" ]
task :zip => SOURCE_FILES + [ :faq, :rdoc, "#{package_dir}/#{zip_file}" ]
task :gem => SOURCE_FILES + [ :faq, "#{package_dir}/#{gem_file}" ]
task :package => [ :gzip, :bzip, :zip, :gem ]
directory package_dir
file package_dir_path do
mkdir_p package_dir_path rescue nil
PACKAGE_FILES.each do |fn|
f = File.join( package_dir_path, fn )
if File.directory?( fn )
mkdir_p f unless File.exist?( f )
else
dir = File.dirname( f )
mkdir_p dir unless File.exist?( dir )
rm_f f
safe_ln fn, f
end
end
end
file "#{package_dir}/#{zip_file}" => package_dir_path do
rm_f "#{package_dir}/#{zip_file}"
chdir package_dir do
sh %{zip -r #{zip_file} #{package_name}}
end
end
file "#{package_dir}/#{gz_file}" => package_dir_path do
rm_f "#{package_dir}/#{gz_file}"
chdir package_dir do
sh %{tar czvf #{gz_file} #{package_name}}
end
end
file "#{package_dir}/#{bz2_file}" => package_dir_path do
rm_f "#{package_dir}/#{bz2_file}"
chdir package_dir do
sh %{tar cjvf #{bz2_file} #{package_name}}
end
end
file "#{package_dir}/#{gem_file}" => package_dir do
spec = eval(File.read(PACKAGE_NAME+".gemspec"))
Gem::Builder.new(spec).build
mv gem_file, "#{package_dir}/#{gem_file}"
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'api'
rdoc.title = "SQLite3/Ruby"
rdoc.options += %w(--line-numbers --inline-source --main README.rdoc)
rdoc.rdoc_files.include('lib/**/*.rb')
if can_require( "rdoc/generators/template/html/jamis" )
rdoc.template = "jamis"
end
end
desc "Publish the API documentation"
task :pubrdoc => [ :rdoc ] do
Rake::SshDirPublisher.new(
"minam@rubyforge.org",
"/var/www/gforge-projects/sqlite-ruby/sqlite3/",
"api" ).upload
end
desc "Publish the FAQ"
task :pubfaq => [ :faq ] do
Rake::SshFilePublisher.new(
"minam@rubyforge.org",
"/var/www/gforge-projects/sqlite-ruby/sqlite3",
"doc/faq",
"faq.html" ).upload
end
desc "Publish the documentation"
task :pubdoc => [:pubrdoc, :pubfaq]
desc "Build the Native extension"
task :build do
cd 'ext/sqlite3_api' do
ruby 'extconf.rb'
system 'make'
end
end
desc "Package a beta release"
task :beta do
require 'yaml'
system 'svn up'
rev = YAML.load(`svn info`)["Revision"]
version = File.read("lib/sqlite3/version.rb")
version.gsub!(/#:beta-tag:/, %(STRING << ".#{rev}"))
File.open("lib/sqlite3/version.rb", "w") { |f| f.write(version) }
system "rake gem"
system "svn revert lib/sqlite3/version.rb"
end

View file

@ -0,0 +1,4 @@
extconf.rb
post-clean.rb
post-distclean.rb
sqlite3_api.i

View file

@ -0,0 +1,146 @@
SHELL = /bin/sh
#### Start of system configuration section. ####
srcdir = .
topdir = /opt/local/lib/ruby/1.8/i686-darwin9.2.2
hdrdir = $(topdir)
VPATH = $(srcdir):$(topdir):$(hdrdir)
prefix = $(DESTDIR)/opt/local
exec_prefix = $(prefix)
sitedir = $(prefix)/lib/ruby/site_ruby
rubylibdir = $(libdir)/ruby/$(ruby_version)
archdir = $(rubylibdir)/$(arch)
sbindir = $(exec_prefix)/sbin
vendordir = $(prefix)/lib/ruby/vendor_ruby
datadir = $(prefix)/share
includedir = $(prefix)/include
infodir = $(prefix)/info
sysconfdir = $(prefix)/etc
mandir = $(DESTDIR)/opt/local/share/man
libdir = $(exec_prefix)/lib
sharedstatedir = $(prefix)/com
oldincludedir = $(DESTDIR)/usr/include
sitearchdir = $(sitelibdir)/$(sitearch)
vendorarchdir = $(vendorlibdir)/$(vendorarch)
bindir = $(exec_prefix)/bin
localstatedir = $(prefix)/var
vendorlibdir = $(vendordir)/$(ruby_version)
sitelibdir = $(sitedir)/$(ruby_version)
libexecdir = $(exec_prefix)/libexec
CC = gcc
LIBRUBY = $(LIBRUBY_SO)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
RUBY_EXTCONF_H =
CFLAGS = -fno-common -O2 -fno-common -pipe -fno-common
INCFLAGS = -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I.
CPPFLAGS = -DHAVE_SQLITE3_H -I/usr/local/include -I/opt/local/include
CXXFLAGS = $(CFLAGS)
DLDFLAGS = -L. -L/opt/local/lib
LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
AR = ar
EXEEXT =
RUBY_INSTALL_NAME = ruby
RUBY_SO_NAME = ruby
arch = i686-darwin9.2.2
sitearch = i686-darwin9.2.2
vendorarch = i686-darwin9.2.2
ruby_version = 1.8
ruby = /opt/local/bin/ruby
RUBY = $(ruby)
RM = rm -f
MAKEDIRS = mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
#### End of system configuration section. ####
preload =
libpath = . $(libdir) /usr/local/lib
LIBPATH = -L"." -L"$(libdir)" -L"/usr/local/lib"
DEFFILE =
CLEANFILES = mkmf.log
DISTCLEANFILES =
extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lsqlite3 -lpthread -ldl -lobjc
SRCS = sqlite3_api_wrap.c
OBJS = sqlite3_api_wrap.o
TARGET = sqlite3_api
DLLIB = $(TARGET).bundle
EXTSTATIC =
STATIC_LIB =
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
TARGET_SO = $(DLLIB)
CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
all: $(DLLIB)
static: $(STATIC_LIB)
clean:
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
distclean: clean
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
realclean: distclean
install: install-so install-rb
install-so: $(RUBYARCHDIR)
install-so: $(RUBYARCHDIR)/$(DLLIB)
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
$(RUBYARCHDIR):
$(MAKEDIRS) $@
site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
.cc.o:
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.cxx.o:
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.cpp.o:
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.C.o:
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
.c.o:
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
$(DLLIB): $(OBJS)
@-$(RM) $@
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
$(OBJS): ruby.h defines.h

View file

@ -0,0 +1,16 @@
require 'mkmf'
SWIG_WRAP = "sqlite3_api_wrap.c"
dir_config( "sqlite3", "/usr/local" )
have_library( "rt", "fdatasync" )
if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
if !File.exists?( SWIG_WRAP ) || with_config( "swig", false )
puts "creating #{SWIG_WRAP}"
system "swig -ruby sqlite3_api.i" or raise "could not build wrapper via swig (perhaps swig is not installed?)"
end
create_makefile( "sqlite3_api" )
end

View file

@ -0,0 +1,71 @@
have_library: checking for fdatasync() in -lrt... -------------------- no
"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lrt -lpthread -ldl -lobjc "
conftest.c: In function t:
conftest.c:3: error: fdatasync undeclared (first use in this function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))fdatasync; return 0; }
/* end */
"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lrt -lpthread -ldl -lobjc "
ld: library not found for -lrt
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { fdatasync(); return 0; }
/* end */
"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lrt -lpthread -ldl -lobjc "
ld: library not found for -lrt
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: int fdatasync();
2: /*top*/
3: int main() { return 0; }
4: int t() { fdatasync(); return 0; }
/* end */
--------------------
have_header: checking for sqlite3.h... -------------------- yes
"gcc -E -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <sqlite3.h>
/* end */
--------------------
have_library: checking for sqlite3_open() in -lsqlite3... -------------------- yes
"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lsqlite3 -lpthread -ldl -lobjc "
conftest.c: In function t:
conftest.c:3: error: sqlite3_open undeclared (first use in this function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))sqlite3_open; return 0; }
/* end */
"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lsqlite3 -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { sqlite3_open(); return 0; }
/* end */
--------------------

View file

@ -0,0 +1,358 @@
%module "SQLite3::driver::native::API"
%include "typemaps.i"
%{
#include <sqlite3.h>
#include "ruby.h"
#ifndef RSTRING_PTR
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
#endif
#ifndef RSTRING_LEN
#define RSTRING_LEN(s) (RSTRING(s)->len)
#endif
#define Init_API Init_sqlite3_api
struct CallbackData {
VALUE proc;
VALUE proc2;
VALUE data;
};
typedef struct CallbackData CallbackData;
typedef void RUBY_BLOB;
typedef void RUBY_VALBLOB;
int Sqlite3_ruby_busy_handler(void* data,int value) {
VALUE result;
CallbackData *cb = (CallbackData*)data;
result = rb_funcall(
cb->proc, rb_intern("call"), 2, cb->data, INT2FIX(value) );
return FIX2INT(result);
}
static void mark_CallbackData(void* ptr) {
CallbackData* cb = (CallbackData*)ptr;
if (cb->proc != Qnil)
rb_gc_mark(cb->proc);
if (cb->proc2 != Qnil)
rb_gc_mark(cb->proc2);
if (cb->data != Qnil)
rb_gc_mark(cb->data);
}
int Sqlite3_ruby_authorizer(void* data,int type,
const char* a,const char* b,const char* c,const char* d)
{
VALUE result;
CallbackData *cb = (CallbackData*)data;
result = rb_funcall(
cb->proc, rb_intern("call"), 6, cb->data, INT2FIX(type),
( a ? rb_str_new2(a) : Qnil ), ( b ? rb_str_new2(b) : Qnil ),
( c ? rb_str_new2(c) : Qnil ), ( d ? rb_str_new2(d) : Qnil ) );
return FIX2INT(result);
}
void Sqlite3_ruby_trace(void* data, const char *sql) {
CallbackData *cb = (CallbackData*)data;
rb_funcall( cb->proc, rb_intern("call"), 2, cb->data,
sql ? rb_str_new2(sql) : Qnil );
}
void Sqlite3_ruby_function_step(sqlite3_context* ctx,int n,
sqlite3_value** args)
{
CallbackData *data;
VALUE rb_args;
VALUE *rb_context;
int idx;
data = (CallbackData*)sqlite3_user_data(ctx);
if( data->proc2 != Qnil ) {
rb_context = (VALUE*)sqlite3_aggregate_context(ctx,sizeof(VALUE));
if( *rb_context == 0 ) {
*rb_context = rb_hash_new();
rb_gc_register_address( rb_context );
}
}
rb_args = rb_ary_new2(n+1);
rb_ary_push( rb_args, SWIG_NewPointerObj(ctx,SWIGTYPE_p_sqlite3_context,0) );
for( idx = 0; idx < n; idx++ ) {
rb_ary_push( rb_args, SWIG_NewPointerObj(args[idx],
SWIGTYPE_p_sqlite3_value,0) );
}
rb_apply( data->proc, rb_intern("call"), rb_args );
}
void Sqlite3_ruby_function_final(sqlite3_context *ctx) {
VALUE *rb_context;
CallbackData *data;
rb_context = (VALUE*)sqlite3_aggregate_context(ctx,sizeof(VALUE));
if( *rb_context == 0 ) {
*rb_context = rb_hash_new();
rb_gc_register_address( rb_context );
}
data = (CallbackData*)sqlite3_user_data(ctx);
rb_funcall( data->proc2, rb_intern("call"), 1,
SWIG_NewPointerObj(ctx,SWIGTYPE_p_sqlite3_context,0) );
rb_gc_unregister_address( rb_context );
}
%}
%markfunc CallbackData "mark_CallbackData";
struct CallbackData {
VALUE proc;
VALUE proc2;
VALUE data;
};
%typemap(in) const void *str {
$1 = (void*)RSTRING_PTR($input);
}
%typemap(in) (const char *filename, sqlite3**) {
$1 = STR2CSTR($input);
$2 = (sqlite3**)malloc( sizeof( sqlite3* ) );
}
%typemap(argout) (const char *filename, sqlite3**) {
VALUE ary;
ary = rb_ary_new2(2);
rb_ary_push( ary, $result );
rb_ary_push( ary, SWIG_NewPointerObj( *$2, SWIGTYPE_p_sqlite3, 0 ) );
free( $2 );
$result = ary;
}
%typemap(in) (const void *filename, sqlite3**) {
$1 = (void*)RSTRING_PTR($input);
$2 = (sqlite3**)malloc( sizeof( sqlite3* ) );
}
%typemap(argout) (const void *filename, sqlite3**) {
VALUE ary;
ary = rb_ary_new2(2);
rb_ary_push( ary, $result );
rb_ary_push( ary, SWIG_NewPointerObj( *$2, SWIGTYPE_p_sqlite3, 0 ) );
free( $2 );
$result = ary;
}
typedef void RUBY_BLOB;
%typemap(out) const RUBY_BLOB * {
$result = $1 ?
rb_str_new( (char*)$1, sqlite3_column_bytes( arg1, arg2 ) ) : Qnil;
}
typedef void RUBY_VALBLOB;
%typemap(out) const RUBY_VALBLOB * {
$result = $1 ? rb_str_new( (char*)$1, sqlite3_value_bytes( arg1 ) ) : Qnil;
}
%typemap(out) const void * {
int i;
if( $1 ) {
for( i = 0; ((char*)$1)[i]; i += 2 );
$result = rb_str_new( (char*)$1, i );
} else $result = Qnil;
}
%typemap(in) (const char * sql,int,sqlite3_stmt**,const char**) (sqlite3_stmt *stmt, char *errmsg) {
$1 = RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
$3 = &stmt2;
$4 = &errmsg2;
}
%typemap(argout) (const char* sql,int,sqlite3_stmt**,const char**) {
VALUE ary;
ary = rb_ary_new2(3);
rb_ary_push( ary, $result );
rb_ary_push( ary, SWIG_NewPointerObj( stmt2, SWIGTYPE_p_sqlite3_stmt, 0 ) );
rb_ary_push( ary, errmsg2 ? rb_str_new2( errmsg2 ) : Qnil );
$result = ary;
}
%typemap(in) (const void* sql,int,sqlite3_stmt**,const void**) (sqlite3_stmt *stmt, void *errmsg) {
$1 = RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
$3 = &stmt2;
$4 = &errmsg2;
}
%typemap(argout) (const void* sql,int,sqlite3_stmt**,const void**) {
VALUE ary;
int i;
for( i = 0; ((char*)errmsg2)[i]; i += 2 );
ary = rb_ary_new2(3);
rb_ary_push( ary, $result );
rb_ary_push( ary, SWIG_NewPointerObj( stmt2, SWIGTYPE_p_sqlite3_stmt, 0 ) );
rb_ary_push( ary, errmsg2 ? rb_str_new( (char*)errmsg2, i ) : Qnil );
$result = ary;
}
%typemap(in) (const void *blob,int) {
$1 = (void*)RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
}
%typemap(in) (const void *blob,int,void(*free)(void*)) {
$1 = (void*)RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
$3 = SQLITE_TRANSIENT;
}
%typemap(in) (const char *text,int) {
$1 = RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
}
%typemap(in) (const char *text,int,void(*free)(void*)) {
$1 = RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
$3 = SQLITE_TRANSIENT;
}
%typemap(in) (const void *utf16,int) {
$1 = (void*)RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
}
%typemap(in) (const void *utf16,int,void(*free)(void*)) {
$1 = (void*)RSTRING_PTR($input);
$2 = RSTRING_LEN($input);
$3 = SQLITE_TRANSIENT;
}
%typemap(out) sqlite_int64 {
$result = rb_ll2inum( $1 );
}
%typemap(out) const char * {
$result = $1 ? rb_str_new2($1) : Qnil;
}
%typemap(in) sqlite_int64 {
$1 = rb_num2ll( $input );
}
%typemap(in) (sqlite3_context*,int data_size) {
SWIG_ConvertPtr($input,(void**)&$1, SWIGTYPE_p_sqlite3_context, 1);
$2 = 4;
}
%typemap(out) VALUE* {
$result = *(VALUE*)$1;
}
%constant int Sqlite3_ruby_busy_handler(void*,int);
%constant int Sqlite3_ruby_authorizer(void*,int,const char*,const char*,const char*,const char*);
%constant void Sqlite3_ruby_trace(void*,const char*);
%constant void Sqlite3_ruby_function_step(sqlite3_context* ctx,int n,
sqlite3_value** args);
%constant void Sqlite3_ruby_function_final(sqlite3_context* ctx);
const char *sqlite3_libversion(void);
int sqlite3_close(sqlite3*);
sqlite_int64 sqlite3_last_insert_rowid(sqlite3*);
int sqlite3_changes(sqlite3*);
int sqlite3_total_changes(sqlite3*);
void sqlite3_interrupt(sqlite3*);
int sqlite3_complete(const char*);
int sqlite3_complete16(const void *str);
int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
int sqlite3_busy_timeout(sqlite3*,int);
int sqlite3_set_authorizer(sqlite3*, int(*)(void*,int,const char*,const char*,const char*,const char*), void*);
int sqlite3_trace(sqlite3*, void(*)(void*,const char*), void*);
int sqlite3_open(const char *filename, sqlite3 **);
int sqlite3_open16(const void *filename, sqlite3 **);
int sqlite3_errcode(sqlite3*);
const char *sqlite3_errmsg(sqlite3*);
const void *sqlite3_errmsg16(sqlite3*);
int sqlite3_prepare(sqlite3*,const char* sql,int,sqlite3_stmt**,const char**);
int sqlite3_prepare16(sqlite3*,const void* sql,int,sqlite3_stmt**,const void**);
int sqlite3_bind_blob(sqlite3_stmt*,int,const void *blob,int,void(*free)(void*));
int sqlite3_bind_double(sqlite3_stmt*,int,double);
int sqlite3_bind_int(sqlite3_stmt*,int,int);
int sqlite3_bind_int64(sqlite3_stmt*,int,sqlite_int64);
int sqlite3_bind_null(sqlite3_stmt*,int);
int sqlite3_bind_text(sqlite3_stmt*,int,const char*text,int,void(*free)(void*));
int sqlite3_bind_text16(sqlite3_stmt*,int,const void*utf16,int,void(*free)(void*));
int sqlite3_bind_parameter_count(sqlite3_stmt*);
const char *sqlite3_bind_parameter_name(sqlite3_stmt*,int);
int sqlite3_bind_parameter_index(sqlite3_stmt*,const char*);
int sqlite3_column_count(sqlite3_stmt*);
const char *sqlite3_column_name(sqlite3_stmt*,int);
const void *sqlite3_column_name16(sqlite3_stmt*,int);
const char *sqlite3_column_decltype(sqlite3_stmt*,int);
const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
int sqlite3_step(sqlite3_stmt*);
int sqlite3_data_count(sqlite3_stmt*);
const RUBY_BLOB *sqlite3_column_blob(sqlite3_stmt*,int);
int sqlite3_column_bytes(sqlite3_stmt*,int);
int sqlite3_column_bytes16(sqlite3_stmt*,int);
double sqlite3_column_double(sqlite3_stmt*,int);
double sqlite3_column_int(sqlite3_stmt*,int);
sqlite_int64 sqlite3_column_int64(sqlite3_stmt*,int);
const char *sqlite3_column_text(sqlite3_stmt*,int);
const void *sqlite3_column_text16(sqlite3_stmt*,int);
int sqlite3_column_type(sqlite3_stmt*,int);
int sqlite3_finalize(sqlite3_stmt*);
int sqlite3_reset(sqlite3_stmt*);
int sqlite3_create_function(sqlite3*,const char*str,int,int,void*,void(*func)(sqlite3_context*,int,sqlite3_value**),void(*step)(sqlite3_context*,int,sqlite3_value**),void(*final)(sqlite3_context*));
int sqlite3_create_function16(sqlite3*,const void*str,int,int,void*,void(*func)(sqlite3_context*,int,sqlite3_value**),void(*step)(sqlite3_context*,int,sqlite3_value**),void(*final)(sqlite3_context*));
int sqlite3_aggregate_count(sqlite3_context*);
const RUBY_VALBLOB *sqlite3_value_blob(sqlite3_value*);
int sqlite3_value_bytes(sqlite3_value*);
int sqlite3_value_bytes16(sqlite3_value*);
double sqlite3_value_double(sqlite3_value*);
int sqlite3_value_int(sqlite3_value*);
sqlite_int64 sqlite3_value_int64(sqlite3_value*);
const char *sqlite3_value_text(sqlite3_value*);
const void *sqlite3_value_text16(sqlite3_value*);
const void *sqlite3_value_text16le(sqlite3_value*);
const void *sqlite3_value_text16be(sqlite3_value*);
int sqlite3_value_type(sqlite3_value*);
void sqlite3_result_blob(sqlite3_context*,const void *blob,int,void(*free)(void*));
void sqlite3_result_double(sqlite3_context*,double);
void sqlite3_result_error(sqlite3_context*,const char *text,int);
void sqlite3_result_error16(sqlite3_context*,const void *blob,int);
void sqlite3_result_int(sqlite3_context*,int);
void sqlite3_result_int64(sqlite3_context*,sqlite_int64);
void sqlite3_result_text(sqlite3_context*,const char* text,int,void(*free)(void*));
void sqlite3_result_text16(sqlite3_context*,const void* utf16,int,void(*free)(void*));
void sqlite3_result_text16le(sqlite3_context*,const void* utf16,int,void(*free)(void*));
void sqlite3_result_text16be(sqlite3_context*,const void* utf16,int,void(*free)(void*));
void sqlite3_result_value(sqlite3_context*,sqlite3_value*);
VALUE *sqlite3_aggregate_context(sqlite3_context*,int data_size);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
REM This is not guaranteed to work, ever. It's just a little helper
REM script that I threw together to help me build the win32 version of
REM the library. If someone with more win32-fu than I wants to make
REM something more robust, please feel free! I'd love to include it.
REM -- Jamis Buck
cl /LD /Ie:\WinSDK\Include /Ic:\ruby\lib\ruby\1.8\i386-mswin32 /Ic:\ruby\sqlite3 /Ic:\ruby\src\ruby-1.8.4_2006-04-14 sqlite3_api_wrap.c /link /LIBPATH:c:\ruby\sqlite3 /LIBPATH:e:\WinSDK\Lib /LIBPATH:c:\ruby\lib sqlite3.lib msvcrt-ruby18.lib

View file

@ -0,0 +1 @@
require 'sqlite3/database'

View file

@ -1,35 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
module SQLite3 ; module Constants module SQLite3 ; module Constants
module TextRep module TextRep

View file

@ -1,36 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'base64'
require 'sqlite3/constants' require 'sqlite3/constants'
require 'sqlite3/errors' require 'sqlite3/errors'
require 'sqlite3/pragmas' require 'sqlite3/pragmas'
@ -180,6 +147,9 @@ module SQLite3
# Returns a Statement object representing the given SQL. This does not # Returns a Statement object representing the given SQL. This does not
# execute the statement; it merely prepares the statement for execution. # execute the statement; it merely prepares the statement for execution.
#
# The Statement can then be executed using Statement#execute.
#
def prepare( sql ) def prepare( sql )
stmt = @statement_factory.new( self, sql ) stmt = @statement_factory.new( self, sql )
if block_given? if block_given?
@ -335,19 +305,19 @@ module SQLite3
# The handler will be invoked with the name of the resource that was # The handler will be invoked with the name of the resource that was
# busy, and the number of times it has been retried. # busy, and the number of times it has been retried.
# #
# See also #busy_timeout. # See also the mutually exclusive #busy_timeout.
def busy_handler( data=nil, &block ) # :yields: data, retries def busy_handler( data=nil, &block ) # :yields: data, retries
result = @driver.busy_handler( @handle, data, &block ) result = @driver.busy_handler( @handle, data, &block )
Error.check( result, self ) Error.check( result, self )
end end
# Indicates that if a request for a resource terminates because that # Indicates that if a request for a resource terminates because that
# resource is busy, SQLite should wait for the indicated number of # resource is busy, SQLite should sleep and retry for up to the indicated
# milliseconds before trying again. By default, SQLite does not retry # number of milliseconds. By default, SQLite does not retry
# busy resources. To restore the default behavior, send 0 as the # busy resources. To restore the default behavior, send 0 as the
# +ms+ parameter. # +ms+ parameter.
# #
# See also #busy_handler. # See also the mutually exclusive #busy_handler.
def busy_timeout( ms ) def busy_timeout( ms )
result = @driver.busy_timeout( @handle, ms ) result = @driver.busy_timeout( @handle, ms )
Error.check( result, self ) Error.check( result, self )

View file

@ -1,35 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'dl/import' require 'dl/import'
module SQLite3 ; module Driver; module DL; module SQLite3 ; module Driver; module DL;

View file

@ -1,35 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3/driver/dl/api' require 'sqlite3/driver/dl/api'
warn "The DL driver for sqlite3-ruby is deprecated and will be removed" warn "The DL driver for sqlite3-ruby is deprecated and will be removed"
@ -263,6 +231,7 @@ module SQLite3 ; module Driver ; module DL
api_delegate :aggregate_count api_delegate :aggregate_count
api_delegate :bind_double api_delegate :bind_double
api_delegate :bind_int api_delegate :bind_int
api_delegate :bind_int64
api_delegate :bind_null api_delegate :bind_null
api_delegate :bind_parameter_index api_delegate :bind_parameter_index
api_delegate :bind_parameter_name api_delegate :bind_parameter_name

View file

@ -1,35 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3_api' require 'sqlite3_api'
module SQLite3 ; module Driver ; module Native module SQLite3 ; module Driver ; module Native
@ -191,7 +159,7 @@ module SQLite3 ; module Driver ; module Native
end end
def self.api_delegate( name ) def self.api_delegate( name )
define_method( name ) { |*args| API.send( "sqlite3_#{name}", *args ) } eval "def #{name} (*args) API.sqlite3_#{name}( *args ) ; end"
end end
api_delegate :libversion api_delegate :libversion

View file

@ -1,40 +1,8 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3/constants' require 'sqlite3/constants'
module SQLite3 module SQLite3
class Exception < ::Exception class Exception < ::StandardError
@code = 0 @code = 0
# The numeric error code that this exception represents. # The numeric error code that this exception represents.

View file

@ -1,35 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3/errors' require 'sqlite3/errors'
module SQLite3 module SQLite3
@ -54,8 +22,8 @@ module SQLite3
case mode case mode
when String when String
case mode.downcase case mode.downcase
when "on", "yes", "true", "y", "t" then mode = "'ON'" when "on", "yes", "true", "y", "t"; mode = "'ON'"
when "off", "no", "false", "n", "f" then mode = "'OFF'" when "off", "no", "false", "n", "f"; mode = "'OFF'"
else else
raise Exception, raise Exception,
"unrecognized pragma parameter #{mode.inspect}" "unrecognized pragma parameter #{mode.inspect}"
@ -290,10 +258,12 @@ module SQLite3
# unquotes those values. # unquotes those values.
def tweak_default(hash) def tweak_default(hash)
case hash["dflt_value"] case hash["dflt_value"]
when /^null$/i then when /^null$/i
hash["dflt_value"] = nil hash["dflt_value"] = nil
when /^'(.*)'$/ when /^'(.*)'$/
hash["dflt_value"] = $1.gsub(/''/, "'") hash["dflt_value"] = $1.gsub(/''/, "'")
when /^"(.*)"$/
hash["dflt_value"] = $1.gsub(/""/, '"')
end end
end end
end end

View file

@ -1,35 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3/constants' require 'sqlite3/constants'
require 'sqlite3/errors' require 'sqlite3/errors'
@ -42,16 +10,25 @@ module SQLite3
class ResultSet class ResultSet
include Enumerable include Enumerable
# A trivial module for adding a +types+ accessor to an object. # The class of which we return an object in case we want an Array as
module TypesContainer # result. (ArrayFields is installed.)
class ArrayWithTypes < Array
attr_accessor :types attr_accessor :types
end end
# A trivial module for adding a +fields+ accessor to an object. # The class of which we return an object in case we want an Array as
module FieldsContainer # result. (ArrayFields is not installed.)
class ArrayWithTypesAndFields < Array
attr_accessor :types
attr_accessor :fields attr_accessor :fields
end end
# The class of which we return an object in case we want a Hash as
# result.
class HashWithTypes < Hash
attr_accessor :types
end
# Create a new ResultSet attached to the given database, using the # Create a new ResultSet attached to the given database, using the
# given sql text. # given sql text.
def initialize( db, stmt ) def initialize( db, stmt )
@ -65,6 +42,9 @@ module SQLite3
# to the first row of the result set. # to the first row of the result set.
def commence def commence
result = @driver.step( @stmt.handle ) result = @driver.step( @stmt.handle )
if result == Constants::ErrorCode::ERROR
@driver.reset( @stmt.handle )
end
check result check result
@first_row = true @first_row = true
end end
@ -121,10 +101,13 @@ module SQLite3
unless @eof unless @eof
row = [] row = []
@driver.data_count( @stmt.handle ).times do |column| @driver.data_count( @stmt.handle ).times do |column|
case @driver.column_type( @stmt.handle, column ) type = @driver.column_type( @stmt.handle, column )
when Constants::ColumnType::NULL then
if type == Constants::ColumnType::TEXT
row << @driver.column_text( @stmt.handle, column )
elsif type == Constants::ColumnType::NULL
row << nil row << nil
when Constants::ColumnType::BLOB then elsif type == Constants::ColumnType::BLOB
row << @driver.column_blob( @stmt.handle, column ) row << @driver.column_blob( @stmt.handle, column )
else else
row << @driver.column_text( @stmt.handle, column ) row << @driver.column_text( @stmt.handle, column )
@ -138,15 +121,18 @@ module SQLite3
end end
if @db.results_as_hash if @db.results_as_hash
new_row = Hash[ *( @stmt.columns.zip( row ).flatten ) ] new_row = HashWithTypes[ *( @stmt.columns.zip( row ).to_a.flatten ) ]
row.each_with_index { |value,idx| new_row[idx] = value } row.each_with_index { |value,idx| new_row[idx] = value }
row = new_row row = new_row
else else
row.extend FieldsContainer unless row.respond_to?(:fields) if row.respond_to?(:fields)
row = ArrayWithTypes.new(row)
else
row = ArrayWithTypesAndFields.new(row)
end
row.fields = @stmt.columns row.fields = @stmt.columns
end end
row.extend TypesContainer
row.types = @stmt.types row.types = @stmt.types
return row return row

View file

@ -1,35 +1,3 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3/errors' require 'sqlite3/errors'
require 'sqlite3/resultset' require 'sqlite3/resultset'
@ -122,7 +90,11 @@ module SQLite3
when Bignum then when Bignum then
@driver.bind_int64( @handle, param, value ) @driver.bind_int64( @handle, param, value )
when Integer then when Integer then
if value >= (2 ** 31)
@driver.bind_int64( @handle, param, value )
else
@driver.bind_int( @handle, param, value ) @driver.bind_int( @handle, param, value )
end
when Numeric then when Numeric then
@driver.bind_double( @handle, param, value.to_f ) @driver.bind_double( @handle, param, value.to_f )
when Blob then when Blob then

View file

@ -1,36 +1,5 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'time' require 'time'
require 'date'
module SQLite3 module SQLite3
@ -48,6 +17,7 @@ module SQLite3
# translators for most SQL data types. # translators for most SQL data types.
def initialize def initialize
@translators = Hash.new( proc { |type,value| value } ) @translators = Hash.new( proc { |type,value| value } )
@type_name_cache = {}
register_default_translators register_default_translators
end end
@ -81,18 +51,22 @@ module SQLite3
# A convenience method for working with type names. This returns the "base" # A convenience method for working with type names. This returns the "base"
# type name, without any parenthetical data. # type name, without any parenthetical data.
def type_name( type ) def type_name( type )
return "" if type.nil? @type_name_cache[type] ||= begin
type = "" if type.nil?
type = $1 if type =~ /^(.*?)\(/ type = $1 if type =~ /^(.*?)\(/
type.upcase type.upcase
end end
end
private :type_name private :type_name
# Register the default translators for the current Translator instance. # Register the default translators for the current Translator instance.
# This includes translators for most major SQL data types. # This includes translators for most major SQL data types.
def register_default_translators def register_default_translators
[ "date", [ "time",
"datetime", "timestamp" ].each { |type| add_translator( type ) { |t, v| Time.parse( v ) } }
"time" ].each { |type| add_translator( type ) { |t,v| Time.parse( v ) } }
add_translator( "date" ) { |t,v| Date.parse(v) }
add_translator( "datetime" ) { |t,v| DateTime.parse(v) }
[ "decimal", [ "decimal",
"float", "float",
@ -120,7 +94,6 @@ module SQLite3
end end
end end
add_translator( "timestamp" ) { |type, value| Time.at( value.to_i ) }
add_translator( "tinyint" ) do |type, value| add_translator( "tinyint" ) do |type, value|
if type =~ /\(\s*1\s*\)/ if type =~ /\(\s*1\s*\)/
value.to_i == 1 value.to_i == 1

View file

@ -0,0 +1,57 @@
require 'sqlite3/constants'
module SQLite3
class Value
attr_reader :handle
def initialize( db, handle )
@driver = db.driver
@handle = handle
end
def null?
type == :null
end
def to_blob
@driver.value_blob( @handle )
end
def length( utf16=false )
if utf16
@driver.value_bytes16( @handle )
else
@driver.value_bytes( @handle )
end
end
def to_f
@driver.value_double( @handle )
end
def to_i
@driver.value_int( @handle )
end
def to_int64
@driver.value_int64( @handle )
end
def to_s( utf16=false )
@driver.value_text( @handle, utf16 )
end
def type
case @driver.value_type( @handle )
when Constants::ColumnType::INTEGER then :int
when Constants::ColumnType::FLOAT then :float
when Constants::ColumnType::TEXT then :text
when Constants::ColumnType::BLOB then :blob
when Constants::ColumnType::NULL then :null
end
end
end
end

View file

@ -0,0 +1,14 @@
module SQLite3
module Version
MAJOR = 1
MINOR = 2
TINY = 4
STRING = [ MAJOR, MINOR, TINY ].join( "." )
#:beta-tag:
end
end

1333
vendor/plugins/sqlite3-ruby/setup.rb vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,33 +0,0 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3/database'

View file

@ -1,89 +0,0 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
require 'sqlite3/constants'
module SQLite3
class Value
attr_reader :handle
def initialize( db, handle )
@driver = db.driver
@handle = handle
end
def null?
type == :null
end
def to_blob
@driver.value_blob( @handle )
end
def length( utf16=false )
if utf16
@driver.value_bytes16( @handle )
else
@driver.value_bytes( @handle )
end
end
def to_f
@driver.value_double( @handle )
end
def to_i
@driver.value_int( @handle )
end
def to_int64
@driver.value_int64( @handle )
end
def to_s( utf16=false )
@driver.value_text( @handle, utf16 )
end
def type
case @driver.value_type( @handle )
when Constants::ColumnType::INTEGER then :int
when Constants::ColumnType::FLOAT then :float
when Constants::ColumnType::TEXT then :text
when Constants::ColumnType::BLOB then :blob
when Constants::ColumnType::NULL then :null
end
end
end
end

View file

@ -1,46 +0,0 @@
#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * The names of its contributors may not be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =============================================================================
#++
module SQLite3
module Version
MAJOR = 1
MINOR = 2
TINY = 1
STRING = [ MAJOR, MINOR, TINY ].join( "." )
#:beta-tag:
end
end

140
vendor/plugins/sqlite3-ruby/test/bm.rb vendored Normal file
View file

@ -0,0 +1,140 @@
require 'benchmark'
N = 1000
$VERBOSE=nil
puts "file require"
Benchmark.bm( 7 ) do |x|
x.report('sqlite') do
N.times do
$".delete_if { |i| i =~ /sqlite/ }
require 'sqlite'
end
end
x.report('sqlite3') do
N.times do
$".delete_if { |i| i =~ /sqlite3/ }
require 'sqlite3'
end
end
end
puts
puts "database creation..."
Benchmark.bm( 7 ) do |x|
x.report('sqlite') do
N.times do
File.delete "test.db" rescue nil
SQLite::Database.open( "test.db" ).close
end
end
x.report('sqlite3') do
N.times do
File.delete "test.db" rescue nil
SQLite3::Database.open( "test.db" ).close
end
end
end
File.delete "test.db" rescue nil
SQLite::Database.open( "test.db" ).close
SQLite3::Database.open( "test3.db" ).close
puts
puts "database open..."
Benchmark.bm( 7 ) do |x|
x.report('sqlite') do
N.times do
SQLite::Database.open( "test.db" ).close
end
end
x.report('sqlite3') do
N.times do
SQLite3::Database.open( "test3.db" ).close
end
end
end
File.delete "test.db" rescue nil
File.delete "test3.db" rescue nil
db = SQLite::Database.open( "test.db" )
db3 = SQLite3::Database.open( "test3.db" )
db.execute "create table foo (a,b)"
db3.execute "create table foo (a,b)"
puts
puts "insertions"
Benchmark.bm( 7 ) do |x|
x.report('sqlite') do
db.transaction do
N.times do |i|
db.execute "insert into foo values (#{i}, #{i+1})"
end
end
end
x.report('sqlite3') do
db3.transaction do
N.times do |i|
db3.execute "insert into foo values (#{i}, #{i+1})"
end
end
end
end
puts
puts "insertions using prepared statement"
Benchmark.bm( 7 ) do |x|
x.report('sqlite') do
db.transaction do
stmt = db.prepare "insert into foo values (?,?)"
N.times { |i| stmt.execute i, i+1 }
end
end
x.report('sqlite3') do
db3.transaction do
db3.prepare( "insert into foo values (?,?)" ) do |stmt|
N.times { |i| stmt.execute i, i+1 }
end
end
end
end
db.close
db3.close
File.delete "test.db" rescue nil
File.delete "test3.db" rescue nil
db = SQLite::Database.open( "test.db" )
db3 = SQLite3::Database.open( "test3.db" )
db.execute "create table foo (a,b)"
db.execute "insert into foo values (1,2)"
db.execute "insert into foo values (3,4)"
db.execute "insert into foo values (5,6)"
db3.execute "create table foo (a,b)"
db3.execute "insert into foo values (1,2)"
db3.execute "insert into foo values (3,4)"
db3.execute "insert into foo values (5,6)"
puts
puts "queries"
Benchmark.bm( 7 ) do |x|
x.report('sqlite') do
N.times do
db.execute "select * from foo"
end
end
x.report('sqlite3') do
N.times do
db3.execute "select * from foo"
end
end
end
db.close
db3.close
File.delete "test.db" rescue nil
File.delete "test3.db" rescue nil

View file

@ -0,0 +1,292 @@
if (ENV["SQLITE3_DRIVERS"] || "Native").split(/,/).include?("DL")
$:.unshift "../../../lib"
require 'sqlite3/constants'
require 'sqlite3/driver/dl/driver'
require 'test/unit'
class TC_DL_Driver < Test::Unit::TestCase
def utf16ify( str )
chars = str.split(//)
chars.zip(["\0"] * chars.length).flatten.join
end
def setup
@driver = SQLite3::Driver::DL::Driver.new
@dbname = "test.db"
@db = nil
end
def teardown
@driver.close( @db ) rescue nil
File.delete @dbname rescue nil
end
def test_open
result, @db = @driver.open( @dbname )
assert_equal SQLite3::Constants::ErrorCode::OK, result
assert File.exist?( @dbname )
end
def test_open_utf16
name = utf16ify( @dbname )
result, @db = @driver.open( name, true )
assert_equal SQLite3::Constants::ErrorCode::OK, result
assert File.exist?( @dbname )
end
def test_errmsg
result, @db = @driver.open( @dbname )
msg = @driver.errmsg( @db )
assert_equal msg, "not an error"
end
def test_errmsg16
result, @db = @driver.open( @dbname )
msg = @driver.errmsg( @db, true )
assert_equal msg, utf16ify( "not an error" )
end
def test_prepare
result, @db = @driver.open( @dbname )
sql = "create table foo ( a, b )"
result, handle, remainder = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
assert_equal "", remainder
@driver.finalize( handle )
end
def test_prepare_error
result, @db = @driver.open( @dbname )
sql = "create tble foo ( a, b )"
result, handle, remainder = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::ERROR, result
end
def test_prepare_remainder
result, @db = @driver.open( @dbname )
sql = "create table foo ( a, b ); select * from foo"
result, handle, remainder = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
assert_equal " select * from foo", remainder
@driver.finalize( handle )
end
def test_prepare16
result, @db = @driver.open( @dbname )
sql = utf16ify( "create table foo ( a, b )" )
result, handle, remainder = @driver.prepare( @db, sql, true )
assert_equal SQLite3::Constants::ErrorCode::OK, result
assert_equal "", remainder
@driver.finalize( handle )
end
def test_prepare16_remainder
result, @db = @driver.open( @dbname )
sql = utf16ify( "create table foo ( a, b ); select * from foo" )
result, handle, remainder = @driver.prepare( @db, sql, true )
assert_equal SQLite3::Constants::ErrorCode::OK, result
assert_equal utf16ify( " select * from foo" ), remainder
@driver.finalize( handle )
end
def test_complete
assert @driver.complete?( "select * from foo;" )
end
def test_complete_fail
assert !@driver.complete?( "select * from foo" )
end
def test_complete16
assert @driver.complete?( utf16ify("select * from foo;"), true )
end
def create_foo
result, @db = @driver.open( @dbname )
sql = "create table foo ( a, b )"
result, handle, = @driver.prepare( @db, sql )
@driver.step( handle )
@driver.finalize( handle )
end
def populate_foo
create_foo
sql = "insert into foo values ( 100, 200 )"
result, handle, = @driver.prepare( @db, sql )
@driver.step( handle )
@driver.finalize( handle )
end
def test_step
populate_foo
sql = "select * from foo"
result, handle, = @driver.prepare( @db, sql )
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::ROW, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::DONE, result
@driver.finalize( handle )
end
def test_step_fail
populate_foo
sql = "select * from"
result, handle, = @driver.prepare( @db, sql )
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::MISUSE, result
@driver.finalize( handle )
end
def test_bind_blob
create_foo
sql = "insert into foo (b) values (?)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.bind_blob( handle, 1, "a\0b\1c\2d\0e" )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::DONE, result
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
sql = "select b from foo"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::ROW, result
assert_equal "a\0b\1c\2d\0e", @driver.column_blob( handle, 0 )
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
end
def test_bind_double
create_foo
sql = "insert into foo (b) values (?)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.bind_double( handle, 1, 3.14 )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::DONE, result
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
sql = "select b from foo"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::ROW, result
assert_equal 3.14, @driver.column_double( handle, 0 )
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
end
def test_bind_int
create_foo
sql = "insert into foo (b) values (?)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.bind_int( handle, 1, 14 )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::DONE, result
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
sql = "select b from foo"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::ROW, result
assert_equal 14, @driver.column_int( handle, 0 )
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
end
def test_bind_null
create_foo
sql = "insert into foo (b) values (?)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.bind_null( handle, 1 )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::DONE, result
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
sql = "select b from foo"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::ROW, result
assert_equal SQLite3::Constants::ColumnType::NULL,
@driver.column_type( handle, 0 )
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
end
def test_bind_text
create_foo
sql = "insert into foo (b) values (?)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.bind_text( handle, 1, "hello, world" )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::DONE, result
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
sql = "select b from foo"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::ROW, result
assert_equal "hello, world", @driver.column_text( handle, 0 )
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
end
def test_bind_text16
create_foo
sql = "insert into foo (b) values (?)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.bind_text( handle, 1, utf16ify("hello, world"), true )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::DONE, result
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
sql = "select b from foo"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.step( handle )
assert_equal SQLite3::Constants::ErrorCode::ROW, result
assert_equal "hello, world", @driver.column_text( handle, 0 )
result = @driver.finalize( handle )
assert_equal SQLite3::Constants::ErrorCode::OK, result
end
def test_bind_parameter_index
create_foo
sql = "insert into foo (b) values (:hello)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
result = @driver.bind_parameter_index( handle, ":hello" )
assert_equal 1, result
result = @driver.bind_parameter_index( handle, ":foo" )
assert_equal 0, result
@driver.finalize( handle )
end
def test_bind_parameter_name
create_foo
sql = "insert into foo (a,b) values (?,:foo)"
result, handle, = @driver.prepare( @db, sql )
assert_equal SQLite3::Constants::ErrorCode::OK, result
assert_nil nil, @driver.bind_parameter_name(handle,1)
assert_equal ":foo", @driver.bind_parameter_name(handle,2)
@driver.finalize( handle )
end
end
end

View file

@ -0,0 +1,45 @@
require 'rubygems'
gem 'mocha'
require 'mocha'
class Driver < Mocha::Mock
def initialize
super
stubs( :open ).returns([0, 'cookie'])
stubs( :close ).returns(0)
stubs( :complete? ).returns(0)
stubs( :errmsg ).returns('')
stubs( :errcode ).returns(0)
stubs( :trace ).returns(nil)
stubs( :set_authorizer ).returns(0)
stubs( :prepare ).returns([0, 'stmt', 'remainder'])
stubs( :finalize ).returns(0)
stubs( :changes ).returns(14)
stubs( :total_changes ).returns(28)
stubs( :interrupt ).returns(0)
end
end
class MockResultSet < Mocha::Mock
def initialize
super
stubs( :each ).yields(['foo'])
stubs( :columns ).returns(['name'])
end
end
class Statement < Mocha::Mock
attr_reader :handle
attr_reader :sql
attr_reader :last_result
def initialize( handle, sql )
super()
@handle = handle
@sql = sql
stubs( :close ).returns(0)
stubs( :remainder ).returns('')
stubs( :execute ).returns(MockResultSet.new)
end
end

View file

@ -0,0 +1,126 @@
$:.unshift "../lib", "../ext/sqlite3_api"
require 'sqlite3'
require 'benchmark'
N = 1000
$VERBOSE=nil
puts "database creation..."
Benchmark.bm( 7 ) do |x|
x.report('dl') do
N.times do
File.delete "test.db" rescue nil
SQLite3::Database.open( "test.db", :driver => "DL" ).close
end
end
x.report('native') do
N.times do
File.delete "test.db" rescue nil
SQLite3::Database.open( "test.db", :driver => "Native" ).close
end
end
end
File.delete "test.db" rescue nil
SQLite3::Database.open( "test.db" ).close
puts
puts "database open..."
Benchmark.bm( 7 ) do |x|
x.report('dl') do
N.times do
SQLite3::Database.open( "test.db", :driver => "DL" ).close
end
end
x.report('native') do
N.times do
SQLite3::Database.open( "test.db", :driver => "Native" ).close
end
end
end
File.delete "test.db" rescue nil
dl = SQLite3::Database.open( "test-dl.db", :driver => "DL" )
native = SQLite3::Database.open( "test-native.db", :driver => "Native" )
dl.execute "create table foo (a,b)"
native.execute "create table foo (a,b)"
puts
puts "insertions"
Benchmark.bm( 7 ) do |x|
x.report('dl') do
dl.transaction do
N.times do |i|
dl.execute "insert into foo values (#{i}, #{i+1})"
end
end
end
x.report('native') do
native.transaction do
N.times do |i|
native.execute "insert into foo values (#{i}, #{i+1})"
end
end
end
end
puts
puts "insertions using prepared statement"
Benchmark.bm( 7 ) do |x|
x.report('dl') do
dl.transaction do
dl.prepare "insert into foo values (?,?)" do |stmt|
N.times { |i| stmt.execute i, i+1 }
end
end
end
x.report('native') do
native.transaction do
native.prepare( "insert into foo values (?,?)" ) do |stmt|
N.times { |i| stmt.execute i, i+1 }
end
end
end
end
dl.close
native.close
File.delete "test-dl.db" rescue nil
File.delete "test-native.db" rescue nil
dl = SQLite3::Database.open( "test-dl.db", :driver => "DL" )
native = SQLite3::Database.open( "test-native.db", :driver => "Native" )
dl.execute "create table foo (a,b)"
dl.execute "insert into foo values (1,2)"
dl.execute "insert into foo values (3,4)"
dl.execute "insert into foo values (5,6)"
native.execute "create table foo (a,b)"
native.execute "insert into foo values (1,2)"
native.execute "insert into foo values (3,4)"
native.execute "insert into foo values (5,6)"
puts
puts "queries"
Benchmark.bm( 7 ) do |x|
x.report('dl') do
N.times do
dl.execute "select * from foo"
end
end
x.report('native') do
N.times do
native.execute "select * from foo"
end
end
end
dl.close
native.close
File.delete "test-dl.db" rescue nil
File.delete "test-native.db" rescue nil

View file

@ -0,0 +1,198 @@
$:.unshift "../lib"
require 'sqlite3/database'
require 'test/unit'
require 'mocks'
class TC_Database_Init < Test::Unit::TestCase
def test_new
# any_instance fails here...
driver = Driver.new
driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie'])
Driver.stubs(:new).returns(driver)
db = SQLite3::Database.new( 'foo.db', :driver => Driver )
assert !db.closed?
assert !db.results_as_hash
assert !db.type_translation
end
def test_open
driver = Driver.new
driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie'])
Driver.stubs(:new).returns(driver)
db = SQLite3::Database.open( "foo.db", :driver => Driver )
assert !db.closed?
assert !db.results_as_hash
assert !db.type_translation
end
def test_with_type_translation
db = SQLite3::Database.open( "foo.db", :driver => Driver,
:type_translation => true )
assert db.type_translation
end
def test_with_results_as_hash
db = SQLite3::Database.open( "foo.db", :driver => Driver,
:results_as_hash => true )
assert db.results_as_hash
end
def test_with_type_translation_and_results_as_hash
db = SQLite3::Database.open( "foo.db", :driver => Driver,
:results_as_hash => true,
:type_translation => true )
assert db.results_as_hash
assert db.type_translation
end
end
class TC_Database < Test::Unit::TestCase
def setup
@db = SQLite3::Database.open( "foo.db",
:driver => Driver, :statement_factory => Statement )
end
def test_quote
assert_equal "''one''two''three''", SQLite3::Database.quote(
"'one'two'three'" )
end
def test_complete
Driver.any_instance.expects(:complete?)
@db.complete? "foo"
end
def test_errmsg
Driver.any_instance.expects(:errmsg)
@db.errmsg
end
def test_errcode
Driver.any_instance.expects(:errcode)
@db.errcode
end
def test_translator
translator = @db.translator
assert_instance_of SQLite3::Translator, translator
end
def test_close
Driver.any_instance.expects(:close).returns(0)
@db.close
assert @db.closed?
Driver.any_instance.expects(:close).never
@db.close
end
def test_trace
Driver.any_instance.expects(:trace).with('cookie', 15)
@db.trace( 15 ) { "foo" }
# assert_equal 1, driver.mock_blocks[:trace].length
end
def test_authorizer
Driver.any_instance.expects(:set_authorizer).with('cookie', 15).returns(0)
@db.authorizer( 15 ) { "foo" }
# assert_equal 1, driver.mock_blocks[:set_authorizer].length
end
def test_prepare_no_block
Statement.any_instance.expects(:close).never
assert_nothing_raised { @db.prepare( "foo" ) }
end
def test_prepare_with_block
called = false
# any_instance fails here...
statement = Statement.new('cookie', 'foo')
statement.expects(:close).once
Statement.stubs(:new).returns(statement)
@db.prepare( "foo" ) { |stmt| called = true }
assert called
end
def test_execute_no_block
# any_instance fails here...
statement = Statement.new('cookie', 'foo')
statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new)
Statement.stubs(:new).returns(statement)
MockResultSet.any_instance.stubs(:inject).returns([['foo']])
result = @db.execute( "foo", "bar", "baz" )
assert_equal [["foo"]], result
end
def test_execute_with_block
called = false
# any_instance fails here...
statement = Statement.new('cookie', 'foo')
statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new)
Statement.stubs(:new).returns(statement)
@db.execute( "foo", "bar", "baz" ) do |row|
called = true
assert_equal ["foo"], row
end
assert called
end
def test_execute2_no_block
# any_instance fails here...
statement = Statement.new('cookie', 'foo')
statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new)
Statement.stubs(:new).returns(statement)
MockResultSet.any_instance.stubs(:inject).returns([['name'], ['foo']])
result = @db.execute2( "foo", "bar", "baz" )
assert_equal [["name"],["foo"]], result
end
def test_execute2_with_block
called = false
parts = [ ["name"],["foo"] ]
# any_instance fails here...
statement = Statement.new('cookie', 'foo')
statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new)
Statement.stubs(:new).returns(statement)
@db.execute2( "foo", "bar", "baz" ) do |row|
called = true
assert_equal parts.shift, row
end
assert called
end
def test_execute_batch
# any_instance fails here...
statement = Statement.new('cookie', 'foo')
statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new)
Statement.stubs(:new).returns(statement)
@db.execute_batch( "foo", "bar", "baz" )
end
def test_get_first_row
result = @db.get_first_row( "foo", "bar", "baz" )
assert_equal ["foo"], result
end
def test_get_first_value
result = @db.get_first_value( "foo", "bar", "baz" )
assert_equal "foo", result
end
def test_changes
Driver.any_instance.expects(:changes).returns(14)
assert_equal 14, @db.changes
end
def test_total_changes
Driver.any_instance.expects(:total_changes).returns(28)
assert_equal 28, @db.total_changes
end
def test_interrupt
Driver.any_instance.expects(:interrupt)
@db.interrupt
end
end

View file

@ -0,0 +1,21 @@
$:.unshift "../lib"
require 'sqlite3/errors'
require 'test/unit'
require 'mocha'
class TC_Errors < Test::Unit::TestCase
(1..26).each do |code|
define_method( "test_error_code_%02d" % code ) do
db = stub('database', :errmsg => 'message')
begin
SQLite3::Error.check( code, db )
rescue SQLite3::Exception => e
assert_instance_of SQLite3::EXCEPTIONS[code], e
assert_equal code, e.code
assert_equal code, e.class.code
assert_equal "message", e.message
end
end
end
end

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,6 @@
Dir.chdir File.dirname( __FILE__ )
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../ext/sqlite3_api"
p $LOAD_PATH
Dir["**/tc_*.rb"].each { |file| load file }