Search in sources :

Example 1 with MySQLItemVisitor

use of com.actiontech.dble.plan.visitor.MySQLItemVisitor in project dble by actiontech.

the class DruidSelectParser method isSumFuncOrSubQuery.

private boolean isSumFuncOrSubQuery(String schema, SQLExpr itemExpr) {
    MySQLItemVisitor ev = new MySQLItemVisitor(schema, CharsetUtil.getCharsetDefaultIndex("utf8"), DbleServer.getInstance().getTmManager());
    itemExpr.accept(ev);
    Item selItem = ev.getItem();
    return contaisSumFuncOrSubquery(selItem);
}
Also used : MySQLItemVisitor(com.actiontech.dble.plan.visitor.MySQLItemVisitor) Item(com.actiontech.dble.plan.common.item.Item)

Example 2 with MySQLItemVisitor

use of com.actiontech.dble.plan.visitor.MySQLItemVisitor in project dble by actiontech.

the class ShowTables method responseDirect.

private static void responseDirect(ServerConnection c, String cSchema, ShowCreateStmtInfo info) {
    ByteBuffer buffer = c.allocate();
    Map<String, String> tableMap = getTableSet(cSchema, info);
    PackageBufINf bufInf;
    if (info.isFull()) {
        List<FieldPacket> fieldPackets = new ArrayList<>(2);
        bufInf = writeFullTablesHeader(buffer, c, cSchema, fieldPackets);
        if (info.getWhere() != null) {
            MySQLItemVisitor mev = new MySQLItemVisitor(c.getSchema(), c.getCharset().getResultsIndex(), DbleServer.getInstance().getTmManager());
            info.getWhereExpr().accept(mev);
            List<Field> sourceFields = HandlerTool.createFields(fieldPackets);
            Item whereItem = HandlerTool.createItem(mev.getItem(), sourceFields, 0, false, DMLResponseHandler.HandlerType.WHERE);
            bufInf = writeFullTablesRow(bufInf.getBuffer(), c, tableMap, bufInf.getPacketId(), whereItem, sourceFields);
        } else {
            bufInf = writeFullTablesRow(bufInf.getBuffer(), c, tableMap, bufInf.getPacketId(), null, null);
        }
    } else {
        bufInf = writeTablesHeaderAndRows(buffer, c, tableMap, cSchema);
    }
    writeRowEof(bufInf.getBuffer(), c, bufInf.getPacketId());
}
Also used : MySQLItemVisitor(com.actiontech.dble.plan.visitor.MySQLItemVisitor) Field(com.actiontech.dble.plan.common.field.Field) Item(com.actiontech.dble.plan.common.item.Item) PackageBufINf(com.actiontech.dble.manager.handler.PackageBufINf) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 3 with MySQLItemVisitor

use of com.actiontech.dble.plan.visitor.MySQLItemVisitor in project dble by actiontech.

the class ShowTablesHandler method fieldEofResponse.

@Override
public void fieldEofResponse(byte[] header, List<byte[]> fields, List<FieldPacket> fieldPacketsNull, byte[] eof, boolean isLeft, BackendConnection conn) {
    ServerConnection source = session.getSource();
    buffer = allocBuffer();
    PackageBufINf bufInf;
    if (info.isFull()) {
        List<FieldPacket> fieldPackets = new ArrayList<>(2);
        bufInf = ShowTables.writeFullTablesHeader(buffer, source, showTableSchema, fieldPackets);
        packetId = bufInf.getPacketId();
        buffer = bufInf.getBuffer();
        if (info.getWhere() != null) {
            MySQLItemVisitor mev = new MySQLItemVisitor(source.getSchema(), source.getCharset().getResultsIndex(), DbleServer.getInstance().getTmManager());
            info.getWhereExpr().accept(mev);
            sourceFields = HandlerTool.createFields(fieldPackets);
            whereItem = HandlerTool.createItem(mev.getItem(), sourceFields, 0, false, DMLResponseHandler.HandlerType.WHERE);
            bufInf = ShowTables.writeFullTablesRow(buffer, source, shardingTablesMap, packetId, whereItem, sourceFields);
            packetId = bufInf.getPacketId();
            buffer = bufInf.getBuffer();
        } else {
            bufInf = ShowTables.writeFullTablesRow(buffer, source, shardingTablesMap, packetId, null, null);
            packetId = bufInf.getPacketId();
            buffer = bufInf.getBuffer();
        }
    } else {
        bufInf = ShowTables.writeTablesHeaderAndRows(buffer, source, shardingTablesMap, showTableSchema);
        packetId = bufInf.getPacketId();
        buffer = bufInf.getBuffer();
    }
}
Also used : MySQLItemVisitor(com.actiontech.dble.plan.visitor.MySQLItemVisitor) PackageBufINf(com.actiontech.dble.manager.handler.PackageBufINf) ArrayList(java.util.ArrayList) ServerConnection(com.actiontech.dble.server.ServerConnection) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Aggregations

MySQLItemVisitor (com.actiontech.dble.plan.visitor.MySQLItemVisitor)3 PackageBufINf (com.actiontech.dble.manager.handler.PackageBufINf)2 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)2 Item (com.actiontech.dble.plan.common.item.Item)2 Field (com.actiontech.dble.plan.common.field.Field)1 ServerConnection (com.actiontech.dble.server.ServerConnection)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1