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

Bind BLOBs as BLOBs instead of strings #98

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/include/sqlite_stmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SQLiteStatement {
throw InternalException("Unsupported type for SQLiteStatement::Bind");
}
void BindText(idx_t col, const string_t &value);
void BindBlob(idx_t col, const string_t &value);
void BindValue(Vector &col, idx_t c, idx_t r);
int GetType(idx_t col);
bool IsOpen();
Expand Down
6 changes: 6 additions & 0 deletions src/sqlite_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ void SQLiteStatement::Bind(idx_t col, double value) {
SQLiteUtils::Check(sqlite3_bind_double(stmt, col + 1, value), db);
}

void SQLiteStatement::BindBlob(idx_t col, const string_t &value) {
SQLiteUtils::Check(sqlite3_bind_blob(stmt, col + 1, value.GetDataUnsafe(), value.GetSize(), nullptr), db);
}

void SQLiteStatement::BindText(idx_t col, const string_t &value) {
SQLiteUtils::Check(sqlite3_bind_text(stmt, col + 1, value.GetDataUnsafe(), value.GetSize(), nullptr), db);
}
Expand All @@ -152,6 +156,8 @@ void SQLiteStatement::BindValue(Vector &col, idx_t c, idx_t r) {
Bind<double>(c, FlatVector::GetData<double>(col)[r]);
break;
case LogicalTypeId::BLOB:
BindBlob(c, FlatVector::GetData<string_t>(col)[r]);
break;
case LogicalTypeId::VARCHAR:
BindText(c, FlatVector::GetData<string_t>(col)[r]);
break;
Expand Down
Loading