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.
data/ext/duckdb/result.c CHANGED
@@ -24,12 +24,11 @@ static void deallocate(void *ctx);
24
24
  static VALUE allocate(VALUE klass);
25
25
  static size_t memsize(const void *p);
26
26
  static VALUE duckdb_result_column_count(VALUE oDuckDBResult);
27
- static VALUE duckdb_result_row_count(VALUE oDuckDBResult);
28
27
  static VALUE duckdb_result_rows_changed(VALUE oDuckDBResult);
29
28
  static VALUE duckdb_result_columns(VALUE oDuckDBResult);
30
29
  static VALUE duckdb_result_streaming_p(VALUE oDuckDBResult);
31
30
  static VALUE destroy_data_chunk(VALUE arg);
32
- static VALUE duckdb_result_chunk_each(VALUE oDuckDBResult);
31
+ static VALUE duckdb_result__chunk_each(VALUE oDuckDBResult);
33
32
 
34
33
  static VALUE duckdb_result__chunk_stream(VALUE oDuckDBResult);
35
34
  static VALUE yield_rows(VALUE arg);
@@ -147,36 +146,6 @@ static VALUE duckdb_result_column_count(VALUE oDuckDBResult) {
147
146
  return LL2NUM(duckdb_column_count(&(ctx->result)));
148
147
  }
149
148
 
150
- /*
151
- * call-seq:
152
- * result.row_count -> Integer
153
- *
154
- * Returns the column size of the result.
155
- *
156
- * DuckDB::Database.open do |db|
157
- * db.connect do |con|
158
- * r = con.query('CREATE TABLE t2 (id INT, name VARCHAR(128))')
159
- * r = con.query("INSERT INTO t2 VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Catherine')")
160
- * r = con.query('SELECT * FROM t2')
161
- * r.row_count # => 3
162
- * r = con.query('SELECT * FROM t2 where id = 1')
163
- * r.row_count # => 1
164
- * end
165
- * end
166
- *
167
- */
168
- static VALUE duckdb_result_row_count(VALUE oDuckDBResult) {
169
-
170
- #ifdef DUCKDB_API_NO_DEPRECATED
171
- return Qnil;
172
- #else
173
- rubyDuckDBResult *ctx;
174
- rb_warn("`row_count` will be deprecated in the future.");
175
- TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
176
- return LL2NUM(duckdb_row_count(&(ctx->result)));
177
- #endif
178
- }
179
-
180
149
  /*
181
150
  * call-seq:
182
151
  * result.columns -> DuckDB::Column[]
@@ -200,11 +169,7 @@ static VALUE duckdb_result_columns(VALUE oDuckDBResult) {
200
169
  }
201
170
 
202
171
  /*
203
- * call-seq:
204
- * result.streaming? -> Boolean
205
- *
206
- * Returns true if the result is streaming, otherwise false.
207
- *
172
+ * :nodoc:
208
173
  */
