From e5a90e22e7b11d9c98c3f2c0a295a859e7ec6ab6 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sun, 2 Mar 2008 12:23:18 -0500 Subject: Whitespace, remove some debugging. --- src/mysqlerl.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/mysqlerl.c b/src/mysqlerl.c index 1e36b86..0faa31d 100644 --- a/src/mysqlerl.c +++ b/src/mysqlerl.c @@ -13,6 +13,13 @@ const char *QUERY_MSG = "sql_query"; +void +usage() +{ + fprintf(stderr, "Usage: mysqlerl host port db_name user passwd\n"); + exit(1); +} + ETERM * handle_mysql_result(MYSQL_RES *result) { @@ -22,6 +29,7 @@ handle_mysql_result(MYSQL_RES *result) num_fields = mysql_num_fields(result); fields = mysql_fetch_fields(result); + cols = (ETERM **)malloc(num_fields * sizeof(ETERM *)); for (i = 0; i < num_fields; i++) { logmsg("DEBUG: cols[%d]: %s", i, fields[i].name); @@ -42,34 +50,26 @@ handle_mysql_result(MYSQL_RES *result) rowtup = (ETERM **)malloc(num_fields * sizeof(ETERM *)); for (j = 0; j < num_fields; j++) { - logmsg("DEBUG: rows[%d][%d] (%d): '%s'", i, j, lengths[j], row[j]); if (row[j]) rowtup[j] = erl_mk_estring(row[j], lengths[j]); else rowtup[j] = erl_mk_atom("NULL"); - logmsg("DEBUG: rowtup[%d]: %d", j, rowtup[j]); } - logmsg("DEBUG: making tuple of %d", num_fields); rt = erl_mk_tuple(rowtup, num_fields); if (rt == NULL) { logmsg("ERROR: couldn't allocate %d-tuple", num_fields); exit(3); } - logmsg("DEBUG: copying rt"); rows[i] = erl_format("~w", rt); - logmsg("DEBUG: freeing row fields"); for (j = 0; j < num_fields; j++) erl_free_term(rowtup[j]); free(rowtup); erl_free_term(rt); } - logmsg("DEBUG: making row list"); erows = erl_mk_list(rows, num_rows); - logmsg("DEBUG: preparing response"); - resp = erl_format("{selected, ~w, ~w}", - ecols, erows); + resp = erl_format("{selected, ~w, ~w}", ecols, erows); for (i = 0; i < num_fields; i++) erl_free_term(cols[i]); @@ -138,13 +138,6 @@ dispatch_db_cmd(MYSQL *dbh, ETERM *msg) erl_free_term(tag); } -void -usage() -{ - fprintf(stderr, "Usage: mysqlerl host port db_name user passwd\n"); - exit(1); -} - int main(int argc, char *argv[]) { -- cgit v1.2.3