duckdb 1.1.3.1 → 1.2.0.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/make_documents.yml +34 -0
- data/.github/workflows/test_on_macos.yml +2 -3
- data/.github/workflows/test_on_ubuntu.yml +2 -2
- data/.github/workflows/test_on_windows.yml +2 -2
- data/.gitignore +1 -0
- data/.rdoc_options +22 -0
- data/CHANGELOG.md +45 -0
- data/Dockerfile +2 -2
- data/Gemfile.lock +14 -12
- data/README.md +2 -1
- data/duckdb.gemspec +1 -0
- data/ext/duckdb/appender.c +92 -79
- data/ext/duckdb/blob.c +3 -0
- data/ext/duckdb/column.c +33 -3
- data/ext/duckdb/config.c +3 -0
- data/ext/duckdb/connection.c +6 -0
- data/ext/duckdb/database.c +6 -0
- data/ext/duckdb/duckdb.c +1 -0
- data/ext/duckdb/error.c +3 -0
- data/ext/duckdb/extconf.rb +0 -3
- data/ext/duckdb/extracted_statements.c +3 -0
- data/ext/duckdb/logical_type.c +187 -0
- data/ext/duckdb/logical_type.h +13 -0
- data/ext/duckdb/pending_result.c +5 -0
- data/ext/duckdb/prepared_statement.c +43 -6
- data/ext/duckdb/result.c +16 -44
- data/ext/duckdb/ruby-duckdb.h +2 -0
- data/lib/duckdb/appender.rb +211 -48
- data/lib/duckdb/column.rb +0 -2
- data/lib/duckdb/interval.rb +12 -10
- data/lib/duckdb/logical_type.rb +22 -0
- data/lib/duckdb/pending_result.rb +1 -1
- data/lib/duckdb/result.rb +16 -16
- data/lib/duckdb/version.rb +1 -1
- data/lib/duckdb.rb +1 -0
- metadata +9 -6
data/ext/duckdb/column.c
CHANGED
@@ -6,6 +6,7 @@ static void deallocate(void *ctx);
|
|
6
6
|
static VALUE allocate(VALUE klass);
|
7
7
|
static size_t memsize(const void *p);
|
8
8
|
static VALUE duckdb_column__type(VALUE oDuckDBColumn);
|
9
|
+
static VALUE duckdb_column__logical_type(VALUE oDuckDBColumn);
|
9
10
|
static VALUE duckdb_column_get_name(VALUE oDuckDBColumn);
|
10
11
|
|
11
12
|
static const rb_data_type_t column_data_type = {
|
@@ -29,9 +30,7 @@ static size_t memsize(const void *p) {
|
|
29
30
|
return sizeof(rubyDuckDBColumn);
|
30
31
|
}
|
31
32
|
|
32
|
-
/*
|
33
|
-
*
|
34
|
-
*/
|
33
|
+
/* :nodoc: */
|
35
34
|
VALUE duckdb_column__type(VALUE oDuckDBColumn) {
|
36
35
|
rubyDuckDBColumn *ctx;
|
37
36
|
rubyDuckDBResult *ctxresult;
|
@@ -47,6 +46,33 @@ VALUE duckdb_column__type(VALUE oDuckDBColumn) {
|
|
47
46
|
return INT2FIX(type);
|
48
47
|
}
|
49
48
|
|
49
|
+
/*
|
50
|
+
* call-seq:
|
51
|
+
* column.logical_type -> DuckDB::LogicalType
|
52
|
+
*
|
53
|
+
* Returns the logical type class.
|
54
|
+
*
|
55
|
+
*/
|
56
|
+
VALUE duckdb_column__logical_type(VALUE oDuckDBColumn) {
|
57
|
+
rubyDuckDBColumn *ctx;
|
58
|
+
rubyDuckDBResult *ctxresult;
|
59
|
+
VALUE result;
|
60
|
+
duckdb_logical_type _logical_type;
|
61
|
+
VALUE logical_type = Qnil;
|
62
|
+
|
63
|
+
TypedData_Get_Struct(oDuckDBColumn, rubyDuckDBColumn, &column_data_type, ctx);
|
64
|
+
|
65
|
+
result = rb_ivar_get(oDuckDBColumn, rb_intern("result"));
|
66
|
+
ctxresult = get_struct_result(result);
|
67
|
+
_logical_type = duckdb_column_logical_type(&(ctxresult->result), ctx->col);
|
68
|
+
|
69
|
+
if (_logical_type) {
|
70
|
+
logical_type = rbduckdb_create_logical_type(_logical_type);
|
71
|
+
}
|
72
|
+
|
73
|
+
return logical_type;
|
74
|
+
}
|
75
|
+
|
50
76
|
/*
|
51
77
|
* call-seq:
|
52
78
|
* column.name -> string.
|
@@ -82,9 +108,13 @@ VALUE rbduckdb_create_column(VALUE oDuckDBResult, idx_t col) {
|
|
82
108
|
}
|
83
109
|
|
84
110
|
void rbduckdb_init_duckdb_column(void) {
|
111
|
+
#if 0
|
112
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
113
|
+
#endif
|
85
114
|
cDuckDBColumn = rb_define_class_under(mDuckDB, "Column", rb_cObject);
|
86
115
|
rb_define_alloc_func(cDuckDBColumn, allocate);
|
87
116
|
|
88
117
|
rb_define_private_method(cDuckDBColumn, "_type", duckdb_column__type, 0);
|
118
|
+
rb_define_method(cDuckDBColumn, "logical_type", duckdb_column__logical_type, 0);
|
89
119
|
rb_define_method(cDuckDBColumn, "name", duckdb_column_get_name, 0);
|
90
120
|
}
|
data/ext/duckdb/config.c
CHANGED
@@ -80,6 +80,9 @@ static VALUE config_set_config(VALUE self, VALUE key, VALUE value) {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
void rbduckdb_init_duckdb_config(void) {
|
83
|
+
#if 0
|
84
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
85
|
+
#endif
|
83
86
|
cDuckDBConfig = rb_define_class_under(mDuckDB, "Config", rb_cObject);
|
84
87
|
rb_define_alloc_func(cDuckDBConfig, allocate);
|
85
88
|
rb_define_singleton_method(cDuckDBConfig, "size", config_s_size, 0);
|
data/ext/duckdb/connection.c
CHANGED
@@ -114,6 +114,7 @@ static VALUE duckdb_connection_query_progress(VALUE self) {
|
|
114
114
|
return rb_funcall(mDuckDBConverter, rb_intern("_to_query_progress"), 3, DBL2NUM(progress.percentage), ULL2NUM(progress.rows_processed), ULL2NUM(progress.total_rows_to_process));
|
115
115
|
}
|
116
116
|
|
117
|
+
/* :nodoc: */
|
117
118
|
static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase) {
|
118
119
|
rubyDuckDBConnection *ctx;
|
119
120
|
rubyDuckDB *ctxdb;
|
@@ -131,6 +132,7 @@ static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase) {
|
|
131
132
|
return self;
|
132
133
|
}
|
133
134
|
|
135
|
+
/* :nodoc: */
|
134
136
|
static VALUE duckdb_connection_query_sql(VALUE self, VALUE str) {
|
135
137
|
rubyDuckDBConnection *ctx;
|
136
138
|
rubyDuckDBResult *ctxr;
|
@@ -151,6 +153,9 @@ static VALUE duckdb_connection_query_sql(VALUE self, VALUE str) {
|
|
151
153
|
}
|
152
154
|
|
153
155
|
void rbduckdb_init_duckdb_connection(void) {
|
156
|
+
#if 0
|
157
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
158
|
+
#endif
|
154
159
|
cDuckDBConnection = rb_define_class_under(mDuckDB, "Connection", rb_cObject);
|
155
160
|
rb_define_alloc_func(cDuckDBConnection, allocate);
|
156
161
|
|
@@ -158,5 +163,6 @@ void rbduckdb_init_duckdb_connection(void) {
|
|
158
163
|
rb_define_method(cDuckDBConnection, "interrupt", duckdb_connection_interrupt, 0);
|
159
164
|
rb_define_method(cDuckDBConnection, "query_progress", duckdb_connection_query_progress, 0);
|
160
165
|
rb_define_private_method(cDuckDBConnection, "_connect", duckdb_connection_connect, 1);
|
166
|
+
/* TODO: query_sql => _query_sql */
|
161
167
|
rb_define_private_method(cDuckDBConnection, "query_sql", duckdb_connection_query_sql, 1);
|
162
168
|
}
|
data/ext/duckdb/database.c
CHANGED
@@ -43,6 +43,7 @@ rubyDuckDB *rbduckdb_get_struct_database(VALUE obj) {
|
|
43
43
|
return ctx;
|
44
44
|
}
|
45
45
|
|
46
|
+
/* :nodoc: */
|
46
47
|
static VALUE duckdb_database_s_open(int argc, VALUE *argv, VALUE cDuckDBDatabase) {
|
47
48
|
rubyDuckDB *ctx;
|
48
49
|
VALUE obj;
|
@@ -64,6 +65,7 @@ static VALUE duckdb_database_s_open(int argc, VALUE *argv, VALUE cDuckDBDatabase
|
|
64
65
|
return obj;
|
65
66
|
}
|
66
67
|
|
68
|
+
/* :nodoc: */
|
67
69
|
static VALUE duckdb_database_s_open_ext(int argc, VALUE *argv, VALUE cDuckDBDatabase) {
|
68
70
|
rubyDuckDB *ctx;
|
69
71
|
VALUE obj;
|
@@ -98,6 +100,7 @@ static VALUE duckdb_database_s_open_ext(int argc, VALUE *argv, VALUE cDuckDBData
|
|
98
100
|
return obj;
|
99
101
|
}
|
100
102
|
|
103
|
+
/* :nodoc: */
|
101
104
|
static VALUE duckdb_database_connect(VALUE self) {
|
102
105
|
return rbduckdb_create_connection(self);
|
103
106
|
}
|
@@ -116,6 +119,9 @@ static VALUE duckdb_database_close(VALUE self) {
|
|
116
119
|
}
|
117
120
|
|
118
121
|
void rbduckdb_init_duckdb_database(void) {
|
122
|
+
#if 0
|
123
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
124
|
+
#endif
|
119
125
|
cDuckDBDatabase = rb_define_class_under(mDuckDB, "Database", rb_cObject);
|
120
126
|
rb_define_alloc_func(cDuckDBDatabase, allocate);
|
121
127
|
rb_define_singleton_method(cDuckDBDatabase, "_open", duckdb_database_s_open, -1);
|
data/ext/duckdb/duckdb.c
CHANGED
@@ -31,6 +31,7 @@ Init_duckdb_native(void) {
|
|
31
31
|
rbduckdb_init_duckdb_connection();
|
32
32
|
rbduckdb_init_duckdb_result();
|
33
33
|
rbduckdb_init_duckdb_column();
|
34
|
+
rbduckdb_init_duckdb_logical_type();
|
34
35
|
rbduckdb_init_duckdb_prepared_statement();
|
35
36
|
rbduckdb_init_duckdb_pending_result();
|
36
37
|
rbduckdb_init_duckdb_blob();
|
data/ext/duckdb/error.c
CHANGED
data/ext/duckdb/extconf.rb
CHANGED
@@ -61,9 +61,6 @@ check_duckdb_library('duckdb', 'duckdb_appender_column_count', DUCKDB_REQUIRED_V
|
|
61
61
|
# check duckdb >= 1.0.0
|
62
62
|
have_func('duckdb_fetch_chunk', 'duckdb.h')
|
63
63
|
|
64
|
-
# check duckdb >= 1.0.0
|
65
|
-
have_func('duckdb_fetch_chunk', 'duckdb.h')
|
66
|
-
|
67
64
|
# check duckdb >= 1.1.0
|
68
65
|
have_func('duckdb_result_error_type', 'duckdb.h')
|
69
66
|
|
@@ -95,6 +95,9 @@ static VALUE duckdb_extracted_statements_prepared_statement(VALUE self, VALUE co
|
|
95
95
|
}
|
96
96
|
|
97
97
|
void rbduckdb_init_duckdb_extracted_statements(void) {
|
98
|
+
#if 0
|
99
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
100
|
+
#endif
|
98
101
|
cDuckDBExtractedStatements = rb_define_class_under(mDuckDB, "ExtractedStatementsImpl", rb_cObject);
|
99
102
|
|
100
103
|
rb_define_alloc_func(cDuckDBExtractedStatements, allocate);
|
@@ -0,0 +1,187 @@
|
|
1
|
+
#include "ruby-duckdb.h"
|
2
|
+
|
3
|
+
static VALUE cDuckDBLogicalType;
|
4
|
+
|
5
|
+
static void deallocate(void *ctx);
|
6
|
+
static VALUE allocate(VALUE klass);
|
7
|
+
static size_t memsize(const void *p);
|
8
|
+
static VALUE duckdb_logical_type__type(VALUE self);
|
9
|
+
static VALUE duckdb_logical_type_width(VALUE self);
|
10
|
+
static VALUE duckdb_logical_type_scale(VALUE self);
|
11
|
+
static VALUE duckdb_logical_type_child_type(VALUE self);
|
12
|
+
static VALUE duckdb_logical_type_size(VALUE self);
|
13
|
+
static VALUE duckdb_logical_type_key_type(VALUE self);
|
14
|
+
static VALUE duckdb_logical_type_value_type(VALUE self);
|
15
|
+
|
16
|
+
static const rb_data_type_t logical_type_data_type = {
|
17
|
+
"DuckDB/LogicalType",
|
18
|
+
{NULL, deallocate, memsize,},
|
19
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
20
|
+
};
|
21
|
+
|
22
|
+
static void deallocate(void *ctx) {
|
23
|
+
rubyDuckDBLogicalType *p = (rubyDuckDBLogicalType *)ctx;
|
24
|
+
|
25
|
+
if (p->logical_type) {
|
26
|
+
duckdb_destroy_logical_type(&(p->logical_type));
|
27
|
+
}
|
28
|
+
|
29
|
+
xfree(p);
|
30
|
+
}
|
31
|
+
|
32
|
+
static VALUE allocate(VALUE klass) {
|
33
|
+
rubyDuckDBLogicalType *ctx = xcalloc((size_t)1, sizeof(rubyDuckDBLogicalType));
|
34
|
+
return TypedData_Wrap_Struct(klass, &logical_type_data_type, ctx);
|
35
|
+
}
|
36
|
+
|
37
|
+
static size_t memsize(const void *p) {
|
38
|
+
return sizeof(rubyDuckDBLogicalType);
|
39
|
+
}
|
40
|
+
|
41
|
+
/*
|
42
|
+
* call-seq:
|
43
|
+
* decimal_col.logical_type.type -> Symbol
|
44
|
+
*
|
45
|
+
* Returns the logical type's type symbol.
|
46
|
+
*
|
47
|
+
*/
|
48
|
+
static VALUE duckdb_logical_type__type(VALUE self) {
|
49
|
+
rubyDuckDBLogicalType *ctx;
|
50
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
51
|
+
return INT2FIX(duckdb_get_type_id(ctx->logical_type));
|
52
|
+
}
|
53
|
+
|
54
|
+
/*
|
55
|
+
* call-seq:
|
56
|
+
* decimal_col.logical_type.width -> Integer
|
57
|
+
*
|
58
|
+
* Returns the width of the decimal column.
|
59
|
+
*
|
60
|
+
*/
|
61
|
+
static VALUE duckdb_logical_type_width(VALUE self) {
|
62
|
+
rubyDuckDBLogicalType *ctx;
|
63
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
64
|
+
return INT2FIX(duckdb_decimal_width(ctx->logical_type));
|
65
|
+
}
|
66
|
+
|
67
|
+
/*
|
68
|
+
* call-seq:
|
69
|
+
* decimal_col.logical_type.scale -> Integer
|
70
|
+
*
|
71
|
+
* Returns the scale of the decimal column.
|
72
|
+
*
|
73
|
+
*/
|
74
|
+
static VALUE duckdb_logical_type_scale(VALUE self) {
|
75
|
+
rubyDuckDBLogicalType *ctx;
|
76
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
77
|
+
return INT2FIX(duckdb_decimal_scale(ctx->logical_type));
|
78
|
+
}
|
79
|
+
|
80
|
+
/*
|
81
|
+
* call-seq:
|
82
|
+
* list_col.logical_type.child_type -> DuckDB::LogicalType
|
83
|
+
*
|
84
|
+
* Returns the child logical type for list and map types, otherwise nil.
|
85
|
+
*
|
86
|
+
*/
|
87
|
+
static VALUE duckdb_logical_type_child_type(VALUE self) {
|
88
|
+
rubyDuckDBLogicalType *ctx;
|
89
|
+
duckdb_type type_id;
|
90
|
+
duckdb_logical_type child_logical_type;
|
91
|
+
VALUE logical_type = Qnil;
|
92
|
+
|
93
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
94
|
+
type_id = duckdb_get_type_id(ctx->logical_type);
|
95
|
+
|
96
|
+
switch(type_id) {
|
97
|
+
case DUCKDB_TYPE_LIST:
|
98
|
+
case DUCKDB_TYPE_MAP:
|
99
|
+
child_logical_type = duckdb_list_type_child_type(ctx->logical_type);
|
100
|
+
logical_type = rbduckdb_create_logical_type(child_logical_type);
|
101
|
+
break;
|
102
|
+
case DUCKDB_TYPE_ARRAY:
|
103
|
+
child_logical_type = duckdb_array_type_child_type(ctx->logical_type);
|
104
|
+
logical_type = rbduckdb_create_logical_type(child_logical_type);
|
105
|
+
break;
|
106
|
+
default:
|
107
|
+
logical_type = Qnil;
|
108
|
+
}
|
109
|
+
return logical_type;
|
110
|
+
}
|
111
|
+
|
112
|
+
/*
|
113
|
+
* call-seq:
|
114
|
+
* list_col.logical_type.size -> Integer
|
115
|
+
*
|
116
|
+
* Returns the size of the array column, otherwise 0.
|
117
|
+
*
|
118
|
+
*/
|
119
|
+
static VALUE duckdb_logical_type_size(VALUE self) {
|
120
|
+
rubyDuckDBLogicalType *ctx;
|
121
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
122
|
+
return INT2FIX(duckdb_array_type_array_size(ctx->logical_type));
|
123
|
+
}
|
124
|
+
|
125
|
+
/*
|
126
|
+
* call-seq:
|
127
|
+
* map_col.logical_type.key_type -> DuckDB::LogicalType
|
128
|
+
*
|
129
|
+
* Returns the key logical type for map type, otherwise nil.
|
130
|
+
*
|
131
|
+
*/
|
132
|
+
static VALUE duckdb_logical_type_key_type(VALUE self) {
|
133
|
+
rubyDuckDBLogicalType *ctx;
|
134
|
+
duckdb_logical_type key_logical_type;
|
135
|
+
VALUE logical_type = Qnil;
|
136
|
+
|
137
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
138
|
+
key_logical_type = duckdb_map_type_key_type(ctx->logical_type);
|
139
|
+
logical_type = rbduckdb_create_logical_type(key_logical_type);
|
140
|
+
return logical_type;
|
141
|
+
}
|
142
|
+
|
143
|
+
/*
|
144
|
+
* call-seq:
|
145
|
+
* map_col.logical_type.value_type -> DuckDB::LogicalType
|
146
|
+
*
|
147
|
+
* Returns the value logical type for map type, otherwise nil.
|
148
|
+
*
|
149
|
+
*/
|
150
|
+
static VALUE duckdb_logical_type_value_type(VALUE self) {
|
151
|
+
rubyDuckDBLogicalType *ctx;
|
152
|
+
duckdb_logical_type value_logical_type;
|
153
|
+
VALUE logical_type = Qnil;
|
154
|
+
|
155
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
156
|
+
value_logical_type = duckdb_map_type_value_type(ctx->logical_type);
|
157
|
+
logical_type = rbduckdb_create_logical_type(value_logical_type);
|
158
|
+
return logical_type;
|
159
|
+
}
|
160
|
+
|
161
|
+
VALUE rbduckdb_create_logical_type(duckdb_logical_type logical_type) {
|
162
|
+
VALUE obj;
|
163
|
+
rubyDuckDBLogicalType *ctx;
|
164
|
+
|
165
|
+
obj = allocate(cDuckDBLogicalType);
|
166
|
+
TypedData_Get_Struct(obj, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
167
|
+
|
168
|
+
ctx->logical_type = logical_type;
|
169
|
+
|
170
|
+
return obj;
|
171
|
+
}
|
172
|
+
|
173
|
+
void rbduckdb_init_duckdb_logical_type(void) {
|
174
|
+
#if 0
|
175
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
176
|
+
#endif
|
177
|
+
cDuckDBLogicalType = rb_define_class_under(mDuckDB, "LogicalType", rb_cObject);
|
178
|
+
rb_define_alloc_func(cDuckDBLogicalType, allocate);
|
179
|
+
|
180
|
+
rb_define_private_method(cDuckDBLogicalType, "_type", duckdb_logical_type__type, 0);
|
181
|
+
rb_define_method(cDuckDBLogicalType, "width", duckdb_logical_type_width, 0);
|
182
|
+
rb_define_method(cDuckDBLogicalType, "scale", duckdb_logical_type_scale, 0);
|
183
|
+
rb_define_method(cDuckDBLogicalType, "child_type", duckdb_logical_type_child_type, 0);
|
184
|
+
rb_define_method(cDuckDBLogicalType, "size", duckdb_logical_type_size, 0);
|
185
|
+
rb_define_method(cDuckDBLogicalType, "key_type", duckdb_logical_type_key_type, 0);
|
186
|
+
rb_define_method(cDuckDBLogicalType, "value_type", duckdb_logical_type_value_type, 0);
|
187
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#ifndef RUBY_DUCKDB_LOGICAL_TYPE_H
|
2
|
+
#define RUBY_DUCKDB_LOGICAL_TYPE_H
|
3
|
+
|
4
|
+
struct _rubyDuckDBLogicalType {
|
5
|
+
duckdb_logical_type logical_type;
|
6
|
+
};
|
7
|
+
|
8
|
+
typedef struct _rubyDuckDBLogicalType rubyDuckDBLogicalType;
|
9
|
+
|
10
|
+
void rbduckdb_init_duckdb_logical_type(void);
|
11
|
+
VALUE rbduckdb_create_logical_type(duckdb_logical_type logical_type);
|
12
|
+
|
13
|
+
#endif
|
data/ext/duckdb/pending_result.c
CHANGED
@@ -124,11 +124,13 @@ static VALUE duckdb_pending_result_execute_pending(VALUE self) {
|
|
124
124
|
return result;
|
125
125
|
}
|
126
126
|
|
127
|
+
/* :nodoc: */
|
127
128
|
static VALUE duckdb_pending_result__state(VALUE self) {
|
128
129
|
rubyDuckDBPendingResult *ctx = get_struct_pending_result(self);
|
129
130
|
return INT2FIX(ctx->state);
|
130
131
|
}
|
131
132
|
|
133
|
+
/* :nodoc: */
|
132
134
|
static VALUE duckdb_pending_result__execute_check_state(VALUE self) {
|
133
135
|
rubyDuckDBPendingResult *ctx = get_struct_pending_result(self);
|
134
136
|
return INT2FIX(duckdb_pending_execute_check_state(ctx->pending_result));
|
@@ -141,6 +143,9 @@ rubyDuckDBPendingResult *get_struct_pending_result(VALUE obj) {
|
|
141
143
|
}
|
142
144
|
|
143
145
|
void rbduckdb_init_duckdb_pending_result(void) {
|
146
|
+
#if 0
|
147
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
148
|
+
#endif
|
144
149
|
cDuckDBPendingResult = rb_define_class_under(mDuckDB, "PendingResult", rb_cObject);
|
145
150
|
rb_define_alloc_func(cDuckDBPendingResult, allocate);
|
146
151
|
|
@@ -102,21 +102,47 @@ static VALUE duckdb_prepared_statement_nparams(VALUE self) {
|
|
102
102
|
return ULL2NUM(duckdb_nparams(ctx->prepared_statement));
|
103
103
|
}
|
104
104
|
|
105
|
+
/* :nodoc: */
|
106
|
+
typedef struct {
|
107
|
+
duckdb_prepared_statement prepared_statement;
|
108
|
+
duckdb_result *out_result;
|
109
|
+
duckdb_state retval;
|
110
|
+
} duckdb_prepared_statement_execute_nogvl_args;
|
111
|
+
|
112
|
+
/* :nodoc: */
|
113
|
+
static void duckdb_prepared_statement_execute_nogvl(void *ptr) {
|
114
|
+
duckdb_prepared_statement_execute_nogvl_args *args = (duckdb_prepared_statement_execute_nogvl_args *)ptr;
|
115
|
+
|
116
|
+
args->retval = duckdb_execute_prepared(args->prepared_statement, args->out_result);
|
117
|
+
}
|
118
|
+
|
105
119
|
static VALUE duckdb_prepared_statement_execute(VALUE self) {
|
106
120
|
rubyDuckDBPreparedStatement *ctx;
|
107
121
|
rubyDuckDBResult *ctxr;
|
122
|
+
const char *error;
|
108
123
|
VALUE result = rbduckdb_create_result();
|
109
|
-
const char *p = NULL;
|
110
124
|
|
111
125
|
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
112
126
|
ctxr = get_struct_result(result);
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
127
|
+
|
128
|
+
duckdb_prepared_statement_execute_nogvl_args args = {
|
129
|
+
.prepared_statement = ctx->prepared_statement,
|
130
|
+
.out_result = &(ctxr->result),
|
131
|
+
.retval = DuckDBError,
|
132
|
+
};
|
133
|
+
|
134
|
+
rb_thread_call_without_gvl((void *)duckdb_prepared_statement_execute_nogvl, &args, RUBY_UBF_IO, 0);
|
135
|
+
duckdb_state state = args.retval;
|
136
|
+
|
137
|
+
if (state == DuckDBError) {
|
138
|
+
error = duckdb_result_error(args.out_result);
|
139
|
+
if (error == NULL) {
|
140
|
+
error = duckdb_prepare_error(args.prepared_statement);
|
117
141
|
}
|
118
|
-
|
142
|
+
|
143
|
+
rb_raise(eDuckDBError, "%s", error ? error : "Failed to execute prepared statement.");
|
119
144
|
}
|
145
|
+
|
120
146
|
return result;
|
121
147
|
}
|
122
148
|
|
@@ -316,18 +342,21 @@ static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx) {
|
|
316
342
|
return self;
|
317
343
|
}
|
318
344
|
|
345
|
+
/* :nodoc: */
|
319
346
|
static VALUE duckdb_prepared_statement__statement_type(VALUE self) {
|
320
347
|
rubyDuckDBPreparedStatement *ctx;
|
321
348
|
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
322
349
|
return INT2FIX(duckdb_prepared_statement_type(ctx->prepared_statement));
|
323
350
|
}
|
324
351
|
|
352
|
+
/* :nodoc: */
|
325
353
|
static VALUE duckdb_prepared_statement__param_type(VALUE self, VALUE vidx) {
|
326
354
|
rubyDuckDBPreparedStatement *ctx;
|
327
355
|
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
328
356
|
return INT2FIX(duckdb_param_type(ctx->prepared_statement, NUM2ULL(vidx)));
|
329
357
|
}
|
330
358
|
|
359
|
+
/* :nodoc: */
|
331
360
|
static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day) {
|
332
361
|
rubyDuckDBPreparedStatement *ctx;
|
333
362
|
duckdb_date dt;
|
@@ -344,6 +373,7 @@ static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE
|
|
344
373
|
return self;
|
345
374
|
}
|
346
375
|
|
376
|
+
/* :nodoc: */
|
347
377
|
static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE hour, VALUE min, VALUE sec, VALUE micros){
|
348
378
|
rubyDuckDBPreparedStatement *ctx;
|
349
379
|
duckdb_time time;
|
@@ -361,6 +391,7 @@ static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE
|
|
361
391
|
return self;
|
362
392
|
}
|
363
393
|
|
394
|
+
/* :nodoc: */
|
364
395
|
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) {
|
365
396
|
duckdb_timestamp timestamp;
|
366
397
|
rubyDuckDBPreparedStatement *ctx;
|
@@ -375,6 +406,7 @@ static VALUE duckdb_prepared_statement__bind_timestamp(VALUE self, VALUE vidx, V
|
|
375
406
|
return self;
|
376
407
|
}
|
377
408
|
|
409
|
+
/* :nodoc: */
|
378
410
|
static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VALUE months, VALUE days, VALUE micros) {
|
379
411
|
duckdb_interval interval;
|
380
412
|
rubyDuckDBPreparedStatement *ctx;
|
@@ -390,6 +422,7 @@ static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VA
|
|
390
422
|
return self;
|
391
423
|
}
|
392
424
|
|
425
|
+
/* :nodoc: */
|
393
426
|
static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper) {
|
394
427
|
duckdb_hugeint hugeint;
|
395
428
|
rubyDuckDBPreparedStatement *ctx;
|
@@ -406,6 +439,7 @@ static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VAL
|
|
406
439
|
return self;
|
407
440
|
}
|
408
441
|
|
442
|
+
/* :nodoc: */
|
409
443
|
static VALUE duckdb_prepared_statement__bind_decimal(VALUE self, VALUE vidx, VALUE lower, VALUE upper, VALUE width, VALUE scale) {
|
410
444
|
duckdb_hugeint hugeint;
|
411
445
|
duckdb_decimal decimal;
|
@@ -433,6 +467,9 @@ rubyDuckDBPreparedStatement *get_struct_prepared_statement(VALUE self) {
|
|
433
467
|
}
|
434
468
|
|
435
469
|
void rbduckdb_init_duckdb_prepared_statement(void) {
|
470
|
+
#if 0
|
471
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
472
|
+
#endif
|
436
473
|
cDuckDBPreparedStatement = rb_define_class_under(mDuckDB, "PreparedStatement", rb_cObject);
|
437
474
|
|
438
475
|
rb_define_alloc_func(cDuckDBPreparedStatement, allocate);
|