duckdb 1.2.0.0 → 1.2.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 +2 -2
- data/.github/workflows/test_on_ubuntu.yml +2 -2
- data/.github/workflows/test_on_windows.yml +3 -2
- data/CHANGELOG.md +30 -0
- data/Dockerfile +1 -1
- data/Gemfile.lock +9 -9
- data/ext/duckdb/appender.c +58 -104
- data/ext/duckdb/database.c +8 -0
- data/ext/duckdb/database.h +1 -0
- data/ext/duckdb/duckdb.c +3 -0
- data/ext/duckdb/extconf.rb +5 -5
- data/ext/duckdb/instance_cache.c +108 -0
- data/ext/duckdb/instance_cache.h +17 -0
- data/ext/duckdb/logical_type.c +255 -0
- data/ext/duckdb/prepared_statement.c +89 -3
- data/ext/duckdb/result.c +1 -1
- data/ext/duckdb/ruby-duckdb.h +12 -8
- data/lib/duckdb/appender.rb +263 -24
- data/lib/duckdb/instance_cache.rb +26 -0
- data/lib/duckdb/logical_type.rb +131 -0
- data/lib/duckdb/prepared_statement.rb +58 -1
- data/lib/duckdb/version.rb +1 -1
- data/lib/duckdb.rb +1 -0
- metadata +6 -3
data/ext/duckdb/logical_type.c
CHANGED
@@ -8,10 +8,21 @@ static size_t memsize(const void *p);
|
|
8
8
|
static VALUE duckdb_logical_type__type(VALUE self);
|
9
9
|
static VALUE duckdb_logical_type_width(VALUE self);
|
10
10
|
static VALUE duckdb_logical_type_scale(VALUE self);
|
11
|
+
static VALUE duckdb_logical_type_child_count(VALUE self);
|
12
|
+
static VALUE duckdb_logical_type_child_name_at(VALUE self, VALUE cidx);
|
11
13
|
static VALUE duckdb_logical_type_child_type(VALUE self);
|
14
|
+
static VALUE duckdb_logical_type_child_type_at(VALUE self, VALUE cidx);
|
12
15
|
static VALUE duckdb_logical_type_size(VALUE self);
|
13
16
|
static VALUE duckdb_logical_type_key_type(VALUE self);
|
14
17
|
static VALUE duckdb_logical_type_value_type(VALUE self);
|
18
|
+
static VALUE duckdb_logical_type_member_count(VALUE self);
|
19
|
+
static VALUE duckdb_logical_type_member_name_at(VALUE self, VALUE midx);
|
20
|
+
static VALUE duckdb_logical_type_member_type_at(VALUE self, VALUE midx);
|
21
|
+
static VALUE duckdb_logical_type__internal_type(VALUE self);
|
22
|
+
static VALUE duckdb_logical_type_dictionary_size(VALUE self);
|
23
|
+
static VALUE duckdb_logical_type_dictionary_value_at(VALUE self, VALUE didx);
|
24
|
+
static VALUE duckdb_logical_type__get_alias(VALUE self);
|
25
|
+
static VALUE duckdb_logical_type__set_alias(VALUE self, VALUE aname);
|
15
26
|
|
16
27
|
static const rb_data_type_t logical_type_data_type = {
|
17
28
|
"DuckDB/LogicalType",
|
@@ -77,6 +88,43 @@ static VALUE duckdb_logical_type_scale(VALUE self) {
|
|
77
88
|
return INT2FIX(duckdb_decimal_scale(ctx->logical_type));
|
78
89
|
}
|
79
90
|
|
91
|
+
/*
|
92
|
+
* call-seq:
|
93
|
+
* struct_col.logical_type.child_count -> Integer
|
94
|
+
*
|
95
|
+
* Returns the number of children of a struct type, otherwise 0.
|
96
|
+
*
|
97
|
+
*/
|
98
|
+
static VALUE duckdb_logical_type_child_count(VALUE self) {
|
99
|
+
rubyDuckDBLogicalType *ctx;
|
100
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
101
|
+
return INT2FIX(duckdb_struct_type_child_count(ctx->logical_type));
|
102
|
+
}
|
103
|
+
|
104
|
+
/*
|
105
|
+
* call-seq:
|
106
|
+
* struct_col.logical_type.child_name(index) -> String
|
107
|
+
*
|
108
|
+
* Returns the name of the struct child at the specified index.
|
109
|
+
*
|
110
|
+
*/
|
111
|
+
static VALUE duckdb_logical_type_child_name_at(VALUE self, VALUE cidx) {
|
112
|
+
rubyDuckDBLogicalType *ctx;
|
113
|
+
VALUE cname;
|
114
|
+
const char *child_name;
|
115
|
+
idx_t idx = NUM2ULL(cidx);
|
116
|
+
|
117
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
118
|
+
|
119
|
+
child_name = duckdb_struct_type_child_name(ctx->logical_type, idx);
|
120
|
+
if (child_name == NULL) {
|
121
|
+
rb_raise(eDuckDBError, "fail to get name of %llu child", (unsigned long long)idx);
|
122
|
+
}
|
123
|
+
cname = rb_str_new_cstr(child_name);
|
124
|
+
duckdb_free((void *)child_name);
|
125
|
+
return cname;
|
126
|
+
}
|
127
|
+
|
80
128
|
/*
|
81
129
|
* call-seq:
|
82
130
|
* list_col.logical_type.child_type -> DuckDB::LogicalType
|
@@ -109,6 +157,31 @@ static VALUE duckdb_logical_type_child_type(VALUE self) {
|
|
109
157
|
return logical_type;
|
110
158
|
}
|
111
159
|
|
160
|
+
/*
|
161
|
+
* call-seq:
|
162
|
+
* struct_col.logical_type.child_type_at(index) -> DuckDB::LogicalType
|
163
|
+
*
|
164
|
+
* Returns the child logical type for struct types at the specified index as a
|
165
|
+
* DuckDB::LogicalType object.
|
166
|
+
*
|
167
|
+
*/
|
168
|
+
static VALUE duckdb_logical_type_child_type_at(VALUE self, VALUE cidx) {
|
169
|
+
rubyDuckDBLogicalType *ctx;
|
170
|
+
duckdb_logical_type struct_child_type;
|
171
|
+
idx_t idx = NUM2ULL(cidx);
|
172
|
+
|
173
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
174
|
+
|
175
|
+
struct_child_type = duckdb_struct_type_child_type(ctx->logical_type, idx);
|
176
|
+
if (struct_child_type == NULL) {
|
177
|
+
rb_raise(eDuckDBError,
|
178
|
+
"Failed to get the struct child type at index %llu",
|
179
|
+
(unsigned long long)idx);
|
180
|
+
}
|
181
|
+
|
182
|
+
return rbduckdb_create_logical_type(struct_child_type);
|
183
|
+
}
|
184
|
+
|
112
185
|
/*
|
113
186
|
* call-seq:
|
114
187
|
* list_col.logical_type.size -> Integer
|
@@ -158,6 +231,177 @@ static VALUE duckdb_logical_type_value_type(VALUE self) {
|
|
158
231
|
return logical_type;
|
159
232
|
}
|
160
233
|
|
234
|
+
/*
|
235
|
+
* call-seq:
|
236
|
+
* member_col.logical_type.member_count -> Integer
|
237
|
+
*
|
238
|
+
* Returns the member count of union type, otherwise 0.
|
239
|
+
*
|
240
|
+
*/
|
241
|
+
static VALUE duckdb_logical_type_member_count(VALUE self) {
|
242
|
+
rubyDuckDBLogicalType *ctx;
|
243
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
244
|
+
return INT2FIX(duckdb_union_type_member_count(ctx->logical_type));
|
245
|
+
}
|
246
|
+
|
247
|
+
/*
|
248
|
+
* call-seq:
|
249
|
+
* union_col.logical_type.member_name_at(index) -> String
|
250
|
+
*
|
251
|
+
* Returns the name of the union member at the specified index.
|
252
|
+
*
|
253
|
+
*/
|
254
|
+
static VALUE duckdb_logical_type_member_name_at(VALUE self, VALUE midx) {
|
255
|
+
rubyDuckDBLogicalType *ctx;
|
256
|
+
VALUE mname;
|
257
|
+
const char *member_name;
|
258
|
+
idx_t idx = NUM2ULL(midx);
|
259
|
+
|
260
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
261
|
+
|
262
|
+
member_name = duckdb_union_type_member_name(ctx->logical_type, idx);
|
263
|
+
if (member_name == NULL) {
|
264
|
+
rb_raise(eDuckDBError, "fail to get name of %llu member", (unsigned long long)idx);
|
265
|
+
}
|
266
|
+
mname = rb_str_new_cstr(member_name);
|
267
|
+
duckdb_free((void *)member_name);
|
268
|
+
return mname;
|
269
|
+
}
|
270
|
+
|
271
|
+
/*
|
272
|
+
* call-seq:
|
273
|
+
* union_col.logical_type.member_type_at(index) -> DuckDB::LogicalType
|
274
|
+
*
|
275
|
+
* Returns the logical type of the union member at the specified index as a
|
276
|
+
* DuckDB::LogicalType object.
|
277
|
+
*
|
278
|
+
*/
|
279
|
+
static VALUE duckdb_logical_type_member_type_at(VALUE self, VALUE midx) {
|
280
|
+
rubyDuckDBLogicalType *ctx;
|
281
|
+
duckdb_logical_type union_member_type;
|
282
|
+
idx_t idx = NUM2ULL(midx);
|
283
|
+
|
284
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
285
|
+
|
286
|
+
union_member_type = duckdb_union_type_member_type(ctx->logical_type, idx);
|
287
|
+
if (union_member_type == NULL) {
|
288
|
+
rb_raise(eDuckDBError,
|
289
|
+
"Failed to get the union member type at index %llu",
|
290
|
+
(unsigned long long)idx);
|
291
|
+
}
|
292
|
+
|
293
|
+
return rbduckdb_create_logical_type(union_member_type);
|
294
|
+
}
|
295
|
+
|
296
|
+
/*
|
297
|
+
* call-seq:
|
298
|
+
* enum_col.logical_type.internal_type -> Symbol
|
299
|
+
*
|
300
|
+
* Returns the logical type's internal type.
|
301
|
+
*
|
302
|
+
*/
|
303
|
+
static VALUE duckdb_logical_type__internal_type(VALUE self) {
|
304
|
+
rubyDuckDBLogicalType *ctx;
|
305
|
+
duckdb_type type_id;
|
306
|
+
duckdb_type internal_type_id;
|
307
|
+
|
308
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
309
|
+
|
310
|
+
type_id = duckdb_get_type_id(ctx->logical_type);
|
311
|
+
switch (type_id) {
|
312
|
+
case DUCKDB_TYPE_DECIMAL:
|
313
|
+
internal_type_id = duckdb_decimal_internal_type(ctx->logical_type);
|
314
|
+
break;
|
315
|
+
case DUCKDB_TYPE_ENUM:
|
316
|
+
internal_type_id = duckdb_enum_internal_type(ctx->logical_type);
|
317
|
+
break;
|
318
|
+
default:
|
319
|
+
internal_type_id = DUCKDB_TYPE_INVALID;
|
320
|
+
}
|
321
|
+
|
322
|
+
return INT2FIX(internal_type_id);
|
323
|
+
}
|
324
|
+
|
325
|
+
/*
|
326
|
+
* call-seq:
|
327
|
+
* enum_col.logical_type.dictionary_size -> Integer
|
328
|
+
*
|
329
|
+
* Returns the dictionary size of the enum type.
|
330
|
+
*
|
331
|
+
*/
|
332
|
+
static VALUE duckdb_logical_type_dictionary_size(VALUE self) {
|
333
|
+
rubyDuckDBLogicalType *ctx;
|
334
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
335
|
+
return INT2FIX(duckdb_enum_dictionary_size(ctx->logical_type));
|
336
|
+
}
|
337
|
+
|
338
|
+
/*
|
339
|
+
* call-seq:
|
340
|
+
* enum_col.logical_type.dictionary_value_at(index) -> String
|
341
|
+
*
|
342
|
+
* Returns the dictionary value at the specified index.
|
343
|
+
*
|
344
|
+
*/
|
345
|
+
static VALUE duckdb_logical_type_dictionary_value_at(VALUE self, VALUE didx) {
|
346
|
+
rubyDuckDBLogicalType *ctx;
|
347
|
+
VALUE dvalue;
|
348
|
+
const char *dict_value;
|
349
|
+
idx_t idx = NUM2ULL(didx);
|
350
|
+
|
351
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
352
|
+
|
353
|
+
dict_value = duckdb_enum_dictionary_value(ctx->logical_type, idx);
|
354
|
+
if (dict_value == NULL) {
|
355
|
+
rb_raise(eDuckDBError, "fail to get dictionary value of %llu", (unsigned long long)idx);
|
356
|
+
}
|
357
|
+
dvalue = rb_utf8_str_new_cstr(dict_value);
|
358
|
+
duckdb_free((void *)dict_value);
|
359
|
+
return dvalue;
|
360
|
+
}
|
361
|
+
|
362
|
+
/*
|
363
|
+
* call-seq:
|
364
|
+
* col.logical_type.alias -> String
|
365
|
+
*
|
366
|
+
* Returns the alias of the logical type.
|
367
|
+
*
|
368
|
+
*/
|
369
|
+
static VALUE duckdb_logical_type__get_alias(VALUE self) {
|
370
|
+
rubyDuckDBLogicalType *ctx;
|
371
|
+
VALUE alias = Qnil;
|
372
|
+
const char *_alias;
|
373
|
+
|
374
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
375
|
+
|
376
|
+
_alias = duckdb_logical_type_get_alias(ctx->logical_type);
|
377
|
+
if (_alias != NULL) {
|
378
|
+
alias = rb_utf8_str_new_cstr(_alias);
|
379
|
+
}
|
380
|
+
duckdb_free((void *)_alias);
|
381
|
+
return alias;
|
382
|
+
}
|
383
|
+
|
384
|
+
/*
|
385
|
+
* call-seq:
|
386
|
+
* col.logical_type.alias(alias) -> String
|
387
|
+
*
|
388
|
+
* Return the set alias of the logical type.
|
389
|
+
*
|
390
|
+
*/
|
391
|
+
static VALUE duckdb_logical_type__set_alias(VALUE self, VALUE aname) {
|
392
|
+
rubyDuckDBLogicalType *ctx;
|
393
|
+
VALUE alias = Qnil;
|
394
|
+
const char *_alias = StringValuePtr(aname);
|
395
|
+
|
396
|
+
TypedData_Get_Struct(self, rubyDuckDBLogicalType, &logical_type_data_type, ctx);
|
397
|
+
duckdb_logical_type_set_alias(ctx->logical_type, _alias);
|
398
|
+
if (_alias != NULL) {
|
399
|
+
alias = rb_utf8_str_new_cstr(_alias);
|
400
|
+
}
|
401
|
+
|
402
|
+
return alias;
|
403
|
+
}
|
404
|
+
|
161
405
|
VALUE rbduckdb_create_logical_type(duckdb_logical_type logical_type) {
|
162
406
|
VALUE obj;
|
163
407
|
rubyDuckDBLogicalType *ctx;
|
@@ -180,8 +424,19 @@ void rbduckdb_init_duckdb_logical_type(void) {
|
|
180
424
|
rb_define_private_method(cDuckDBLogicalType, "_type", duckdb_logical_type__type, 0);
|
181
425
|
rb_define_method(cDuckDBLogicalType, "width", duckdb_logical_type_width, 0);
|
182
426
|
rb_define_method(cDuckDBLogicalType, "scale", duckdb_logical_type_scale, 0);
|
427
|
+
rb_define_method(cDuckDBLogicalType, "child_count", duckdb_logical_type_child_count, 0);
|
428
|
+
rb_define_method(cDuckDBLogicalType, "child_name_at", duckdb_logical_type_child_name_at, 1);
|
183
429
|
rb_define_method(cDuckDBLogicalType, "child_type", duckdb_logical_type_child_type, 0);
|
430
|
+
rb_define_method(cDuckDBLogicalType, "child_type_at", duckdb_logical_type_child_type_at, 1);
|
184
431
|
rb_define_method(cDuckDBLogicalType, "size", duckdb_logical_type_size, 0);
|
185
432
|
rb_define_method(cDuckDBLogicalType, "key_type", duckdb_logical_type_key_type, 0);
|
186
433
|
rb_define_method(cDuckDBLogicalType, "value_type", duckdb_logical_type_value_type, 0);
|
434
|
+
rb_define_method(cDuckDBLogicalType, "member_count", duckdb_logical_type_member_count, 0);
|
435
|
+
rb_define_method(cDuckDBLogicalType, "member_name_at", duckdb_logical_type_member_name_at, 1);
|
436
|
+
rb_define_method(cDuckDBLogicalType, "member_type_at", duckdb_logical_type_member_type_at, 1);
|
437
|
+
rb_define_method(cDuckDBLogicalType, "_internal_type", duckdb_logical_type__internal_type, 0);
|
438
|
+
rb_define_method(cDuckDBLogicalType, "dictionary_size", duckdb_logical_type_dictionary_size, 0);
|
439
|
+
rb_define_method(cDuckDBLogicalType, "dictionary_value_at", duckdb_logical_type_dictionary_value_at, 1);
|
440
|
+
rb_define_method(cDuckDBLogicalType, "get_alias", duckdb_logical_type__get_alias, 0);
|
441
|
+
rb_define_method(cDuckDBLogicalType, "set_alias", duckdb_logical_type__set_alias, 1);
|
187
442
|
}
|
@@ -27,11 +27,16 @@ static VALUE duckdb_prepared_statement_bind_blob(VALUE self, VALUE vidx, VALUE b
|
|
27
27
|
static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx);
|
28
28
|
static VALUE duckdb_prepared_statement__statement_type(VALUE self);
|
29
29
|
static VALUE duckdb_prepared_statement__param_type(VALUE self, VALUE vidx);
|
30
|
+
static VALUE duckdb_prepared_statement__bind_uint8(VALUE self, VALUE vidx, VALUE val);
|
31
|
+
static VALUE duckdb_prepared_statement__bind_uint16(VALUE self, VALUE vidx, VALUE val);
|
32
|
+
static VALUE duckdb_prepared_statement__bind_uint32(VALUE self, VALUE vidx, VALUE val);
|
33
|
+
static VALUE duckdb_prepared_statement__bind_uint64(VALUE self, VALUE vidx, VALUE val);
|
30
34
|
static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day);
|
31
35
|
static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
32
36
|
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);
|
33
37
|
static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VALUE months, VALUE days, VALUE micros);
|
34
38
|
static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper);
|
39
|
+
static VALUE duckdb_prepared_statement__bind_uhugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper);
|
35
40
|
static VALUE duckdb_prepared_statement__bind_decimal(VALUE self, VALUE vidx, VALUE lower, VALUE upper, VALUE width, VALUE scale);
|
36
41
|
|
37
42
|
static const rb_data_type_t prepared_statement_data_type = {
|
@@ -121,6 +126,7 @@ static VALUE duckdb_prepared_statement_execute(VALUE self) {
|
|
121
126
|
rubyDuckDBResult *ctxr;
|
122
127
|
const char *error;
|
123
128
|
VALUE result = rbduckdb_create_result();
|
129
|
+
VALUE msg;
|
124
130
|
|
125
131
|
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
126
132
|
ctxr = get_struct_result(result);
|
@@ -135,12 +141,13 @@ static VALUE duckdb_prepared_statement_execute(VALUE self) {
|
|
135
141
|
duckdb_state state = args.retval;
|
136
142
|
|
137
143
|
if (state == DuckDBError) {
|
138
|
-
error =
|
144
|
+
error = duckdb_prepare_error(args.prepared_statement);
|
139
145
|
if (error == NULL) {
|
140
|
-
error =
|
146
|
+
error = duckdb_result_error(args.out_result);
|
141
147
|
}
|
148
|
+
msg = rb_str_new2(error ? error : "Failed to execute prepared statement.");
|
142
149
|
|
143
|
-
rb_raise(eDuckDBError, "%s",
|
150
|
+
rb_raise(eDuckDBError, "%s", StringValuePtr(msg));
|
144
151
|
}
|
145
152
|
|
146
153
|
return result;
|
@@ -241,6 +248,7 @@ static VALUE duckdb_prepared_statement_bind_int8(VALUE self, VALUE vidx, VALUE v
|
|
241
248
|
return self;
|
242
249
|
}
|
243
250
|
|
251
|
+
|
244
252
|
static VALUE duckdb_prepared_statement_bind_int16(VALUE self, VALUE vidx, VALUE val) {
|
245
253
|
rubyDuckDBPreparedStatement *ctx;
|
246
254
|
idx_t idx = check_index(vidx);
|
@@ -356,6 +364,62 @@ static VALUE duckdb_prepared_statement__param_type(VALUE self, VALUE vidx) {
|
|
356
364
|
return INT2FIX(duckdb_param_type(ctx->prepared_statement, NUM2ULL(vidx)));
|
357
365
|
}
|
358
366
|
|
367
|
+
/* :nodoc: */
|
368
|
+
static VALUE duckdb_prepared_statement__bind_uint8(VALUE self, VALUE vidx, VALUE val) {
|
369
|
+
rubyDuckDBPreparedStatement *ctx;
|
370
|
+
idx_t idx = check_index(vidx);
|
371
|
+
uint8_t ui8val = (uint8_t)NUM2UINT(val);
|
372
|
+
|
373
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
374
|
+
|
375
|
+
if (duckdb_bind_uint8(ctx->prepared_statement, idx, ui8val) == DuckDBError) {
|
376
|
+
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
377
|
+
}
|
378
|
+
return self;
|
379
|
+
}
|
380
|
+
|
381
|
+
/* :nodoc: */
|
382
|
+
static VALUE duckdb_prepared_statement__bind_uint16(VALUE self, VALUE vidx, VALUE val) {
|
383
|
+
rubyDuckDBPreparedStatement *ctx;
|
384
|
+
idx_t idx = check_index(vidx);
|
385
|
+
uint16_t ui16val = (uint16_t)NUM2UINT(val);
|
386
|
+
|
387
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
388
|
+
|
389
|
+
if (duckdb_bind_uint16(ctx->prepared_statement, idx, ui16val) == DuckDBError) {
|
390
|
+
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
391
|
+
}
|
392
|
+
return self;
|
393
|
+
}
|
394
|
+
|
395
|
+
/* :nodoc: */
|
396
|
+
static VALUE duckdb_prepared_statement__bind_uint32(VALUE self, VALUE vidx, VALUE val) {
|
397
|
+
rubyDuckDBPreparedStatement *ctx;
|
398
|
+
idx_t idx = check_index(vidx);
|
399
|
+
uint32_t ui32val = (uint32_t)NUM2UINT(val);
|
400
|
+
|
401
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
402
|
+
|
403
|
+
if (duckdb_bind_uint32(ctx->prepared_statement, idx, ui32val) == DuckDBError) {
|
404
|
+
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
405
|
+
}
|
406
|
+
return self;
|
407
|
+
}
|
408
|
+
|
409
|
+
/* :nodoc: */
|
410
|
+
static VALUE duckdb_prepared_statement__bind_uint64(VALUE self, VALUE vidx, VALUE val) {
|
411
|
+
rubyDuckDBPreparedStatement *ctx;
|
412
|
+
idx_t idx = check_index(vidx);
|
413
|
+
uint64_t ui64val = (uint64_t)NUM2ULL(val);
|
414
|
+
|
415
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
416
|
+
|
417
|
+
if (duckdb_bind_uint64(ctx->prepared_statement, idx, ui64val) == DuckDBError) {
|
418
|
+
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
419
|
+
}
|
420
|
+
return self;
|
421
|
+
}
|
422
|
+
|
359
423
|
/* :nodoc: */
|
360
424
|
static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day) {
|
361
425
|
rubyDuckDBPreparedStatement *ctx;
|
@@ -439,6 +503,23 @@ static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VAL
|
|
439
503
|
return self;
|
440
504
|
}
|
441
505
|
|
506
|
+
/* :nodoc: */
|
507
|
+
static VALUE duckdb_prepared_statement__bind_uhugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper) {
|
508
|
+
duckdb_uhugeint uhugeint;
|
509
|
+
rubyDuckDBPreparedStatement *ctx;
|
510
|
+
idx_t idx = check_index(vidx);
|
511
|
+
|
512
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
513
|
+
uhugeint.lower = NUM2ULL(lower);
|
514
|
+
uhugeint.upper = NUM2ULL(upper);
|
515
|
+
|
516
|
+
if (duckdb_bind_uhugeint(ctx->prepared_statement, idx, uhugeint) == DuckDBError) {
|
517
|
+
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
518
|
+
}
|
519
|
+
|
520
|
+
return self;
|
521
|
+
}
|
522
|
+
|
442
523
|
/* :nodoc: */
|
443
524
|
static VALUE duckdb_prepared_statement__bind_decimal(VALUE self, VALUE vidx, VALUE lower, VALUE upper, VALUE width, VALUE scale) {
|
444
525
|
duckdb_hugeint hugeint;
|
@@ -491,6 +572,10 @@ void rbduckdb_init_duckdb_prepared_statement(void) {
|
|
491
572
|
rb_define_method(cDuckDBPreparedStatement, "bind_varchar", duckdb_prepared_statement_bind_varchar, 2);
|
492
573
|
rb_define_method(cDuckDBPreparedStatement, "bind_blob", duckdb_prepared_statement_bind_blob, 2);
|
493
574
|
rb_define_method(cDuckDBPreparedStatement, "bind_null", duckdb_prepared_statement_bind_null, 1);
|
575
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_bind_uint8", duckdb_prepared_statement__bind_uint8, 2);
|
576
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_bind_uint16", duckdb_prepared_statement__bind_uint16, 2);
|
577
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_bind_uint32", duckdb_prepared_statement__bind_uint32, 2);
|
578
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_bind_uint64", duckdb_prepared_statement__bind_uint64, 2);
|
494
579
|
rb_define_private_method(cDuckDBPreparedStatement, "_statement_type", duckdb_prepared_statement__statement_type, 0);
|
495
580
|
rb_define_private_method(cDuckDBPreparedStatement, "_param_type", duckdb_prepared_statement__param_type, 1);
|
496
581
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_date", duckdb_prepared_statement__bind_date, 4);
|
@@ -498,5 +583,6 @@ void rbduckdb_init_duckdb_prepared_statement(void) {
|
|
498
583
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_timestamp", duckdb_prepared_statement__bind_timestamp, 8);
|
499
584
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_interval", duckdb_prepared_statement__bind_interval, 4);
|
500
585
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_hugeint", duckdb_prepared_statement__bind_hugeint, 3);
|
586
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_bind_uhugeint", duckdb_prepared_statement__bind_uhugeint, 3);
|
501
587
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_decimal", duckdb_prepared_statement__bind_decimal, 5);
|
502
588
|
}
|
data/ext/duckdb/result.c
CHANGED
@@ -279,7 +279,7 @@ static VALUE duckdb_result__return_type(VALUE oDuckDBResult) {
|
|
279
279
|
/*
|
280
280
|
* remove this #if ... #else statement when dropping duckdb 1.1.0.
|
281
281
|
*/
|
282
|
-
#if !defined(HAVE_DUCKDB_H_GE_V1_1_1) && defined(
|
282
|
+
#if !defined(HAVE_DUCKDB_H_GE_V1_1_1) && defined(DUCKDB_API_NO_DEPRECATED)
|
283
283
|
rb_raise(eDuckDBError, "duckdb_result_return_type C-API is not available with duckdb v1.1.0 with enabled DUCKDB_API_NO_DEPRECATED.");
|
284
284
|
#else
|
285
285
|
return INT2FIX(duckdb_result_return_type(ctx->result));
|
data/ext/duckdb/ruby-duckdb.h
CHANGED
@@ -8,18 +8,14 @@
|
|
8
8
|
#include "ruby/thread.h"
|
9
9
|
#include <duckdb.h>
|
10
10
|
|
11
|
-
#ifdef HAVE_DUCKDB_FETCH_CHUNK
|
12
|
-
#define HAVE_DUCKDB_H_GE_V1_0_0 1
|
13
|
-
#endif
|
14
|
-
|
15
|
-
#ifdef HAVE_DUCKDB_RESULT_ERROR_TYPE
|
16
|
-
#define HAVE_DUCKDB_H_GE_V1_1_0 1
|
17
|
-
#endif
|
18
|
-
|
19
11
|
#ifdef HAVE_CONST_DUCKDB_TYPE_SQLNULL
|
20
12
|
#define HAVE_DUCKDB_H_GE_V1_1_1 1
|
21
13
|
#endif
|
22
14
|
|
15
|
+
#ifdef HAVE_DUCKDB_CREATE_INSTANCE_CACHE
|
16
|
+
#define HAVE_DUCKDB_H_GE_V1_2_0 1
|
17
|
+
#endif
|
18
|
+
|
23
19
|
#include "./error.h"
|
24
20
|
#include "./database.h"
|
25
21
|
#include "./connection.h"
|
@@ -36,6 +32,10 @@
|
|
36
32
|
#include "./appender.h"
|
37
33
|
#include "./config.h"
|
38
34
|
|
35
|
+
#ifdef HAVE_DUCKDB_H_GE_V1_2_0
|
36
|
+
#include "./instance_cache.h"
|
37
|
+
#endif
|
38
|
+
|
39
39
|
extern VALUE mDuckDB;
|
40
40
|
extern VALUE cDuckDBDatabase;
|
41
41
|
extern VALUE cDuckDBConnection;
|
@@ -47,4 +47,8 @@ extern VALUE cDuckDBPreparedStatement;
|
|
47
47
|
extern VALUE PositiveInfinity;
|
48
48
|
extern VALUE NegativeInfinity;
|
49
49
|
|
50
|
+
#ifdef HAVE_DUCKDB_H_GE_V1_2_0
|
51
|
+
extern VALUE cDuckDBInstanceCache;
|
52
|
+
#endif
|
53
|
+
|
50
54
|
#endif
|