209
174
  static VALUE duckdb_result_streaming_p(VALUE oDuckDBResult) {
210
175
  rubyDuckDBResult *ctx;
@@ -212,6 +177,7 @@ static VALUE duckdb_result_streaming_p(VALUE oDuckDBResult) {
212
177
  #ifdef DUCKDB_API_NO_DEPRECATED
213
178
  return Qtrue;
214
179
  #else
180
+ rb_warn("`DuckDB::Result#streaming?` will be deprecated in the future.");
215
181
  /* FIXME streaming is allways true. so this method is not useful and deprecated. */
216
182
  TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
217
183
  return duckdb_result_is_streaming(ctx->result) ? Qtrue : Qfalse;
@@ -224,7 +190,8 @@ static VALUE destroy_data_chunk(VALUE arg) {
224
190
  return Qnil;
225
191
  }
226
192
 
227
- static VALUE duckdb_result_chunk_each(VALUE oDuckDBResult) {
193
+ /* :nodoc: */
194
+ static VALUE duckdb_result__chunk_each(VALUE oDuckDBResult) {
228
195
  /*
229
196
  #ifdef HAVE_DUCKDB_H_GE_V1_0_0
230
197
  return duckdb_result__chunk_stream(oDuckDBResult);
@@ -258,6 +225,7 @@ static VALUE duckdb_result_chunk_each(VALUE oDuckDBResult) {
258
225
  */
259
226
  }
260
227
 
228
+ /* :nodoc: */
261
229
  static VALUE duckdb_result__chunk_stream(VALUE oDuckDBResult) {
262
230
  rubyDuckDBResult *ctx;
263
231
  struct chunk_arg arg;
@@ -268,11 +236,7 @@ static VALUE duckdb_result__chunk_stream(VALUE oDuckDBResult) {
268
236
 
269
237
  arg.col_count = duckdb_column_count(&(ctx->result));
270
238
 
271
- #ifdef HAVE_DUCKDB_H_GE_V1_0_0
272
239
  while((arg.chunk = duckdb_fetch_chunk(ctx->result)) != NULL) {
273
- #else
274
- while((arg.chunk = duckdb_stream_fetch_chunk(ctx->result)) != NULL) {
275
- #endif
276
240
  rb_ensure(yield_rows, (VALUE)&arg, destroy_data_chunk, (VALUE)&arg);
277
241
  }
278
242
  return Qnil;
@@ -301,31 +265,35 @@ static VALUE yield_rows(VALUE arg) {
301
265
  return Qnil;
302
266
  }
303
267
 
268
+ /* :nodoc: */
304
269
  static VALUE duckdb_result__column_type(VALUE oDuckDBResult, VALUE col_idx) {
305
270
  rubyDuckDBResult *ctx;
306
271
  TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
307
272
  return LL2NUM(duckdb_column_type(&(ctx->result), NUM2LL(col_idx)));
308
273
  }
309
274
 
275
+ /* :nodoc: */
310
276
  static VALUE duckdb_result__return_type(VALUE oDuckDBResult) {
311
277
  rubyDuckDBResult *ctx;
312
278
  TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
313
279
  /*
314
280
  * remove this #if ... #else statement when dropping duckdb 1.1.0.
315
281
  */
316
- #if !defined(HAVE_DUCKDB_H_GE_V1_1_1) && defined(HAVE_DUCKDB_H_GE_V1_1_0) && defined(DUCKDB_API_NO_DEPRECATED)
282
+ #if !defined(HAVE_DUCKDB_H_GE_V1_1_1) && defined(DUCKDB_API_NO_DEPRECATED)
317
283
  rb_raise(eDuckDBError, "duckdb_result_return_type C-API is not available with duckdb v1.1.0 with enabled DUCKDB_API_NO_DEPRECATED.");
318
284
  #else
319
285
  return INT2FIX(duckdb_result_return_type(ctx->result));
320
286
  #endif
321
287
  }
322
288
 
289
+ /* :nodoc: */
323
290
  static VALUE duckdb_result__statement_type(VALUE oDuckDBResult) {
324
291
  rubyDuckDBResult *ctx;
325
292
  TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
326
293
  return INT2FIX(duckdb_result_statement_type(ctx->result));
327
294
  }
328
295
 
296
+ /* :nodoc: */
329
297
  static VALUE duckdb_result__enum_internal_type(VALUE oDuckDBResult, VALUE col_idx) {
330
298
  rubyDuckDBResult *ctx;
331
299
  VALUE type = Qnil;
@@ -340,6 +308,7 @@ static VALUE duckdb_result__enum_internal_type(VALUE oDuckDBResult, VALUE col_id
340
308
  return type;
341
309
  }
342
310
 
311
+ /* :nodoc: */
343
312
  static VALUE duckdb_result__enum_dictionary_size(VALUE oDuckDBResult, VALUE col_idx) {
344
313
  rubyDuckDBResult *ctx;
345
314
  VALUE size = Qnil;
@@ -354,6 +323,7 @@ static VALUE duckdb_result__enum_dictionary_size(VALUE oDuckDBResult, VALUE col_
354
323
  return size;
355
324
  }
356
325
 
326
+ /* :nodoc: */
357
327
  static VALUE duckdb_result__enum_dictionary_value(VALUE oDuckDBResult, VALUE col_idx, VALUE idx) {
358
328
  rubyDuckDBResult *ctx;
359
329
  VALUE value = Qnil;
@@ -884,6 +854,9 @@ static VALUE vector_value(duckdb_vector vector, idx_t row_idx) {
884
854
  }
885
855
 
886
856
  void rbduckdb_init_duckdb_result(void) {
857
+ #if 0
858
+ VALUE mDuckDB = rb_define_module("DuckDB");
859
+ #endif
887
860
  cDuckDBResult = rb_define_class_under(mDuckDB, "Result", rb_cObject);
888
861
  id__to_date = rb_intern("_to_date");
889
862
  id__to_time = rb_intern("_to_time");
@@ -902,11 +875,10 @@ void rbduckdb_init_duckdb_result(void) {
902
875
  rb_define_alloc_func(cDuckDBResult, allocate);
903
876
 
904
877
  rb_define_method(cDuckDBResult, "column_count", duckdb_result_column_count, 0);
905
- rb_define_method(cDuckDBResult, "row_count", duckdb_result_row_count, 0); /* deprecated */
906
878
  rb_define_method(cDuckDBResult, "rows_changed", duckdb_result_rows_changed, 0);
907
879
  rb_define_method(cDuckDBResult, "columns", duckdb_result_columns, 0);
908
880
  rb_define_method(cDuckDBResult, "streaming?", duckdb_result_streaming_p, 0);
909
- rb_define_method(cDuckDBResult, "chunk_each", duckdb_result_chunk_each, 0);
881
+ rb_define_private_method(cDuckDBResult, "_chunk_each", duckdb_result__chunk_each, 0);
910
882
  rb_define_private_method(cDuckDBResult, "_chunk_stream", duckdb_result__chunk_stream, 0);
911
883
  rb_define_private_method(cDuckDBResult, "_column_type", duckdb_result__column_type, 1);
912
884
  rb_define_private_method(cDuckDBResult, "_return_type", duckdb_result__return_type, 0);
@@ -5,25 +5,23 @@
5
5
  #define DUCKDB_NO_EXTENSION_FUNCTIONS // disable extension C-functions
6
6
 
7
7
  #include "ruby.h"
8
+ #include "ruby/thread.h"
8
9
  #include <duckdb.h>
9
10
 
10
- #ifdef HAVE_DUCKDB_FETCH_CHUNK
11
- #define HAVE_DUCKDB_H_GE_V1_0_0 1
12
- #endif
13
-
14
- #ifdef HAVE_DUCKDB_RESULT_ERROR_TYPE
15
- #define HAVE_DUCKDB_H_GE_V1_1_0 1
16
- #endif
17
-
18
11
  #ifdef HAVE_CONST_DUCKDB_TYPE_SQLNULL
19
12
  #define HAVE_DUCKDB_H_GE_V1_1_1 1
20
13
  #endif
21
14
 
15
+ #ifdef HAVE_DUCKDB_CREATE_INSTANCE_CACHE
16
+ #define HAVE_DUCKDB_H_GE_V1_2_0 1
17
+ #endif
18
+
22
19
  #include "./error.h"
23
20
  #include "./database.h"
24
21
  #include "./connection.h"
25
22
  #include "./result.h"
26
23
  #include "./column.h"
24
+ #include "./logical_type.h"
27
25
  #include "./prepared_statement.h"
28
26
  #include "./extracted_statements.h"
29
27
  #include "./pending_result.h"