Search in sources :

Example 11 with ColumnDefPacket

use of io.mycat.beans.mysql.packet.ColumnDefPacket in project Mycat2 by MyCATApache.

the class RowSetJdbcPreparedJdbcQuery method extracted.

public static <R> void extracted(Promise<SqlResult<R>> promise, Statement statement, ResultSet resultSet, Collector<Row, ?, R> collector) throws SQLException {
    try {
        if (resultSet == null) {
            Object o = collector.supplier().get();
            Function<Object, Object> finisher = (Function) collector.finisher();
            promise.complete(new MySqlResult<>(0, 0, 0, (R) finisher.apply(o), Collections.emptyList()));
            return;
        }
        JdbcRowMetaData metaData = new JdbcRowMetaData(resultSet.getMetaData());
        int columnCount = metaData.getColumnCount();
        List<ColumnDescriptor> columnDescriptors = new ArrayList<>();
        for (int i = 0; i < columnCount; i++) {
            int index = i;
            columnDescriptors.add(new ColumnDescriptor() {

                @Override
                public String name() {
                    return metaData.getColumnName(index);
                }

                @Override
                public boolean isArray() {
                    return false;
                }

                @Override
                public String typeName() {
                    return null;
                }

                @Override
                public JDBCType jdbcType() {
                    return JDBCType.valueOf(metaData.getColumnType(index));
                }
            });
        }
        RowDesc rowDesc = new RowDesc(metaData.getColumnList(), columnDescriptors);
        ColumnDefPacket[] columnDefPackets = new ColumnDefPacket[columnCount];
        for (int i = 0; i < columnCount; i++) {
            columnDefPackets[i] = new ColumnDefPacketImpl(metaData, i);
        }
        if (collector instanceof StreamMysqlCollector) {
            MySQLRowDesc mySQLRowDesc = new MySQLRowDesc(Arrays.asList(columnDefPackets).stream().map(packet -> {
                String catalog = new String(packet.getColumnCatalog());
                String schema = new String(packet.getColumnSchema());
                String table = new String(packet.getColumnTable());
                String orgTable = new String(packet.getColumnOrgTable());
                String name = new String(packet.getColumnName());
                String orgName = new String(packet.getColumnOrgName());
                int characterSet = packet.getColumnCharsetSet();
                long columnLength = packet.getColumnLength();
                DataType type = DataType.valueOf(packet.getColumnType() == 15 ? 253 : packet.getColumnType());
                int flags = packet.getColumnFlags();
                byte decimals = packet.getColumnDecimals();
                ColumnDefinition columnDefinition = new ColumnDefinition(catalog, schema, table, orgTable, name, orgName, characterSet, columnLength, type, flags, decimals);
                return columnDefinition;
            }).toArray(n -> new ColumnDefinition[n]), DataFormat.TEXT);
            ((StreamMysqlCollector) collector).onColumnDefinitions(mySQLRowDesc);
        }
        {
            Object supplier = collector.supplier().get();
            BiConsumer<Object, Row> accumulator = (BiConsumer) collector.accumulator();
            Function<Object, Object> finisher = (Function) collector.finisher();
            int count = 0;
            while (resultSet.next()) {
                JDBCRow jdbcRow = new MycatRow(rowDesc);
                for (int i = 0; i < columnCount; i++) {
                    jdbcRow.addValue(resultSet.getObject(i + 1));
                }
                count++;
                accumulator.accept(supplier, jdbcRow);
            }
            finisher.apply(supplier);
            resultSet.close();
            statement.close();
            promise.complete(new MySqlResult<>(count, 0, 0, (R) supplier, columnDescriptors));
        }
    } catch (Throwable throwable) {
        promise.tryFail(throwable);
    }
}
Also used : DataFormat(io.vertx.mysqlclient.impl.datatype.DataFormat) java.sql(java.sql) Arrays(java.util.Arrays) MetaClusterCurrent(io.mycat.MetaClusterCurrent) AbstractMySqlConnectionImpl.adaptType(io.mycat.vertxmycat.AbstractMySqlConnectionImpl.adaptType) LoggerFactory(org.slf4j.LoggerFactory) MySQLRowDesc(io.vertx.mysqlclient.impl.MySQLRowDesc) Function(java.util.function.Function) IOExecutor(io.mycat.IOExecutor) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) JDBCRow(io.vertx.jdbcclient.impl.JDBCRow) StreamMysqlCollector(io.vertx.mysqlclient.impl.codec.StreamMysqlCollector) BiConsumer(java.util.function.BiConsumer) AbstractMySqlConnectionImpl.toObjects(io.mycat.vertxmycat.AbstractMySqlConnectionImpl.toObjects) DataType(io.vertx.mysqlclient.impl.datatype.DataType) ColumnDefinition(io.vertx.mysqlclient.impl.protocol.ColumnDefinition) Collector(java.util.stream.Collector) io.vertx.sqlclient(io.vertx.sqlclient) JdbcRowMetaData(io.mycat.beans.mycat.JdbcRowMetaData) Logger(org.slf4j.Logger) ColumnDefPacket(io.mycat.beans.mysql.packet.ColumnDefPacket) Promise(io.vertx.core.Promise) PreparedStatement(java.sql.PreparedStatement) Future(io.vertx.core.Future) List(java.util.List) ColumnDescriptor(io.vertx.sqlclient.desc.ColumnDescriptor) ColumnDefPacketImpl(io.mycat.beans.mysql.packet.ColumnDefPacketImpl) MycatPreparedStatementUtil(io.mycat.calcite.executor.MycatPreparedStatementUtil) VertxRowSetImpl(io.vertx.mysqlclient.impl.codec.VertxRowSetImpl) RowDesc(io.vertx.sqlclient.impl.RowDesc) Handler(io.vertx.core.Handler) Collections(java.util.Collections) JDBCRow(io.vertx.jdbcclient.impl.JDBCRow) ArrayList(java.util.ArrayList) Function(java.util.function.Function) ColumnDefPacket(io.mycat.beans.mysql.packet.ColumnDefPacket) DataType(io.vertx.mysqlclient.impl.datatype.DataType) JdbcRowMetaData(io.mycat.beans.mycat.JdbcRowMetaData) MySQLRowDesc(io.vertx.mysqlclient.impl.MySQLRowDesc) StreamMysqlCollector(io.vertx.mysqlclient.impl.codec.StreamMysqlCollector) ColumnDescriptor(io.vertx.sqlclient.desc.ColumnDescriptor) ColumnDefPacketImpl(io.mycat.beans.mysql.packet.ColumnDefPacketImpl) ColumnDefinition(io.vertx.mysqlclient.impl.protocol.ColumnDefinition) MySQLRowDesc(io.vertx.mysqlclient.impl.MySQLRowDesc) RowDesc(io.vertx.sqlclient.impl.RowDesc) BiConsumer(java.util.function.BiConsumer)

Example 12 with ColumnDefPacket

use of io.mycat.beans.mysql.packet.ColumnDefPacket in project Mycat2 by MyCATApache.

the class BinaryResultSetHandler method onBinaryRow.

@Override
public void onBinaryRow(MySQLPacket mySQLPacket, int startPos, int endPos) {
    collector.onRowStart();
    int nullBitMapStartPos = startPos + 4 + 1;
    int nullBitMapEndPos = nullBitMapStartPos + binaryNullBitMapLength;
    mySQLPacket.packetReadStartIndex(nullBitMapEndPos);
    for (int columnIndex = 0; columnIndex < currentColumnDefList.length; columnIndex++) {
        ColumnDefPacket columnDef = currentColumnDefList[columnIndex];
        int i = nullBitMapStartPos + (columnIndex + 2) / 8;
        byte aByte = mySQLPacket.getByte(i);
        boolean isNull = ((aByte & (1 << (columnIndex & 7))) != 0);
        int startIndex = mySQLPacket.packetReadStartIndex();
        int columnType = columnDef.getColumnType();
        if (isNull) {
            switch(columnType) {
                default:
                    {
                        throw new MycatException("unknown field message:{}", columnType);
                    }
                case FIELD_TYPE_DECIMAL:
                    {
                        collector.collectNullDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff);
                        break;
                    }
                case FIELD_TYPE_TINY:
                    {
                        collector.collectNullTiny(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_SHORT:
                    {
                        collector.collectNullShort(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_LONG:
                    {
                        collector.collectNullLong(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_FLOAT:
                    {
                        collector.collectNullFloat(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_DOUBLE:
                    {
                        collector.collectNullDouble(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_NULL:
                    {
                        collector.collectNull(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_TIMESTAMP:
                    {
                        collector.collectNullTimestamp(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_LONGLONG:
                    {
                        collector.collectNullLongLong(columnIndex, columnDef);
                        break;
                    }
                case MySQLFieldsType.FIELD_TYPE_INT24:
                    {
                        collector.collectNullInt24(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_DATE:
                    {
                        collector.collectNullDate(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_TIME:
                    {
                        collector.collectNullTime(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_DATETIME:
                    {
                        collector.collectNullDatetime(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_YEAR:
                    {
                        collector.collectNullYear(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_NEWDATE:
                    {
                        collector.collectNullNewDate(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_VARCHAR:
                    {
                        collector.collectNullVarChar(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_BIT:
                    {
                        collector.collectNullBit(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_NEW_DECIMAL:
                    {
                        collector.collectNullNewDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff);
                        break;
                    }
                case FIELD_TYPE_ENUM:
                    {
                        collector.collectNullEnum(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_SET:
                    {
                        collector.collectNullSet(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_TINY_BLOB:
                    {
                        collector.collectNullTinyBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_MEDIUM_BLOB:
                    {
                        collector.collectNullMediumBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_LONG_BLOB:
                    {
                        collector.collectNullLongBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_BLOB:
                    {
                        collector.collectNullBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_VAR_STRING:
                    {
                        collector.collectNullVarString(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_STRING:
                    {
                        collector.collectNullTinyString(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_GEOMETRY:
                    {
                        collector.collectNullGeometry(columnIndex, columnDef);
                        break;
                    }
            }
            continue;
        }
        /**
         * 二进制格式,详细看协议,startIndex 是
         * 字符串类型,长度的开始位置;
         * 值类型,不带长度
         */
        switch(columnType) {
            default:
                {
                    throw new MycatException("unknown field message {}", (columnType));
                }
            case FIELD_TYPE_DECIMAL:
                {
                    collector.collectDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_TINY:
                {
                    collector.collectTiny(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_SHORT:
                {
                    collector.collectShort(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_LONG:
                {
                    collector.collectLong(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_FLOAT:
                {
                    collector.collectFloat(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_DOUBLE:
                {
                    collector.collectDouble(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_NULL:
                {
                    collector.collectNull(columnIndex, columnDef);
                    break;
                }
            case FIELD_TYPE_TIMESTAMP:
                {
                    collector.collectTimestamp(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_LONGLONG:
                {
                    collector.collectLongLong(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_INT24:
                {
                    collector.collectInt24(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_DATE:
                {
                    collector.collectDate(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_TIME:
                {
                    collector.collectTime(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_DATETIME:
                {
                    collector.collectDatetime(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_YEAR:
                {
                    collector.collectYear(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_NEWDATE:
                {
                    collector.collectNewDate(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_VARCHAR:
                {
                    collector.collectVarChar(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_BIT:
                {
                    collector.collectBit(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_NEW_DECIMAL:
                {
                    collector.collectNewDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_ENUM:
                {
                    collector.collectEnum(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_SET:
                {
                    collector.collectSet(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_TINY_BLOB:
                {
                    collector.collectTinyBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_MEDIUM_BLOB:
                {
                    collector.collectMediumBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_LONG_BLOB:
                {
                    collector.collectLongBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_BLOB:
                {
                    collector.collectBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_VAR_STRING:
                {
                    collector.collectVarString(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_STRING:
                {
                    collector.collectTinyString(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_GEOMETRY:
                {
                    collector.collectGeometry(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
        }
    }
    collector.onRowEnd();
}
Also used : ColumnDefPacket(io.mycat.beans.mysql.packet.ColumnDefPacket) MycatException(io.mycat.MycatException)

Example 13 with ColumnDefPacket

use of io.mycat.beans.mysql.packet.ColumnDefPacket in project Mycat2 by MyCATApache.

the class TextResultSetHandler method onTextRow.

@Override
public void onTextRow(MySQLPacket mySQLPacket, int startPos, int endPos) throws MycatException {
    for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
        int startIndex = mySQLPacket.packetReadStartIndex();
        if (!columnFilter(columnIndex)) {
            mySQLPacket.skipLenencBytes(startIndex);
            continue;
        }
        ColumnDefPacket columnDef = currentColumnDefList[columnIndex];
        int columnType = columnDef.getColumnType();
        if (isNull(mySQLPacket, startIndex)) {
            mySQLPacket.packetReadStartIndex(startIndex + 1);
            switch(columnType) {
                default:
                    {
                        throw new MycatException("unknown field message:{}", (columnType));
                    }
                case FIELD_TYPE_DECIMAL:
                    {
                        collector.collectNullDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff);
                        break;
                    }
                case FIELD_TYPE_TINY:
                    {
                        collector.collectNullTiny(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_SHORT:
                    {
                        collector.collectNullShort(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_LONG:
                    {
                        collector.collectNullLong(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_FLOAT:
                    {
                        collector.collectNullFloat(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_DOUBLE:
                    {
                        collector.collectNullDouble(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_NULL:
                    {
                        collector.collectNull(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_TIMESTAMP:
                    {
                        collector.collectNullTimestamp(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_LONGLONG:
                    {
                        collector.collectNullLongLong(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_INT24:
                    {
                        collector.collectNullInt24(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_DATE:
                    {
                        collector.collectNullDate(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_TIME:
                    {
                        collector.collectNullTime(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_DATETIME:
                    {
                        collector.collectNullDatetime(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_YEAR:
                    {
                        collector.collectNullYear(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_NEWDATE:
                    {
                        collector.collectNullNewDate(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_VARCHAR:
                    {
                        collector.collectNullVarChar(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_BIT:
                    {
                        collector.collectNullBit(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_NEW_DECIMAL:
                    {
                        collector.collectNullNewDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff);
                        break;
                    }
                case FIELD_TYPE_ENUM:
                    {
                        collector.collectNullEnum(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_SET:
                    {
                        collector.collectNullSet(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_TINY_BLOB:
                    {
                        collector.collectNullTinyBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_MEDIUM_BLOB:
                    {
                        collector.collectNullMediumBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_LONG_BLOB:
                    {
                        collector.collectNullLongBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_BLOB:
                    {
                        collector.collectNullBlob(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_VAR_STRING:
                    {
                        collector.collectNullVarString(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_STRING:
                    {
                        collector.collectNullTinyString(columnIndex, columnDef);
                        break;
                    }
                case FIELD_TYPE_GEOMETRY:
                    {
                        collector.collectNullGeometry(columnIndex, columnDef);
                        break;
                    }
            }
            continue;
        }
        switch(columnType) {
            default:
                {
                    throw new MycatException("unknown field message:{}", (columnType));
                }
            case FIELD_TYPE_DECIMAL:
                {
                    collector.collectDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_TINY:
                {
                    collector.collectTiny(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_SHORT:
                {
                    collector.collectShort(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_LONG:
                {
                    collector.collectLong(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_FLOAT:
                {
                    collector.collectFloat(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_DOUBLE:
                {
                    collector.collectDouble(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_NULL:
                {
                    collector.collectNull(columnIndex, columnDef);
                    break;
                }
            case FIELD_TYPE_TIMESTAMP:
                {
                    collector.collectTimestamp(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_LONGLONG:
                {
                    collector.collectLongLong(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_INT24:
                {
                    collector.collectInt24(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_DATE:
                {
                    collector.collectDate(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_TIME:
                {
                    collector.collectTime(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_DATETIME:
                {
                    collector.collectDatetime(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_YEAR:
                {
                    collector.collectYear(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_NEWDATE:
                {
                    collector.collectNewDate(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_VARCHAR:
                {
                    collector.collectVarChar(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_BIT:
                {
                    collector.collectBit(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_NEW_DECIMAL:
                {
                    collector.collectNewDecimal(columnIndex, columnDef, columnDef.getColumnDecimals() & 0xff, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_ENUM:
                {
                    collector.collectEnum(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_SET:
                {
                    collector.collectSet(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_TINY_BLOB:
                {
                    collector.collectTinyBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_MEDIUM_BLOB:
                {
                    collector.collectMediumBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_LONG_BLOB:
                {
                    collector.collectLongBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_BLOB:
                {
                    collector.collectBlob(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_VAR_STRING:
                {
                    collector.collectVarString(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_STRING:
                {
                    collector.collectTinyString(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
            case FIELD_TYPE_GEOMETRY:
                {
                    collector.collectGeometry(columnIndex, columnDef, mySQLPacket, startIndex);
                    break;
                }
        }
        int mayBeErrorStartIndex = mySQLPacket.packetReadStartIndex();
        if (mySQLPacket.skipLenencBytes(startIndex) == mayBeErrorStartIndex) {
        }
    }
    collector.onRowEnd();
}
Also used : ColumnDefPacket(io.mycat.beans.mysql.packet.ColumnDefPacket) MycatException(io.mycat.MycatException)

Example 14 with ColumnDefPacket

use of io.mycat.beans.mysql.packet.ColumnDefPacket in project Mycat2 by MyCATApache.

the class MySQLResultSet method create.

public static MySQLResultSet create(ColumnDefPacket[] columnDefPackets, List<Object[]> rows) {
    MySQLResultSet mySQLResultSet = new MySQLResultSet();
    for (ColumnDefPacket columnDefPacket : columnDefPackets) {
        mySQLResultSet.addColumn(columnDefPacket);
    }
    mySQLResultSet.rows = rows;
    return mySQLResultSet;
}
Also used : ColumnDefPacket(io.mycat.beans.mysql.packet.ColumnDefPacket)

Example 15 with ColumnDefPacket

use of io.mycat.beans.mysql.packet.ColumnDefPacket in project Mycat2 by MyCATApache.

the class OneResultSetCollector method collectColumnList.

public void collectColumnList(ColumnDefPacket[] packets) {
    columns = new HashMap<>(packets.length);
    for (int i = 0; i < packets.length; i++) {
        ColumnDefPacket packet = packets[i];
        columns.put(packet.getColumnNameString(), i);
    }
    result = new ArrayList[packets.length];
    for (int i = 0; i < packets.length; i++) {
        result[i] = new ArrayList();
        columnCount++;
    }
}
Also used : ColumnDefPacket(io.mycat.beans.mysql.packet.ColumnDefPacket)

Aggregations

ColumnDefPacket (io.mycat.beans.mysql.packet.ColumnDefPacket)16 MySQLResultSet (io.mycat.prototypeserver.mysql.MySQLResultSet)6 ColumnDefPacketImpl (io.mycat.beans.mysql.packet.ColumnDefPacketImpl)3 DataType (io.vertx.mysqlclient.impl.datatype.DataType)3 ArrayList (java.util.ArrayList)3 MycatException (io.mycat.MycatException)2 ColumnDefinition (io.vertx.mysqlclient.impl.protocol.ColumnDefinition)2 Function (java.util.function.Function)2 NotNull (org.jetbrains.annotations.NotNull)2 SQLName (com.alibaba.druid.sql.ast.SQLName)1 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)1 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)1 SQLCreateDatabaseStatement (com.alibaba.druid.sql.ast.statement.SQLCreateDatabaseStatement)1 SQLShowCreateTableStatement (com.alibaba.druid.sql.ast.statement.SQLShowCreateTableStatement)1 Field (com.mysql.cj.result.Field)1 IOExecutor (io.mycat.IOExecutor)1 MetaClusterCurrent (io.mycat.MetaClusterCurrent)1 RowBaseIterator (io.mycat.api.collector.RowBaseIterator)1 JdbcRowMetaData (io.mycat.beans.mycat.JdbcRowMetaData)1 MycatMySQLRowMetaData (io.mycat.beans.mycat.MycatMySQLRowMetaData)1