duckdb 1.0.0.1 → 1.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test_on_macos.yml +15 -3
- data/.github/workflows/test_on_ubuntu.yml +15 -3
- data/.github/workflows/test_on_windows.yml +2 -2
- data/CHANGELOG.md +64 -1
- data/Dockerfile +2 -2
- data/Gemfile.lock +6 -6
- data/README.md +0 -3
- data/benchmark/async_query.rb +0 -2
- data/benchmark/to_intern_ips.rb +0 -1
- data/duckdb.gemspec +1 -1
- data/ext/duckdb/duckdb.c +4 -0
- data/ext/duckdb/extconf.rb +6 -7
- data/ext/duckdb/pending_result.c +7 -0
- data/ext/duckdb/prepared_statement.c +35 -9
- data/ext/duckdb/result.c +246 -411
- data/ext/duckdb/ruby-duckdb.h +6 -0
- data/lib/duckdb/column.rb +2 -38
- data/lib/duckdb/config.rb +47 -49
- data/lib/duckdb/connection.rb +0 -1
- data/lib/duckdb/converter/int_to_sym.rb +127 -0
- data/lib/duckdb/converter.rb +68 -0
- data/lib/duckdb/database.rb +2 -4
- data/lib/duckdb/infinity.rb +8 -0
- data/lib/duckdb/pending_result.rb +16 -5
- data/lib/duckdb/prepared_statement.rb +29 -2
- data/lib/duckdb/result.rb +39 -78
- data/lib/duckdb/version.rb +1 -1
- data/lib/duckdb.rb +1 -0
- data/sample/async_query.rb +0 -1
- data/sample/async_query_stream.rb +0 -1
- metadata +6 -7
- data/benchmark/to_bigdecimal_ips.rb +0 -16
- data/benchmark/to_hugeint_ips.rb +0 -16
- data/benchmark/to_hugeint_profile.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17d405dc19edeb4bbdea3da427974d5a3904fb2f10536fae4494fa284bebd8ff
|
4
|
+
data.tar.gz: 8f26f51c5d14d8854009619916008a8742ebf09f351e5e8f025ccc2fad9ccf13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a15f0763765f35dc5c86cde1425acc6c1e001bec99fd3901aeeeaf74ca94d3af9ad9905be43c8b2a7c0eb3b87a68d20945f25063c8a2e77ba527e54c3c8d49e
|
7
|
+
data.tar.gz: 0061c636c7d80629677b27cab21b173690b8e7aed3f8f8df86783632e92bca9a7349ae80e2e6cb32b04ea356c61c31a9abfdd15da1b05b138f3de186411c5969
|
@@ -15,8 +15,8 @@ jobs:
|
|
15
15
|
runs-on: macos-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
ruby: ['3.
|
19
|
-
duckdb: ['1.0.0', '0.10.3']
|
18
|
+
ruby: ['3.1.6', '3.2.4', '3.3.5', '3.4.0-preview1', 'head']
|
19
|
+
duckdb: ['1.1.0', '1.0.0', '0.10.3']
|
20
20
|
|
21
21
|
steps:
|
22
22
|
- uses: actions/checkout@v4
|
@@ -45,11 +45,23 @@ jobs:
|
|
45
45
|
cp -rip duckdb-tmp-v$DUCKDB_VERSION/build/release/src/*.dylib duckdb-v$DUCKDB_VERSION/build/release/src
|
46
46
|
cp -rip duckdb-tmp-v$DUCKDB_VERSION/src/include duckdb-v$DUCKDB_VERSION/src/
|
47
47
|
|
48
|
-
- name:
|
48
|
+
- name: bundle install with Ruby ${{ matrix.ruby }}
|
49
49
|
env:
|
50
50
|
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
51
51
|
run: |
|
52
52
|
bundle install --jobs 4 --retry 3
|
53
|
+
|
54
|
+
# - name: Build test with DUCKDB_API_NO_DEPRECATED and Ruby ${{ matrix.ruby }}
|
55
|
+
# env:
|
56
|
+
# DUCKDB_VERSION: ${{ matrix.duckdb }}
|
57
|
+
# run: |
|
58
|
+
# env DUCKDB_API_NO_DEPRECATED=1 bundle exec rake build -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
|
59
|
+
# bundle exec rake clean
|
60
|
+
|
61
|
+
- name: Build with Ruby ${{ matrix.ruby }}
|
62
|
+
env:
|
63
|
+
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
64
|
+
run: |
|
53
65
|
bundle exec rake build -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
|
54
66
|
|
55
67
|
- name: test with Ruby ${{ matrix.ruby }}
|
@@ -15,8 +15,8 @@ jobs:
|
|
15
15
|
runs-on: ubuntu-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
ruby: ['3.
|
19
|
-
duckdb: ['1.0.0', '0.10.3']
|
18
|
+
ruby: ['3.1.6', '3.2.4', '3.3.5', '3.4.0-preview1', 'head']
|
19
|
+
duckdb: ['1.1.0', '1.0.0', '0.10.3']
|
20
20
|
|
21
21
|
steps:
|
22
22
|
- uses: actions/checkout@v4
|
@@ -45,11 +45,23 @@ jobs:
|
|
45
45
|
cp -rip duckdb-tmp-v$DUCKDB_VERSION/build/release/src/*.so duckdb-v$DUCKDB_VERSION/build/release/src
|
46
46
|
cp -rip duckdb-tmp-v$DUCKDB_VERSION/src/include duckdb-v$DUCKDB_VERSION/src/
|
47
47
|
|
48
|
-
- name:
|
48
|
+
- name: bundle install with Ruby ${{ matrix.ruby }}
|
49
49
|
env:
|
50
50
|
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
51
51
|
run: |
|
52
52
|
bundle install --jobs 4 --retry 3
|
53
|
+
|
54
|
+
- name: Build test with DUCKDB_API_NO_DEPRECATED and Ruby ${{ matrix.ruby }}
|
55
|
+
env:
|
56
|
+
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
57
|
+
run: |
|
58
|
+
env DUCKDB_API_NO_DEPRECATED=1 bundle exec rake build -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
|
59
|
+
bundle exec rake clean
|
60
|
+
|
61
|
+
- name: Build with Ruby ${{ matrix.ruby }}
|
62
|
+
env:
|
63
|
+
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
64
|
+
run: |
|
53
65
|
bundle exec rake build -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
|
54
66
|
|
55
67
|
- name: test with Ruby ${{ matrix.ruby }}
|
@@ -15,8 +15,8 @@ jobs:
|
|
15
15
|
runs-on: windows-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
ruby: ['3.
|
19
|
-
duckdb: ['1.0.0', '0.10.3']
|
18
|
+
ruby: ['3.1.5', '3.2.4', '3.3.4', 'ucrt', 'mingw', 'mswin', 'head']
|
19
|
+
duckdb: ['1.1.0', '1.0.0', '0.10.3']
|
20
20
|
|
21
21
|
steps:
|
22
22
|
- uses: actions/checkout@v4
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,70 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
|
5
|
+
# 1.1.0.0 - 2024-09-15
|
6
|
+
- drop ruby 3.0.x.
|
7
|
+
- bump duckdb to 1.1.0.
|
8
|
+
- Add `DuckDB::PendingResult#execute_check_state` to check the state of the pending result.
|
9
|
+
- Add `DuckDB::PreparedStatement#clear_bindings` to clear all bindings.
|
10
|
+
- Add `DuckDB::PreparedStatement#param_type` to get the type of the paramerter type.
|
11
|
+
- The return value is one of the `:invalid`, `:boolean`, `:tinyint`, `:smallint`, `:integer`, `:bigint`, `:utinyint`,
|
12
|
+
`:usmallint`, `:uinteger`, `:ubigint`, `:float`, `:double`, `:timestamp`, `:date`, `:time`, `:interval`, `:hugeint`,
|
13
|
+
`:uhugeint`, `:varchar`, `:blob`, `:decimal`, `:timestamp_s`, `:timestamp_ms`, `:timestamp_ns`, `:enum`, `:list`,
|
14
|
+
`:struct`, `:map`, `:array`, `:uuid`, `:union`, `:bit`, `:time_tz`, `:timestamp_tz`.
|
15
|
+
- Add `DuckDB::PreparedStatement#statement_type` to get the type of the statement.
|
16
|
+
- The return value is one of the `:invalid`, `:select`, `:insert`, `:update`, `:explain`, `:delete`, `:prepare`, `:create`,
|
17
|
+
`:execute`, `:alter`, `:transaction`, `:copy`, `:analyze`, `:variable_set`, `:create_func`,
|
18
|
+
`:drop`, `:export`, `:pragma`, `:vacuum`, `:call`, `:set`, `:load`, `:relation`, `:extension`,
|
19
|
+
`:logical_plan`, `:attach`, `:detach`, `:multi`.
|
20
|
+
- Add `DuckDB::Result#statement_type` to get the return type of the statement.
|
21
|
+
- The return value is one of the `:invalid`, `:select`, `:insert`, `:update`, `:explain`, `:delete`, `:prepare`, `:create`,
|
22
|
+
`:execute`, `:alter`, `:transaction`, `:copy`, `:analyze`, `:variable_set`, `:create_func`,
|
23
|
+
`:drop`, `:export`, `:pragma`, `:vacuum`, `:call`, `:set`, `:load`, `:relation`, `:extension`,
|
24
|
+
`:logical_plan`, `:attach`, `:detach`, `:multi`.
|
25
|
+
- Add `DuckDB::Result#return_type` to get the return type of the result.
|
26
|
+
- The return value is one of the `:invalid`, `:query_result`, `:rows_changed`, `:nothing`.
|
27
|
+
- The following method will be deprecated.
|
28
|
+
- `DuckDB::Result#use_chunk_each?`
|
29
|
+
- `DuckDB::Result#use_chunk_each=`
|
30
|
+
|
31
|
+
## Breaking changes
|
32
|
+
- drop duckdb v0.9.x.
|
33
|
+
- skip to check duckdb_parameter_name is available.
|
34
|
+
- The following methods are deprecated.
|
35
|
+
- `DuckDB::Result#_null?`
|
36
|
+
- `DuckDB::Result#_to_boolean`
|
37
|
+
- `DuckDB::Result#_to_smallint`
|
38
|
+
- `DuckDB::Result#_to_utinyint`
|
39
|
+
- `DuckDB::Result#_to_integer`
|
40
|
+
- `DuckDB::Result#_to_bigint`
|
41
|
+
- `DuckDB::Result#_to_hugeint`
|
42
|
+
- `DuckDB::Result#_to_hugeint_internal`
|
43
|
+
- `DuckDB::Result#__to_hugeint_internal`
|
44
|
+
- `DuckDB::Result#_to_decimal`
|
45
|
+
- `DuckDB::Result#_to_decimal_internal`
|
46
|
+
- `DuckDB::Result#__to_decimal_internal`
|
47
|
+
- `DuckDB::Result#_to_float`
|
48
|
+
- `DuckDB::Result#_to_double`
|
49
|
+
- `DuckDB::Result#_to_string`
|
50
|
+
- `DuckDB::Result#_to_string_internal`
|
51
|
+
- `DuckDB::Result#_to_blob`
|
52
|
+
- `DuckDB::Result#to_value`
|
53
|
+
- `DuckDB::Result#row`
|
54
|
+
- `DuckDB::Result#use_chunk_each?` is always true.
|
55
|
+
- `DuckDB::Result#use_chunk_each=` always ignores the argument.
|
56
|
+
- `DuckDB::Result#each` always works the same as `DuckDB::Result#chunk_each`.
|
57
|
+
|
58
|
+
# 1.0.0.2 - 2024-06-23
|
59
|
+
- DuckDB::Result supports TIMESTAMPTZ column type (only when DuckDB::Result.use_chunk_each is true).
|
60
|
+
- Supporting TIMESTAMPTZ is experimental.
|
61
|
+
- DuckDB::Result supports TIMETZ column type (only when DuckDB::Result.use_chunk_each is true).
|
62
|
+
- DuckDB::Result supports TIMESTAMP_NS column type (only when DuckDB::Result.use_chunk_each is true).
|
63
|
+
- DuckDB::Result supports TIMESTAMP_MS column type (only when DuckDB::Result.use_chunk_each is true).
|
64
|
+
- DuckDB::Result supports TIMESTAMP_S column type (only when DuckDB::Result.use_chunk_each is true).
|
65
|
+
- DuckDB::Result supports STRUCT column type (only when DuckDB::Result.use_chunk_each is true).
|
66
|
+
- DuckDB::Result supports MAP column type (only when DuckDB::Result.use_chunk_each is true).
|
67
|
+
- DuckDB::Result supports UNION column type (only when DuckDB::Result.use_chunk_each is true).
|
68
|
+
- DuckDB::Result supports BIT column type (only when DuckDB::Result.use_chunk_each is true).
|
6
69
|
|
7
70
|
# 1.0.0.1 - 2024-06-16
|
8
71
|
- support fetch the value from UHUGEINT type column.
|
data/Dockerfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
duckdb (1.0.0
|
4
|
+
duckdb (1.1.0.0)
|
5
5
|
bigdecimal (>= 3.1.4)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
benchmark-ips (2.
|
10
|
+
benchmark-ips (2.14.0)
|
11
11
|
bigdecimal (3.1.8)
|
12
12
|
mini_portile2 (2.8.7)
|
13
|
-
minitest (5.
|
14
|
-
nokogiri (1.16.
|
13
|
+
minitest (5.25.1)
|
14
|
+
nokogiri (1.16.7)
|
15
15
|
mini_portile2 (~> 2.8.2)
|
16
16
|
racc (~> 1.4)
|
17
|
-
nokogiri (1.16.
|
17
|
+
nokogiri (1.16.7-x86_64-linux)
|
18
18
|
racc (~> 1.4)
|
19
|
-
racc (1.8.
|
19
|
+
racc (1.8.1)
|
20
20
|
rake (13.2.1)
|
21
21
|
rake-compiler (1.2.7)
|
22
22
|
rake
|
data/README.md
CHANGED
@@ -119,9 +119,6 @@ con.query('SELECT * FROM users WHERE name = $name AND email = $email', name: 'Al
|
|
119
119
|
You can use async query.
|
120
120
|
|
121
121
|
```ruby
|
122
|
-
DuckDB::Result.use_chunk_each = true
|
123
|
-
...
|
124
|
-
|
125
122
|
pending_result = con.async_query_stream('SLOW QUERY')
|
126
123
|
pending_result.execute_task while pending_result.state == :not_ready
|
127
124
|
|
data/benchmark/async_query.rb
CHANGED
data/benchmark/to_intern_ips.rb
CHANGED
data/duckdb.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
end
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
spec.extensions = ['ext/duckdb/extconf.rb']
|
29
|
-
spec.required_ruby_version = '>= 3.
|
29
|
+
spec.required_ruby_version = '>= 3.1.0'
|
30
30
|
spec.add_dependency 'bigdecimal', '>= 3.1.4'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler', '~> 2.3'
|
data/ext/duckdb/duckdb.c
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#include "ruby-duckdb.h"
|
2
2
|
|
3
3
|
VALUE mDuckDB;
|
4
|
+
VALUE PositiveInfinity;
|
5
|
+
VALUE NegativeInfinity;
|
4
6
|
|
5
7
|
static VALUE duckdb_s_library_version(VALUE self);
|
6
8
|
|
@@ -19,6 +21,8 @@ static VALUE duckdb_s_library_version(VALUE self) {
|
|
19
21
|
void
|
20
22
|
Init_duckdb_native(void) {
|
21
23
|
mDuckDB = rb_define_module("DuckDB");
|
24
|
+
PositiveInfinity = rb_str_new_literal("infinity");
|
25
|
+
NegativeInfinity = rb_str_new_literal("-infinity");
|
22
26
|
|
23
27
|
rb_define_singleton_method(mDuckDB, "library_version", duckdb_s_library_version, 0);
|
24
28
|
|
data/ext/duckdb/extconf.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'mkmf'
|
4
4
|
|
5
|
-
DUCKDB_REQUIRED_VERSION = '0.
|
5
|
+
DUCKDB_REQUIRED_VERSION = '0.10.0'
|
6
6
|
|
7
7
|
def check_duckdb_header(header, version)
|
8
8
|
found = find_header(
|
@@ -56,10 +56,7 @@ end
|
|
56
56
|
dir_config('duckdb')
|
57
57
|
|
58
58
|
check_duckdb_header('duckdb.h', DUCKDB_REQUIRED_VERSION)
|
59
|
-
check_duckdb_library('duckdb', '
|
60
|
-
|
61
|
-
# check duckdb >= 0.9.0
|
62
|
-
have_func('duckdb_bind_parameter_index', 'duckdb.h')
|
59
|
+
check_duckdb_library('duckdb', 'duckdb_appender_column_count', DUCKDB_REQUIRED_VERSION)
|
63
60
|
|
64
61
|
# check duckdb >= 0.10.0
|
65
62
|
have_func('duckdb_appender_column_count', 'duckdb.h')
|
@@ -67,7 +64,9 @@ have_func('duckdb_appender_column_count', 'duckdb.h')
|
|
67
64
|
# check duckdb >= 1.0.0
|
68
65
|
have_func('duckdb_fetch_chunk', 'duckdb.h')
|
69
66
|
|
70
|
-
#
|
71
|
-
have_func('
|
67
|
+
# check duckdb >= 1.1.0
|
68
|
+
have_func('duckdb_result_error_type', 'duckdb.h')
|
69
|
+
|
70
|
+
$CFLAGS << ' -DDUCKDB_API_NO_DEPRECATED' if ENV['DUCKDB_API_NO_DEPRECATED']
|
72
71
|
|
73
72
|
create_makefile('duckdb/duckdb_native')
|
data/ext/duckdb/pending_result.c
CHANGED
@@ -10,6 +10,7 @@ static VALUE duckdb_pending_result_execute_task(VALUE self);
|
|
10
10
|
static VALUE duckdb_pending_result_execute_pending(VALUE self);
|
11
11
|
static VALUE duckdb_pending_result_execution_finished_p(VALUE self);
|
12
12
|
static VALUE duckdb_pending_result__state(VALUE self);
|
13
|
+
static VALUE duckdb_pending_result__execute_check_state(VALUE self);
|
13
14
|
|
14
15
|
static const rb_data_type_t pending_result_data_type = {
|
15
16
|
"DuckDB/PendingResult",
|
@@ -128,6 +129,11 @@ static VALUE duckdb_pending_result__state(VALUE self) {
|
|
128
129
|
return INT2FIX(ctx->state);
|
129
130
|
}
|
130
131
|
|
132
|
+
static VALUE duckdb_pending_result__execute_check_state(VALUE self) {
|
133
|
+
rubyDuckDBPendingResult *ctx = get_struct_pending_result(self);
|
134
|
+
return INT2FIX(duckdb_pending_execute_check_state(ctx->pending_result));
|
135
|
+
}
|
136
|
+
|
131
137
|
rubyDuckDBPendingResult *get_struct_pending_result(VALUE obj) {
|
132
138
|
rubyDuckDBPendingResult *ctx;
|
133
139
|
TypedData_Get_Struct(obj, rubyDuckDBPendingResult, &pending_result_data_type, ctx);
|
@@ -143,4 +149,5 @@ void rbduckdb_init_duckdb_pending_result(void) {
|
|
143
149
|
rb_define_method(cDuckDBPendingResult, "execute_pending", duckdb_pending_result_execute_pending, 0);
|
144
150
|
rb_define_method(cDuckDBPendingResult, "execution_finished?", duckdb_pending_result_execution_finished_p, 0);
|
145
151
|
rb_define_private_method(cDuckDBPendingResult, "_state", duckdb_pending_result__state, 0);
|
152
|
+
rb_define_private_method(cDuckDBPendingResult, "_execute_check_state", duckdb_pending_result__execute_check_state, 0);
|
146
153
|
}
|
@@ -11,10 +11,8 @@ static VALUE duckdb_prepared_statement_execute(VALUE self);
|
|
11
11
|
static idx_t check_index(VALUE vidx);
|
12
12
|
|
13
13
|
static VALUE duckdb_prepared_statement_bind_parameter_index(VALUE self, VALUE name);
|
14
|
-
#ifdef HAVE_DUCKDB_PARAMETER_NAME
|
15
14
|
static VALUE duckdb_prepared_statement_parameter_name(VALUE self, VALUE vidx);
|
16
|
-
|
17
|
-
|
15
|
+
static VALUE duckdb_prepared_statement_clear_bindings(VALUE self);
|
18
16
|
static VALUE duckdb_prepared_statement_bind_bool(VALUE self, VALUE vidx, VALUE val);
|
19
17
|
static VALUE duckdb_prepared_statement_bind_int8(VALUE self, VALUE vidx, VALUE val);
|
20
18
|
static VALUE duckdb_prepared_statement_bind_int16(VALUE self, VALUE vidx, VALUE val);
|
@@ -25,6 +23,8 @@ static VALUE duckdb_prepared_statement_bind_double(VALUE self, VALUE vidx, VALUE
|
|
25
23
|
static VALUE duckdb_prepared_statement_bind_varchar(VALUE self, VALUE vidx, VALUE str);
|
26
24
|
static VALUE duckdb_prepared_statement_bind_blob(VALUE self, VALUE vidx, VALUE blob);
|
27
25
|
static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx);
|
26
|
+
static VALUE duckdb_prepared_statement__statement_type(VALUE self);
|
27
|
+
static VALUE duckdb_prepared_statement__param_type(VALUE self, VALUE vidx);
|
28
28
|
static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day);
|
29
29
|
static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
30
30
|
static VALUE duckdb_prepared_statement__bind_timestamp(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
@@ -125,7 +125,6 @@ static VALUE duckdb_prepared_statement_bind_parameter_index(VALUE self, VALUE na
|
|
125
125
|
return ULL2NUM(idx);
|
126
126
|
}
|
127
127
|
|
128
|
-
#ifdef HAVE_DUCKDB_PARAMETER_NAME
|
129
128
|
static VALUE duckdb_prepared_statement_parameter_name(VALUE self, VALUE vidx) {
|
130
129
|
rubyDuckDBPreparedStatement *ctx;
|
131
130
|
VALUE vname;
|
@@ -142,7 +141,23 @@ static VALUE duckdb_prepared_statement_parameter_name(VALUE self, VALUE vidx) {
|
|
142
141
|
duckdb_free((void *)name);
|
143
142
|
return vname;
|
144
143
|
}
|
145
|
-
|
144
|
+
|
145
|
+
/*
|
146
|
+
* call-seq:
|
147
|
+
* prepared_statement.clear_bindings -> DuckDB::PreparedStatement
|
148
|
+
*
|
149
|
+
* clear all bindings of prepared statement.
|
150
|
+
*/
|
151
|
+
static VALUE duckdb_prepared_statement_clear_bindings(VALUE self) {
|
152
|
+
rubyDuckDBPreparedStatement *ctx;
|
153
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
154
|
+
|
155
|
+
if (duckdb_clear_bindings(ctx->prepared_statement) == DuckDBError) {
|
156
|
+
const char *error = duckdb_prepare_error(ctx->prepared_statement);
|
157
|
+
rb_raise(eDuckDBError, "fail to clear bindings. %s", error);
|
158
|
+
}
|
159
|
+
return self;
|
160
|
+
}
|
146
161
|
|
147
162
|
static VALUE duckdb_prepared_statement_bind_bool(VALUE self, VALUE vidx, VALUE val) {
|
148
163
|
rubyDuckDBPreparedStatement *ctx;
|
@@ -273,6 +288,18 @@ static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx) {
|
|
273
288
|
return self;
|
274
289
|
}
|
275
290
|
|
291
|
+
static VALUE duckdb_prepared_statement__statement_type(VALUE self) {
|
292
|
+
rubyDuckDBPreparedStatement *ctx;
|
293
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
294
|
+
return INT2FIX(duckdb_prepared_statement_type(ctx->prepared_statement));
|
295
|
+
}
|
296
|
+
|
297
|
+
static VALUE duckdb_prepared_statement__param_type(VALUE self, VALUE vidx) {
|
298
|
+
rubyDuckDBPreparedStatement *ctx;
|
299
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
300
|
+
return INT2FIX(duckdb_param_type(ctx->prepared_statement, NUM2ULL(vidx)));
|
301
|
+
}
|
302
|
+
|
276
303
|
static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day) {
|
277
304
|
rubyDuckDBPreparedStatement *ctx;
|
278
305
|
duckdb_date dt;
|
@@ -366,11 +393,8 @@ void rbduckdb_init_duckdb_prepared_statement(void) {
|
|
366
393
|
rb_define_method(cDuckDBPreparedStatement, "execute", duckdb_prepared_statement_execute, 0);
|
367
394
|
rb_define_method(cDuckDBPreparedStatement, "nparams", duckdb_prepared_statement_nparams, 0);
|
368
395
|
rb_define_method(cDuckDBPreparedStatement, "bind_parameter_index", duckdb_prepared_statement_bind_parameter_index, 1);
|
369
|
-
|
370
|
-
#ifdef HAVE_DUCKDB_PARAMETER_NAME
|
371
396
|
rb_define_method(cDuckDBPreparedStatement, "parameter_name", duckdb_prepared_statement_parameter_name, 1);
|
372
|
-
|
373
|
-
|
397
|
+
rb_define_method(cDuckDBPreparedStatement, "clear_bindings", duckdb_prepared_statement_clear_bindings, 0);
|
374
398
|
rb_define_method(cDuckDBPreparedStatement, "bind_bool", duckdb_prepared_statement_bind_bool, 2);
|
375
399
|
rb_define_method(cDuckDBPreparedStatement, "bind_int8", duckdb_prepared_statement_bind_int8, 2);
|
376
400
|
rb_define_method(cDuckDBPreparedStatement, "bind_int16", duckdb_prepared_statement_bind_int16, 2);
|
@@ -381,6 +405,8 @@ void rbduckdb_init_duckdb_prepared_statement(void) {
|
|
381
405
|
rb_define_method(cDuckDBPreparedStatement, "bind_varchar", duckdb_prepared_statement_bind_varchar, 2);
|
382
406
|
rb_define_method(cDuckDBPreparedStatement, "bind_blob", duckdb_prepared_statement_bind_blob, 2);
|
383
407
|
rb_define_method(cDuckDBPreparedStatement, "bind_null", duckdb_prepared_statement_bind_null, 1);
|
408
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_statement_type", duckdb_prepared_statement__statement_type, 0);
|
409
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_param_type", duckdb_prepared_statement__param_type, 1);
|
384
410
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_date", duckdb_prepared_statement__bind_date, 4);
|
385
411
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_time", duckdb_prepared_statement__bind_time, 5);
|
386
412
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_timestamp", duckdb_prepared_statement__bind_timestamp, 8);
|