duckdb 0.5.1.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test_on_macos.yml +4 -4
- data/.github/workflows/test_on_ubuntu.yml +4 -4
- data/.github/workflows/test_on_windows.yml +3 -3
- data/CHANGELOG.md +34 -7
- data/Gemfile.lock +3 -3
- data/duckdb.gemspec +1 -1
- data/ext/duckdb/duckdb.c +14 -0
- data/ext/duckdb/extconf.rb +22 -3
- data/ext/duckdb/prepared_statement.c +18 -0
- data/ext/duckdb/result.c +67 -0
- data/ext/duckdb/ruby-duckdb.h +4 -0
- data/lib/duckdb/appender.rb +2 -9
- data/lib/duckdb/converter.rb +13 -0
- data/lib/duckdb/library_version.rb +3 -0
- data/lib/duckdb/prepared_statement.rb +30 -3
- data/lib/duckdb/version.rb +1 -1
- data/lib/duckdb.rb +1 -0
- metadata +8 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d4780513bea94513e38b460cf9580b9bad9b9128d913a46f58f2054451cf838d
|
|
4
|
+
data.tar.gz: 5cbfe5da32da9562d121d634a7a45fdc153222bb4c5b8c79a2f37dbff6f57f27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04acc6297bac9ae7d217072d1fec3b7c603f407270143d654f738462e0f540a2e8ebdb67fa4d466ff13636dab279a0d245241201c9b3f829f4e97fbf628fb086
|
|
7
|
+
data.tar.gz: aa200fce49d05edee27095771e4c7e394a7431b8b1881e58d053f46dafc628920e4924c899159619c2fd337c6607eeed55f5863ea0e119f13ec2236d72c33f6b
|
|
@@ -15,11 +15,11 @@ jobs:
|
|
|
15
15
|
runs-on: macos-latest
|
|
16
16
|
strategy:
|
|
17
17
|
matrix:
|
|
18
|
-
ruby: ['2.
|
|
19
|
-
duckdb: ['0.
|
|
18
|
+
ruby: ['2.7.7', '3.0.5', '3.1.3', '3.2.1', 'head']
|
|
19
|
+
duckdb: ['0.7.0', '0.6.1']
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@v3
|
|
23
23
|
|
|
24
24
|
- name: Set up Ruby
|
|
25
25
|
uses: ruby/setup-ruby@v1
|
|
@@ -28,7 +28,7 @@ jobs:
|
|
|
28
28
|
|
|
29
29
|
- name: duckdb cache
|
|
30
30
|
id: duckdb-cache
|
|
31
|
-
uses: actions/cache@
|
|
31
|
+
uses: actions/cache@v3
|
|
32
32
|
with:
|
|
33
33
|
path: duckdb-v${{ matrix.duckdb }}
|
|
34
34
|
key: ${{ runner.os }}-duckdb-v${{ matrix.duckdb }}
|
|
@@ -15,11 +15,11 @@ jobs:
|
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
16
|
strategy:
|
|
17
17
|
matrix:
|
|
18
|
-
ruby: ['2.
|
|
19
|
-
duckdb: ['0.
|
|
18
|
+
ruby: ['2.7.7', '3.0.5', '3.1.3', '3.2.1', 'head']
|
|
19
|
+
duckdb: ['0.7.0', '0.6.1']
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@v3
|
|
23
23
|
|
|
24
24
|
- name: Set up Ruby
|
|
25
25
|
uses: ruby/setup-ruby@v1
|
|
@@ -28,7 +28,7 @@ jobs:
|
|
|
28
28
|
|
|
29
29
|
- name: duckdb cache
|
|
30
30
|
id: duckdb-cache
|
|
31
|
-
uses: actions/cache@
|
|
31
|
+
uses: actions/cache@v3
|
|
32
32
|
with:
|
|
33
33
|
path: duckdb-v${{ matrix.duckdb }}
|
|
34
34
|
key: ${{ runner.os }}-duckdb-v${{ matrix.duckdb }}
|
|
@@ -15,11 +15,11 @@ jobs:
|
|
|
15
15
|
runs-on: windows-latest
|
|
16
16
|
strategy:
|
|
17
17
|
matrix:
|
|
18
|
-
ruby: ['2.
|
|
19
|
-
duckdb: ['0.
|
|
18
|
+
ruby: ['2.7.7', '3.0.5', '3.1.3', '3.2.1', 'ucrt', 'mingw', 'mswin', 'head']
|
|
19
|
+
duckdb: ['0.7.0', '0.6.1']
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@v3
|
|
23
23
|
|
|
24
24
|
- name: Set up Ruby
|
|
25
25
|
uses: ruby/setup-ruby@v1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
# ChangeLog
|
|
2
2
|
|
|
3
|
+
# 0.7.0
|
|
4
|
+
- bump duckdb to 0.7.0
|
|
5
|
+
- fix have_func argument order
|
|
6
|
+
- remove unused variable in test
|
|
7
|
+
- add DuckDB::LIBRARY_VERSION
|
|
8
|
+
- add DuckDB::Result#_to_string_internal
|
|
9
|
+
- add DuckDB::Result#__to_hugeint_internal
|
|
10
|
+
- add DuckDB::Result#__to_decimal_internal
|
|
11
|
+
- add Ruby 3.2.1 on CI test
|
|
12
|
+
- add Ruby mswin on CI test
|
|
13
|
+
## Breaking Change
|
|
14
|
+
- drop Ruby 2.6
|
|
15
|
+
|
|
16
|
+
# 0.6.1
|
|
17
|
+
- bump Ruby to 3.2.0 on CI
|
|
18
|
+
- fix deprected warning (double_heap is deprecated in GC.verify_compaction_references) with Ruby 3.2.0 on CI
|
|
19
|
+
- bump duckdb to 0.6.1 on CI
|
|
20
|
+
- add DuckDB::PreparedStatement#bind_hugeint_internal
|
|
21
|
+
- fix gem install error on M1 MacOS
|
|
22
|
+
- implement DuckDB.library_version
|
|
23
|
+
- use duckdb_value_string instead of duckdb_value_varchar if duckdb_value_string is available.
|
|
24
|
+
- bump Ruby to 3.2.0rc1
|
|
25
|
+
- bump duckdb to 0.6.0
|
|
26
|
+
|
|
27
|
+
## Breaking Change
|
|
28
|
+
- drop duckdb <= 0.4.x. ruby-duckdb supports duckdb >= 0.5.0
|
|
29
|
+
|
|
3
30
|
# 0.5.1.1
|
|
4
31
|
- bug fix: reading the boolean column
|
|
5
32
|
|
|
6
33
|
# 0.5.1
|
|
7
|
-
- bump duckdb 0.5.1
|
|
34
|
+
- bump duckdb to 0.5.1
|
|
8
35
|
|
|
9
36
|
# 0.5.0
|
|
10
37
|
- update bundle version of Gemfile.lock
|
|
11
38
|
- add ruby ucrt test on Windows
|
|
12
39
|
- use TypedData_Wrap_Struct, TypedData_Get_Struct
|
|
13
|
-
- bump duckdb 0.5.0
|
|
40
|
+
- bump duckdb to 0.5.0
|
|
14
41
|
- fix utf-8 encoding.
|
|
15
42
|
- add DuckDB::Result#enum_dictionary_values
|
|
16
43
|
- add DuckDB::Result#row_count, DuckDB::Result#row_size(alias of row_count).
|
|
@@ -20,19 +47,19 @@
|
|
|
20
47
|
- bind_varchar does not raised DuckDB::Error when the binding column is date or datetime.
|
|
21
48
|
|
|
22
49
|
# 0.3.4.0
|
|
23
|
-
- bump duckdb 0.3.4
|
|
50
|
+
- bump duckdb to 0.3.4
|
|
24
51
|
|
|
25
52
|
# 0.3.3.0
|
|
26
53
|
- DuckDB::Column#type supports :decimal.
|
|
27
|
-
- bump duckdb 0.3.3.
|
|
28
|
-
- bump Ruby 2.6.10, 2.7.6, 3.0.4, 3.1.2.
|
|
54
|
+
- bump duckdb to 0.3.3.
|
|
55
|
+
- bump Ruby to 2.6.10, 2.7.6, 3.0.4, 3.1.2.
|
|
29
56
|
|
|
30
57
|
# 0.3.2.0
|
|
31
58
|
|
|
32
59
|
- bind_time, bind_timestamp, bind_date, bind_timeinterval to DuckDB::PreparedStatement
|
|
33
60
|
- bump duckdb 0.3.2
|
|
34
|
-
- bump Ruby 3.1.1, add Ruby mingw in CI.
|
|
35
|
-
- bump Ruby 2.6.9, 2.7.5, 3.0.3 in CI.
|
|
61
|
+
- bump Ruby to 3.1.1, add Ruby mingw in CI.
|
|
62
|
+
- bump Ruby to 2.6.9, 2.7.5, 3.0.3 in CI.
|
|
36
63
|
|
|
37
64
|
## BREAKING CHANGE
|
|
38
65
|
- drop duckdb <= 0.2.8
|
data/Gemfile.lock
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 = '>= 2.
|
|
29
|
+
spec.required_ruby_version = '>= 2.7.0'
|
|
30
30
|
|
|
31
31
|
spec.add_development_dependency 'bundler', '~> 2.3'
|
|
32
32
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
data/ext/duckdb/duckdb.c
CHANGED
|
@@ -2,10 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
VALUE mDuckDB;
|
|
4
4
|
|
|
5
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
|
6
|
+
static VALUE duckdb_s_library_version(VALUE self);
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
|
10
|
+
static VALUE duckdb_s_library_version(VALUE self) {
|
|
11
|
+
return rb_str_new2(duckdb_library_version());
|
|
12
|
+
}
|
|
13
|
+
#endif
|
|
14
|
+
|
|
5
15
|
void
|
|
6
16
|
Init_duckdb_native(void) {
|
|
7
17
|
mDuckDB = rb_define_module("DuckDB");
|
|
8
18
|
|
|
19
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
|
20
|
+
rb_define_singleton_method(mDuckDB, "library_version", duckdb_s_library_version, 0);
|
|
21
|
+
#endif
|
|
22
|
+
|
|
9
23
|
init_duckdb_error();
|
|
10
24
|
init_duckdb_database();
|
|
11
25
|
init_duckdb_connection();
|
data/ext/duckdb/extconf.rb
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
require 'mkmf'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
def duckdb_library_available?(func)
|
|
4
|
+
header = find_header('duckdb.h') || find_header('duckdb.h', '/opt/homebrew/include')
|
|
5
|
+
library = have_func(func, 'duckdb.h') || find_library('duckdb', func, '/opt/homebrew/opt/duckdb/lib')
|
|
6
|
+
header && library
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def check_duckdb_library(func, version)
|
|
10
|
+
return if duckdb_library_available?(func)
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
msg = "duckdb >= #{version} is not found. Install duckdb >= #{version} library and header file."
|
|
13
|
+
puts ''
|
|
14
|
+
puts '*' * 80
|
|
15
|
+
puts msg
|
|
16
|
+
puts '*' * 80
|
|
17
|
+
puts ''
|
|
18
|
+
raise msg
|
|
19
|
+
end
|
|
6
20
|
|
|
7
|
-
|
|
21
|
+
dir_config('duckdb')
|
|
22
|
+
|
|
23
|
+
check_duckdb_library('duckdb_pending_prepared', '0.5.0')
|
|
8
24
|
|
|
9
25
|
# check duckdb >= 0.3.3
|
|
10
26
|
# ducdb >= 0.3.3 if duckdb_append_data_chunk() is defined.
|
|
11
27
|
have_func('duckdb_append_data_chunk', 'duckdb.h')
|
|
12
28
|
|
|
29
|
+
# check duckdb >= 0.6.0
|
|
30
|
+
have_func('duckdb_value_string', 'duckdb.h')
|
|
31
|
+
|
|
13
32
|
have_func('duckdb_free', 'duckdb.h')
|
|
14
33
|
|
|
15
34
|
create_makefile('duckdb/duckdb_native')
|
|
@@ -23,6 +23,7 @@ static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE
|
|
|
23
23
|
static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
|
24
24
|
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);
|
|
25
25
|
static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VALUE months, VALUE days, VALUE micros);
|
|
26
|
+
static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper);
|
|
26
27
|
|
|
27
28
|
static const rb_data_type_t prepared_statement_data_type = {
|
|
28
29
|
"DuckDB/PreparedStatement",
|
|
@@ -283,6 +284,22 @@ static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VA
|
|
|
283
284
|
return self;
|
|
284
285
|
}
|
|
285
286
|
|
|
287
|
+
static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper) {
|
|
288
|
+
duckdb_hugeint hugeint;
|
|
289
|
+
rubyDuckDBPreparedStatement *ctx;
|
|
290
|
+
idx_t idx = check_index(vidx);
|
|
291
|
+
|
|
292
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
|
293
|
+
hugeint.lower = NUM2ULL(lower);
|
|
294
|
+
hugeint.upper = NUM2LL(upper);
|
|
295
|
+
|
|
296
|
+
if (duckdb_bind_hugeint(ctx->prepared_statement, idx, hugeint) == DuckDBError) {
|
|
297
|
+
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return self;
|
|
301
|
+
}
|
|
302
|
+
|
|
286
303
|
void init_duckdb_prepared_statement(void) {
|
|
287
304
|
cDuckDBPreparedStatement = rb_define_class_under(mDuckDB, "PreparedStatement", rb_cObject);
|
|
288
305
|
|
|
@@ -305,4 +322,5 @@ void init_duckdb_prepared_statement(void) {
|
|
|
305
322
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_time", duckdb_prepared_statement__bind_time, 5);
|
|
306
323
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_timestamp", duckdb_prepared_statement__bind_timestamp, 8);
|
|
307
324
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_interval", duckdb_prepared_statement__bind_interval, 4);
|
|
325
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_bind_hugeint", duckdb_prepared_statement__bind_hugeint, 3);
|
|
308
326
|
}
|
data/ext/duckdb/result.c
CHANGED
|
@@ -10,6 +10,8 @@ static VALUE to_ruby_obj_smallint(duckdb_result *result, idx_t col_idx, idx_t ro
|
|
|
10
10
|
static VALUE to_ruby_obj_utinyint(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
11
11
|
static VALUE to_ruby_obj_integer(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
12
12
|
static VALUE to_ruby_obj_bigint(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
13
|
+
static VALUE to_ruby_obj_hugeint(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
14
|
+
static VALUE to_ruby_obj_decimal(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
13
15
|
static VALUE to_ruby_obj_float(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
14
16
|
static VALUE to_ruby_obj_double(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
15
17
|
static VALUE to_ruby_obj_blob(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
|
@@ -24,9 +26,12 @@ static VALUE duckdb_result__to_smallint(VALUE oDuckDBResult, VALUE row_idx, VALU
|
|
|
24
26
|
static VALUE duckdb_result__to_utinyint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
25
27
|
static VALUE duckdb_result__to_integer(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
26
28
|
static VALUE duckdb_result__to_bigint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
29
|
+
static VALUE duckdb_result___to_hugeint_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
30
|
+
static VALUE duckdb_result___to_decimal_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
27
31
|
static VALUE duckdb_result__to_float(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
28
32
|
static VALUE duckdb_result__to_double(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
29
33
|
static VALUE duckdb_result__to_string(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
34
|
+
static VALUE duckdb_result__to_string_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
30
35
|
static VALUE duckdb_result__to_blob(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
|
31
36
|
static VALUE duckdb_result__enum_internal_type(VALUE oDuckDBResult, VALUE col_idx);
|
|
32
37
|
static VALUE duckdb_result__enum_dictionary_size(VALUE oDuckDBResult, VALUE col_idx);
|
|
@@ -85,6 +90,16 @@ static VALUE to_ruby_obj_bigint(duckdb_result *result, idx_t col_idx, idx_t row_
|
|
|
85
90
|
return rb_int2big(i64val);
|
|
86
91
|
}
|
|
87
92
|
|
|
93
|
+
static VALUE to_ruby_obj_hugeint(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
|
94
|
+
duckdb_hugeint hugeint = duckdb_value_hugeint(result, col_idx, row_idx);
|
|
95
|
+
return rb_ary_new3(2, ULL2NUM(hugeint.lower), LL2NUM(hugeint.upper));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static VALUE to_ruby_obj_decimal(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
|
99
|
+
duckdb_decimal decimal = duckdb_value_decimal(result, col_idx, row_idx);
|
|
100
|
+
return rb_ary_new3(4, ULL2NUM(decimal.value.lower), LL2NUM(decimal.value.upper), UINT2NUM(decimal.width), UINT2NUM(decimal.scale));
|
|
101
|
+
}
|
|
102
|
+
|
|
88
103
|
static VALUE to_ruby_obj_float(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
|
89
104
|
float fval = duckdb_value_float(result, col_idx, row_idx);
|
|
90
105
|
return DBL2NUM(fval);
|
|
@@ -255,6 +270,20 @@ static VALUE duckdb_result__to_bigint(VALUE oDuckDBResult, VALUE row_idx, VALUE
|
|
|
255
270
|
return to_ruby_obj_bigint(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
|
256
271
|
}
|
|
257
272
|
|
|
273
|
+
static VALUE duckdb_result___to_hugeint_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
|
274
|
+
rubyDuckDBResult *ctx;
|
|
275
|
+
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
|
276
|
+
|
|
277
|
+
return to_ruby_obj_hugeint(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
static VALUE duckdb_result___to_decimal_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
|
281
|
+
rubyDuckDBResult *ctx;
|
|
282
|
+
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
|
283
|
+
|
|
284
|
+
return to_ruby_obj_decimal(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
|
285
|
+
}
|
|
286
|
+
|
|
258
287
|
static VALUE duckdb_result__to_float(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
|
259
288
|
rubyDuckDBResult *ctx;
|
|
260
289
|
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
|
@@ -271,14 +300,49 @@ static VALUE duckdb_result__to_double(VALUE oDuckDBResult, VALUE row_idx, VALUE
|
|
|
271
300
|
|
|
272
301
|
static VALUE duckdb_result__to_string(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
|
273
302
|
rubyDuckDBResult *ctx;
|
|
303
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
|
304
|
+
duckdb_string p;
|
|
305
|
+
#else
|
|
274
306
|
char *p;
|
|
307
|
+
#endif
|
|
275
308
|
VALUE obj;
|
|
276
309
|
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
|
277
310
|
|
|
311
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
|
312
|
+
p = duckdb_value_string(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
|
313
|
+
if (p.data) {
|
|
314
|
+
obj = rb_utf8_str_new(p.data, p.size);
|
|
315
|
+
duckdb_free(p.data);
|
|
316
|
+
#else
|
|
278
317
|
p = duckdb_value_varchar(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
|
279
318
|
if (p) {
|
|
280
319
|
obj = rb_utf8_str_new_cstr(p);
|
|
281
320
|
duckdb_free(p);
|
|
321
|
+
#endif
|
|
322
|
+
return obj;
|
|
323
|
+
}
|
|
324
|
+
return Qnil;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
static VALUE duckdb_result__to_string_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
|
328
|
+
rubyDuckDBResult *ctx;
|
|
329
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
|
330
|
+
duckdb_string p;
|
|
331
|
+
#else
|
|
332
|
+
char *p;
|
|
333
|
+
#endif
|
|
334
|
+
VALUE obj;
|
|
335
|
+
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
|
336
|
+
|
|
337
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
|
338
|
+
p = duckdb_value_string_internal(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
|
339
|
+
if (p.data) {
|
|
340
|
+
obj = rb_utf8_str_new(p.data, p.size);
|
|
341
|
+
#else
|
|
342
|
+
p = duckdb_value_varchar_internal(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
|
343
|
+
if (p) {
|
|
344
|
+
obj = rb_utf8_str_new_cstr(p);
|
|
345
|
+
#endif
|
|
282
346
|
return obj;
|
|
283
347
|
}
|
|
284
348
|
return Qnil;
|
|
@@ -354,9 +418,12 @@ void init_duckdb_result(void) {
|
|
|
354
418
|
rb_define_private_method(cDuckDBResult, "_to_utinyint", duckdb_result__to_utinyint, 2);
|
|
355
419
|
rb_define_private_method(cDuckDBResult, "_to_integer", duckdb_result__to_integer, 2);
|
|
356
420
|
rb_define_private_method(cDuckDBResult, "_to_bigint", duckdb_result__to_bigint, 2);
|
|
421
|
+
rb_define_private_method(cDuckDBResult, "__to_hugeint_internal", duckdb_result___to_hugeint_internal, 2);
|
|
422
|
+
rb_define_private_method(cDuckDBResult, "__to_decimal_internal", duckdb_result___to_decimal_internal, 2);
|
|
357
423
|
rb_define_private_method(cDuckDBResult, "_to_float", duckdb_result__to_float, 2);
|
|
358
424
|
rb_define_private_method(cDuckDBResult, "_to_double", duckdb_result__to_double, 2);
|
|
359
425
|
rb_define_private_method(cDuckDBResult, "_to_string", duckdb_result__to_string, 2);
|
|
426
|
+
rb_define_private_method(cDuckDBResult, "_to_string_internal", duckdb_result__to_string_internal, 2);
|
|
360
427
|
rb_define_private_method(cDuckDBResult, "_to_blob", duckdb_result__to_blob, 2);
|
|
361
428
|
rb_define_private_method(cDuckDBResult, "_enum_internal_type", duckdb_result__enum_internal_type, 1);
|
|
362
429
|
rb_define_private_method(cDuckDBResult, "_enum_dictionary_size", duckdb_result__enum_dictionary_size, 1);
|
data/ext/duckdb/ruby-duckdb.h
CHANGED
data/lib/duckdb/appender.rb
CHANGED
|
@@ -33,15 +33,8 @@ module DuckDB
|
|
|
33
33
|
# .end_row
|
|
34
34
|
#
|
|
35
35
|
def append_hugeint(value)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
half = 1 << 64
|
|
39
|
-
upper = value / half
|
|
40
|
-
lower = value - upper * half
|
|
41
|
-
_append_hugeint(lower, upper)
|
|
42
|
-
else
|
|
43
|
-
raise(ArgumentError, "2nd argument `#{value}` must be Integer.")
|
|
44
|
-
end
|
|
36
|
+
lower, upper = integer_to_hugeint(value)
|
|
37
|
+
_append_hugeint(lower, upper)
|
|
45
38
|
end
|
|
46
39
|
|
|
47
40
|
#
|
data/lib/duckdb/converter.rb
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
module DuckDB
|
|
2
2
|
module Converter
|
|
3
|
+
HALF_HUGEINT = 1 << 64
|
|
4
|
+
|
|
3
5
|
private
|
|
4
6
|
|
|
7
|
+
def integer_to_hugeint(value)
|
|
8
|
+
case value
|
|
9
|
+
when Integer
|
|
10
|
+
upper = value / HALF_HUGEINT
|
|
11
|
+
lower = value - upper * HALF_HUGEINT
|
|
12
|
+
[lower, upper]
|
|
13
|
+
else
|
|
14
|
+
raise(ArgumentError, "2nd argument `#{value}` must be Integer.")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
5
18
|
def iso8601_interval_to_hash(value)
|
|
6
19
|
digit = ''
|
|
7
20
|
time = false
|
|
@@ -15,10 +15,21 @@ module DuckDB
|
|
|
15
15
|
class PreparedStatement
|
|
16
16
|
include DuckDB::Converter
|
|
17
17
|
|
|
18
|
-
RANGE_INT16 = -
|
|
19
|
-
RANGE_INT32 = -
|
|
20
|
-
RANGE_INT64 = -
|
|
18
|
+
RANGE_INT16 = -32_768..32_767
|
|
19
|
+
RANGE_INT32 = -2_147_483_648..2_147_483_647
|
|
20
|
+
RANGE_INT64 = -9_223_372_036_854_775_808..9_223_372_036_854_775_807
|
|
21
21
|
|
|
22
|
+
# binds i-th parameter with SQL prepared statement.
|
|
23
|
+
# The first argument is index of parameter.
|
|
24
|
+
# The index of first parameter is 1 not 0.
|
|
25
|
+
# The second argument value is to expected Integer value.
|
|
26
|
+
# This method uses bind_varchar internally.
|
|
27
|
+
# require 'duckdb'
|
|
28
|
+
# db = DuckDB::Database.open('duckdb_database')
|
|
29
|
+
# con = db.connect
|
|
30
|
+
# sql ='SELECT name FROM users WHERE bigint_col = ?'
|
|
31
|
+
# stmt = PreparedStatement.new(con, sql)
|
|
32
|
+
# stmt.bind_hugeint(1, 1_234_567_890_123_456_789_012_345)
|
|
22
33
|
def bind_hugeint(i, value)
|
|
23
34
|
case value
|
|
24
35
|
when Integer
|
|
@@ -28,6 +39,22 @@ module DuckDB
|
|
|
28
39
|
end
|
|
29
40
|
end
|
|
30
41
|
|
|
42
|
+
# binds i-th parameter with SQL prepared statement.
|
|
43
|
+
# The first argument is index of parameter.
|
|
44
|
+
# The index of first parameter is 1 not 0.
|
|
45
|
+
# The second argument value must be Integer value.
|
|
46
|
+
# This method uses duckdb_bind_hugeint internally.
|
|
47
|
+
# require 'duckdb'
|
|
48
|
+
# db = DuckDB::Database.open('duckdb_database')
|
|
49
|
+
# con = db.connect
|
|
50
|
+
# sql ='SELECT name FROM users WHERE bigint_col = ?'
|
|
51
|
+
# stmt = PreparedStatement.new(con, sql)
|
|
52
|
+
# stmt.bind_hugeint_internal(1, 1_234_567_890_123_456_789_012_345)
|
|
53
|
+
def bind_hugeint_internal(index, value)
|
|
54
|
+
lower, upper = integer_to_hugeint(value)
|
|
55
|
+
_bind_hugeint(index, lower, upper)
|
|
56
|
+
end
|
|
57
|
+
|
|
31
58
|
# binds i-th parameter with SQL prepared statement.
|
|
32
59
|
# The first argument is index of parameter.
|
|
33
60
|
# The index of first parameter is 1 not 0.
|
data/lib/duckdb/version.rb
CHANGED
data/lib/duckdb.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: duckdb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Masaki Suketa
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -119,6 +119,7 @@ files:
|
|
|
119
119
|
- lib/duckdb/connection.rb
|
|
120
120
|
- lib/duckdb/converter.rb
|
|
121
121
|
- lib/duckdb/database.rb
|
|
122
|
+
- lib/duckdb/library_version.rb
|
|
122
123
|
- lib/duckdb/prepared_statement.rb
|
|
123
124
|
- lib/duckdb/result.rb
|
|
124
125
|
- lib/duckdb/version.rb
|
|
@@ -129,7 +130,7 @@ metadata:
|
|
|
129
130
|
homepage_uri: https://github.com/suketa/ruby-duckdb
|
|
130
131
|
source_code_uri: https://github.com/suketa/ruby-duckdb
|
|
131
132
|
changelog_uri: https://github.com/suketa/ruby-duckdb/blob/master/CHANGELOG.md
|
|
132
|
-
post_install_message:
|
|
133
|
+
post_install_message:
|
|
133
134
|
rdoc_options: []
|
|
134
135
|
require_paths:
|
|
135
136
|
- lib
|
|
@@ -137,15 +138,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
137
138
|
requirements:
|
|
138
139
|
- - ">="
|
|
139
140
|
- !ruby/object:Gem::Version
|
|
140
|
-
version: 2.
|
|
141
|
+
version: 2.7.0
|
|
141
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
requirements:
|
|
143
144
|
- - ">="
|
|
144
145
|
- !ruby/object:Gem::Version
|
|
145
146
|
version: '0'
|
|
146
147
|
requirements: []
|
|
147
|
-
rubygems_version: 3.
|
|
148
|
-
signing_key:
|
|
148
|
+
rubygems_version: 3.4.6
|
|
149
|
+
signing_key:
|
|
149
150
|
specification_version: 4
|
|
150
151
|
summary: This module is Ruby binding for DuckDB database engine.
|
|
151
152
|
test_files: []
|