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