From 51d00b969b2b06d306ac6513468b1645305ddeae Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 4 Nov 2014 00:10:03 +0100 Subject: [PATCH] extended print helper --- src/build_and_run_tests.sh | 11 +++++++---- src/lib/Statement.h | 1 - src/lib/sqlhelper.cpp | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/build_and_run_tests.sh b/src/build_and_run_tests.sh index 8101981..d08fbc2 100644 --- a/src/build_and_run_tests.sh +++ b/src/build_and_run_tests.sh @@ -4,10 +4,7 @@ make clean # make tests # ./bin/tests -# make execution -# ./bin/sql_execution "SELECT a FROM foo WHERE a > 12 OR b > 3 AND c = 3" -# ./bin/sql_execution "SELECT col1, col2, 'test' FROM table, foo WHERE age > 12 AND zipcode = 12345 GROUP BY col1;" -# ./bin/sql_execution "SELECT * from table WHERE (b OR NOT a) AND a = 12.5 JOIN table2 ON a = b" +make execution make grammar_test @@ -20,4 +17,10 @@ echo "\n\n" ./bin/grammar_test -f "(SELECT a FROM foo WHERE a > 12 OR b > 3 AND c = 3 LIMIT 10)" +echo "\n\n" + +./bin/sql_execution "SELECT a FROM foo WHERE a > 12 OR b > 3 AND c = 3" +./bin/sql_execution "SELECT col1, col2, 'test' FROM table, foo WHERE age > 12 AND zipcode = 12345 GROUP BY col1 ORDER BY col2 DESC LIMIT 100;" +# ./bin/sql_execution "SELECT * from table WHERE (b OR NOT a) AND a = 12.5 JOIN table2 ON a = b" + echo "\n\n" \ No newline at end of file diff --git a/src/lib/Statement.h b/src/lib/Statement.h index 74f2cef..ac97b84 100644 --- a/src/lib/Statement.h +++ b/src/lib/Statement.h @@ -22,7 +22,6 @@ typedef enum { typedef enum { - kOrderNone, kOrderAsc, kOrderDesc } OrderType; diff --git a/src/lib/sqlhelper.cpp b/src/lib/sqlhelper.cpp index 2887934..aa1cabd 100644 --- a/src/lib/sqlhelper.cpp +++ b/src/lib/sqlhelper.cpp @@ -64,10 +64,22 @@ void printSelectStatementInfo(SelectStatement* stmt, uint num_indent) { inprint("Sources:", num_indent+1); printTableRefInfo(stmt->from_table, num_indent+2); - inprint("Search Conditions:", num_indent+1); if (stmt->where_clause != NULL) { + inprint("Search Conditions:", num_indent+1); printExpression(stmt->where_clause, num_indent+2); - } else inprint("null", num_indent+2); + } + + if (stmt->order != NULL) { + inprint("OrderBy:", num_indent+1); + printExpression(stmt->order->expr, num_indent+2); + if (stmt->order->type == kOrderAsc) inprint("ascending", num_indent+2); + else inprint("descending", num_indent+2); + } + + if (stmt->limit != NULL) { + inprint("Limit:", num_indent+1); + inprint(stmt->limit->limit, num_indent+2); + } }