Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Deal with node exiting race bug, clean some stuff.

  • Loading branch information...
commit a3401c87eb91c4b08503a643807566995386e007 1 parent ef34faf
@grumdrig authored Eric Fredricksen committed
Showing with 20 additions and 14 deletions.
  1. +1 −1  compiloop.py
  2. +13 −13 sqlite3_bindings.cc
  3. +6 −0 test.js
View
2  compiloop.py
@@ -9,7 +9,7 @@
def handler():
os.system("clear; rm -f test.db")
- os.system("node-waf build && node test.js && sqlite3 test.db .dump");
+ os.system("node-waf build && node test.js && sleep 1 && sqlite3 test.db .dump");
mtime = []
while True:
View
26 sqlite3_bindings.cc
@@ -87,15 +87,18 @@ class Sqlite3Db : public EventEmitter
String::Utf8Value usql(args[0]->ToString());
const char* sql(*usql);
- int changes = 0;
int param = 0;
- Local<Array> result(Array::New(0));
+ Local<Array> all(Array::New(0));
for(;;) {
sqlite3_stmt* stmt;
int rc = sqlite3_prepare_v2(*db, sql, -1, &stmt, &sql);
+ if (rc != SQLITE_OK) {
+ return ThrowException(Exception::Error(String::New(
+ sqlite3_errmsg(*db))));
+ }
if (!stmt) break;
Statement statement(stmt);
@@ -122,7 +125,7 @@ class Sqlite3Db : public EventEmitter
}
}
- Local<Array> rosult(Array::New(0));
+ Local<Array> rows(Array::New(0));
for (int r = 0; ; ++r) {
int rc = sqlite3_step(statement);
@@ -148,7 +151,7 @@ class Sqlite3Db : public EventEmitter
row->Set(String::NewSymbol(sqlite3_column_name(statement, c)),
value);
}
- rosult->Set(Integer::New(rosult->Length()), row);
+ rows->Set(Integer::New(rows->Length()), row);
} else if (rc == SQLITE_DONE) {
break;
} else {
@@ -157,20 +160,17 @@ class Sqlite3Db : public EventEmitter
}
}
- changes += sqlite3_changes(*db);
+ rows->Set(String::New("rowsAffected"),
+ Integer::New(sqlite3_changes(*db)));
+ rows->Set(String::New("insertId"),
+ Integer::New(sqlite3_last_insert_rowid(*db)));
- rosult->Set(String::New("rowsAffected"), Integer::New(sqlite3_changes(*db)));
- rosult->Set(String::New("insertId"),
- Integer::New(sqlite3_last_insert_rowid(*db)));
- result->Set(Integer::New(result->Length()), rosult);
+ all->Set(Integer::New(all->Length()), rows);
sqlite3_finalize(stmt);
}
- result->Set(String::New("rowsAffected"), Integer::New(changes));
- result->Set(String::New("insertId"),
- Integer::New(sqlite3_last_insert_rowid(*db)));
- return result;
+ return all;
}
View
6 test.js
@@ -82,6 +82,12 @@ db.transaction(function(tx) {
var na = db.query("");
asserteq(na, null);
+try {
+ na = db.query("CRAPPY QUERY THAT DOESN'T WORK");
+ asserteq("Apples", "Oranges");
+} catch (e) {
+}
+
db.close();
sys.puts("OK\n");
Please sign in to comment.
Something went wrong with that request. Please try again.