ext/duckdb/result.c in duckdb-0.8.1 vs ext/duckdb/result.c in duckdb-0.8.1.1

- old
+ new

@@ -360,10 +360,11 @@ TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx); logical_type = duckdb_column_logical_type(&(ctx->result), NUM2LL(col_idx)); if (logical_type) { type = LL2NUM(duckdb_enum_internal_type(logical_type)); } + duckdb_destroy_logical_type(&logical_type); return type; } static VALUE duckdb_result__enum_dictionary_size(VALUE oDuckDBResult, VALUE col_idx) { rubyDuckDBResult *ctx; @@ -373,10 +374,11 @@ TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx); logical_type = duckdb_column_logical_type(&(ctx->result), NUM2LL(col_idx)); if (logical_type) { size = UINT2NUM(duckdb_enum_dictionary_size(logical_type)); } + duckdb_destroy_logical_type(&logical_type); return size; } static VALUE duckdb_result__enum_dictionary_value(VALUE oDuckDBResult, VALUE col_idx, VALUE idx) { rubyDuckDBResult *ctx; @@ -391,33 +393,32 @@ if (p) { value = rb_utf8_str_new_cstr(p); duckdb_free(p); } } + duckdb_destroy_logical_type(&logical_type); return value; } VALUE create_result(void) { return allocate(cDuckDBResult); } #ifdef HAVE_DUCKDB_H_GE_V080 static VALUE vector_date(void *vector_data, idx_t row_idx) { duckdb_date_struct date = duckdb_from_date(((duckdb_date *) vector_data)[row_idx]); - VALUE mConverter = rb_const_get(mDuckDB, rb_intern("Converter")); - return rb_funcall(mConverter, rb_intern("_to_date"), 3, + return rb_funcall(mDuckDBConverter, rb_intern("_to_date"), 3, INT2FIX(date.year), INT2FIX(date.month), INT2FIX(date.day) ); } static VALUE vector_timestamp(void* vector_data, idx_t row_idx) { duckdb_timestamp_struct data = duckdb_from_timestamp(((duckdb_timestamp *)vector_data)[row_idx]); - VALUE mConverter = rb_const_get(mDuckDB, rb_intern("Converter")); - return rb_funcall(mConverter, rb_intern("_to_time"), 7, + return rb_funcall(mDuckDBConverter, rb_intern("_to_time"), 7, INT2FIX(data.date.year), INT2FIX(data.date.month), INT2FIX(data.date.day), INT2FIX(data.time.hour), INT2FIX(data.time.min), @@ -426,12 +427,11 @@ ); } static VALUE vector_interval(void* vector_data, idx_t row_idx) { duckdb_interval data = ((duckdb_interval *)vector_data)[row_idx]; - VALUE mConverter = rb_const_get(mDuckDB, rb_intern("Converter")); - return rb_funcall(mConverter, rb_intern("_to_interval_from_vector"), 3, + return rb_funcall(mDuckDBConverter, rb_intern("_to_interval_from_vector"), 3, INT2NUM(data.months), INT2NUM(data.days), LL2NUM(data.micros) ); } @@ -454,21 +454,19 @@ } } static VALUE vector_hugeint(void* vector_data, idx_t row_idx) { duckdb_hugeint hugeint = ((duckdb_hugeint *)vector_data)[row_idx]; - VALUE mConverter = rb_const_get(mDuckDB, rb_intern("Converter")); - return rb_funcall(mConverter, rb_intern("_to_hugeint_from_vector"), 2, + return rb_funcall(mDuckDBConverter, rb_intern("_to_hugeint_from_vector"), 2, ULL2NUM(hugeint.lower), LL2NUM(hugeint.upper) ); } static VALUE vector_decimal(duckdb_logical_type ty, void* vector_data, idx_t row_idx) { uint8_t width = duckdb_decimal_width(ty); uint8_t scale = duckdb_decimal_scale(ty); - VALUE mConverter = rb_const_get(mDuckDB, rb_intern("Converter")); duckdb_type type = duckdb_decimal_internal_type(ty); duckdb_hugeint value; value.upper = 0; value.lower = 0; @@ -479,11 +477,11 @@ break; default: rb_warn("Unknown decimal internal type %d", type); } - return rb_funcall(mConverter, rb_intern("_to_decimal_from_vector"), 4, + return rb_funcall(mDuckDBConverter, rb_intern("_to_decimal_from_vector"), 4, INT2FIX(width), INT2FIX(scale), ULL2NUM(value.lower), LL2NUM(value.upper) ); @@ -579,12 +577,11 @@ return hash; } static VALUE vector_uuid(void* vector_data, idx_t row_idx) { duckdb_hugeint hugeint = ((duckdb_hugeint *)vector_data)[row_idx]; - VALUE mConverter = rb_const_get(mDuckDB, rb_intern("Converter")); - return rb_funcall(mConverter, rb_intern("_to_uuid_from_vector"), 2, + return rb_funcall(mDuckDBConverter, rb_intern("_to_uuid_from_vector"), 2, ULL2NUM(hugeint.lower), LL2NUM(hugeint.upper) ); } @@ -620,9 +617,21 @@ case DUCKDB_TYPE_INTEGER: obj = INT2NUM(((int32_t *) vector_data)[row_idx]); break; case DUCKDB_TYPE_BIGINT: obj = LL2NUM(((int64_t *) vector_data)[row_idx]); + break; + case DUCKDB_TYPE_UTINYINT: + obj = INT2FIX(((uint8_t *) vector_data)[row_idx]); + break; + case DUCKDB_TYPE_USMALLINT: + obj = INT2FIX(((uint16_t *) vector_data)[row_idx]); + break; + case DUCKDB_TYPE_UINTEGER: + obj = UINT2NUM(((uint32_t *) vector_data)[row_idx]); + break; + case DUCKDB_TYPE_UBIGINT: + obj = ULL2NUM(((uint64_t *) vector_data)[row_idx]); break; case DUCKDB_TYPE_HUGEINT: obj = vector_hugeint(vector_data, row_idx); break; case DUCKDB_TYPE_FLOAT: