Commit d5917371 by Orlando Vazquez

remove debugging output

parent dae75342
...@@ -16,7 +16,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -16,7 +16,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
var sys = require("sys"); var sys = require("sys");
var puts = sys.puts;
var sqlite = require("./sqlite3_bindings"); var sqlite = require("./sqlite3_bindings");
var Database = exports.Database = function () { var Database = exports.Database = function () {
...@@ -26,14 +25,11 @@ var Database = exports.Database = function () { ...@@ -26,14 +25,11 @@ var Database = exports.Database = function () {
}; };
Database.prototype.dispatch = function () { Database.prototype.dispatch = function () {
puts('dispatching');
if (!this.queue || this.currentQuery if (!this.queue || this.currentQuery
|| !this.queue.length) { || !this.queue.length) {
puts("no queries\n" + inspect([this.queue, this.currentQuery]));
return; return;
} }
this.currentQuery = this.queue.shift(); this.currentQuery = this.queue.shift();
puts("current query\n" + inspect(this.currentQuery));
this.executeQuery.apply(this, this.currentQuery); this.executeQuery.apply(this, this.currentQuery);
} }
...@@ -79,7 +75,6 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) { ...@@ -79,7 +75,6 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) {
bindIndex = bindIndex || 1; bindIndex = bindIndex || 1;
var value = bindings.shift(); var value = bindings.shift();
puts("setting index " + bindIndex + " to " + value);
process.nextTick(function () { process.nextTick(function () {
statement.bind(bindIndex, value, function () { statement.bind(bindIndex, value, function () {
innerFunction(statement, bindings, bindIndex+1); innerFunction(statement, bindings, bindIndex+1);
...@@ -90,7 +85,6 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) { ...@@ -90,7 +85,6 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) {
function queryDone(statement, rows) { function queryDone(statement, rows) {
if (statement.tail) { if (statement.tail) {
puts("omg it has a tail");
statement.finalize(function () { statement.finalize(function () {
self.db.prepare(statement.tail, onPrepare); self.db.prepare(statement.tail, onPrepare);
}); });
...@@ -116,14 +110,12 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) { ...@@ -116,14 +110,12 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) {
return; return;
} }
rows.push(row); rows.push(row);
puts("added " + inspect(row));
process.nextTick(innerFunction); process.nextTick(innerFunction);
}); });
})(); })();
} }
function onPrepare(error, statement) { function onPrepare(error, statement) {
puts("prep args " + inspect(arguments));
if (bindings) { if (bindings) {
if (Object.prototype.toString.call(bindings) === "[object Array]") { if (Object.prototype.toString.call(bindings) === "[object Array]") {
doBindingsByIndex(statement, bindings, doStep); doBindingsByIndex(statement, bindings, doStep);
...@@ -134,7 +126,6 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) { ...@@ -134,7 +126,6 @@ Database.prototype.executeQuery = function(sql, bindings, queryCallback) {
} }
} }
puts("preparing");
this.db.prepare(sql, onPrepare); this.db.prepare(sql, onPrepare);
} }
......
...@@ -249,7 +249,6 @@ protected: ...@@ -249,7 +249,6 @@ protected:
struct close_request *close_req = (struct close_request *)(req->data); struct close_request *close_req = (struct close_request *)(req->data);
Sqlite3Db* dbo = close_req->dbo; Sqlite3Db* dbo = close_req->dbo;
int rc = req->result = sqlite3_close(*dbo); int rc = req->result = sqlite3_close(*dbo);
printf("closed database, rc = %d\n", rc);
dbo->db_ = NULL; dbo->db_ = NULL;
return 0; return 0;
} }
...@@ -517,13 +516,11 @@ protected: ...@@ -517,13 +516,11 @@ protected:
switch(bind_req->key_type) { switch(bind_req->key_type) {
case KEY_INT: case KEY_INT:
index = *(int*)(bind_req->key); index = *(int*)(bind_req->key);
printf("key was %d\n", index);
break; break;
case KEY_STRING: case KEY_STRING:
index = sqlite3_bind_parameter_index( index = sqlite3_bind_parameter_index(
*sto, (char*)(bind_req->key)); *sto, (char*)(bind_req->key));
printf("key was %s (index %d)\n", (char*)(bind_req->key), index);
break; break;
default: { default: {
...@@ -539,20 +536,16 @@ protected: ...@@ -539,20 +536,16 @@ protected:
int rc = 0; int rc = 0;
switch(bind_req->value_type) { switch(bind_req->value_type) {
case VALUE_INT: case VALUE_INT:
printf("value was an int\n");
rc = sqlite3_bind_int(*sto, index, *(int*)(bind_req->value)); rc = sqlite3_bind_int(*sto, index, *(int*)(bind_req->value));
break; break;
case VALUE_DOUBLE: case VALUE_DOUBLE:
printf("value was a double %f\n", *(double*)(bind_req->value));
rc = sqlite3_bind_double(*sto, index, *(double*)(bind_req->value)); rc = sqlite3_bind_double(*sto, index, *(double*)(bind_req->value));
break; break;
case VALUE_STRING: case VALUE_STRING:
printf("value was a string, '%s'\n", (char*)(bind_req->value));
rc = sqlite3_bind_text(*sto, index, (char*)(bind_req->value), rc = sqlite3_bind_text(*sto, index, (char*)(bind_req->value),
bind_req->value_size, SQLITE_TRANSIENT); bind_req->value_size, SQLITE_TRANSIENT);
break; break;
case VALUE_NULL: case VALUE_NULL:
printf("value was NULL\n");
rc = sqlite3_bind_null(*sto, index); rc = sqlite3_bind_null(*sto, index);
break; break;
...@@ -593,7 +586,6 @@ protected: ...@@ -593,7 +586,6 @@ protected:
strcpy(key, *keyValue); strcpy(key, *keyValue);
bind_req->key = key; bind_req->key = key;
printf("attempting to bind to key %s\n", key);
} }
else if (args[0]->IsInt32()) { else if (args[0]->IsInt32()) {
bind_req->key_type = KEY_INT; bind_req->key_type = KEY_INT;
...@@ -603,7 +595,6 @@ protected: ...@@ -603,7 +595,6 @@ protected:
// don't forget to `free` this // don't forget to `free` this
bind_req->key = index; bind_req->key = index;
printf("attempting to bind to index %d\n", (int) *index);
} }
// setup value // setup value
...@@ -676,7 +667,6 @@ protected: ...@@ -676,7 +667,6 @@ protected:
TryCatch try_catch; TryCatch try_catch;
Local<Value> argv[1]; Local<Value> argv[1];
printf("rc for finalize = %d\n", (int)req->result);
argv[0] = Local<Value>::New(Undefined()); argv[0] = Local<Value>::New(Undefined());
finalize_req->cb->Call( finalize_req->cb->Call(
...@@ -762,11 +752,9 @@ protected: ...@@ -762,11 +752,9 @@ protected:
struct step_request *step_req = (struct step_request *)(req->data); struct step_request *step_req = (struct step_request *)(req->data);
void **data = step_req->column_data; void **data = step_req->column_data;
printf("there were %d columns\n", step_req->column_count);
Local<Value> argv[2]; Local<Value> argv[2];
if (step_req->error_msg) { if (step_req->error_msg) {
printf("there's been an error %d\n", (int) req->result);
argv[0] = Exception::Error(String::New(step_req->error_msg)); argv[0] = Exception::Error(String::New(step_req->error_msg));
} }
else { else {
...@@ -782,21 +770,18 @@ protected: ...@@ -782,21 +770,18 @@ protected:
for (int i = 0; i < step_req->column_count; i++) { for (int i = 0; i < step_req->column_count; i++) {
switch(step_req->column_types[i]) { switch(step_req->column_types[i]) {
case SQLITE_INTEGER: case SQLITE_INTEGER:
printf("integer value was %d\n", *(int*)(step_req->column_data[i]));
row->Set(String::New(step_req->column_names[i]), row->Set(String::New(step_req->column_names[i]),
Int32::New(*(int*) (step_req->column_data[i]))); Int32::New(*(int*) (step_req->column_data[i])));
free((int*)(step_req->column_data[i])); free((int*)(step_req->column_data[i]));
break; break;
case SQLITE_TEXT: case SQLITE_TEXT:
printf("string value was %s\n", (char *) (step_req->column_data[i]));
row->Set(String::New(step_req->column_names[i]), row->Set(String::New(step_req->column_names[i]),
String::New((char *) (step_req->column_data[i]))); String::New((char *) (step_req->column_data[i])));
// don't free this pointer, it's owned by sqlite3 // don't free this pointer, it's owned by sqlite3
break; break;
default: // no default
printf("Unknown type error!\n");
} }
} }
...@@ -830,7 +815,6 @@ protected: ...@@ -830,7 +815,6 @@ protected:
sqlite3_stmt *stmt = *sto; sqlite3_stmt *stmt = *sto;
int rc = req->result = sqlite3_step(stmt); int rc = req->result = sqlite3_step(stmt);
printf("result of step %d\n", rc);
if (rc == SQLITE_ROW) { if (rc == SQLITE_ROW) {
// would be nice to cache the column names and type data somewhere // would be nice to cache the column names and type data somewhere
step_req->column_count = sqlite3_column_count(stmt); step_req->column_count = sqlite3_column_count(stmt);
...@@ -850,7 +834,6 @@ protected: ...@@ -850,7 +834,6 @@ protected:
int *value = (int *) malloc(sizeof(int)); int *value = (int *) malloc(sizeof(int));
*value = sqlite3_column_int(stmt, i); *value = sqlite3_column_int(stmt, i);
step_req->column_data[i] = value; step_req->column_data[i] = value;
printf("serialized int %d\n", *(int *)(step_req->column_data[i]));
} }
break; break;
...@@ -858,7 +841,6 @@ protected: ...@@ -858,7 +841,6 @@ protected:
double *value = (double *) malloc(sizeof(double)); double *value = (double *) malloc(sizeof(double));
*value = sqlite3_column_double(stmt, i); *value = sqlite3_column_double(stmt, i);
step_req->column_data[i] = value; step_req->column_data[i] = value;
printf("serialized float\n");
} }
break; break;
...@@ -870,13 +852,11 @@ protected: ...@@ -870,13 +852,11 @@ protected:
// until it is used in `EIO_AfterStep` // until it is used in `EIO_AfterStep`
char *value = (char *) sqlite3_column_text(stmt, i); char *value = (char *) sqlite3_column_text(stmt, i);
step_req->column_data[i] = value; step_req->column_data[i] = value;
printf("serialized text %s\n", (char *)(step_req->column_data[i]));
} }
break; break;
default: { default: {
// unsupported type // unsupported type
printf("default, not serialized\n");
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment