ext/duckdb/prepared_statement.c in duckdb-0.3.2.0 vs ext/duckdb/prepared_statement.c in duckdb-0.3.3.0
- old
+ new
@@ -16,28 +16,15 @@
static VALUE duckdb_prepared_statement_bind_float(VALUE self, VALUE vidx, VALUE val);
static VALUE duckdb_prepared_statement_bind_double(VALUE self, VALUE vidx, VALUE val);
static VALUE duckdb_prepared_statement_bind_varchar(VALUE self, VALUE vidx, VALUE str);
static VALUE duckdb_prepared_statement_bind_blob(VALUE self, VALUE vidx, VALUE blob);
static VALUE duckdb_prepared_statement_bind_null(VALUE self, VALUE vidx);
-
-#ifdef HAVE_DUCKDB_BIND_DATE
static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day);
-#endif
-
-#ifdef HAVE_DUCKDB_BIND_TIME
static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE hour, VALUE min, VALUE sec, VALUE micros);
-#endif
-
-#ifdef HAVE_DUCKDB_BIND_TIMESTAMP
static VALUE duckdb_prepared_statement__bind_timestamp(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros);
-#endif
-
-#ifdef HAVE_DUCKDB_BIND_INTERVAL
static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VALUE months, VALUE days, VALUE micros);
-#endif
-
static void deallocate(void *ctx) {
rubyDuckDBPreparedStatement *p = (rubyDuckDBPreparedStatement *)ctx;
duckdb_destroy_prepare(&(p->prepared_statement));
xfree(p);
@@ -72,18 +59,11 @@
}
static VALUE duckdb_prepared_statement_nparams(VALUE self) {
rubyDuckDBPreparedStatement *ctx;
Data_Get_Struct(self, rubyDuckDBPreparedStatement, ctx);
-#ifdef HAVE_DUCKDB_NPARAMS_029
return rb_int2big(duckdb_nparams(ctx->prepared_statement));
-#else
- if (duckdb_nparams(ctx->prepared_statement, &(ctx->nparams)) == DuckDBError) {
- rb_raise(eDuckDBError, "failed to get number of parameters");
- }
- return rb_int2big(ctx->nparams);
-#endif
}
static VALUE duckdb_prepared_statement_execute(VALUE self) {
rubyDuckDBPreparedStatement *ctx;
@@ -230,11 +210,10 @@
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
}
return self;
}
-#ifdef HAVE_DUCKDB_BIND_DATE
static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day) {
rubyDuckDBPreparedStatement *ctx;
duckdb_date dt;
idx_t idx = check_index(vidx);
@@ -244,13 +223,11 @@
if (duckdb_bind_date(ctx->prepared_statement, idx, dt) == DuckDBError) {
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
}
return self;
}
-#endif
-#ifdef HAVE_DUCKDB_BIND_TIME
static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE hour, VALUE min, VALUE sec, VALUE micros){
rubyDuckDBPreparedStatement *ctx;
duckdb_time time;
idx_t idx = check_index(vidx);
@@ -261,13 +238,11 @@
if (duckdb_bind_time(ctx->prepared_statement, idx, time) == DuckDBError) {
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
}
return self;
}
-#endif
-#ifdef HAVE_DUCKDB_BIND_TIMESTAMP
static VALUE duckdb_prepared_statement__bind_timestamp(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros) {
duckdb_timestamp timestamp;
rubyDuckDBPreparedStatement *ctx;
idx_t idx = check_index(vidx);
@@ -277,13 +252,11 @@
if (duckdb_bind_timestamp(ctx->prepared_statement, idx, timestamp) == DuckDBError) {
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
}
return self;
}
-#endif
-#ifdef HAVE_DUCKDB_BIND_INTERVAL
static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VALUE months, VALUE days, VALUE micros) {
duckdb_interval interval;
rubyDuckDBPreparedStatement *ctx;
idx_t idx = check_index(vidx);
@@ -293,11 +266,10 @@
if (duckdb_bind_interval(ctx->prepared_statement, idx, interval) == DuckDBError) {
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
}
return self;
}
-#endif
void init_duckdb_prepared_statement(void) {
cDuckDBPreparedStatement = rb_define_class_under(mDuckDB, "PreparedStatement", rb_cObject);
rb_define_alloc_func(cDuckDBPreparedStatement, allocate);
@@ -314,15 +286,9 @@
rb_define_method(cDuckDBPreparedStatement, "bind_double", duckdb_prepared_statement_bind_double, 2);
rb_define_method(cDuckDBPreparedStatement, "bind_varchar", duckdb_prepared_statement_bind_varchar, 2);
rb_define_method(cDuckDBPreparedStatement, "bind_blob", duckdb_prepared_statement_bind_blob, 2);
rb_define_method(cDuckDBPreparedStatement, "bind_null", duckdb_prepared_statement_bind_null, 1);
rb_define_private_method(cDuckDBPreparedStatement, "_bind_date", duckdb_prepared_statement__bind_date, 4);
-#ifdef HAVE_DUCKDB_BIND_TIME
rb_define_private_method(cDuckDBPreparedStatement, "_bind_time", duckdb_prepared_statement__bind_time, 5);
-#endif
-#ifdef HAVE_DUCKDB_BIND_TIMESTAMP
rb_define_private_method(cDuckDBPreparedStatement, "_bind_timestamp", duckdb_prepared_statement__bind_timestamp, 8);
-#endif
-#ifdef HAVE_DUCKDB_BIND_INTERVAL
rb_define_private_method(cDuckDBPreparedStatement, "_bind_interval", duckdb_prepared_statement__bind_interval, 4);
-#endif
}