duckdb 1.1.3.1 → 1.2.1.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 +63 -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 +140 -173
- 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 +5 -8
- data/ext/duckdb/extracted_statements.c +3 -0
- data/ext/duckdb/logical_type.c +323 -0
- data/ext/duckdb/logical_type.h +13 -0
- data/ext/duckdb/pending_result.c +5 -0
- data/ext/duckdb/prepared_statement.c +64 -6
- data/ext/duckdb/result.c +17 -45
- data/ext/duckdb/ruby-duckdb.h +6 -8
- data/lib/duckdb/appender.rb +458 -56
- data/lib/duckdb/column.rb +0 -2
- data/lib/duckdb/interval.rb +12 -10
- data/lib/duckdb/logical_type.rb +110 -0
- data/lib/duckdb/pending_result.rb +1 -1
- data/lib/duckdb/prepared_statement.rb +18 -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/appender.c
CHANGED
@@ -6,36 +6,33 @@ static void deallocate(void *);
|
|
6
6
|
static VALUE allocate(VALUE klass);
|
7
7
|
static size_t memsize(const void *p);
|
8
8
|
static VALUE appender_initialize(VALUE klass, VALUE con, VALUE schema, VALUE table);
|
9
|
-
static VALUE
|
10
|
-
static VALUE
|
11
|
-
static VALUE
|
12
|
-
static VALUE
|
13
|
-
static VALUE
|
14
|
-
static VALUE
|
15
|
-
static VALUE
|
16
|
-
static VALUE
|
17
|
-
static VALUE
|
18
|
-
static VALUE
|
19
|
-
static VALUE
|
20
|
-
static VALUE
|
21
|
-
static VALUE
|
22
|
-
static VALUE
|
23
|
-
static VALUE
|
24
|
-
static VALUE
|
25
|
-
static VALUE
|
26
|
-
|
27
|
-
#ifdef HAVE_DUCKDB_H_GE_V1_1_0
|
28
|
-
static VALUE appender_append_default(VALUE self);
|
29
|
-
#endif
|
30
|
-
|
9
|
+
static VALUE appender_error_message(VALUE self);
|
10
|
+
static VALUE appender__append_bool(VALUE self, VALUE val);
|
11
|
+
static VALUE appender__append_int8(VALUE self, VALUE val);
|
12
|
+
static VALUE appender__append_int16(VALUE self, VALUE val);
|
13
|
+
static VALUE appender__append_int32(VALUE self, VALUE val);
|
14
|
+
static VALUE appender__append_int64(VALUE self, VALUE val);
|
15
|
+
static VALUE appender__append_uint8(VALUE self, VALUE val);
|
16
|
+
static VALUE appender__append_uint16(VALUE self, VALUE val);
|
17
|
+
static VALUE appender__append_uint32(VALUE self, VALUE val);
|
18
|
+
static VALUE appender__append_uint64(VALUE self, VALUE val);
|
19
|
+
static VALUE appender__append_float(VALUE self, VALUE val);
|
20
|
+
static VALUE appender__append_double(VALUE self, VALUE val);
|
21
|
+
static VALUE appender__append_varchar(VALUE self, VALUE val);
|
22
|
+
static VALUE appender__append_varchar_length(VALUE self, VALUE val, VALUE len);
|
23
|
+
static VALUE appender__append_blob(VALUE self, VALUE val);
|
24
|
+
static VALUE appender__append_null(VALUE self);
|
25
|
+
static VALUE appender__append_default(VALUE self);
|
26
|
+
static VALUE appender__end_row(VALUE self);
|
31
27
|
static VALUE appender__append_date(VALUE self, VALUE yearval, VALUE monthval, VALUE dayval);
|
32
28
|
static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VALUE micros);
|
33
29
|
static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
34
30
|
static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
35
31
|
static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper);
|
36
32
|
static VALUE appender__append_uhugeint(VALUE self, VALUE lower, VALUE upper);
|
37
|
-
static VALUE
|
38
|
-
static VALUE
|
33
|
+
static VALUE appender__flush(VALUE self);
|
34
|
+
static VALUE appender__close(VALUE self);
|
35
|
+
static VALUE duckdb_state_to_bool_value(duckdb_state state);
|
39
36
|
|
40
37
|
static const rb_data_type_t appender_data_type = {
|
41
38
|
"DuckDB/Appender",
|
@@ -82,27 +79,40 @@ static VALUE appender_initialize(VALUE self, VALUE con, VALUE schema, VALUE tabl
|
|
82
79
|
return self;
|
83
80
|
}
|
84
81
|
|
85
|
-
|
82
|
+
/* call-seq:
|
83
|
+
* appender.error_message -> String
|
84
|
+
*
|
85
|
+
* Returns the error message of the appender. If there is no error, then it returns nil.
|
86
|
+
*
|
87
|
+
* require 'duckdb'
|
88
|
+
* db = DuckDB::Database.open
|
89
|
+
* con = db.connect
|
90
|
+
* con.query('CREATE TABLE users (id INTEGER, name VARCHAR)')
|
91
|
+
* appender = con.appender('users')
|
92
|
+
* appender.error_message # => nil
|
93
|
+
*/
|
94
|
+
static VALUE appender_error_message(VALUE self) {
|
86
95
|
rubyDuckDBAppender *ctx;
|
96
|
+
const char *msg;
|
87
97
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
88
98
|
|
89
|
-
|
90
|
-
|
99
|
+
msg = duckdb_appender_error(ctx->appender);
|
100
|
+
if (msg == NULL) {
|
101
|
+
return Qnil;
|
91
102
|
}
|
92
|
-
return
|
103
|
+
return rb_str_new2(msg);
|
93
104
|
}
|
94
105
|
|
95
|
-
|
106
|
+
/* :nodoc: */
|
107
|
+
static VALUE appender__end_row(VALUE self) {
|
96
108
|
rubyDuckDBAppender *ctx;
|
97
109
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
98
110
|
|
99
|
-
|
100
|
-
rb_raise(eDuckDBError, "failed to flush");
|
101
|
-
}
|
102
|
-
return self;
|
111
|
+
return duckdb_state_to_bool_value(duckdb_appender_end_row(ctx->appender));
|
103
112
|
}
|
104
113
|
|
105
|
-
|
114
|
+
/* :nodoc: */
|
115
|
+
static VALUE appender__append_bool(VALUE self, VALUE val) {
|
106
116
|
rubyDuckDBAppender *ctx;
|
107
117
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
108
118
|
|
@@ -110,145 +120,121 @@ static VALUE appender_append_bool(VALUE self, VALUE val) {
|
|
110
120
|
rb_raise(rb_eArgError, "argument must be boolean");
|
111
121
|
}
|
112
122
|
|
113
|
-
|
114
|
-
rb_raise(eDuckDBError, "failed to append boolean");
|
115
|
-
}
|
116
|
-
return self;
|
123
|
+
return duckdb_state_to_bool_value(duckdb_append_bool(ctx->appender, (val == Qtrue)));
|
117
124
|
}
|
118
125
|
|
119
|
-
|
126
|
+
/* :nodoc: */
|
127
|
+
static VALUE appender__append_int8(VALUE self, VALUE val) {
|
120
128
|
rubyDuckDBAppender *ctx;
|
121
129
|
int8_t i8val = (int8_t)NUM2INT(val);
|
122
130
|
|
123
131
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
124
132
|
|
125
|
-
|
126
|
-
rb_raise(eDuckDBError, "failed to append");
|
127
|
-
}
|
128
|
-
return self;
|
133
|
+
return duckdb_state_to_bool_value(duckdb_append_int8(ctx->appender, i8val));
|
129
134
|
}
|
130
135
|
|
131
|
-
|
136
|
+
/* :nodoc: */
|
137
|
+
static VALUE appender__append_int16(VALUE self, VALUE val) {
|
132
138
|
rubyDuckDBAppender *ctx;
|
133
139
|
int16_t i16val = (int16_t)NUM2INT(val);
|
134
140
|
|
135
141
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
136
142
|
|
137
|
-
|
138
|
-
rb_raise(eDuckDBError, "failed to append");
|
139
|
-
}
|
140
|
-
return self;
|
143
|
+
return duckdb_state_to_bool_value(duckdb_append_int16(ctx->appender, i16val));
|
141
144
|
}
|
142
145
|
|
143
|
-
|
146
|
+
/* :nodoc: */
|
147
|
+
static VALUE appender__append_int32(VALUE self, VALUE val) {
|
144
148
|
rubyDuckDBAppender *ctx;
|
145
149
|
int32_t i32val = (int32_t)NUM2INT(val);
|
146
150
|
|
147
151
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
148
152
|
|
149
|
-
|
150
|
-
rb_raise(eDuckDBError, "failed to append");
|
151
|
-
}
|
152
|
-
return self;
|
153
|
+
return duckdb_state_to_bool_value(duckdb_append_int32(ctx->appender, i32val));
|
153
154
|
}
|
154
155
|
|
155
|
-
|
156
|
+
/* :nodoc: */
|
157
|
+
static VALUE appender__append_int64(VALUE self, VALUE val) {
|
156
158
|
rubyDuckDBAppender *ctx;
|
157
159
|
int64_t i64val = (int64_t)NUM2LL(val);
|
158
160
|
|
159
161
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
160
162
|
|
161
|
-
|
162
|
-
rb_raise(eDuckDBError, "failed to append");
|
163
|
-
}
|
164
|
-
return self;
|
163
|
+
return duckdb_state_to_bool_value(duckdb_append_int64(ctx->appender, i64val));
|
165
164
|
}
|
166
165
|
|
167
|
-
|
166
|
+
/* :nodoc: */
|
167
|
+
static VALUE appender__append_uint8(VALUE self, VALUE val) {
|
168
168
|
rubyDuckDBAppender *ctx;
|
169
|
-
|
169
|
+
uint8_t ui8val = (uint8_t)NUM2UINT(val);
|
170
170
|
|
171
171
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
172
172
|
|
173
|
-
|
174
|
-
rb_raise(eDuckDBError, "failed to append");
|
175
|
-
}
|
176
|
-
return self;
|
173
|
+
return duckdb_state_to_bool_value(duckdb_append_uint8(ctx->appender, ui8val));
|
177
174
|
}
|
178
175
|
|
179
|
-
|
176
|
+
/* :nodoc: */
|
177
|
+
static VALUE appender__append_uint16(VALUE self, VALUE val) {
|
180
178
|
rubyDuckDBAppender *ctx;
|
181
179
|
uint16_t ui16val = (uint16_t)NUM2UINT(val);
|
182
180
|
|
183
181
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
184
182
|
|
185
|
-
|
186
|
-
rb_raise(eDuckDBError, "failed to append");
|
187
|
-
}
|
188
|
-
return self;
|
183
|
+
return duckdb_state_to_bool_value(duckdb_append_uint16(ctx->appender, ui16val));
|
189
184
|
}
|
190
185
|
|
191
|
-
|
186
|
+
/* :nodoc: */
|
187
|
+
static VALUE appender__append_uint32(VALUE self, VALUE val) {
|
192
188
|
rubyDuckDBAppender *ctx;
|
193
189
|
uint32_t ui32val = (uint32_t)NUM2UINT(val);
|
194
190
|
|
195
191
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
196
192
|
|
197
|
-
|
198
|
-
rb_raise(eDuckDBError, "failed to append");
|
199
|
-
}
|
200
|
-
return self;
|
193
|
+
return duckdb_state_to_bool_value(duckdb_append_uint32(ctx->appender, ui32val));
|
201
194
|
}
|
202
195
|
|
203
|
-
|
196
|
+
/* :nodoc: */
|
197
|
+
static VALUE appender__append_uint64(VALUE self, VALUE val) {
|
204
198
|
rubyDuckDBAppender *ctx;
|
205
199
|
uint64_t ui64val = (uint64_t)NUM2ULL(val);
|
206
200
|
|
207
201
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
208
202
|
|
209
|
-
|
210
|
-
rb_raise(eDuckDBError, "failed to append");
|
211
|
-
}
|
212
|
-
return self;
|
203
|
+
return duckdb_state_to_bool_value(duckdb_append_uint64(ctx->appender, ui64val));
|
213
204
|
}
|
214
205
|
|
215
|
-
|
206
|
+
/* :nodoc: */
|
207
|
+
static VALUE appender__append_float(VALUE self, VALUE val) {
|
216
208
|
rubyDuckDBAppender *ctx;
|
217
209
|
float fval = (float)NUM2DBL(val);
|
218
210
|
|
219
211
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
220
212
|
|
221
|
-
|
222
|
-
rb_raise(eDuckDBError, "failed to append");
|
223
|
-
}
|
224
|
-
return self;
|
213
|
+
return duckdb_state_to_bool_value(duckdb_append_float(ctx->appender, fval));
|
225
214
|
}
|
226
215
|
|
227
|
-
|
216
|
+
/* :nodoc: */
|
217
|
+
static VALUE appender__append_double(VALUE self, VALUE val) {
|
228
218
|
rubyDuckDBAppender *ctx;
|
229
219
|
double dval = NUM2DBL(val);
|
230
220
|
|
231
221
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
232
222
|
|
233
|
-
|
234
|
-
rb_raise(eDuckDBError, "failed to append");
|
235
|
-
}
|
236
|
-
return self;
|
223
|
+
return duckdb_state_to_bool_value(duckdb_append_double(ctx->appender, dval));
|
237
224
|
}
|
238
225
|
|
239
|
-
|
226
|
+
/* :nodoc: */
|
227
|
+
static VALUE appender__append_varchar(VALUE self, VALUE val) {
|
240
228
|
rubyDuckDBAppender *ctx;
|
241
229
|
char *pval = StringValuePtr(val);
|
242
230
|
|
243
231
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
244
232
|
|
245
|
-
|
246
|
-
rb_raise(eDuckDBError, "failed to append");
|
247
|
-
}
|
248
|
-
return self;
|
233
|
+
return duckdb_state_to_bool_value(duckdb_append_varchar(ctx->appender, pval));
|
249
234
|
}
|
250
235
|
|
251
|
-
|
236
|
+
/* :nodoc: */
|
237
|
+
static VALUE appender__append_varchar_length(VALUE self, VALUE val, VALUE len) {
|
252
238
|
rubyDuckDBAppender *ctx;
|
253
239
|
|
254
240
|
char *pval = StringValuePtr(val);
|
@@ -256,13 +242,11 @@ static VALUE appender_append_varchar_length(VALUE self, VALUE val, VALUE len) {
|
|
256
242
|
|
257
243
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
258
244
|
|
259
|
-
|
260
|
-
rb_raise(eDuckDBError, "failed to append");
|
261
|
-
}
|
262
|
-
return self;
|
245
|
+
return duckdb_state_to_bool_value(duckdb_append_varchar_length(ctx->appender, pval, length));
|
263
246
|
}
|
264
247
|
|
265
|
-
|
248
|
+
/* :nodoc: */
|
249
|
+
static VALUE appender__append_blob(VALUE self, VALUE val) {
|
266
250
|
rubyDuckDBAppender *ctx;
|
267
251
|
|
268
252
|
char *pval = StringValuePtr(val);
|
@@ -270,34 +254,26 @@ static VALUE appender_append_blob(VALUE self, VALUE val) {
|
|
270
254
|
|
271
255
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
272
256
|
|
273
|
-
|
274
|
-
rb_raise(eDuckDBError, "failed to append");
|
275
|
-
}
|
276
|
-
return self;
|
257
|
+
return duckdb_state_to_bool_value(duckdb_append_blob(ctx->appender, (void *)pval, length));
|
277
258
|
}
|
278
259
|
|
279
|
-
|
260
|
+
/* :nodoc: */
|
261
|
+
static VALUE appender__append_null(VALUE self) {
|
280
262
|
rubyDuckDBAppender *ctx;
|
281
263
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
282
264
|
|
283
|
-
|
284
|
-
rb_raise(eDuckDBError, "failed to append");
|
285
|
-
}
|
286
|
-
return self;
|
265
|
+
return duckdb_state_to_bool_value(duckdb_append_null(ctx->appender));
|
287
266
|
}
|
288
267
|
|
289
|
-
|
290
|
-
static VALUE
|
268
|
+
/* :nodoc: */
|
269
|
+
static VALUE appender__append_default(VALUE self) {
|
291
270
|
rubyDuckDBAppender *ctx;
|
292
271
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
293
272
|
|
294
|
-
|
295
|
-
rb_raise(eDuckDBError, "failed to append");
|
296
|
-
}
|
297
|
-
return self;
|
273
|
+
return duckdb_state_to_bool_value(duckdb_append_default(ctx->appender));
|
298
274
|
}
|
299
|
-
#endif
|
300
275
|
|
276
|
+
/* :nodoc: */
|
301
277
|
static VALUE appender__append_date(VALUE self, VALUE year, VALUE month, VALUE day) {
|
302
278
|
duckdb_date dt;
|
303
279
|
rubyDuckDBAppender *ctx;
|
@@ -305,12 +281,10 @@ static VALUE appender__append_date(VALUE self, VALUE year, VALUE month, VALUE da
|
|
305
281
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
306
282
|
dt = rbduckdb_to_duckdb_date_from_value(year, month, day);
|
307
283
|
|
308
|
-
|
309
|
-
rb_raise(eDuckDBError, "failed to append date");
|
310
|
-
}
|
311
|
-
return self;
|
284
|
+
return duckdb_state_to_bool_value(duckdb_append_date(ctx->appender, dt));
|
312
285
|
}
|
313
286
|
|
287
|
+
/* :nodoc: */
|
314
288
|
static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VALUE micros) {
|
315
289
|
duckdb_interval interval;
|
316
290
|
rubyDuckDBAppender *ctx;
|
@@ -318,12 +292,10 @@ static VALUE appender__append_interval(VALUE self, VALUE months, VALUE days, VAL
|
|
318
292
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
319
293
|
rbduckdb_to_duckdb_interval_from_value(&interval, months, days, micros);
|
320
294
|
|
321
|
-
|
322
|
-
rb_raise(eDuckDBError, "failed to append interval");
|
323
|
-
}
|
324
|
-
return self;
|
295
|
+
return duckdb_state_to_bool_value(duckdb_append_interval(ctx->appender, interval));
|
325
296
|
}
|
326
297
|
|
298
|
+
/* :nodoc: */
|
327
299
|
static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec, VALUE micros) {
|
328
300
|
duckdb_time time;
|
329
301
|
rubyDuckDBAppender *ctx;
|
@@ -331,12 +303,10 @@ static VALUE appender__append_time(VALUE self, VALUE hour, VALUE min, VALUE sec,
|
|
331
303
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
332
304
|
time = rbduckdb_to_duckdb_time_from_value(hour, min, sec, micros);
|
333
305
|
|
334
|
-
|
335
|
-
rb_raise(eDuckDBError, "failed to append time");
|
336
|
-
}
|
337
|
-
return self;
|
306
|
+
return duckdb_state_to_bool_value(duckdb_append_time(ctx->appender, time));
|
338
307
|
}
|
339
308
|
|
309
|
+
/* :nodoc: */
|
340
310
|
static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros) {
|
341
311
|
duckdb_timestamp timestamp;
|
342
312
|
|
@@ -346,12 +316,10 @@ static VALUE appender__append_timestamp(VALUE self, VALUE year, VALUE month, VAL
|
|
346
316
|
|
347
317
|
timestamp = rbduckdb_to_duckdb_timestamp_from_value(year, month, day, hour, min, sec, micros);
|
348
318
|
|
349
|
-
|
350
|
-
rb_raise(eDuckDBError, "failed to append timestamp");
|
351
|
-
}
|
352
|
-
return self;
|
319
|
+
return duckdb_state_to_bool_value(duckdb_append_timestamp(ctx->appender, timestamp));
|
353
320
|
}
|
354
321
|
|
322
|
+
/* :nodoc: */
|
355
323
|
static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper) {
|
356
324
|
duckdb_hugeint hugeint;
|
357
325
|
|
@@ -361,12 +329,11 @@ static VALUE appender__append_hugeint(VALUE self, VALUE lower, VALUE upper) {
|
|
361
329
|
rubyDuckDBAppender *ctx;
|
362
330
|
|
363
331
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
364
|
-
|
365
|
-
|
366
|
-
}
|
367
|
-
return self;
|
332
|
+
|
333
|
+
return duckdb_state_to_bool_value(duckdb_append_hugeint(ctx->appender, hugeint));
|
368
334
|
}
|
369
335
|
|
336
|
+
/* :nodoc: */
|
370
337
|
static VALUE appender__append_uhugeint(VALUE self, VALUE lower, VALUE upper) {
|
371
338
|
duckdb_uhugeint uhugeint;
|
372
339
|
|
@@ -376,64 +343,64 @@ static VALUE appender__append_uhugeint(VALUE self, VALUE lower, VALUE upper) {
|
|
376
343
|
rubyDuckDBAppender *ctx;
|
377
344
|
|
378
345
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
379
|
-
|
380
|
-
|
381
|
-
}
|
382
|
-
return self;
|
346
|
+
|
347
|
+
return duckdb_state_to_bool_value(duckdb_append_uhugeint(ctx->appender, uhugeint));
|
383
348
|
}
|
384
349
|
|
385
|
-
|
350
|
+
/* :nodoc: */
|
351
|
+
static VALUE appender__flush(VALUE self) {
|
386
352
|
rubyDuckDBAppender *ctx;
|
387
353
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
388
354
|
|
389
|
-
|
390
|
-
rb_raise(eDuckDBError, "failed to flush");
|
391
|
-
}
|
392
|
-
return self;
|
355
|
+
return duckdb_state_to_bool_value(duckdb_appender_flush(ctx->appender));
|
393
356
|
}
|
394
357
|
|
395
|
-
|
358
|
+
/* :nodoc: */
|
359
|
+
static VALUE appender__close(VALUE self) {
|
396
360
|
rubyDuckDBAppender *ctx;
|
397
361
|
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
|
398
362
|
|
399
|
-
|
400
|
-
|
363
|
+
return duckdb_state_to_bool_value(duckdb_appender_close(ctx->appender));
|
364
|
+
}
|
365
|
+
|
366
|
+
static VALUE duckdb_state_to_bool_value(duckdb_state state) {
|
367
|
+
if (state == DuckDBSuccess) {
|
368
|
+
return Qtrue;
|
401
369
|
}
|
402
|
-
return
|
370
|
+
return Qfalse;
|
403
371
|
}
|
404
372
|
|
405
373
|
void rbduckdb_init_duckdb_appender(void) {
|
374
|
+
#if 0
|
375
|
+
VALUE mDuckDB = rb_define_module("DuckDB");
|
376
|
+
#endif
|
406
377
|
cDuckDBAppender = rb_define_class_under(mDuckDB, "Appender", rb_cObject);
|
407
378
|
rb_define_alloc_func(cDuckDBAppender, allocate);
|
408
379
|
rb_define_method(cDuckDBAppender, "initialize", appender_initialize, 3);
|
409
|
-
rb_define_method(cDuckDBAppender, "
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
#endif
|
430
|
-
|
380
|
+
rb_define_method(cDuckDBAppender, "error_message", appender_error_message, 0);
|
381
|
+
rb_define_private_method(cDuckDBAppender, "_end_row", appender__end_row, 0);
|
382
|
+
rb_define_private_method(cDuckDBAppender, "_flush", appender__flush, 0);
|
383
|
+
rb_define_private_method(cDuckDBAppender, "_close", appender__close, 0);
|
384
|
+
rb_define_private_method(cDuckDBAppender, "_append_bool", appender__append_bool, 1);
|
385
|
+
rb_define_private_method(cDuckDBAppender, "_append_int8", appender__append_int8, 1);
|
386
|
+
rb_define_private_method(cDuckDBAppender, "_append_int16", appender__append_int16, 1);
|
387
|
+
rb_define_private_method(cDuckDBAppender, "_append_int32", appender__append_int32, 1);
|
388
|
+
rb_define_private_method(cDuckDBAppender, "_append_int64", appender__append_int64, 1);
|
389
|
+
rb_define_private_method(cDuckDBAppender, "_append_uint8", appender__append_uint8, 1);
|
390
|
+
rb_define_private_method(cDuckDBAppender, "_append_uint16", appender__append_uint16, 1);
|
391
|
+
rb_define_private_method(cDuckDBAppender, "_append_uint32", appender__append_uint32, 1);
|
392
|
+
rb_define_private_method(cDuckDBAppender, "_append_uint64", appender__append_uint64, 1);
|
393
|
+
rb_define_private_method(cDuckDBAppender, "_append_float", appender__append_float, 1);
|
394
|
+
rb_define_private_method(cDuckDBAppender, "_append_double", appender__append_double, 1);
|
395
|
+
rb_define_private_method(cDuckDBAppender, "_append_varchar", appender__append_varchar, 1);
|
396
|
+
rb_define_private_method(cDuckDBAppender, "_append_varchar_length", appender__append_varchar_length, 2);
|
397
|
+
rb_define_private_method(cDuckDBAppender, "_append_blob", appender__append_blob, 1);
|
398
|
+
rb_define_private_method(cDuckDBAppender, "_append_null", appender__append_null, 0);
|
399
|
+
rb_define_private_method(cDuckDBAppender, "_append_default", appender__append_default, 0);
|
431
400
|
rb_define_private_method(cDuckDBAppender, "_append_date", appender__append_date, 3);
|
432
401
|
rb_define_private_method(cDuckDBAppender, "_append_interval", appender__append_interval, 3);
|
433
402
|
rb_define_private_method(cDuckDBAppender, "_append_time", appender__append_time, 4);
|
434
403
|
rb_define_private_method(cDuckDBAppender, "_append_timestamp", appender__append_timestamp, 7);
|
435
404
|
rb_define_private_method(cDuckDBAppender, "_append_hugeint", appender__append_hugeint, 2);
|
436
405
|
rb_define_private_method(cDuckDBAppender, "_append_uhugeint", appender__append_uhugeint, 2);
|
437
|
-
rb_define_method(cDuckDBAppender, "flush", appender_flush, 0);
|
438
|
-
rb_define_method(cDuckDBAppender, "close", appender_close, 0);
|
439
406
|
}
|
data/ext/duckdb/blob.c
CHANGED
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
|
}
|