Skip to content

Commit

Permalink
Merge pull request #98 from asg017/main
Browse files Browse the repository at this point in the history
Bind BLOBs as BLOBs instead of strings
  • Loading branch information
Mytherin authored Sep 4, 2024
2 parents 647f140 + 3ec103d commit d4a7917
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
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

0 comments on commit d4a7917

Please sign in to comment.