duckdb 0.2.8.0 → 0.3.2.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 +21 -4
- data/.github/workflows/test_on_ubuntu.yml +26 -37
- data/.github/workflows/test_on_windows.yml +22 -9
- data/CHANGELOG.md +37 -0
- data/CONTRIBUTION.md +24 -0
- data/Gemfile.lock +2 -1
- data/README.md +31 -3
- data/duckdb.gemspec +2 -2
- data/ext/duckdb/appender.c +117 -4
- data/ext/duckdb/blob.c +1 -5
- data/ext/duckdb/blob.h +0 -4
- data/ext/duckdb/config.c +3 -5
- data/ext/duckdb/connection.c +14 -15
- data/ext/duckdb/database.c +10 -16
- data/ext/duckdb/duckdb.c +1 -7
- data/ext/duckdb/error.c +1 -2
- data/ext/duckdb/extconf.rb +29 -8
- data/ext/duckdb/prepared_statement.c +136 -40
- data/ext/duckdb/result.c +70 -41
- data/ext/duckdb/ruby-duckdb.h +1 -16
- data/ext/duckdb/util.c +45 -0
- data/ext/duckdb/util.h +13 -0
- data/lib/duckdb/appender.rb +158 -10
- data/lib/duckdb/config.rb +1 -4
- data/lib/duckdb/converter.rb +52 -0
- data/lib/duckdb/prepared_statement.rb +114 -10
- data/lib/duckdb/version.rb +1 -1
- data/lib/duckdb.rb +1 -0
- metadata +8 -5
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96ad27d302c878ca4d207d86e1eb24e61be890c8585d6bd9231237900479053d
|
4
|
+
data.tar.gz: 4e0fb0daf725f53acd454ee77c179ef1af57a96b9308bc6f303853e28fe9b9a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b407a06ebf245a9534362a5106fe7d8bd74a55f2234bf2c734da067f2a8ef150472f8b40a312acd9d0957fb27515ec67fb536cf019375825e6e62d2c1ea82e8e
|
7
|
+
data.tar.gz: e2da40b4d0cb0eb25a77a6e1b383cf54a4bd8618cc31d670f59d5068c74603e41d14c4f57f9e3f909a339798f7e2a0d0143239483aef8ea8094c92cdcac417f4
|
@@ -1,13 +1,22 @@
|
|
1
1
|
name: MacOS
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types:
|
9
|
+
- opened
|
10
|
+
- synchronize
|
11
|
+
- reopened
|
4
12
|
|
5
13
|
jobs:
|
6
14
|
build:
|
7
15
|
runs-on: macos-latest
|
8
16
|
strategy:
|
9
17
|
matrix:
|
10
|
-
ruby: ['2.
|
18
|
+
ruby: ['2.6.9', '2.7.5', '3.0.3', '3.1.1', 'head']
|
19
|
+
duckdb: ['0.3.2', '0.3.1']
|
11
20
|
|
12
21
|
steps:
|
13
22
|
- uses: actions/checkout@v2
|
@@ -17,9 +26,17 @@ jobs:
|
|
17
26
|
with:
|
18
27
|
ruby-version: ${{ matrix.ruby }}
|
19
28
|
|
20
|
-
- name:
|
29
|
+
- name: download duckdb binary for MacOS 64bit
|
30
|
+
env:
|
31
|
+
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
21
32
|
run: |
|
22
|
-
|
33
|
+
curl -OL https://github.com/duckdb/duckdb/releases/download/v${DUCKDB_VERSION}/libduckdb-osx-amd64.zip
|
34
|
+
|
35
|
+
- name: extract zip file
|
36
|
+
run: |
|
37
|
+
unzip libduckdb-osx-amd64.zip
|
38
|
+
cp duckdb.h /usr/local/include
|
39
|
+
cp libduckdb.dylib /usr/local/lib
|
23
40
|
|
24
41
|
- name: Build and test with Rake with Ruby ${{ matrix.ruby }}
|
25
42
|
run: |
|
@@ -1,6 +1,14 @@
|
|
1
1
|
name: Ubuntu
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types:
|
9
|
+
- opened
|
10
|
+
- synchronize
|
11
|
+
- reopened
|
4
12
|
|
5
13
|
jobs:
|
6
14
|
build:
|
@@ -8,8 +16,8 @@ jobs:
|
|
8
16
|
runs-on: ubuntu-latest
|
9
17
|
strategy:
|
10
18
|
matrix:
|
11
|
-
ruby: ['2.
|
12
|
-
duckdb: ['0.2
|
19
|
+
ruby: ['2.6.9', '2.7.5', '3.0.3', '3.1.1', 'head']
|
20
|
+
duckdb: ['0.3.2', '0.3.1']
|
13
21
|
|
14
22
|
steps:
|
15
23
|
- uses: actions/checkout@v2
|
@@ -19,43 +27,24 @@ jobs:
|
|
19
27
|
with:
|
20
28
|
ruby-version: ${{ matrix.ruby }}
|
21
29
|
|
22
|
-
- name: duckdb
|
23
|
-
id: duckdb-cache
|
24
|
-
uses: actions/cache@
|
30
|
+
- name: duckdb cache
|
31
|
+
id: duckdb-cache
|
32
|
+
uses: actions/cache@v2
|
25
33
|
with:
|
26
|
-
path: duckdb-
|
27
|
-
key: ${{ runner.os }}-duckdb-
|
28
|
-
restore-keys: |
|
29
|
-
${{ runner.os }}-duckdb-v0_2_8
|
34
|
+
path: duckdb-v${{ matrix.duckdb }}
|
35
|
+
key: ${{ runner.os }}-duckdb-v${{ matrix.duckdb }}
|
30
36
|
|
31
|
-
- name: duckdb
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
path: duckdb-v0.2.7
|
36
|
-
key: ${{ runner.os }}-duckdb-v0_2_7_001
|
37
|
-
restore-keys: |
|
38
|
-
${{ runner.os }}-duckdb-v0_2_7
|
39
|
-
|
40
|
-
- name: Build duckdb 0.2.8
|
41
|
-
if: steps.duckdb-cache-v0_2_8.outputs.cache-hit != 'true'
|
42
|
-
run: |
|
43
|
-
git clone -b v0.2.8 https://github.com/cwida/duckdb.git duckdb-tmp-v0.2.8
|
44
|
-
cd duckdb-tmp-v0.2.8 && make && cd ..
|
45
|
-
rm -rf duckdb-v0.2.8
|
46
|
-
mkdir -p duckdb-v0.2.8/build/release/src duckdb-v0.2.8/src
|
47
|
-
cp -rip duckdb-tmp-v0.2.8/build/release/src/*.so duckdb-v0.2.8/build/release/src
|
48
|
-
cp -rip duckdb-tmp-v0.2.8/src/include duckdb-v0.2.8/src/
|
49
|
-
|
50
|
-
- name: Build duckdb 0.2.7
|
51
|
-
if: steps.duckdb-cache-v0_2_7.outputs.cache-hit != 'true'
|
37
|
+
- name: Build duckdb ${{ matrix.duckdb }}
|
38
|
+
env:
|
39
|
+
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
40
|
+
if: steps.duckdb-cache.outputs.cache-hit != 'true'
|
52
41
|
run: |
|
53
|
-
git clone -b
|
54
|
-
cd duckdb-tmp-
|
55
|
-
rm -rf duckdb-
|
56
|
-
mkdir -p duckdb-
|
57
|
-
cp -rip duckdb-tmp-
|
58
|
-
cp -rip duckdb-tmp-
|
42
|
+
git clone -b v$DUCKDB_VERSION https://github.com/cwida/duckdb.git duckdb-tmp-v$DUCKDB_VERSION
|
43
|
+
cd duckdb-tmp-v$DUCKDB_VERSION && make && cd ..
|
44
|
+
rm -rf duckdb-v$DUCKDB_VERSION
|
45
|
+
mkdir -p duckdb-v$DUCKDB_VERSION/build/release/src duckdb-v$DUCKDB_VERSION/src
|
46
|
+
cp -rip duckdb-tmp-v$DUCKDB_VERSION/build/release/src/*.so duckdb-v$DUCKDB_VERSION/build/release/src
|
47
|
+
cp -rip duckdb-tmp-v$DUCKDB_VERSION/src/include duckdb-v$DUCKDB_VERSION/src/
|
59
48
|
|
60
49
|
- name: Build and test with Rake with Ruby ${{ matrix.ruby }}
|
61
50
|
env:
|
@@ -1,13 +1,22 @@
|
|
1
1
|
name: Windows
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types:
|
9
|
+
- opened
|
10
|
+
- synchronize
|
11
|
+
- reopened
|
4
12
|
|
5
13
|
jobs:
|
6
14
|
build:
|
7
15
|
runs-on: windows-latest
|
8
16
|
strategy:
|
9
17
|
matrix:
|
10
|
-
ruby: ['2.
|
18
|
+
ruby: ['2.6.9', '2.7.5', '3.0.3', '3.1.1', 'mingw', 'head']
|
19
|
+
duckdb: ['0.3.2', '0.3.1']
|
11
20
|
|
12
21
|
steps:
|
13
22
|
- uses: actions/checkout@v2
|
@@ -18,20 +27,24 @@ jobs:
|
|
18
27
|
ruby-version: ${{ matrix.ruby }}
|
19
28
|
|
20
29
|
- name: download duckdb binary for windows 64bit
|
30
|
+
env:
|
31
|
+
DUCKDB_VERSION: ${{ matrix.duckdb }}
|
21
32
|
run: |
|
22
|
-
curl -OL https://github.com/duckdb/duckdb/releases/download/
|
33
|
+
curl -OL https://github.com/duckdb/duckdb/releases/download/v${env:DUCKDB_VERSION}/libduckdb-windows-amd64.zip
|
23
34
|
|
24
35
|
- name: extract zip file
|
25
36
|
run: |
|
26
|
-
|
37
|
+
unzip libduckdb-windows-amd64.zip
|
38
|
+
|
39
|
+
- name: setup duckdb.dll
|
40
|
+
run: |
|
41
|
+
cp duckdb.dll C:/Windows/System32/
|
27
42
|
|
28
43
|
- name: Build with Rake with Ruby ${{ matrix.ruby }}
|
29
44
|
run: |
|
30
45
|
bundle install
|
31
46
|
bundle exec rake build -- --with-duckdb-include=../../../.. --with-duckdb-lib=../../../..
|
32
47
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# run: |
|
37
|
-
# rake test
|
48
|
+
- name: rake test
|
49
|
+
run: |
|
50
|
+
rake test
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,42 @@
|
|
1
1
|
# ChangeLog
|
2
2
|
|
3
|
+
# 0.3.2.0
|
4
|
+
|
5
|
+
- bind_time, bind_timestamp, bind_date, bind_timeinterval to DuckDB::PreparedStatement
|
6
|
+
- bump duckdb 0.3.2
|
7
|
+
- bump Ruby 3.1.1, add Ruby mingw in CI.
|
8
|
+
- bump Ruby 2.6.9, 2.7.5, 3.0.3 in CI.
|
9
|
+
|
10
|
+
## BREAKING CHANGE
|
11
|
+
- drop duckdb <= 0.2.8
|
12
|
+
|
13
|
+
# 0.3.1.0
|
14
|
+
|
15
|
+
- bump duckdb to 0.3.1 in CI.
|
16
|
+
- bump duckdb to 0.3.0 in CI.
|
17
|
+
- append_time, append_date, append_timestamp of DuckDB::Appender accept argument
|
18
|
+
having to_str to convert time string.
|
19
|
+
|
20
|
+
# 0.2.9.0
|
21
|
+
|
22
|
+
- add DuckDB::Appender#append
|
23
|
+
- breaking change.
|
24
|
+
- append_timestamp is called when the argument is Time object.
|
25
|
+
- append_date is called when the argument is Date object.
|
26
|
+
- add DuckDB::Appender#append_timestamp.
|
27
|
+
- add DuckDB::Appender#append_interval. append_interval is expremental.
|
28
|
+
- add DuckDB::Result#rows_changed
|
29
|
+
- refactoring DuckDB::Append#append_hugeint with duckdb v0.2.9
|
30
|
+
- test 2 versions of duckdb on github actions macos CI.
|
31
|
+
- fix windows CI failes
|
32
|
+
- update github actions CI on ubuntu
|
33
|
+
- fix to build with duckdb v0.2.9
|
34
|
+
- use duckdb_prepare_error when get error message of prepared statement.
|
35
|
+
- add DuckDB::Appender#append_date
|
36
|
+
- add DuckDB::Appender#append_time
|
37
|
+
|
38
|
+
# 0.2.8.0
|
39
|
+
|
3
40
|
- DuckDB::Database.open accepts 2-nd argument as DuckDB::Config object.
|
4
41
|
- add DuckDB::Config
|
5
42
|
- bump duckdb to 0.2.8 in CI
|
data/CONTRIBUTION.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Contribution Guide
|
2
|
+
|
3
|
+
## Issue
|
4
|
+
|
5
|
+
If you spot a problem, [search if an issue already exists](https://github.com/suketa/ruby-duckdb/issues).
|
6
|
+
If a related issue doesn't exist, you can open a [new issue](https://github.com/suketa/ruby-duckdb/issues/new).
|
7
|
+
|
8
|
+
|
9
|
+
## Fix Issues or Add New Features.
|
10
|
+
|
11
|
+
1. install [Ruby](https://www.ruby-lang.org/) into your local machine.
|
12
|
+
2. install [duckdb](https://duckdb.org/) into your local machine.
|
13
|
+
3. fork the repository and `git clone` to your local machine.
|
14
|
+
4. run `bundle install`
|
15
|
+
5. run `rake build`
|
16
|
+
or you might run with C duckdb header and library directories:
|
17
|
+
`rake build -- --with-duckdb-include=/duckdb_header_directory --with-duckdb-lib=/duckdb_library_directory`
|
18
|
+
6. run `rake test`
|
19
|
+
7. create new branch to change the code.
|
20
|
+
8. change the code.
|
21
|
+
9. write test.
|
22
|
+
10. run `rake test` and confirm all tests pass.
|
23
|
+
11. git push.
|
24
|
+
12. create PR.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# ruby-duckdb
|
2
2
|
|
3
|
-
[](https://travis-ci.com/suketa/ruby-duckdb)
|
4
3
|
[](https://github.com/suketa/ruby-duckdb/actions?query=workflow%3AUbuntu)
|
5
4
|
[](https://github.com/suketa/ruby-duckdb/actions?query=workflow%3AMacOS)
|
5
|
+
[](https://github.com/suketa/ruby-duckdb/actions?query=workflow%3AWindows)
|
6
6
|
|
7
7
|
## Description
|
8
8
|
|
@@ -12,16 +12,44 @@ ruby-duckdb is Ruby binding for [DuckDB](http://www.duckdb.org) database engine
|
|
12
12
|
|
13
13
|
You must have [DuckDB](http://www.duckdb.org) engine installed in order to build/use this module.
|
14
14
|
|
15
|
+
## Pre-requisite setup (Linux):
|
16
|
+
1. Head over to the [DuckDB](https://duckdb.org/) webpage
|
17
|
+
|
18
|
+
2. Download the latest C++ package release for DuckDB
|
19
|
+
|
20
|
+
3. Move the files to their respective location:
|
21
|
+
- Extract the `duckdb.h` and `duckdb.hpp` file to `/usr/local/include`
|
22
|
+
- Extract the `libduckdb.so` file to `/usr/local/lib`
|
23
|
+
|
24
|
+
```sh
|
25
|
+
unzip libduckdb-linux-amd64.zip -d libduckdb
|
26
|
+
sudo mv libduckdb/duckdb.* /usr/local/include/
|
27
|
+
sudo mv libduckdb/libduckdb.so /usr/local/lib
|
28
|
+
```
|
29
|
+
4. To create the necessary link, run `ldconfig` as root:
|
30
|
+
|
31
|
+
```sh
|
32
|
+
sudo ldconfig /usr/local/lib # adding a --verbose flag is optional - but this will let you know if the libduckdb.so library has been linked
|
33
|
+
```
|
34
|
+
## Pre-requisite setup (MacOS):
|
35
|
+
|
36
|
+
Using `brew install` is recommended.
|
37
|
+
|
38
|
+
```sh
|
39
|
+
brew install duckdb
|
40
|
+
```
|
41
|
+
|
15
42
|
## How to Install
|
16
43
|
|
17
44
|
```
|
18
45
|
gem install duckdb
|
19
46
|
```
|
47
|
+
> this will work fine with the above pre-requisite setup.
|
20
48
|
|
21
|
-
or you must specify the location of the
|
49
|
+
or you must specify the location of the C header and library files:
|
22
50
|
|
23
51
|
```
|
24
|
-
gem install duckdb -- --with-duckdb-include=/
|
52
|
+
gem install duckdb -- --with-duckdb-include=/duckdb_header_directory --with-duckdb-lib=/duckdb_library_directory
|
25
53
|
```
|
26
54
|
|
27
55
|
## Usage
|
data/duckdb.gemspec
CHANGED
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
# Specify which files should be added to the gem when it is released.
|
23
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
-
spec.files = Dir.chdir(File.expand_path(
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
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.6.0'
|
30
30
|
|
31
31
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
32
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
data/ext/duckdb/appender.c
CHANGED
@@ -24,19 +24,38 @@ static VALUE appender_append_varchar(VALUE self, VALUE val);
|
|
24
24
|
static VALUE appender_append_varchar_length(VALUE self, VALUE val, VALUE len);
|
25
25
|
static VALUE appender_append_blob(VALUE self, VALUE val);
|
26
26
|
static VALUE appender_append_null(VALUE self);
|
27
|
+
|
28
|
+
#ifdef HAVE_DUCKDB_APPEND_DATE
|
29
|
+
static VALUE appender__append_date(VALUE self, VALUE yearval, VALUE monthval, VALUE dayval);
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#ifdef HAVE_DUCKDB_APPEND_INTERVAL
|
33
|
+
static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VALUE micros);
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#ifdef HAVE_DUCKDB_APPEND_TIME
|
37
|
+
static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#ifdef HAVE_DUCKDB_APPEND_TIMESTAMP
|
41
|
+
static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
42
|
+
#endif
|
43
|
+
|
44
|
+
#ifdef HAVE_DUCKDB_APPEND_HUGEINT
|
45
|
+
static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper);
|
46
|
+
#endif
|
47
|
+
|
27
48
|
static VALUE appender_flush(VALUE self);
|
28
49
|
static VALUE appender_close(VALUE self);
|
29
50
|
|
30
|
-
static void deallocate(void * ctx)
|
31
|
-
{
|
51
|
+
static void deallocate(void * ctx) {
|
32
52
|
rubyDuckDBAppender *p = (rubyDuckDBAppender *)ctx;
|
33
53
|
|
34
54
|
duckdb_appender_destroy(&(p->appender));
|
35
55
|
xfree(p);
|
36
56
|
}
|
37
57
|
|
38
|
-
static VALUE allocate(VALUE klass)
|
39
|
-
{
|
58
|
+
static VALUE allocate(VALUE klass) {
|
40
59
|
rubyDuckDBAppender *ctx = xcalloc((size_t)1, sizeof(rubyDuckDBAppender));
|
41
60
|
return Data_Wrap_Struct(klass, NULL, deallocate, ctx);
|
42
61
|
}
|
@@ -268,6 +287,85 @@ static VALUE appender_append_null(VALUE self) {
|
|
268
287
|
return self;
|
269
288
|
}
|
270
289
|
|
290
|
+
#ifdef HAVE_DUCKDB_APPEND_DATE
|
291
|
+
static VALUE appender__append_date(VALUE self, VALUE year, VALUE month, VALUE day) {
|
292
|
+
duckdb_date dt;
|
293
|
+
rubyDuckDBAppender *ctx;
|
294
|
+
|
295
|
+
Data_Get_Struct(self, rubyDuckDBAppender, ctx);
|
296
|
+
dt = to_duckdb_date_from_value(year, month, day);
|
297
|
+
|
298
|
+
if (duckdb_append_date(ctx->appender, dt) == DuckDBError) {
|
299
|
+
rb_raise(eDuckDBError, "failed to append date");
|
300
|
+
}
|
301
|
+
return self;
|
302
|
+
}
|
303
|
+
#endif
|
304
|
+
|
305
|
+
#ifdef HAVE_DUCKDB_APPEND_INTERVAL
|
306
|
+
static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VALUE micros) {
|
307
|
+
duckdb_interval interval;
|
308
|
+
rubyDuckDBAppender *ctx;
|
309
|
+
|
310
|
+
Data_Get_Struct(self, rubyDuckDBAppender, ctx);
|
311
|
+
to_duckdb_interval_from_value(&interval, months, days, micros);
|
312
|
+
|
313
|
+
if (duckdb_append_interval(ctx->appender, interval) == DuckDBError) {
|
314
|
+
rb_raise(eDuckDBError, "failed to append interval");
|
315
|
+
}
|
316
|
+
return self;
|
317
|
+
}
|
318
|
+
#endif
|
319
|
+
|
320
|
+
#ifdef HAVE_DUCKDB_APPEND_TIME
|
321
|
+
static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec, VALUE micros) {
|
322
|
+
duckdb_time time;
|
323
|
+
rubyDuckDBAppender *ctx;
|
324
|
+
|
325
|
+
Data_Get_Struct(self, rubyDuckDBAppender, ctx);
|
326
|
+
time = to_duckdb_time_from_value(hour, min, sec, micros);
|
327
|
+
|
328
|
+
if (duckdb_append_time(ctx->appender, time) == DuckDBError) {
|
329
|
+
rb_raise(eDuckDBError, "failed to append time");
|
330
|
+
}
|
331
|
+
return self;
|
332
|
+
}
|
333
|
+
#endif
|
334
|
+
|
335
|
+
#ifdef HAVE_DUCKDB_APPEND_TIMESTAMP
|
336
|
+
static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros) {
|
337
|
+
duckdb_timestamp timestamp;
|
338
|
+
|
339
|
+
rubyDuckDBAppender *ctx;
|
340
|
+
|
341
|
+
Data_Get_Struct(self, rubyDuckDBAppender, ctx);
|
342
|
+
|
343
|
+
timestamp = to_duckdb_timestamp_from_value(year, month, day, hour, min, sec, micros);
|
344
|
+
|
345
|
+
if (duckdb_append_timestamp(ctx->appender, timestamp) == DuckDBError) {
|
346
|
+
rb_raise(eDuckDBError, "failed to append timestamp");
|
347
|
+
}
|
348
|
+
return self;
|
349
|
+
}
|
350
|
+
#endif
|
351
|
+
|
352
|
+
#ifdef HAVE_DUCKDB_APPEND_HUGEINT
|
353
|
+
static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper) {
|
354
|
+
duckdb_hugeint hugeint;
|
355
|
+
|
356
|
+
hugeint.lower = NUM2ULL(lower);
|
357
|
+
hugeint.upper = NUM2LL(upper);
|
358
|
+
|
359
|
+
rubyDuckDBAppender *ctx;
|
360
|
+
|
361
|
+
Data_Get_Struct(self, rubyDuckDBAppender, ctx);
|
362
|
+
if (duckdb_append_hugeint(ctx->appender, hugeint) == DuckDBError) {
|
363
|
+
rb_raise(eDuckDBError, "failed to append hugeint");
|
364
|
+
}
|
365
|
+
return self;
|
366
|
+
}
|
367
|
+
#endif
|
368
|
+
|
271
369
|
static VALUE appender_flush(VALUE self) {
|
272
370
|
rubyDuckDBAppender *ctx;
|
273
371
|
Data_Get_Struct(self, rubyDuckDBAppender, ctx);
|
@@ -309,6 +407,21 @@ void init_duckdb_appender(void) {
|
|
309
407
|
rb_define_method(cDuckDBAppender, "append_varchar_length", appender_append_varchar_length, 2);
|
310
408
|
rb_define_method(cDuckDBAppender, "append_blob", appender_append_blob, 1);
|
311
409
|
rb_define_method(cDuckDBAppender, "append_null", appender_append_null, 0);
|
410
|
+
#ifdef HAVE_DUCKDB_APPEND_DATE
|
411
|
+
rb_define_private_method(cDuckDBAppender, "_append_date", appender__append_date, 3);
|
412
|
+
#endif
|
413
|
+
#ifdef HAVE_DUCKDB_APPEND_INTERVAL
|
414
|
+
rb_define_private_method(cDuckDBAppender, "_append_interval", appender__append_interval, 3);
|
415
|
+
#endif
|
416
|
+
#ifdef HAVE_DUCKDB_APPEND_TIME
|
417
|
+
rb_define_private_method(cDuckDBAppender, "_append_time", appender__append_time, 4);
|
418
|
+
#endif
|
419
|
+
#ifdef HAVE_DUCKDB_APPEND_TIMESTAMP
|
420
|
+
rb_define_private_method(cDuckDBAppender, "_append_timestamp", appender__append_timestamp, 7);
|
421
|
+
#endif
|
422
|
+
#ifdef HAVE_DUCKDB_APPEND_HUGEINT
|
423
|
+
rb_define_private_method(cDuckDBAppender, "_append_hugeint", appender__append_hugeint, 2);
|
424
|
+
#endif
|
312
425
|
rb_define_method(cDuckDBAppender, "flush", appender_flush, 0);
|
313
426
|
rb_define_method(cDuckDBAppender, "close", appender_close, 0);
|
314
427
|
}
|
data/ext/duckdb/blob.c
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
#include "ruby-duckdb.h"
|
2
2
|
|
3
|
-
#ifdef HAVE_DUCKDB_VALUE_BLOB
|
4
|
-
|
5
3
|
VALUE cDuckDBBlob;
|
6
4
|
|
7
|
-
void init_duckdb_blob(void)
|
8
|
-
{
|
5
|
+
void init_duckdb_blob(void) {
|
9
6
|
cDuckDBBlob = rb_define_class_under(mDuckDB, "Blob", rb_cString);
|
10
7
|
}
|
11
|
-
#endif /* HAVE_DUCKDB_VALUE_BLOB */
|
data/ext/duckdb/blob.h
CHANGED
data/ext/duckdb/config.c
CHANGED
@@ -11,16 +11,14 @@ static VALUE config_s_get_config_flag(VALUE self, VALUE value);
|
|
11
11
|
static VALUE config_initialize(VALUE self);
|
12
12
|
static VALUE config_set_config(VALUE self, VALUE key, VALUE value);
|
13
13
|
|
14
|
-
static void deallocate(void * ctx)
|
15
|
-
{
|
14
|
+
static void deallocate(void * ctx) {
|
16
15
|
rubyDuckDBConfig *p = (rubyDuckDBConfig *)ctx;
|
17
16
|
|
18
17
|
duckdb_destroy_config(&(p->config));
|
19
18
|
xfree(p);
|
20
19
|
}
|
21
20
|
|
22
|
-
static VALUE allocate(VALUE klass)
|
23
|
-
{
|
21
|
+
static VALUE allocate(VALUE klass) {
|
24
22
|
rubyDuckDBConfig *ctx = xcalloc((size_t)1, sizeof(rubyDuckDBConfig));
|
25
23
|
return Data_Wrap_Struct(klass, NULL, deallocate, ctx);
|
26
24
|
}
|
@@ -37,7 +35,7 @@ static VALUE config_initialize(VALUE self) {
|
|
37
35
|
}
|
38
36
|
|
39
37
|
static VALUE config_s_size(VALUE self) {
|
40
|
-
return
|
38
|
+
return ULONG2NUM(duckdb_config_count());
|
41
39
|
}
|
42
40
|
|
43
41
|
static VALUE config_s_get_config_flag(VALUE klass, VALUE value) {
|
data/ext/duckdb/connection.c
CHANGED
@@ -2,22 +2,25 @@
|
|
2
2
|
|
3
3
|
VALUE cDuckDBConnection;
|
4
4
|
|
5
|
-
static void deallocate(void *ctx)
|
6
|
-
|
5
|
+
static void deallocate(void *ctx);
|
6
|
+
static VALUE allocate(VALUE klass);
|
7
|
+
static VALUE duckdb_connection_disconnect(VALUE self);
|
8
|
+
static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase);
|
9
|
+
static VALUE duckdb_connection_query_sql(VALUE self, VALUE str);
|
10
|
+
|
11
|
+
static void deallocate(void *ctx) {
|
7
12
|
rubyDuckDBConnection *p = (rubyDuckDBConnection *)ctx;
|
8
13
|
|
9
14
|
duckdb_disconnect(&(p->con));
|
10
15
|
xfree(p);
|
11
16
|
}
|
12
17
|
|
13
|
-
static VALUE allocate(VALUE klass)
|
14
|
-
{
|
18
|
+
static VALUE allocate(VALUE klass) {
|
15
19
|
rubyDuckDBConnection *ctx = xcalloc((size_t)1, sizeof(rubyDuckDBConnection));
|
16
20
|
return Data_Wrap_Struct(klass, NULL, deallocate, ctx);
|
17
21
|
}
|
18
22
|
|
19
|
-
VALUE create_connection(VALUE oDuckDBDatabase)
|
20
|
-
{
|
23
|
+
VALUE create_connection(VALUE oDuckDBDatabase) {
|
21
24
|
rubyDuckDB *ctxdb;
|
22
25
|
rubyDuckDBConnection *ctxcon;
|
23
26
|
VALUE obj;
|
@@ -35,8 +38,7 @@ VALUE create_connection(VALUE oDuckDBDatabase)
|
|
35
38
|
return obj;
|
36
39
|
}
|
37
40
|
|
38
|
-
static VALUE duckdb_connection_disconnect(VALUE self)
|
39
|
-
{
|
41
|
+
static VALUE duckdb_connection_disconnect(VALUE self) {
|
40
42
|
rubyDuckDBConnection *ctx;
|
41
43
|
|
42
44
|
Data_Get_Struct(self, rubyDuckDBConnection, ctx);
|
@@ -45,8 +47,7 @@ static VALUE duckdb_connection_disconnect(VALUE self)
|
|
45
47
|
return self;
|
46
48
|
}
|
47
49
|
|
48
|
-
static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase)
|
49
|
-
{
|
50
|
+
static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase) {
|
50
51
|
rubyDuckDBConnection *ctx;
|
51
52
|
rubyDuckDB *ctxdb;
|
52
53
|
|
@@ -63,8 +64,7 @@ static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase)
|
|
63
64
|
return self;
|
64
65
|
}
|
65
66
|
|
66
|
-
static VALUE duckdb_connection_query_sql(VALUE self, VALUE str)
|
67
|
-
{
|
67
|
+
static VALUE duckdb_connection_query_sql(VALUE self, VALUE str) {
|
68
68
|
rubyDuckDBConnection *ctx;
|
69
69
|
rubyDuckDBResult *ctxr;
|
70
70
|
|
@@ -78,13 +78,12 @@ static VALUE duckdb_connection_query_sql(VALUE self, VALUE str)
|
|
78
78
|
}
|
79
79
|
|
80
80
|
if (duckdb_query(ctx->con, StringValueCStr(str), &(ctxr->result)) == DuckDBError) {
|
81
|
-
rb_raise(eDuckDBError, "%s", ctxr->result
|
81
|
+
rb_raise(eDuckDBError, "%s", duckdb_result_error(&(ctxr->result)));
|
82
82
|
}
|
83
83
|
return result;
|
84
84
|
}
|
85
85
|
|
86
|
-
void init_duckdb_connection(void)
|
87
|
-
{
|
86
|
+
void init_duckdb_connection(void) {
|
88
87
|
cDuckDBConnection = rb_define_class_under(mDuckDB, "Connection", rb_cObject);
|
89
88
|
rb_define_alloc_func(cDuckDBConnection, allocate);
|
90
89
|
|