Skip to content

Commit f2755e3

Browse files
authored
Merge pull request #1102 from suketa/fix/table-function-extra-info-conflict
fix: Resolve extra_info pointer conflict between bind and execute callbacks
2 parents 31635c1 + 5297829 commit f2755e3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ext/duckdb/table_function.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static VALUE rbduckdb_table_function_set_bind(VALUE self) {
176176

177177
ctx->bind_proc = rb_block_proc();
178178

179-
duckdb_table_function_set_extra_info(ctx->table_function, ctx, NULL);
179+
duckdb_table_function_set_extra_info(ctx->table_function, (void *)self, NULL);
180180
duckdb_table_function_set_bind(ctx->table_function, table_function_bind_callback);
181181

182182
return self;
@@ -188,13 +188,16 @@ static VALUE call_bind_proc(VALUE arg) {
188188
}
189189

190190
static void table_function_bind_callback(duckdb_bind_info info) {
191+
VALUE self;
191192
rubyDuckDBTableFunction *ctx;
192193
rubyDuckDBBindInfo *bind_info_ctx;
193194
VALUE bind_info_obj;
194195
int state = 0;
195196

196-
ctx = (rubyDuckDBTableFunction *)duckdb_bind_get_extra_info(info);
197-
if (!ctx || ctx->bind_proc == Qnil) {
197+
self = (VALUE)duckdb_bind_get_extra_info(info);
198+
TypedData_Get_Struct(self, rubyDuckDBTableFunction, &table_function_data_type, ctx);
199+
200+
if (ctx->bind_proc == Qnil) {
198201
return;
199202
}
200203

0 commit comments

Comments
 (0)