duckdb 0.0.11 → 0.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 165ee505735c050cb91285841186a9385d46ec4c674183fa31503753a3eb3a79
4
- data.tar.gz: bca9cdb4ecf241dbe581ad0e2a5b3b600d25a75840bef6bdfed744566cfea621
3
+ metadata.gz: 1a0f6c8a46cecbe281cf970b5e8c6fd11c2903a5ddd58bf683341bcb299d7a36
4
+ data.tar.gz: 6ba452c2aa37f77c68905413e3bb6cb27697f8db23bfeca1e8ca1886ce6fb1ab
5
5
  SHA512:
6
- metadata.gz: 81ea7c4bf67e976715f0ccbddb10992cd10ec228e20787c0403dbee799f2db3b37c72103e31352e7931a32df6e8c9ef2e26281c1812d96339c98be312d50b865
7
- data.tar.gz: 2e788022c4977e9ac31c63bce5a1d5251b5866536d959316f228a0e46688426829a4b754305d3681973d6efecd8fdcb24a4f1c8c494d5128481410adf5bfdd49
6
+ metadata.gz: beb0db8d6e590ee4014aa4fb1e09a7093d6b13cebe3ad38f90cf6f29707b5e768696732f33c5d53027032ba7eacc8bf8ddecb9b112a042f05b17bbb98e086197
7
+ data.tar.gz: 228651ac8ed6c13044cbf0e3709444464ff552b0b431b051446def7dce074b38ef8a242f72e75c8c1ba788ae13dfc88a2041f7f2e9e70b64fb3c34c9c2c8ad85
@@ -9,7 +9,7 @@ jobs:
9
9
  strategy:
10
10
  matrix:
11
11
  ruby: ['2.5.8', '2.6.6', '2.7.2', '3.0.0', 'head']
12
- duckdb: ['0.2.4', '0.2.3']
12
+ duckdb: ['0.2.4', '0.2.5']
13
13
 
14
14
  steps:
15
15
  - uses: actions/checkout@v2
@@ -28,14 +28,14 @@ jobs:
28
28
  restore-keys: |
29
29
  ${{ runner.os }}-duckdb-v0_2_4
30
30
 
31
- - name: duckdb 0.2.3 cache
32
- id: duckdb-cache-v0_2_3
31
+ - name: duckdb 0.2.5 cache
32
+ id: duckdb-cache-v0_2_5
33
33
  uses: actions/cache@v1.1.0
34
34
  with:
35
- path: duckdb-v0.2.3
36
- key: ${{ runner.os }}-duckdb-v0_2_3_001
35
+ path: duckdb-v0.2.5
36
+ key: ${{ runner.os }}-duckdb-v0_2_5_001
37
37
  restore-keys: |
38
- ${{ runner.os }}-duckdb-v0_2_3
38
+ ${{ runner.os }}-duckdb-v0_2_5
39
39
 
40
40
  - name: Build duckdb 0.2.4
41
41
  if: steps.duckdb-cache-v0_2_4.outputs.cache-hit != 'true'
