Skip to content

Commit d4a7917

Browse files
authored
Merge pull request #98 from asg017/main
Bind BLOBs as BLOBs instead of strings
2 parents 647f140 + 3ec103d commit d4a7917

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/include/sqlite_stmt.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class SQLiteStatement {
4141
throw InternalException("Unsupported type for SQLiteStatement::Bind");
4242
}
4343
void BindText(idx_t col, const string_t &value);
44+
void BindBlob(idx_t col, const string_t &value);
4445
void BindValue(Vector &col, idx_t c, idx_t r);
4546
int GetType(idx_t col);
4647
bool IsOpen();

src/sqlite_stmt.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ void SQLiteStatement::Bind(idx_t col, double value) {
130130
SQLiteUtils::Check(sqlite3_bind_double(stmt, col + 1, value), db);
131131
}
132132

133+
void SQLiteStatement::BindBlob(idx_t col, const string_t &value) {
134+
SQLiteUtils::Check(sqlite3_bind_blob(stmt, col + 1, value.GetDataUnsafe(), value.GetSize(), nullptr), db);
135+
}
136+
133137
void SQLiteStatement::BindText(idx_t col, const string_t &value) {
134138
SQLiteUtils::Check(sqlite3_bind_text(stmt, col + 1, value.GetDataUnsafe(), value.GetSize(), nullptr), db);
135139
}
@@ -152,6 +156,8 @@ void SQLiteStatement::BindValue(Vector &col, idx_t c, idx_t r) {
152156
Bind<double>(c, FlatVector::GetData<double>(col)[r]);
153157
break;
154158
case LogicalTypeId::BLOB:
159+
BindBlob(c, FlatVector::GetData<string_t>(col)[r]);
160+
break;
155161
case LogicalTypeId::VARCHAR:
156162
BindText(c, FlatVector::GetData<string_t>(col)[r]);
157163
break;

0 commit comments

Comments
 (0)