Search in sources :

Example 1 with ShowColumns

use of com.alibaba.cobar.parser.ast.stmt.dal.ShowColumns in project cobar by alibaba.

the class MySQLDALParser method showColumns.

/**
     * First token is {@link SpecialIdentifier#COLUMNS}
     * 
     * <pre>
     * SHOW [FULL] <code>COLUMNS {FROM | IN} tbl_name [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr] </code>
     * </pre>
     */
private ShowColumns showColumns(boolean full) throws SQLSyntaxErrorException {
    lexer.nextToken();
    match(KW_FROM, KW_IN);
    Identifier table = identifier();
    Identifier database = null;
    switch(lexer.token()) {
        case KW_FROM:
        case KW_IN:
            lexer.nextToken();
            database = identifier();
    }
    switch(lexer.token()) {
        case KW_LIKE:
            String like = like();
            return new ShowColumns(full, table, database, like);
        case KW_WHERE:
            Expression where = where();
            return new ShowColumns(full, table, database, where);
    }
    return new ShowColumns(full, table, database);
}
Also used : Identifier(com.alibaba.cobar.parser.ast.expression.primary.Identifier) Expression(com.alibaba.cobar.parser.ast.expression.Expression) VariableExpression(com.alibaba.cobar.parser.ast.expression.primary.VariableExpression) ShowColumns(com.alibaba.cobar.parser.ast.stmt.dal.ShowColumns) LiteralString(com.alibaba.cobar.parser.ast.expression.primary.literal.LiteralString)

Aggregations

Expression (com.alibaba.cobar.parser.ast.expression.Expression)1 Identifier (com.alibaba.cobar.parser.ast.expression.primary.Identifier)1 VariableExpression (com.alibaba.cobar.parser.ast.expression.primary.VariableExpression)1 LiteralString (com.alibaba.cobar.parser.ast.expression.primary.literal.LiteralString)1 ShowColumns (com.alibaba.cobar.parser.ast.stmt.dal.ShowColumns)1