Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first naive implementation of virtual table #115

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ext/sqlite3/database.h
ext/sqlite3/exception.c
ext/sqlite3/exception.h
ext/sqlite3/extconf.rb
ext/sqlite3/vtable.c
ext/sqlite3/vtable.h
ext/sqlite3/sqlite3.c
ext/sqlite3/sqlite3_ruby.h
ext/sqlite3/statement.c
Expand All @@ -29,6 +31,7 @@ lib/sqlite3/statement.rb
lib/sqlite3/translator.rb
lib/sqlite3/value.rb
lib/sqlite3/version.rb
lib/sqlite3/vtable.rb
setup.rb
tasks/faq.rake
tasks/gem.rake
Expand All @@ -38,7 +41,9 @@ test/helper.rb
test/test_backup.rb
test/test_collation.rb
test/test_database.rb
test/test_database_flags.rb
test/test_database_readonly.rb
test/test_database_readwrite.rb
test/test_deprecated.rb
test/test_encoding.rb
test/test_integration.rb
Expand All @@ -50,3 +55,4 @@ test/test_result_set.rb
test/test_sqlite3.rb
test/test_statement.rb
test/test_statement_execute.rb
test/test_vtable.rb
4 changes: 2 additions & 2 deletions ext/sqlite3/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static VALUE last_insert_row_id(VALUE self)
return LL2NUM(sqlite3_last_insert_rowid(ctx->db));
}

static VALUE sqlite3val2rb(sqlite3_value * val)
VALUE sqlite3val2rb(sqlite3_value * val)
{
switch(sqlite3_value_type(val)) {
case SQLITE_INTEGER:
Expand Down Expand Up @@ -334,7 +334,7 @@ static VALUE sqlite3val2rb(sqlite3_value * val)
}
}

static void set_sqlite3_func_result(sqlite3_context * ctx, VALUE result)
void set_sqlite3_func_result(sqlite3_context * ctx, VALUE result)
{
switch(TYPE(result)) {
case T_NIL:
Expand Down
6 changes: 6 additions & 0 deletions ext/sqlite3/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

#include <sqlite3_ruby.h>

#define DEBUG_LOG(...) (void)(0)
//#define DEBUG_LOG(...) printf(__VA_ARGS__); fflush(stdout)
// used by vtable.c too
void set_sqlite3_func_result(sqlite3_context * ctx, VALUE result);
VALUE sqlite3val2rb(sqlite3_value * val);

struct _sqlite3Ruby {
sqlite3 *db;
};
Expand Down
1 change: 1 addition & 0 deletions ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void Init_sqlite3_native()
#ifdef HAVE_SQLITE3_BACKUP_INIT
init_sqlite3_backup();
#endif
init_sqlite3_vtable();

rb_define_singleton_method(mSqlite3, "libversion", libversion, 0);
rb_define_singleton_method(mSqlite3, "threadsafe", threadsafe_p, 0);
Expand Down
1 change: 1 addition & 0 deletions ext/sqlite3/sqlite3_ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern VALUE cSqlite3Blob;
#include <statement.h>
#include <exception.h>
#include <backup.h>
#include <vtable.h>

int bignum_to_int64(VALUE big, sqlite3_int64 *result);

Expand Down
6 changes: 4 additions & 2 deletions ext/sqlite3/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ static VALUE step(VALUE self)

REQUIRE_OPEN_STMT(ctx);

if(ctx->done_p) return Qnil;
if(ctx->done_p) {
return Qnil;
}

#ifdef HAVE_RUBY_ENCODING_H
{
Expand All @@ -128,8 +130,8 @@ static VALUE step(VALUE self)
}
#endif


stmt = ctx->st;

value = sqlite3_step(stmt);
length = sqlite3_column_count(stmt);
list = rb_ary_new2((long)length);
Expand Down
Loading