use of org.adbcj.Type in project adbcj by mheath.
the class BackendMessageDecoder method decodeRowDescription.
private AbstractBackendMessage decodeRowDescription(DecoderInputStream input) throws IOException {
Charset charset = connectionState.getBackendCharset();
int fieldCount = input.readUnsignedShort();
PgField[] fields = new PgField[fieldCount];
for (int i = 0; i < fieldCount; i++) {
String name = input.readString(charset);
int tableOid = input.readInt();
int columnAttributeNumber = input.readUnsignedShort();
int typeOid = input.readInt();
short typeSize = input.readShort();
int typeModifier = input.readInt();
FormatCode code = FormatCode.values()[input.readShort()];
Type type;
switch(typeOid) {
case PgFieldType.BOOLEAN:
type = Type.BOOLEAN;
break;
case PgFieldType.BIGINT:
type = Type.BIGINT;
break;
case PgFieldType.CHAR:
type = Type.CHAR;
break;
case PgFieldType.DATE:
type = Type.DATE;
break;
case PgFieldType.DOUBLE:
type = Type.DOUBLE;
break;
case PgFieldType.INTEGER:
type = Type.INTEGER;
break;
case PgFieldType.REAL:
type = Type.REAL;
break;
case PgFieldType.SMALLINT:
type = Type.SMALLINT;
break;
case PgFieldType.VARCHAR:
type = Type.VARCHAR;
break;
default:
// TODO Convert more typeOids to ADBCJ types
throw new IllegalStateException("Unable to handle field type with oid " + typeOid);
}
fields[i] = new PgField(i, connectionState.getDatabaseName(), type, name, tableOid, columnAttributeNumber, code, typeSize, typeModifier);
logger.debug("Setting fields for current result set: {}", fields);
connectionState.setCurrentResultSetFields(fields);
}
return new RowDescriptionMessage(fields);
}
Aggregations