Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Support binding multiple rows #222

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/MariaBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void MariaBinding::init_binding(const List& params_) {
binding_update(j, MYSQL_TYPE_TINY, 1);
break;
case MY_INT32:
binding_update(j, MYSQL_TYPE_LONG, 4);
binding_update(j, MYSQL_TYPE_LONG, 4 * n_rows);
break;
case MY_DBL:
binding_update(j, MYSQL_TYPE_DOUBLE, 8);
binding_update(j, MYSQL_TYPE_DOUBLE, 8 * n_rows);
break;
case MY_DATE:
binding_update(j, MYSQL_TYPE_DATE, sizeof(MYSQL_TIME));
Expand Down Expand Up @@ -89,6 +89,8 @@ bool MariaBinding::bind_next_row() {

if (i >= n_rows) return false;

R_xlen_t delta = n_rows - i;

for (int j = 0; j < p; ++j) {
LOG_VERBOSE << j << " -> " << type_name(types[j]);

Expand Down Expand Up @@ -177,11 +179,13 @@ bool MariaBinding::bind_next_row() {
is_null[j] = missing;
}

LOG_VERBOSE << "Binding";
LOG_DEBUG << "Binding";
mysql_stmt_bind_param(statement, &bindings[0]);

LOG_VERBOSE << "Done binding row" << i;
i++;
mysql_stmt_attr_set(statement, STMT_ATTR_ARRAY_SIZE, &delta);

LOG_DEBUG << "Done binding row " << i << " (" << delta << ")";
i += delta;
return true;
}

Expand Down