use of io.vertx.mysqlclient.impl.datatype.DataType in project Mycat2 by MyCATApache.
the class NewVertxConnectionImpl method toColumnMetaData.
public static MycatRowMetaData toColumnMetaData(List<ColumnDefinition> event) {
boolean isMysql = event.get(0) instanceof ColumnDefinition;
if (isMysql) {
List<ColumnDefinition> columnDefinitions = event;
List<ColumnDefPacket> columnDefPackets = new ArrayList<>(event.size());
for (ColumnDefinition columnDefinition : columnDefinitions) {
final String catalog = columnDefinition.catalog();
final String schema = columnDefinition.schema();
final String table = columnDefinition.table();
final String orgTable = columnDefinition.orgTable();
final String name = columnDefinition.name();
final String orgName = columnDefinition.orgName();
final int characterSet = columnDefinition.characterSet();
final long columnLength = columnDefinition.columnLength();
final DataType type = columnDefinition.type();
final int flags = columnDefinition.flags();
byte decimals = columnDefinition.decimals();
if (decimals == 31) {
decimals = 0;
}
ColumnDefPacketImpl mySQLFieldInfo = new ColumnDefPacketImpl();
mySQLFieldInfo.setColumnCatalog(catalog.getBytes());
mySQLFieldInfo.setColumnSchema(schema.getBytes());
mySQLFieldInfo.setColumnTable(table.getBytes());
mySQLFieldInfo.setColumnOrgTable(orgTable.getBytes());
mySQLFieldInfo.setColumnName(name.getBytes());
mySQLFieldInfo.setColumnOrgName(orgName.getBytes());
mySQLFieldInfo.setColumnCharsetSet(characterSet);
mySQLFieldInfo.setColumnLength((int) columnLength);
mySQLFieldInfo.setColumnType(type.id);
mySQLFieldInfo.setColumnFlags(flags);
mySQLFieldInfo.setColumnDecimals(decimals);
columnDefPackets.add(mySQLFieldInfo);
}
return new MycatMySQLRowMetaData(columnDefPackets);
} else {
ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
for (ColumnDefinition columnDescriptor : event) {
resultSetBuilder.addColumnInfo(columnDescriptor.name(), columnDescriptor.jdbcType());
}
RowBaseIterator build = resultSetBuilder.build();
return build.getMetaData();
}
}
Aggregations