use of org.jooq.tools.jdbc.MockResultSet in project jOOQ by jOOQ.
the class AbstractResultQuery method execute.
@Override
protected final int execute(ExecuteContext ctx, ExecuteListener listener) throws SQLException {
listener.executeStart(ctx);
// [#4511] [#4753] PostgreSQL doesn't like fetchSize with autoCommit == true
int f = SettingsTools.getFetchSize(fetchSize, ctx.settings());
if (REPORT_FETCH_SIZE_WITH_AUTOCOMMIT.contains(ctx.dialect()) && f != 0 && ctx.connection().getAutoCommit())
log.info("Fetch Size", "A fetch size of " + f + " was set on a auto-commit PostgreSQL connection, which is not recommended. See http://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor");
SQLException e = executeStatementAndGetFirstResultSet(ctx, rendered.skipUpdateCounts);
listener.executeEnd(ctx);
// Fetch a single result set
notManyIf: if (!many) {
// and that exception is not thrown because of Settings.throwExceptions == THROW_NONE, we can stop
if (e != null)
break notManyIf;
// not a result set.
if (ctx.resultSet() == null) {
DSLContext dsl = DSL.using(ctx.configuration());
Field<Integer> c = DSL.field(name("UPDATE_COUNT"), int.class);
Result<Record1<Integer>> r = dsl.newResult(c);
r.add(dsl.newRecord(c).values(ctx.rows()));
ctx.resultSet(new MockResultSet(r));
}
Field<?>[] fields = getFields(ctx.resultSet().getMetaData());
cursor = new CursorImpl<>(ctx, listener, fields, intern.internIndexes(fields), keepStatement(), keepResultSet(), getRecordType(), SettingsTools.getMaxRows(maxRows, ctx.settings()), autoclosing);
if (!lazy) {
result = cursor.fetch();
cursor = null;
}
} else // Fetch several result sets
{
results = new ResultsImpl(ctx.configuration());
consumeResultSets(ctx, listener, results, intern, e);
}
return result != null ? result.size() : 0;
}
Aggregations