[#6390] SQL Server multiple errors are not propagated if an update count precedes them

This commit is contained in:
lukaseder 2017-07-07 13:35:59 +02:00
parent a2dbec2a2f
commit c3273bb2dd
3 changed files with 34 additions and 26 deletions

View File

@ -430,7 +430,7 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query {
return result;
}
// [#3011] [#3054] Consume additional exceptions if there are any
// [#3011] [#3054] [#6390] Consume additional exceptions if there are any
catch (SQLException e) {
consumeExceptions(ctx.configuration(), stmt, e);
throw e;

View File

@ -506,7 +506,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
listener.executeEnd(ctx);
}
// [#3011] [#3054] Consume additional exceptions if there are any
// [#3011] [#3054] [#6390] Consume additional exceptions if there are any
catch (SQLException e) {
consumeExceptions(ctx.configuration(), ctx.statement(), e);
throw e;

View File

@ -3038,8 +3038,8 @@ final class Tools {
// ------------------------------------------------------------------------
/**
* [#3011] [#3054] Consume additional exceptions if there are any and append
* them to the <code>previous</code> exception's
* [#3011] [#3054] [#6390] Consume additional exceptions if there are any
* and append them to the <code>previous</code> exception's
* {@link SQLException#getNextException()} list.
*/
static final void consumeExceptions(Configuration configuration, PreparedStatement stmt, SQLException previous) {
@ -3193,31 +3193,39 @@ final class Tools {
int rows = (ctx.resultSet() == null) ? ctx.rows() : 0;
for (i = 0; i < maxConsumedResults; i++) {
if (ctx.resultSet() != null) {
anyResults = true;
try {
if (ctx.resultSet() != null) {
anyResults = true;
Field<?>[] fields = new MetaDataFieldProvider(ctx.configuration(), ctx.resultSet().getMetaData()).getFields();
Cursor<Record> c = new CursorImpl<Record>(ctx, listener, fields, intern != null ? intern.internIndexes(fields) : null, true, false);
results.resultsOrRows().add(new ResultsImpl.ResultOrRowsImpl(c.fetch()));
}
else {
if (rows != -1)
results.resultsOrRows().add(new ResultsImpl.ResultOrRowsImpl(rows));
else
break;
Field<?>[] fields = new MetaDataFieldProvider(ctx.configuration(), ctx.resultSet().getMetaData()).getFields();
Cursor<Record> c = new CursorImpl<Record>(ctx, listener, fields, intern != null ? intern.internIndexes(fields) : null, true, false);
results.resultsOrRows().add(new ResultsImpl.ResultOrRowsImpl(c.fetch()));
}
else {
if (rows != -1)
results.resultsOrRows().add(new ResultsImpl.ResultOrRowsImpl(rows));
else
break;
}
if (ctx.statement().getMoreResults()) {
ctx.resultSet(ctx.statement().getResultSet());
}
else {
rows = ctx.statement().getUpdateCount();
ctx.rows(rows);
if (rows != -1)
ctx.resultSet(null);
else
break;
}
}
if (ctx.statement().getMoreResults()) {
ctx.resultSet(ctx.statement().getResultSet());
}
else {
rows = ctx.statement().getUpdateCount();
ctx.rows(rows);
if (rows != -1)
ctx.resultSet(null);
else
break;
// [#3011] [#3054] [#6390] Consume additional exceptions if there are any
catch (SQLException e) {
consumeExceptions(ctx.configuration(), ctx.statement(), e);
throw e;
}
}