ext/duckdb/prepared_statement.c in duckdb-0.0.6 vs ext/duckdb/prepared_statement.c in duckdb-0.0.7

- old
+ new

@@ -59,23 +59,23 @@ rb_raise(eDuckDBError, "%s", ctxr->result.error_message); } return result; } -static index_t check_index(VALUE vidx) +static idx_t check_index(VALUE vidx) { - index_t idx = FIX2INT(vidx); + idx_t idx = FIX2INT(vidx); if (idx <= 0) { rb_raise(rb_eArgError, "index of parameter must be greater than 0"); } return idx; } static VALUE duckdb_prepared_statement_bind_boolean(VALUE self, VALUE vidx, VALUE val) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (val != Qtrue && val != Qfalse) { rb_raise(rb_eArgError, "binding value must be boolean"); } @@ -87,11 +87,11 @@ } static VALUE duckdb_prepared_statement_bind_int16(VALUE self, VALUE vidx, VALUE val) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); int16_t i16val = NUM2INT(val); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (duckdb_bind_int16(ctx->prepared_statement, idx, i16val) == DuckDBError) { @@ -101,11 +101,11 @@ } static VALUE duckdb_prepared_statement_bind_int32(VALUE self, VALUE vidx, VALUE val) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); int32_t i32val = NUM2LONG(val); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (duckdb_bind_int32(ctx->prepared_statement, idx, i32val) == DuckDBError) { @@ -115,11 +115,11 @@ } static VALUE duckdb_prepared_statement_bind_int64(VALUE self, VALUE vidx, VALUE val) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); int64_t i64val = NUM2LL(val); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (duckdb_bind_int64(ctx->prepared_statement, idx, i64val) == DuckDBError) { @@ -129,11 +129,11 @@ } static VALUE duckdb_prepared_statement_bind_float(VALUE self, VALUE vidx, VALUE val) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); double dbl = NUM2DBL(val); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (duckdb_bind_float(ctx->prepared_statement, idx, (float)dbl) == DuckDBError) { @@ -143,11 +143,11 @@ } static VALUE duckdb_prepared_statement_bind_double(VALUE self, VALUE vidx, VALUE val) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); double dbl = NUM2DBL(val); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (duckdb_bind_double(ctx->prepared_statement, idx, dbl) == DuckDBError) { @@ -157,32 +157,30 @@ } static VALUE duckdb_prepared_statement_bind_varchar(VALUE self, VALUE vidx, VALUE str) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (duckdb_bind_varchar(ctx->prepared_statement, idx, StringValuePtr(str)) == DuckDBError) { rb_raise(eDuckDBError, "fail to bind %ld parameter", idx); } return self; } -#ifdef HAVE_DUCKDB_BIND_NULL static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx) { rubyDuckDBPreparedStatement *ctx; - index_t idx = check_index(vidx); + idx_t idx = check_index(vidx); Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx); if (duckdb_bind_null(ctx->prepared_statement, idx) == DuckDBError) { rb_raise(eDuckDBError, "fail to bind %ld parameter", idx); } return self; } -#endif void init_duckdb_prepared_statement(void) { cDuckDBPreparedStatement = rb_define_class_under(mDuckDB, "PreparedStatement", rb_cObject); @@ -196,10 +194,7 @@ rb_define_method(cDuckDBPreparedStatement, "bind_int32", duckdb_prepared_statement_bind_int32, 2); rb_define_method(cDuckDBPreparedStatement, "bind_int64", duckdb_prepared_statement_bind_int64, 2); rb_define_method(cDuckDBPreparedStatement, "bind_float", duckdb_prepared_statement_bind_float, 2); rb_define_method(cDuckDBPreparedStatement, "bind_double", duckdb_prepared_statement_bind_double, 2); rb_define_method(cDuckDBPreparedStatement, "bind_varchar", duckdb_prepared_statement_bind_varchar, 2); -#ifdef HAVE_DUCKDB_BIND_NULL - /* duckdb version > 0.1.1 */ rb_define_method(cDuckDBPreparedStatement, "bind_null", duckdb_prepared_statement_bind_null, 1); -#endif }