[jOOQ/jOOQ#11802] Remove ForceSettingsSignal again
This commit is contained in:
parent
4450c722c8
commit
1c9d4e80db
@ -45,7 +45,6 @@ import static org.jooq.ExecuteType.DDL;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INDEXED;
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.conf.SettingsTools.executePreparedStatements;
|
||||
import static org.jooq.conf.SettingsTools.getParamType;
|
||||
@ -54,16 +53,13 @@ import static org.jooq.impl.DSL.using;
|
||||
import static org.jooq.impl.Tools.EMPTY_PARAM;
|
||||
import static org.jooq.impl.Tools.blocking;
|
||||
import static org.jooq.impl.Tools.consumeExceptions;
|
||||
import static org.jooq.impl.Tools.maxForceSettingsAttempts;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_COUNT_BIND_VALUES;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_FORCE_SETTINGS;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_FORCE_STATIC_STATEMENT;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
@ -76,12 +72,10 @@ import org.jooq.Query;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.conf.ParamType;
|
||||
import org.jooq.conf.QueryPoolable;
|
||||
import org.jooq.conf.SettingsTools;
|
||||
import org.jooq.conf.StatementType;
|
||||
import org.jooq.exception.ControlFlowSignal;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.DetachedException;
|
||||
import org.jooq.impl.DefaultRenderContext.Rendered;
|
||||
import org.jooq.tools.Ints;
|
||||
@ -461,43 +455,27 @@ abstract class AbstractQuery<R extends Record> extends AbstractAttachableQueryPa
|
||||
|
||||
// [#3542] [#4977] Some dialects do not support bind values in DDL statements
|
||||
// [#6474] [#6929] Can this be communicated in a leaner way?
|
||||
int i = 0;
|
||||
forceSettingsLoop:
|
||||
for (;;) {
|
||||
if (ctx.type() == DDL) {
|
||||
ctx.data(DATA_FORCE_STATIC_STATEMENT, true);
|
||||
render = new DefaultRenderContext(c);
|
||||
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
|
||||
}
|
||||
else if (executePreparedStatements(configuration().settings())) {
|
||||
try {
|
||||
if (ctx.type() == DDL) {
|
||||
ctx.data(DATA_FORCE_STATIC_STATEMENT, true);
|
||||
render = render(c);
|
||||
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
|
||||
}
|
||||
else if (executePreparedStatements(configuration().settings())) {
|
||||
try {
|
||||
render = render(c);
|
||||
render.data(DATA_COUNT_BIND_VALUES, true);
|
||||
result = new Rendered(render.visit(this).render(), render.bindValues(), render.skipUpdateCounts());
|
||||
}
|
||||
catch (DefaultRenderContext.ForceInlineSignal e) {
|
||||
ctx.data(DATA_FORCE_STATIC_STATEMENT, true);
|
||||
render = render(c);
|
||||
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
|
||||
}
|
||||
}
|
||||
else {
|
||||
render = render(c);
|
||||
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
|
||||
}
|
||||
|
||||
break forceSettingsLoop;
|
||||
render = new DefaultRenderContext(c);
|
||||
render.data(DATA_COUNT_BIND_VALUES, true);
|
||||
result = new Rendered(render.visit(this).render(), render.bindValues(), render.skipUpdateCounts());
|
||||
}
|
||||
catch (ForceSettingsSignal e) {
|
||||
if (++i >= maxForceSettingsAttempts) {
|
||||
log.warn("Infinite loop", "There was an infinite loop trying to render a SQL query, due to ForceSettingsSignal. Please consider reporting this bug here: https://github.com/jOOQ/jOOQ/issues/new/choose");
|
||||
throw new DataAccessException("Too many force settings attempts");
|
||||
}
|
||||
|
||||
c = c.derive(e.settings);
|
||||
catch (DefaultRenderContext.ForceInlineSignal e) {
|
||||
ctx.data(DATA_FORCE_STATIC_STATEMENT, true);
|
||||
render = new DefaultRenderContext(c);
|
||||
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
|
||||
}
|
||||
}
|
||||
else {
|
||||
render = new DefaultRenderContext(c);
|
||||
result = new Rendered(render.paramType(INLINED).visit(this).render(), null, render.skipUpdateCounts());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -526,12 +504,6 @@ abstract class AbstractQuery<R extends Record> extends AbstractAttachableQueryPa
|
||||
return result;
|
||||
}
|
||||
|
||||
private final DefaultRenderContext render(Configuration c) {
|
||||
DefaultRenderContext render = new DefaultRenderContext(c);
|
||||
render.data(DATA_FORCE_SETTINGS, true);
|
||||
return render;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.exception.ControlFlowSignal;
|
||||
|
||||
/**
|
||||
* A query rendering signal to force re-rendering a query with different
|
||||
* settings.
|
||||
*/
|
||||
class ForceSettingsSignal extends ControlFlowSignal {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -1530836969063166588L;
|
||||
final Settings settings;
|
||||
|
||||
ForceSettingsSignal(Settings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
@ -56,27 +56,6 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -389,12 +389,6 @@ final class Tools {
|
||||
*/
|
||||
DATA_FORCE_STATIC_STATEMENT,
|
||||
|
||||
/**
|
||||
* [#7312] Allow for {@link ForceSettingsSignal} to be thrown in order
|
||||
* to override user-defined settings.
|
||||
*/
|
||||
DATA_FORCE_SETTINGS,
|
||||
|
||||
/**
|
||||
* [#2665] Omit the emission of clause events by {@link QueryPart}s.
|
||||
* <p>
|
||||
@ -743,7 +737,6 @@ final class Tools {
|
||||
* {@link #consumeExceptions(Configuration, PreparedStatement, SQLException)}
|
||||
* helps prevent infinite loops and {@link OutOfMemoryError}.
|
||||
*/
|
||||
static int maxForceSettingsAttempts = 16;
|
||||
static int maxConsumedExceptions = 256;
|
||||
static int maxConsumedResults = 65536;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user