Search in sources :

Example 1 with MySQLPacketQueryResult

use of io.shardingjdbc.proxy.backend.mysql.MySQLPacketQueryResult in project sharding-jdbc by shardingjdbc.

the class SQLExecuteBackendHandler method mergeDQLorDAL.

private List<DatabaseProtocolPacket> mergeDQLorDAL(final SQLStatement sqlStatement, final List<List<DatabaseProtocolPacket>> packets) {
    List<QueryResult> queryResults = new ArrayList<>(packets.size());
    for (List<DatabaseProtocolPacket> each : packets) {
        // TODO replace to a common PacketQueryResult
        queryResults.add(new MySQLPacketQueryResult(each));
    }
    MergedResult mergedResult;
    try {
        mergedResult = MergeEngineFactory.newInstance(ShardingRuleRegistry.getInstance().getShardingRule(), queryResults, sqlStatement).merge();
    } catch (final SQLException ex) {
        return Collections.<DatabaseProtocolPacket>singletonList(new ErrPacket(1, ex.getErrorCode(), "", ex.getSQLState(), ex.getMessage()));
    }
    return buildPackets(packets, mergedResult);
}
Also used : MySQLPacketQueryResult(io.shardingjdbc.proxy.backend.mysql.MySQLPacketQueryResult) QueryResult(io.shardingjdbc.core.merger.QueryResult) SQLException(java.sql.SQLException) MergedResult(io.shardingjdbc.core.merger.MergedResult) ArrayList(java.util.ArrayList) ErrPacket(io.shardingjdbc.proxy.transport.mysql.packet.generic.ErrPacket) DatabaseProtocolPacket(io.shardingjdbc.proxy.transport.common.packet.DatabaseProtocolPacket) MySQLPacketQueryResult(io.shardingjdbc.proxy.backend.mysql.MySQLPacketQueryResult)

Aggregations

MergedResult (io.shardingjdbc.core.merger.MergedResult)1 QueryResult (io.shardingjdbc.core.merger.QueryResult)1 MySQLPacketQueryResult (io.shardingjdbc.proxy.backend.mysql.MySQLPacketQueryResult)1 DatabaseProtocolPacket (io.shardingjdbc.proxy.transport.common.packet.DatabaseProtocolPacket)1 ErrPacket (io.shardingjdbc.proxy.transport.mysql.packet.generic.ErrPacket)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1