duckdb 0.3.4.0 → 0.5.1
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 +10 -3
- data/.github/workflows/test_on_ubuntu.yml +10 -4
- data/.github/workflows/test_on_windows.yml +10 -3
- data/CHANGELOG.md +16 -0
- data/Gemfile.lock +4 -4
- data/README.md +9 -9
- data/duckdb.gemspec +1 -1
- data/ext/duckdb/appender.c +38 -37
- data/ext/duckdb/column.c +30 -13
- data/ext/duckdb/config.c +21 -9
- data/ext/duckdb/config.h +2 -6
- data/ext/duckdb/connection.c +25 -8
- data/ext/duckdb/connection.h +1 -0
- data/ext/duckdb/database.c +22 -9
- data/ext/duckdb/database.h +1 -0
- data/ext/duckdb/duckdb.c +0 -5
- data/ext/duckdb/extconf.rb +1 -6
- data/ext/duckdb/prepared_statement.c +39 -25
- data/ext/duckdb/result.c +238 -77
- data/ext/duckdb/result.h +1 -0
- data/ext/duckdb/ruby-duckdb.h +0 -5
- data/ext/duckdb/util.c +0 -3
- data/ext/duckdb/util.h +0 -4
- data/lib/duckdb/result.rb +50 -0
- data/lib/duckdb/version.rb +1 -1
- metadata +5 -5
data/ext/duckdb/config.h
CHANGED
@@ -1,18 +1,14 @@
|
|
1
1
|
#ifndef RUBY_DUCKDB_CONFIG_H
|
2
2
|
#define RUBY_DUCKDB_CONFIG_H
|
3
3
|
|
4
|
-
#ifdef HAVE_DUCKDB_CREATE_CONFIG
|
5
|
-
|
6
4
|
struct _rubyDuckDBConfig {
|
7
5
|
duckdb_config config;
|
8
6
|
};
|
9
7
|
|
10
8
|
typedef struct _rubyDuckDBConfig rubyDuckDBConfig;
|
11
9
|
|
12
|
-
|
10
|
+
rubyDuckDBConfig *get_struct_config(VALUE obj);
|
13
11
|
|
14
|
-
|
12
|
+
void init_duckdb_config(void);
|
15
13
|
|
16
14
|
#endif
|
17
|
-
|
18
|
-
|
data/ext/duckdb/connection.c
CHANGED
@@ -4,10 +4,17 @@ VALUE cDuckDBConnection;
|
|
4
4
|
|
5
5
|
static void deallocate(void *ctx);
|
6
6
|
static VALUE allocate(VALUE klass);
|
7
|
+
static size_t memsize(const void *p);
|
7
8
|
static VALUE duckdb_connection_disconnect(VALUE self);
|
8
9
|
static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase);
|
9
10
|
static VALUE duckdb_connection_query_sql(VALUE self, VALUE str);
|
10
11
|
|
12
|
+
static const rb_data_type_t connection_data_type = {
|
13
|
+
"DuckDB/Connection",
|
14
|
+
{NULL, deallocate, memsize,},
|
15
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
16
|
+
};
|
17
|
+
|
11
18
|
static void deallocate(void *ctx) {
|
12
19
|
rubyDuckDBConnection *p = (rubyDuckDBConnection *)ctx;
|
13
20
|
|
@@ -17,7 +24,17 @@ static void deallocate(void *ctx) {
|
|
17
24
|
|
18
25
|
static VALUE allocate(VALUE klass) {
|
19
26
|
rubyDuckDBConnection *ctx = xcalloc((size_t)1, sizeof(rubyDuckDBConnection));
|
20
|
-
return
|
27
|
+
return TypedData_Wrap_Struct(klass, &connection_data_type, ctx);
|
28
|
+
}
|
29
|
+
|
30
|
+
static size_t memsize(const void *p) {
|
31
|
+
return sizeof(rubyDuckDBConnection);
|
32
|
+
}
|
33
|
+
|
34
|
+
rubyDuckDBConnection *get_struct_connection(VALUE obj) {
|
35
|
+
rubyDuckDBConnection *ctx;
|
36
|
+
TypedData_Get_Struct(obj, rubyDuckDBConnection, &connection_data_type, ctx);
|
37
|
+
return ctx;
|
21
38
|
}
|
22
39
|
|
23
40
|
VALUE create_connection(VALUE oDuckDBDatabase) {
|
@@ -25,10 +42,10 @@ VALUE create_connection(VALUE oDuckDBDatabase) {
|
|
25
42
|
rubyDuckDBConnection *ctxcon;
|
26
43
|
VALUE obj;
|
27
44
|
|
28
|
-
|
45
|
+
ctxdb = get_struct_database(oDuckDBDatabase);
|
29
46
|
|
30
47
|
obj = allocate(cDuckDBConnection);
|
31
|
-
|
48
|
+
TypedData_Get_Struct(obj, rubyDuckDBConnection, &connection_data_type, ctxcon);
|
32
49
|
|
33
50
|
if (duckdb_connect(ctxdb->db, &(ctxcon->con)) == DuckDBError) {
|
34
51
|
rb_raise(eDuckDBError, "connection error");
|
@@ -41,7 +58,7 @@ VALUE create_connection(VALUE oDuckDBDatabase) {
|
|
41
58
|
static VALUE duckdb_connection_disconnect(VALUE self) {
|
42
59
|
rubyDuckDBConnection *ctx;
|
43
60
|
|
44
|
-
|
61
|
+
TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
|
45
62
|
duckdb_disconnect(&(ctx->con));
|
46
63
|
|
47
64
|
return self;
|
@@ -54,8 +71,8 @@ static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase) {
|
|
54
71
|
if (!rb_obj_is_kind_of(oDuckDBDatabase, cDuckDBDatabase)) {
|
55
72
|
rb_raise(rb_eTypeError, "The first argument must be DuckDB::Database object.");
|
56
73
|
}
|
57
|
-
|
58
|
-
|
74
|
+
ctxdb = get_struct_database(oDuckDBDatabase);
|
75
|
+
TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
|
59
76
|
|
60
77
|
if (duckdb_connect(ctxdb->db, &(ctx->con)) == DuckDBError) {
|
61
78
|
rb_raise(eDuckDBError, "connection error");
|
@@ -70,8 +87,8 @@ static VALUE duckdb_connection_query_sql(VALUE self, VALUE str) {
|
|
70
87
|
|
71
88
|
VALUE result = create_result();
|
72
89
|
|
73
|
-
|
74
|
-
|
90
|
+
TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
|
91
|
+
ctxr = get_struct_result(result);
|
75
92
|
|
76
93
|
if (!(ctx->con)) {
|
77
94
|
rb_raise(eDuckDBError, "Database connection closed");
|
data/ext/duckdb/connection.h
CHANGED
data/ext/duckdb/database.c
CHANGED
@@ -5,11 +5,18 @@ VALUE cDuckDBDatabase;
|
|
5
5
|
static void close_database(rubyDuckDB *p);
|
6
6
|
static void deallocate(void * ctx);
|
7
7
|
static VALUE allocate(VALUE klass);
|
8
|
+
static size_t memsize(const void *p);
|
8
9
|
static VALUE duckdb_database_s_open(int argc, VALUE *argv, VALUE cDuckDBDatabase);
|
9
10
|
static VALUE duckdb_database_s_open_ext(int argc, VALUE *argv, VALUE cDuckDBDatabase);
|
10
11
|
static VALUE duckdb_database_connect(VALUE self);
|
11
12
|
static VALUE duckdb_database_close(VALUE self);
|
12
13
|
|
14
|
+
static const rb_data_type_t database_data_type = {
|
15
|
+
"DuckDB/Database",
|
16
|
+
{NULL, deallocate, memsize,},
|
17
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
18
|
+
};
|
19
|
+
|
13
20
|
static void close_database(rubyDuckDB *p) {
|
14
21
|
duckdb_close(&(p->db));
|
15
22
|
}
|
@@ -21,9 +28,19 @@ static void deallocate(void * ctx) {
|
|
21
28
|
xfree(p);
|
22
29
|
}
|
23
30
|
|
31
|
+
static size_t memsize(const void *p) {
|
32
|
+
return sizeof(rubyDuckDB);
|
33
|
+
}
|
34
|
+
|
24
35
|
static VALUE allocate(VALUE klass) {
|
25
36
|
rubyDuckDB *ctx = xcalloc((size_t)1, sizeof(rubyDuckDB));
|
26
|
-
return
|
37
|
+
return TypedData_Wrap_Struct(klass, &database_data_type, ctx);
|
38
|
+
}
|
39
|
+
|
40
|
+
rubyDuckDB *get_struct_database(VALUE obj) {
|
41
|
+
rubyDuckDB *ctx;
|
42
|
+
TypedData_Get_Struct(obj, rubyDuckDB, &database_data_type, ctx);
|
43
|
+
return ctx;
|
27
44
|
}
|
28
45
|
|
29
46
|
static VALUE duckdb_database_s_open(int argc, VALUE *argv, VALUE cDuckDBDatabase) {
|
@@ -40,14 +57,13 @@ static VALUE duckdb_database_s_open(int argc, VALUE *argv, VALUE cDuckDBDatabase
|
|
40
57
|
}
|
41
58
|
|
42
59
|
obj = allocate(cDuckDBDatabase);
|
43
|
-
|
60
|
+
TypedData_Get_Struct(obj, rubyDuckDB, &database_data_type, ctx);
|
44
61
|
if (duckdb_open(pfile, &(ctx->db)) == DuckDBError) {
|
45
62
|
rb_raise(eDuckDBError, "Failed to open database"); /* FIXME */
|
46
63
|
}
|
47
64
|
return obj;
|
48
65
|
}
|
49
66
|
|
50
|
-
#ifdef HAVE_DUCKDB_OPEN_EXT
|
51
67
|
static VALUE duckdb_database_s_open_ext(int argc, VALUE *argv, VALUE cDuckDBDatabase) {
|
52
68
|
rubyDuckDB *ctx;
|
53
69
|
VALUE obj;
|
@@ -65,12 +81,12 @@ static VALUE duckdb_database_s_open_ext(int argc, VALUE *argv, VALUE cDuckDBData
|
|
65
81
|
}
|
66
82
|
|
67
83
|
obj = allocate(cDuckDBDatabase);
|
68
|
-
|
84
|
+
TypedData_Get_Struct(obj, rubyDuckDB, &database_data_type, ctx);
|
69
85
|
if (!NIL_P(config)) {
|
70
86
|
if (!rb_obj_is_kind_of(config, cDuckDBConfig)) {
|
71
87
|
rb_raise(rb_eTypeError, "The second argument must be DuckDB::Config object.");
|
72
88
|
}
|
73
|
-
|
89
|
+
ctx_config = get_struct_config(config);
|
74
90
|
if (duckdb_open_ext(pfile, &(ctx->db), ctx_config->config, &perror) == DuckDBError) {
|
75
91
|
rb_raise(eDuckDBError, "Failed to open database %s", perror);
|
76
92
|
}
|
@@ -81,7 +97,6 @@ static VALUE duckdb_database_s_open_ext(int argc, VALUE *argv, VALUE cDuckDBData
|
|
81
97
|
}
|
82
98
|
return obj;
|
83
99
|
}
|
84
|
-
#endif /* HAVE_DUCKDB_OPEN_EXT */
|
85
100
|
|
86
101
|
static VALUE duckdb_database_connect(VALUE self) {
|
87
102
|
return create_connection(self);
|
@@ -95,7 +110,7 @@ static VALUE duckdb_database_connect(VALUE self) {
|
|
95
110
|
*/
|
96
111
|
static VALUE duckdb_database_close(VALUE self) {
|
97
112
|
rubyDuckDB *ctx;
|
98
|
-
|
113
|
+
TypedData_Get_Struct(self, rubyDuckDB, &database_data_type, ctx);
|
99
114
|
close_database(ctx);
|
100
115
|
return self;
|
101
116
|
}
|
@@ -104,9 +119,7 @@ void init_duckdb_database(void) {
|
|
104
119
|
cDuckDBDatabase = rb_define_class_under(mDuckDB, "Database", rb_cObject);
|
105
120
|
rb_define_alloc_func(cDuckDBDatabase, allocate);
|
106
121
|
rb_define_singleton_method(cDuckDBDatabase, "_open", duckdb_database_s_open, -1);
|
107
|
-
#ifdef HAVE_DUCKDB_OPEN_EXT
|
108
122
|
rb_define_singleton_method(cDuckDBDatabase, "_open_ext", duckdb_database_s_open_ext, -1);
|
109
|
-
#endif
|
110
123
|
rb_define_private_method(cDuckDBDatabase, "_connect", duckdb_database_connect, 0);
|
111
124
|
rb_define_method(cDuckDBDatabase, "close", duckdb_database_close, 0);
|
112
125
|
}
|
data/ext/duckdb/database.h
CHANGED
data/ext/duckdb/duckdb.c
CHANGED
@@ -13,12 +13,7 @@ Init_duckdb_native(void) {
|
|
13
13
|
init_duckdb_column();
|
14
14
|
init_duckdb_prepared_statement();
|
15
15
|
init_duckdb_blob();
|
16
|
-
|
17
16
|
init_duckdb_appender();
|
18
|
-
|
19
|
-
#ifdef HAVE_DUCKDB_CREATE_CONFIG
|
20
|
-
|
21
17
|
init_duckdb_config();
|
22
18
|
|
23
|
-
#endif /* HAVE_DUCKDB_CREATE_CONFIG */
|
24
19
|
}
|
data/ext/duckdb/extconf.rb
CHANGED
@@ -6,15 +6,10 @@ raise 'duckdb library is not found. Install duckdb library file and header file.
|
|
6
6
|
|
7
7
|
raise 'duckdb >= 0.2.9 is required. Install duckdb >= 0.2.9' unless have_func('duckdb_value_is_null', 'duckdb.h')
|
8
8
|
|
9
|
+
# check duckdb >= 0.3.3
|
9
10
|
# ducdb >= 0.3.3 if duckdb_append_data_chunk() is defined.
|
10
11
|
have_func('duckdb_append_data_chunk', 'duckdb.h')
|
11
12
|
|
12
13
|
have_func('duckdb_free', 'duckdb.h')
|
13
14
|
|
14
|
-
have_func('duckdb_create_config', 'duckdb.h')
|
15
|
-
have_func('duckdb_open_ext', 'duckdb.h')
|
16
|
-
have_func('duckdb_prepare_error', 'duckdb.h')
|
17
|
-
|
18
|
-
have_func('duckdb_append_date', 'duckdb.h')
|
19
|
-
|
20
15
|
create_makefile('duckdb/duckdb_native')
|
@@ -4,6 +4,7 @@ static VALUE cDuckDBPreparedStatement;
|
|
4
4
|
|
5
5
|
static void deallocate(void *ctx);
|
6
6
|
static VALUE allocate(VALUE klass);
|
7
|
+
static size_t memsize(const void *p);
|
7
8
|
static VALUE duckdb_prepared_statement_initialize(VALUE self, VALUE con, VALUE query);
|
8
9
|
static VALUE duckdb_prepared_statement_nparams(VALUE self);
|
9
10
|
static VALUE duckdb_prepared_statement_execute(VALUE self);
|
@@ -23,6 +24,12 @@ static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE
|
|
23
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);
|
24
25
|
static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VALUE months, VALUE days, VALUE micros);
|
25
26
|
|
27
|
+
static const rb_data_type_t prepared_statement_data_type = {
|
28
|
+
"DuckDB/PreparedStatement",
|
29
|
+
{NULL, deallocate, memsize,},
|
30
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
31
|
+
};
|
32
|
+
|
26
33
|
static void deallocate(void *ctx) {
|
27
34
|
rubyDuckDBPreparedStatement *p = (rubyDuckDBPreparedStatement *)ctx;
|
28
35
|
|
@@ -32,7 +39,11 @@ static void deallocate(void *ctx) {
|
|
32
39
|
|
33
40
|
static VALUE allocate(VALUE klass) {
|
34
41
|
rubyDuckDBPreparedStatement *ctx = xcalloc((size_t)1, sizeof(rubyDuckDBPreparedStatement));
|
35
|
-
return
|
42
|
+
return TypedData_Wrap_Struct(klass, &prepared_statement_data_type, ctx);
|
43
|
+
}
|
44
|
+
|
45
|
+
static size_t memsize(const void *p) {
|
46
|
+
return sizeof(rubyDuckDBPreparedStatement);
|
36
47
|
}
|
37
48
|
|
38
49
|
static VALUE duckdb_prepared_statement_initialize(VALUE self, VALUE con, VALUE query) {
|
@@ -43,24 +54,19 @@ static VALUE duckdb_prepared_statement_initialize(VALUE self, VALUE con, VALUE q
|
|
43
54
|
rb_raise(rb_eTypeError, "1st argument should be instance of DackDB::Connection");
|
44
55
|
}
|
45
56
|
|
46
|
-
|
47
|
-
|
57
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
58
|
+
ctxcon = get_struct_connection(con);
|
48
59
|
|
49
60
|
if (duckdb_prepare(ctxcon->con, StringValuePtr(query), &(ctx->prepared_statement)) == DuckDBError) {
|
50
|
-
#ifdef HAVE_DUCKDB_PREPARE_ERROR
|
51
61
|
const char *error = duckdb_prepare_error(ctx->prepared_statement);
|
52
62
|
rb_raise(eDuckDBError, "%s", error);
|
53
|
-
#else
|
54
|
-
/* TODO: include query parameter information in error message. */
|
55
|
-
rb_raise(eDuckDBError, "failed to prepare statement");
|
56
|
-
#endif
|
57
63
|
}
|
58
64
|
return self;
|
59
65
|
}
|
60
66
|
|
61
67
|
static VALUE duckdb_prepared_statement_nparams(VALUE self) {
|
62
68
|
rubyDuckDBPreparedStatement *ctx;
|
63
|
-
|
69
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
64
70
|
return rb_int2big(duckdb_nparams(ctx->prepared_statement));
|
65
71
|
}
|
66
72
|
|
@@ -70,8 +76,8 @@ static VALUE duckdb_prepared_statement_execute(VALUE self) {
|
|
70
76
|
rubyDuckDBResult *ctxr;
|
71
77
|
VALUE result = create_result();
|
72
78
|
|
73
|
-
|
74
|
-
|
79
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
80
|
+
ctxr = get_struct_result(result);
|
75
81
|
if (duckdb_execute_prepared(ctx->prepared_statement, &(ctxr->result)) == DuckDBError) {
|
76
82
|
rb_raise(eDuckDBError, "%s", duckdb_result_error(&(ctxr->result)));
|
77
83
|
}
|
@@ -90,7 +96,7 @@ static VALUE duckdb_prepared_statement_bind_bool(VALUE self, VALUE vidx, VALUE v
|
|
90
96
|
rubyDuckDBPreparedStatement *ctx;
|
91
97
|
idx_t idx = check_index(vidx);
|
92
98
|
|
93
|
-
|
99
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
94
100
|
if (val != Qtrue && val != Qfalse) {
|
95
101
|
rb_raise(rb_eArgError, "binding value must be boolean");
|
96
102
|
}
|
@@ -106,7 +112,7 @@ static VALUE duckdb_prepared_statement_bind_int8(VALUE self, VALUE vidx, VALUE v
|
|
106
112
|
idx_t idx = check_index(vidx);
|
107
113
|
int8_t i8val = (int8_t)NUM2INT(val);
|
108
114
|
|
109
|
-
|
115
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
110
116
|
|
111
117
|
if (duckdb_bind_int8(ctx->prepared_statement, idx, i8val) == DuckDBError) {
|
112
118
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
@@ -119,7 +125,7 @@ static VALUE duckdb_prepared_statement_bind_int16(VALUE self, VALUE vidx, VALUE
|
|
119
125
|
idx_t idx = check_index(vidx);
|
120
126
|
int16_t i16val = NUM2INT(val);
|
121
127
|
|
122
|
-
|
128
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
123
129
|
|
124
130
|
if (duckdb_bind_int16(ctx->prepared_statement, idx, i16val) == DuckDBError) {
|
125
131
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
@@ -132,7 +138,7 @@ static VALUE duckdb_prepared_statement_bind_int32(VALUE self, VALUE vidx, VALUE
|
|
132
138
|
idx_t idx = check_index(vidx);
|
133
139
|
int32_t i32val = NUM2INT(val);
|
134
140
|
|
135
|
-
|
141
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
136
142
|
|
137
143
|
if (duckdb_bind_int32(ctx->prepared_statement, idx, i32val) == DuckDBError) {
|
138
144
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
@@ -145,7 +151,7 @@ static VALUE duckdb_prepared_statement_bind_int64(VALUE self, VALUE vidx, VALUE
|
|
145
151
|
idx_t idx = check_index(vidx);
|
146
152
|
int64_t i64val = NUM2LL(val);
|
147
153
|
|
148
|
-
|
154
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
149
155
|
|
150
156
|
if (duckdb_bind_int64(ctx->prepared_statement, idx, i64val) == DuckDBError) {
|
151
157
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
@@ -158,7 +164,7 @@ static VALUE duckdb_prepared_statement_bind_float(VALUE self, VALUE vidx, VALUE
|
|
158
164
|
idx_t idx = check_index(vidx);
|
159
165
|
double dbl = NUM2DBL(val);
|
160
166
|
|
161
|
-
|
167
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
162
168
|
|
163
169
|
if (duckdb_bind_float(ctx->prepared_statement, idx, (float)dbl) == DuckDBError) {
|
164
170
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
@@ -171,7 +177,7 @@ static VALUE duckdb_prepared_statement_bind_double(VALUE self, VALUE vidx, VALUE
|
|
171
177
|
idx_t idx = check_index(vidx);
|
172
178
|
double dbl = NUM2DBL(val);
|
173
179
|
|
174
|
-
|
180
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
175
181
|
|
176
182
|
if (duckdb_bind_double(ctx->prepared_statement, idx, dbl) == DuckDBError) {
|
177
183
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
@@ -183,7 +189,8 @@ static VALUE duckdb_prepared_statement_bind_varchar(VALUE self, VALUE vidx, VALU
|
|
183
189
|
rubyDuckDBPreparedStatement *ctx;
|
184
190
|
idx_t idx = check_index(vidx);
|
185
191
|
|
186
|
-
|
192
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
193
|
+
|
187
194
|
if (duckdb_bind_varchar(ctx->prepared_statement, idx, StringValuePtr(str)) == DuckDBError) {
|
188
195
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
189
196
|
}
|
@@ -194,7 +201,8 @@ static VALUE duckdb_prepared_statement_bind_blob(VALUE self, VALUE vidx, VALUE b
|
|
194
201
|
rubyDuckDBPreparedStatement *ctx;
|
195
202
|
idx_t idx = check_index(vidx);
|
196
203
|
|
197
|
-
|
204
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
205
|
+
|
198
206
|
if (duckdb_bind_blob(ctx->prepared_statement, idx, (const void *)StringValuePtr(blob), (idx_t)RSTRING_LEN(blob)) == DuckDBError) {
|
199
207
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
200
208
|
}
|
@@ -205,7 +213,8 @@ static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx) {
|
|
205
213
|
rubyDuckDBPreparedStatement *ctx;
|
206
214
|
idx_t idx = check_index(vidx);
|
207
215
|
|
208
|
-
|
216
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
217
|
+
|
209
218
|
if (duckdb_bind_null(ctx->prepared_statement, idx) == DuckDBError) {
|
210
219
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
211
220
|
}
|
@@ -219,10 +228,12 @@ static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE
|
|
219
228
|
|
220
229
|
dt = to_duckdb_date_from_value(year, month, day);
|
221
230
|
|
222
|
-
|
231
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
232
|
+
|
223
233
|
if (duckdb_bind_date(ctx->prepared_statement, idx, dt) == DuckDBError) {
|
224
234
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
225
235
|
}
|
236
|
+
|
226
237
|
return self;
|
227
238
|
}
|
228
239
|
|
@@ -234,10 +245,12 @@ static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE
|
|
234
245
|
|
235
246
|
time = to_duckdb_time_from_value(hour, min, sec, micros);
|
236
247
|
|
237
|
-
|
248
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
249
|
+
|
238
250
|
if (duckdb_bind_time(ctx->prepared_statement, idx, time) == DuckDBError) {
|
239
251
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
240
252
|
}
|
253
|
+
|
241
254
|
return self;
|
242
255
|
}
|
243
256
|
|
@@ -247,7 +260,7 @@ static VALUE duckdb_prepared_statement__bind_timestamp(VALUE self, VALUE vidx, V
|
|
247
260
|
idx_t idx = check_index(vidx);
|
248
261
|
|
249
262
|
timestamp = to_duckdb_timestamp_from_value(year, month, day, hour, min, sec, micros);
|
250
|
-
|
263
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
251
264
|
|
252
265
|
if (duckdb_bind_timestamp(ctx->prepared_statement, idx, timestamp) == DuckDBError) {
|
253
266
|
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
@@ -260,7 +273,8 @@ static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VA
|
|
260
273
|
rubyDuckDBPreparedStatement *ctx;
|
261
274
|
idx_t idx = check_index(vidx);
|
262
275
|
|
263
|
-
|
276
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
277
|
+
|
264
278
|
to_duckdb_interval_from_value(&interval, months, days, micros);
|
265
279
|
|
266
280
|
if (duckdb_bind_interval(ctx->prepared_statement, idx, interval) == DuckDBError) {
|