@@ -47,15 +47,15 @@ jobs:
47
47
  cp -rip duckdb-tmp-v0.2.4/build/release/src/*.so duckdb-v0.2.4/build/release/src
48
48
  cp -rip duckdb-tmp-v0.2.4/src/include duckdb-v0.2.4/src/
49
49
 
50
- - name: Build duckdb 0.2.3
51
- if: steps.duckdb-cache-v0_2_3.outputs.cache-hit != 'true'
50
+ - name: Build duckdb 0.2.5
51
+ if: steps.duckdb-cache-v0_2_5.outputs.cache-hit != 'true'
52
52
  run: |
53
- git clone -b v0.2.3 https://github.com/cwida/duckdb.git duckdb-tmp-v0.2.3
54
- cd duckdb-tmp-v0.2.3 && make && cd ..
55
- rm -rf duckdb-v0.2.3
56
- mkdir -p duckdb-v0.2.3/build/release/src duckdb-v0.2.3/src
57
- cp -rip duckdb-tmp-v0.2.3/build/release/src/*.so duckdb-v0.2.3/build/release/src
58
- cp -rip duckdb-tmp-v0.2.3/src/include duckdb-v0.2.3/src/
53
+ git clone -b v0.2.5 https://github.com/cwida/duckdb.git duckdb-tmp-v0.2.5
54
+ cd duckdb-tmp-v0.2.5 && make && cd ..
55
+ rm -rf duckdb-v0.2.5
56
+ mkdir -p duckdb-v0.2.5/build/release/src duckdb-v0.2.5/src
57
+ cp -rip duckdb-tmp-v0.2.5/build/release/src/*.so duckdb-v0.2.5/build/release/src
58
+ cp -rip duckdb-tmp-v0.2.5/src/include duckdb-v0.2.5/src/
59
59
 
60
60
  - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
61
61
  env:
data/.travis.yml CHANGED
@@ -2,13 +2,13 @@ language: ruby
2
2
  cache:
3
3
  bundler: true
4
4
  directories:
5
- - ${HOME}/duckdb-v0.2.3
5
+ - ${HOME}/duckdb-v0.2.5
6
6
  before_install:
7
7
  - yes | gem update --system
8
- - if [[ ! -d ${HOME}/duckdb-v0.2.3/build ]]; then cd ${HOME} && git clone -b v0.2.3 https://github.com/cwida/duckdb.git duckdb-v0.2.3 && cd duckdb-v0.2.3 && make && cd ${TRAVIS_BUILD_DIR}; fi
8
+ - if [[ ! -d ${HOME}/duckdb-v0.2.5/build ]]; then cd ${HOME} && git clone -b v0.2.5 https://github.com/cwida/duckdb.git duckdb-v0.2.5 && cd duckdb-v0.2.5 && make && cd ${TRAVIS_BUILD_DIR}; fi
9
9
 
10
10
  env:
11
- - DUCKDB_VERSION=0.2.3
11
+ - DUCKDB_VERSION=0.2.5
12
12
  rvm:
13
13
  - 2.5.8
14
14
  - 2.6.6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 0.0.12
4
+
5
+ - bump DuckDB to v0.2.5
6
+ - support BLOB type (with DuckDB version 0.2.5 or later)
7
+
3
8
  ## 0.0.11
4
9
 
5
10
  - fix failure in test_close in test/duckdb_test/database_test.rb because DuckDB error message was changed.
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- duckdb (0.0.11)
4
+ duckdb (0.0.12)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.14.3)
9
+ minitest (5.14.4)
10
10
  rake (13.0.3)
11
11
  rake-compiler (1.1.1)
12
12
  rake
data/README.md CHANGED
@@ -64,3 +64,26 @@ DuckDB::Database.open do |db|
64
64
  end
65
65
  end
66
66
  ```
67
+
68
+ ### using BLOB column
69
+
70
+ BLOB is available with DuckDB v0.2.5 or later.
71
+ Use `DuckDB::Blob.new` or use sting#force_encoding(Encoding::ASCII_8BIT)
72
+
73
+ ```
74
+ require 'duckdb'
75
+
76
+ DuckDB::Database.open do |db|
77
+ db.connect do |con|
78
+ con.query('CREATE TABLE blob_table (binary_data BLOB)')
79
+ stmt = DuckDB::PreparedStatement.new(con, 'INSERT INTO blob_table VALUES ($1)')
80
+
81
+ stmt.bind(1, DuckDB::Blob.new("\0\1\2\3\4\5"))
82
+ # stmt.bind(1, "\0\1\2\3\4\5".force_encoding(Encoding::BINARY))
83
+ stmt.execute
84
+
85
+ result = con.query('SELECT binary_data FROM blob_table')
86
+ p result.first.first
87
+ end
88
+ end
89
+ ```
data/ext/duckdb/blob.c ADDED
@@ -0,0 +1,11 @@
1
+ #include "ruby-duckdb.h"
2
+
3
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
4
+
5
+ VALUE cDuckDBBlob;
6
+
7
+ void init_duckdb_blob(void)
8
+ {
9
+ cDuckDBBlob = rb_define_class_under(mDuckDB, "Blob", rb_cString);
10
+ }
11
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
data/ext/duckdb/blob.h ADDED
@@ -0,0 +1,14 @@
1
+ #ifndef RUBY_DUCKDB_BLOB_H
2
+ #define RUBY_DUCKDB_BLOB_H
3
+
4
+ /*
5
+ * blob is supported by duckdb v0.2.5 or later
6
+ */
7
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
8
+
9
+ void init_duckdb_blob(void);
10
+
11
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
12
+
13
+ #endif
14
+
data/ext/duckdb/duckdb.c CHANGED
@@ -12,4 +12,10 @@ Init_duckdb_native(void)
12
12
  init_duckdb_connection();
13
13
  init_duckdb_result();
14
14
  init_duckdb_prepared_statement();
15
+
16
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
17
+
18
+ init_duckdb_blob();
19
+
20
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
15
21
  }
@@ -2,5 +2,6 @@ require 'mkmf'
2
2
 
3
3
  dir_config('duckdb')
4
4
  if have_library('duckdb')
5
+ have_func('duckdb_value_blob', 'duckdb.h')
5
6
  create_makefile('duckdb/duckdb_native')
6
7
  end
@@ -168,6 +168,20 @@ static VALUE duckdb_prepared_statement_bind_varchar(VALUE self, VALUE vidx, VALU
168
168
  return self;
169
169
  }
170
170
 
171
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
172
+ static VALUE duckdb_prepared_statement_bind_blob(VALUE self, VALUE vidx, VALUE blob)
173
+ {
174
+ rubyDuckDBPreparedStatement *ctx;
175
+ idx_t idx = check_index(vidx);
176
+
177
+ Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
178
+ if (duckdb_bind_blob(ctx->prepared_statement, idx, (const void *)StringValuePtr(blob), (idx_t)RSTRING_LEN(blob)) == DuckDBError) {
179
+ rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
180
+ }
181
+ return self;
182
+ }
183
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
184
+
171
185
  static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx)
