Skip to content

Commit ab3e15d

Browse files
author
Joshua Wise
committed
fixed bug
1 parent f07768d commit ab3e15d

File tree

10 files changed

+12
-24
lines changed

10 files changed

+12
-24
lines changed

src/binder/bind-buffer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
void Binder::BindBuffer(v8::Local<v8::Object> value, int index) {
66
if (!index) {index = NextAnonIndex();}
77

8-
int status = sqlite3_bind_blob(handle, index, node::Buffer::Data(value), node::Buffer::Length(value), transient_buffers ? SQLITE_TRANSIENT : bind_type);
8+
int status = sqlite3_bind_blob(handle, index, node::Buffer::Data(value), node::Buffer::Length(value), bind_type);
99

1010
SetBindingError(status);
1111
}

src/binder/bind-string.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void Binder::BindString(v8::Local<v8::String> value, int index) {
66
if (!index) {index = NextAnonIndex();}
77

88
v8::String::Utf8Value utf8(value);
9-
int status = sqlite3_bind_text(handle, index, *utf8, utf8.length(), bind_type);
9+
int status = sqlite3_bind_text(handle, index, *utf8, utf8.length(), SQLITE_TRANSIENT);
1010

1111
SetBindingError(status);
1212
}

src/binder/binder.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323
#include "bind-object.cc"
2424
#include "bind.cc"
2525

26-
Binder::Binder(sqlite3_stmt* handle, sqlite3_destructor_type bind_type, bool transient_buffers)
26+
Binder::Binder(sqlite3_stmt* handle, sqlite3_destructor_type bind_type)
2727
: handle(handle)
2828
, param_count(sqlite3_bind_parameter_count(handle))
2929
, anon_index(0)
3030
, error(NULL)
3131
, error_extra(NULL)
3232
, error_full(NULL)
33-
, bind_type(bind_type)
34-
, transient_buffers(transient_buffers) {}
33+
, bind_type(bind_type) {}
3534

3635
Binder::~Binder() {
3736
delete[] error_extra;

src/binder/binder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Int64;
88

99
class Binder {
1010
public:
11-
explicit Binder(sqlite3_stmt*, sqlite3_destructor_type, bool = false);
11+
explicit Binder(sqlite3_stmt*, sqlite3_destructor_type);
1212
~Binder();
1313
virtual void Bind(Nan::NAN_METHOD_ARGS_TYPE, int, Query*);
1414
const char* GetError();
@@ -37,7 +37,6 @@ class Binder {
3737
const char* error_full;
3838

3939
sqlite3_destructor_type bind_type;
40-
bool transient_buffers;
4140
};
4241

4342
#endif

src/objects/statement/all.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NAN_METHOD(Statement::All) {
55
if (stmt->column_count == 0) {
66
return Nan::ThrowTypeError("This statement is not read-only. Use run() instead.");
77
}
8-
QUERY_START(stmt, statement, STATEMENT_BIND, info, info.Length());
8+
QUERY_START(stmt, statement, STATEMENT_BIND, SQLITE_STATIC, info, info.Length());
99

1010
unsigned int row_count = 0;
1111
List<v8::Local<v8::Value>> rows;

src/objects/statement/each.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NAN_METHOD(Statement::Each) {
66
return Nan::ThrowTypeError("This statement is not read-only. Use run() instead.");
77
}
88
REQUIRE_LAST_ARGUMENT_FUNCTION(func_index, callback);
9-
QUERY_START(stmt, statement, STATEMENT_BIND_T_BUFFERS, info, func_index);
9+
QUERY_START(stmt, statement, STATEMENT_BIND, SQLITE_TRANSIENT, info, func_index);
1010
stmt->db->in_each = true;
1111

1212
// Retrieve and feed rows.

src/objects/statement/get.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NAN_METHOD(Statement::Get) {
55
if (stmt->column_count == 0) {
66
return Nan::ThrowTypeError("This statement is not read-only. Use run() instead.");
77
}
8-
QUERY_START(stmt, statement, STATEMENT_BIND, info, info.Length());
8+
QUERY_START(stmt, statement, STATEMENT_BIND, SQLITE_STATIC, info, info.Length());
99

1010
int status = sqlite3_step(stmt->st_handle);
1111
if (status == SQLITE_ROW) {

src/objects/statement/run.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NAN_METHOD(Statement::Run) {
55
if (stmt->column_count != 0) {
66
return Nan::ThrowTypeError("This statement is read-only. Use get(), all(), or each() instead.");
77
}
8-
QUERY_START(stmt, statement, STATEMENT_BIND, info, info.Length());
8+
QUERY_START(stmt, statement, STATEMENT_BIND, SQLITE_STATIC, info, info.Length());
99

1010
sqlite3* db_handle = stmt->db->db_handle;
1111
int total_changes_before = sqlite3_total_changes(db_handle);

src/objects/transaction/run.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
NAN_METHOD(Transaction::Run) {
44
Transaction* trans = Nan::ObjectWrap::Unwrap<Transaction>(info.This());
5-
QUERY_START(trans, transaction, TRANSACTION_BIND, info, info.Length());
5+
QUERY_START(trans, transaction, TRANSACTION_BIND, SQLITE_STATIC, info, info.Length());
66

77
sqlite3* db_handle = trans->db->db_handle;
88
TransactionHandles* t_handles = trans->db->t_handles;

src/util/macros.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,6 @@ inline bool IS_32BIT_INT(double num) {
165165
return Nan::ThrowError(_err); \
166166
}
167167

168-
// Should be the same as STATEMENT_BIND, but uses the transient_buffers option.
169-
#define STATEMENT_BIND_T_BUFFERS(stmt, info, info_length, bind_type) \
170-
Binder _binder(stmt->st_handle, bind_type, true); \
171-
_binder.Bind(info, info_length, stmt); \
172-
const char* _err = _binder.GetError(); \
173-
if (_err) { \
174-
STATEMENT_CLEAR_BINDINGS(stmt); \
175-
return Nan::ThrowError(_err); \
176-
}
177-
178168
// Common bind logic for transactions.
179169
#define TRANSACTION_BIND(trans, info, info_length, bind_type) \
180170
MultiBinder _binder(trans->handles, trans->handle_count, bind_type); \
@@ -186,7 +176,7 @@ inline bool IS_32BIT_INT(double num) {
186176
}
187177

188178
// The macro-instruction that runs before an SQLite request.
189-
#define QUERY_START(obj, object_name, BIND_MACRO, info, info_length) \
179+
#define QUERY_START(obj, object_name, BIND_MACRO, bind_type, info, info_length)\
190180
if (obj->db->in_each) { \
191181
return Nan::ThrowTypeError( \
192182
"This database connection is busy executing a query."); \
@@ -197,7 +187,7 @@ inline bool IS_32BIT_INT(double num) {
197187
} \
198188
if (!(obj->state & CONFIG_LOCKED)) {obj->state |= CONFIG_LOCKED;} \
199189
if (!(obj->state & BOUND)) { \
200-
BIND_MACRO(obj, info, info_length, SQLITE_STATIC); \
190+
BIND_MACRO(obj, info, info_length, bind_type); \
201191
} else if (info_length > 0) { \
202192
return Nan::ThrowTypeError( \
203193
"This " #object_name " already has bound parameters."); \

0 commit comments

Comments
 (0)