Search in sources :

Example 1 with FetchDoneEntity

use of com.mysql.cj.protocol.x.FetchDoneEntity in project aws-mysql-jdbc by awslabs.

the class SqlResultBuilder method addProtocolEntity.

@Override
public boolean addProtocolEntity(ProtocolEntity entity) {
    if (entity instanceof Field) {
        this.fields.add((Field) entity);
        if (!this.isRowResult) {
            this.isRowResult = true;
        }
        this.prevEntity = entity;
        return false;
    } else if (entity instanceof Notice) {
        this.statementExecuteOkBuilder.addProtocolEntity(entity);
        return false;
    }
    if (this.isRowResult && this.metadata == null) {
        this.metadata = new DefaultColumnDefinition(this.fields.toArray(new Field[] {}));
    }
    if (entity instanceof Row) {
        this.rows.add(((Row) entity).setMetadata(this.metadata));
    } else if (entity instanceof FetchDoneMoreResults) {
        this.resultSets.add(new SqlSingleResult(this.metadata, this.defaultTimeZone, new BufferedRowList(this.rows), () -> this.statementExecuteOkBuilder.build(), this.pset));
        // clear variables to accept next result set
        this.fields = new ArrayList<>();
        this.metadata = null;
        this.rows = new ArrayList<>();
        this.statementExecuteOkBuilder = new StatementExecuteOkBuilder();
    } else if (entity instanceof FetchDoneEntity) {
        if (this.prevEntity instanceof FetchDoneMoreResults) {
        // no-op, possibly bug in xplugin sending FetchDone immediately following FetchDoneMoreResultsets
        } else {
            this.resultSets.add(new SqlSingleResult(this.metadata, this.defaultTimeZone, new BufferedRowList(this.rows), () -> this.statementExecuteOkBuilder.build(), this.pset));
        }
    } else if (entity instanceof StatementExecuteOk) {
        return true;
    }
    this.prevEntity = entity;
    return false;
}
Also used : BufferedRowList(com.mysql.cj.result.BufferedRowList) Field(com.mysql.cj.result.Field) Notice(com.mysql.cj.protocol.x.Notice) StatementExecuteOkBuilder(com.mysql.cj.protocol.x.StatementExecuteOkBuilder) DefaultColumnDefinition(com.mysql.cj.result.DefaultColumnDefinition) FetchDoneMoreResults(com.mysql.cj.protocol.x.FetchDoneMoreResults) ArrayList(java.util.ArrayList) Row(com.mysql.cj.result.Row) FetchDoneEntity(com.mysql.cj.protocol.x.FetchDoneEntity) StatementExecuteOk(com.mysql.cj.protocol.x.StatementExecuteOk)

Aggregations

FetchDoneEntity (com.mysql.cj.protocol.x.FetchDoneEntity)1 FetchDoneMoreResults (com.mysql.cj.protocol.x.FetchDoneMoreResults)1 Notice (com.mysql.cj.protocol.x.Notice)1 StatementExecuteOk (com.mysql.cj.protocol.x.StatementExecuteOk)1 StatementExecuteOkBuilder (com.mysql.cj.protocol.x.StatementExecuteOkBuilder)1 BufferedRowList (com.mysql.cj.result.BufferedRowList)1 DefaultColumnDefinition (com.mysql.cj.result.DefaultColumnDefinition)1 Field (com.mysql.cj.result.Field)1 Row (com.mysql.cj.result.Row)1 ArrayList (java.util.ArrayList)1