172
186
  {
173
187
  rubyDuckDBPreparedStatement *ctx;
@@ -196,5 +210,8 @@ void init_duckdb_prepared_statement(void)
196
210
  rb_define_method(cDuckDBPreparedStatement, "bind_float", duckdb_prepared_statement_bind_float, 2);
197
211
  rb_define_method(cDuckDBPreparedStatement, "bind_double", duckdb_prepared_statement_bind_double, 2);
198
212
  rb_define_method(cDuckDBPreparedStatement, "bind_varchar", duckdb_prepared_statement_bind_varchar, 2);
213
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
214
+ rb_define_method(cDuckDBPreparedStatement, "bind_blob", duckdb_prepared_statement_bind_blob, 2);
215
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
199
216
  rb_define_method(cDuckDBPreparedStatement, "bind_null", duckdb_prepared_statement_bind_null, 1);
200
217
  }
data/ext/duckdb/result.c CHANGED
@@ -52,6 +52,14 @@ static VALUE to_ruby_obj_double(duckdb_result *result, idx_t col_idx, idx_t row_
52
52
  return DBL2NUM(dval);
53
53
  }
54
54
 
55
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
56
+ static VALUE to_ruby_obj_string_from_blob(duckdb_result *result, idx_t col_idx, idx_t row_idx)
57
+ {
58
+ duckdb_blob bval = duckdb_value_blob(result, col_idx, row_idx);
59
+ return rb_str_new(bval.data, bval.size);
60
+ }
61
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
62
+
55
63
  static VALUE to_ruby_obj(duckdb_result *result, idx_t col_idx, idx_t row_idx)
56
64
  {
57
65
  char *p;
@@ -72,6 +80,10 @@ static VALUE to_ruby_obj(duckdb_result *result, idx_t col_idx, idx_t row_idx)
72
80
  return to_ruby_obj_float(result, col_idx, row_idx);
73
81
  case DUCKDB_TYPE_DOUBLE:
74
82
  return to_ruby_obj_double(result, col_idx, row_idx);
83
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
84
+ case DUCKDB_TYPE_BLOB:
85
+ return to_ruby_obj_string_from_blob(result, col_idx, row_idx);
86
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
75
87
  default:
76
88
  p = duckdb_value_varchar(result, col_idx, row_idx);
77
89
  obj = rb_str_new2(p);
@@ -9,9 +9,22 @@
9
9
  #include "./result.h"
10
10
  #include "./prepared_statement.h"
11
11
 
12
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
13
+
14
+ #include "./blob.h"
15
+
16
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
17
+
12
18
  extern VALUE mDuckDB;
13
19
  extern VALUE cDuckDBDatabase;
14
20
  extern VALUE cDuckDBConnection;
21
+
22
+ #ifdef HAVE_DUCKDB_VALUE_BLOB
23
+
24
+ extern VALUE cDuckDBBlob;
25
+
26
+ #endif /* HAVE_DUCKDB_VALUE_BLOB */
27
+
15
28
  extern VALUE eDuckDBError;
16
29
 
17
30
  #endif
@@ -33,7 +33,11 @@ module DuckDB
33
33
  when Integer
34
34
  bind_int64(i, value)
35
35
  when String
36
- bind_varchar(i, value)
36
+ if defined?(DuckDB::Blob)
37
+ blob?(value) ? bind_blob(i, value) : bind_varchar(i, value)
38
+ else
39
+ bind_varchar(i, value)
40
+ end
37
41
  when TrueClass, FalseClass
38
42
  bind_boolean(i, value)
39
43
  when Time
@@ -44,5 +48,11 @@ module DuckDB
44
48
  rb_raise(DuckDB::Error, "not supported type #{value} (value.class)")
45
49
  end
46
50
  end
51
+
52
+ private
53
+
54
+ def blob?(value)
55
+ value.instance_of?(DuckDB::Blob) || value.encoding == Encoding::BINARY
56
+ end
47
57
  end
48
58
  end
@@ -1,5 +1,5 @@
1
1
  module DuckDB
2
2
  # The version string of ruby-duckdb.
3
3
  # Currently, ruby-duckdb is NOT semantic versioning.
4
- VERSION = '0.0.11'.freeze
4
+ VERSION = '0.0.12'.freeze
5
5
  end
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.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Suketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-06 00:00:00.000000000 Z
11
+ date: 2021-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,6 +88,8 @@ files:
88
88
  - bin/console
89
89
  - bin/setup
90
90
  - duckdb.gemspec
91
+ - ext/duckdb/blob.c
92
+ - ext/duckdb/blob.h
91
93
  - ext/duckdb/connection.c
92
94
  - ext/duckdb/connection.h
93
95
  - ext/duckdb/database.c