diff --git a/src/lib/Expr.h b/src/lib/Expr.h index 62c5b84..5ab054d 100644 --- a/src/lib/Expr.h +++ b/src/lib/Expr.h @@ -75,6 +75,22 @@ struct Expr { OperatorType op_type; char op_char; + + /** + * Convenience accessor methods + */ + inline bool hasAlias() { return alias != NULL; } + inline char* getName() { + if (alias != NULL) return alias; + else return name; + } + inline bool isSimpleOp() { return op_type == SIMPLE_OP; } + inline bool isSimpleOp(char op) { return isSimpleOp() && op_char == op; } + + + /** + * Static expression constructors + */ static Expr* makeOpUnary(OperatorType op, Expr* expr); static Expr* makeOpBinary(Expr* expr1, char op, Expr* expr2); static Expr* makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2); diff --git a/src/lib/Table.h b/src/lib/Table.h index 1f3e0e4..a1951f2 100644 --- a/src/lib/Table.h +++ b/src/lib/Table.h @@ -31,6 +31,7 @@ typedef struct TableRef TableRef; struct TableRef { TableRef(TableRefType type) : type(type), + schema(NULL), name(NULL), alias(NULL), select(NULL), @@ -43,17 +44,29 @@ struct TableRef { TableRefType type; + char* schema; char* name; char* alias; SelectStatement* select; List* list; - // Join memberbs + // Join members TableRef* left; TableRef* right; JoinType join_type; Expr* join_condition; + + + /** + * Convenience accessor methods + */ + inline bool hasSchema() { return schema != NULL; } + + inline char* getName() { + if (alias != NULL) return alias; + else return name; + } };