extended print helper

This commit is contained in:
Pedro 2014-11-04 00:10:03 +01:00
parent 9002abe81b
commit 51d00b969b
3 changed files with 21 additions and 7 deletions

View File

@ -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
@ -21,3 +18,9 @@ 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"

View File

@ -22,7 +22,6 @@ typedef enum {
typedef enum {
kOrderNone,
kOrderAsc,
kOrderDesc
} OrderType;

View File

@ -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);
}
}