diff --git a/jOOQ/src/main/java/org/jooq/DiagnosticsContext.java b/jOOQ/src/main/java/org/jooq/DiagnosticsContext.java
index 6333434ca8..5077d3546b 100644
--- a/jOOQ/src/main/java/org/jooq/DiagnosticsContext.java
+++ b/jOOQ/src/main/java/org/jooq/DiagnosticsContext.java
@@ -50,7 +50,7 @@ import org.jetbrains.annotations.Nullable;
*
* @author Lukas Eder
*/
-public interface DiagnosticsContext {
+public interface DiagnosticsContext extends Scope {
/**
* The object that was diagnosed if available, or null, if there was no specific {@link QueryPart} to attach the diagnostic to.
diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java
index 76f42615e2..9cbfec68c3 100644
--- a/jOOQ/src/main/java/org/jooq/conf/Settings.java
+++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java
@@ -116,6 +116,20 @@ public class Settings
@XmlElement(defaultValue = "WHEN_RESULT_REQUESTED")
@XmlSchemaType(name = "string")
protected FetchIntermediateResult fetchIntermediateResult = FetchIntermediateResult.WHEN_RESULT_REQUESTED;
+ @XmlElement(defaultValue = "true")
+ protected Boolean diagnosticsDuplicateStatements = true;
+ @XmlElement(defaultValue = "true")
+ protected Boolean diagnosticsMissingWasNullCall = true;
+ @XmlElement(defaultValue = "true")
+ protected Boolean diagnosticsRepeatedStatements = true;
+ @XmlElement(defaultValue = "true")
+ protected Boolean diagnosticsTooManyColumnsFetched = true;
+ @XmlElement(defaultValue = "true")
+ protected Boolean diagnosticsTooManyRowsFetched = true;
+ @XmlElement(defaultValue = "true")
+ protected Boolean diagnosticsUnnecessaryWasNullCall = true;
+ @XmlElement(defaultValue = "true")
+ protected Boolean diagnosticsTrivialCondition = true;
@XmlElement(defaultValue = "false")
protected Boolean transformPatterns = false;
@XmlElement(defaultValue = "true")
@@ -1230,6 +1244,197 @@ public class Settings
this.fetchIntermediateResult = value;
}
+ /**
+ * Whether to run the {@link org.jooq.DiagnosticsListener#duplicateStatements(org.jooq.DiagnosticsContext) diagnostic.
+ *
+ * Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured. + * Once configured, this diagnostic is turned on by default. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDiagnosticsDuplicateStatements() { + return diagnosticsDuplicateStatements; + } + + /** + * Sets the value of the diagnosticsDuplicateStatements property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDiagnosticsDuplicateStatements(Boolean value) { + this.diagnosticsDuplicateStatements = value; + } + + /** + * Whether to run the {@link org.jooq.DiagnosticsListener#missingWasNullCall(org.jooq.DiagnosticsContext) diagnostic. + *
+ * Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured. + * Once configured, this diagnostic is turned on by default. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDiagnosticsMissingWasNullCall() { + return diagnosticsMissingWasNullCall; + } + + /** + * Sets the value of the diagnosticsMissingWasNullCall property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDiagnosticsMissingWasNullCall(Boolean value) { + this.diagnosticsMissingWasNullCall = value; + } + + /** + * Whether to run the {@link org.jooq.DiagnosticsListener#repeatedStatements(org.jooq.DiagnosticsContext) diagnostic. + *
+ * Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured. + * Once configured, this diagnostic is turned on by default. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDiagnosticsRepeatedStatements() { + return diagnosticsRepeatedStatements; + } + + /** + * Sets the value of the diagnosticsRepeatedStatements property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDiagnosticsRepeatedStatements(Boolean value) { + this.diagnosticsRepeatedStatements = value; + } + + /** + * Whether to run the {@link org.jooq.DiagnosticsListener#tooManyColumnsFetched(org.jooq.DiagnosticsContext) diagnostic. + *
+ * Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured. + * Once configured, this diagnostic is turned on by default. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDiagnosticsTooManyColumnsFetched() { + return diagnosticsTooManyColumnsFetched; + } + + /** + * Sets the value of the diagnosticsTooManyColumnsFetched property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDiagnosticsTooManyColumnsFetched(Boolean value) { + this.diagnosticsTooManyColumnsFetched = value; + } + + /** + * Whether to run the {@link org.jooq.DiagnosticsListener#tooManyRowsFetched(org.jooq.DiagnosticsContext) diagnostic. + *
+ * Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured. + * Once configured, this diagnostic is turned on by default. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDiagnosticsTooManyRowsFetched() { + return diagnosticsTooManyRowsFetched; + } + + /** + * Sets the value of the diagnosticsTooManyRowsFetched property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDiagnosticsTooManyRowsFetched(Boolean value) { + this.diagnosticsTooManyRowsFetched = value; + } + + /** + * Whether to run the {@link org.jooq.DiagnosticsListener#unnecessaryWasNullCall(org.jooq.DiagnosticsContext) diagnostic. + *
+ * Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured. + * Once configured, this diagnostic is turned on by default. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDiagnosticsUnnecessaryWasNullCall() { + return diagnosticsUnnecessaryWasNullCall; + } + + /** + * Sets the value of the diagnosticsUnnecessaryWasNullCall property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDiagnosticsUnnecessaryWasNullCall(Boolean value) { + this.diagnosticsUnnecessaryWasNullCall = value; + } + + /** + * Whether to run the {@link org.jooq.DiagnosticsListener#trivialCondition(org.jooq.DiagnosticsContext) diagnostic. + *
+ * Diagnostics are turned off if no {@link org.jooq.Configuration#diagnosticsListenerProviders()} are configured. + * Once configured, this diagnostic is turned on by default. + *
+ * This feature is available in the commercial distribution only. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDiagnosticsTrivialCondition() { + return diagnosticsTrivialCondition; + } + + /** + * Sets the value of the diagnosticsTrivialCondition property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDiagnosticsTrivialCondition(Boolean value) { + this.diagnosticsTrivialCondition = value; + } + /** * Transform various syntax patterns to better versions, if possible. *
@@ -4578,6 +4783,41 @@ public class Settings
return this;
}
+ public Settings withDiagnosticsDuplicateStatements(Boolean value) {
+ setDiagnosticsDuplicateStatements(value);
+ return this;
+ }
+
+ public Settings withDiagnosticsMissingWasNullCall(Boolean value) {
+ setDiagnosticsMissingWasNullCall(value);
+ return this;
+ }
+
+ public Settings withDiagnosticsRepeatedStatements(Boolean value) {
+ setDiagnosticsRepeatedStatements(value);
+ return this;
+ }
+
+ public Settings withDiagnosticsTooManyColumnsFetched(Boolean value) {
+ setDiagnosticsTooManyColumnsFetched(value);
+ return this;
+ }
+
+ public Settings withDiagnosticsTooManyRowsFetched(Boolean value) {
+ setDiagnosticsTooManyRowsFetched(value);
+ return this;
+ }
+
+ public Settings withDiagnosticsUnnecessaryWasNullCall(Boolean value) {
+ setDiagnosticsUnnecessaryWasNullCall(value);
+ return this;
+ }
+
+ public Settings withDiagnosticsTrivialCondition(Boolean value) {
+ setDiagnosticsTrivialCondition(value);
+ return this;
+ }
+
public Settings withTransformPatterns(Boolean value) {
setTransformPatterns(value);
return this;
@@ -5607,6 +5847,13 @@ public class Settings
builder.append("bindOffsetTimeType", bindOffsetTimeType);
builder.append("fetchTriggerValuesAfterSQLServerOutput", fetchTriggerValuesAfterSQLServerOutput);
builder.append("fetchIntermediateResult", fetchIntermediateResult);
+ builder.append("diagnosticsDuplicateStatements", diagnosticsDuplicateStatements);
+ builder.append("diagnosticsMissingWasNullCall", diagnosticsMissingWasNullCall);
+ builder.append("diagnosticsRepeatedStatements", diagnosticsRepeatedStatements);
+ builder.append("diagnosticsTooManyColumnsFetched", diagnosticsTooManyColumnsFetched);
+ builder.append("diagnosticsTooManyRowsFetched", diagnosticsTooManyRowsFetched);
+ builder.append("diagnosticsUnnecessaryWasNullCall", diagnosticsUnnecessaryWasNullCall);
+ builder.append("diagnosticsTrivialCondition", diagnosticsTrivialCondition);
builder.append("transformPatterns", transformPatterns);
builder.append("transformPatternsLogging", transformPatternsLogging);
builder.append("transformPatternsTrim", transformPatternsTrim);
@@ -6057,6 +6304,69 @@ public class Settings
return false;
}
}
+ if (diagnosticsDuplicateStatements == null) {
+ if (other.diagnosticsDuplicateStatements!= null) {
+ return false;
+ }
+ } else {
+ if (!diagnosticsDuplicateStatements.equals(other.diagnosticsDuplicateStatements)) {
+ return false;
+ }
+ }
+ if (diagnosticsMissingWasNullCall == null) {
+ if (other.diagnosticsMissingWasNullCall!= null) {
+ return false;
+ }
+ } else {
+ if (!diagnosticsMissingWasNullCall.equals(other.diagnosticsMissingWasNullCall)) {
+ return false;
+ }
+ }
+ if (diagnosticsRepeatedStatements == null) {
+ if (other.diagnosticsRepeatedStatements!= null) {
+ return false;
+ }
+ } else {
+ if (!diagnosticsRepeatedStatements.equals(other.diagnosticsRepeatedStatements)) {
+ return false;
+ }
+ }
+ if (diagnosticsTooManyColumnsFetched == null) {
+ if (other.diagnosticsTooManyColumnsFetched!= null) {
+ return false;
+ }
+ } else {
+ if (!diagnosticsTooManyColumnsFetched.equals(other.diagnosticsTooManyColumnsFetched)) {
+ return false;
+ }
+ }
+ if (diagnosticsTooManyRowsFetched == null) {
+ if (other.diagnosticsTooManyRowsFetched!= null) {
+ return false;
+ }
+ } else {
+ if (!diagnosticsTooManyRowsFetched.equals(other.diagnosticsTooManyRowsFetched)) {
+ return false;
+ }
+ }
+ if (diagnosticsUnnecessaryWasNullCall == null) {
+ if (other.diagnosticsUnnecessaryWasNullCall!= null) {
+ return false;
+ }
+ } else {
+ if (!diagnosticsUnnecessaryWasNullCall.equals(other.diagnosticsUnnecessaryWasNullCall)) {
+ return false;
+ }
+ }
+ if (diagnosticsTrivialCondition == null) {
+ if (other.diagnosticsTrivialCondition!= null) {
+ return false;
+ }
+ } else {
+ if (!diagnosticsTrivialCondition.equals(other.diagnosticsTrivialCondition)) {
+ return false;
+ }
+ }
if (transformPatterns == null) {
if (other.transformPatterns!= null) {
return false;
@@ -7285,6 +7595,13 @@ public class Settings
result = ((prime*result)+((bindOffsetTimeType == null)? 0 :bindOffsetTimeType.hashCode()));
result = ((prime*result)+((fetchTriggerValuesAfterSQLServerOutput == null)? 0 :fetchTriggerValuesAfterSQLServerOutput.hashCode()));
result = ((prime*result)+((fetchIntermediateResult == null)? 0 :fetchIntermediateResult.hashCode()));
+ result = ((prime*result)+((diagnosticsDuplicateStatements == null)? 0 :diagnosticsDuplicateStatements.hashCode()));
+ result = ((prime*result)+((diagnosticsMissingWasNullCall == null)? 0 :diagnosticsMissingWasNullCall.hashCode()));
+ result = ((prime*result)+((diagnosticsRepeatedStatements == null)? 0 :diagnosticsRepeatedStatements.hashCode()));
+ result = ((prime*result)+((diagnosticsTooManyColumnsFetched == null)? 0 :diagnosticsTooManyColumnsFetched.hashCode()));
+ result = ((prime*result)+((diagnosticsTooManyRowsFetched == null)? 0 :diagnosticsTooManyRowsFetched.hashCode()));
+ result = ((prime*result)+((diagnosticsUnnecessaryWasNullCall == null)? 0 :diagnosticsUnnecessaryWasNullCall.hashCode()));
+ result = ((prime*result)+((diagnosticsTrivialCondition == null)? 0 :diagnosticsTrivialCondition.hashCode()));
result = ((prime*result)+((transformPatterns == null)? 0 :transformPatterns.hashCode()));
result = ((prime*result)+((transformPatternsLogging == null)? 0 :transformPatternsLogging.hashCode()));
result = ((prime*result)+((transformPatternsTrim == null)? 0 :transformPatternsTrim.hashCode()));
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDiagnosticsContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDiagnosticsContext.java
index 2f3eece99d..eb4423f0f9 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultDiagnosticsContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDiagnosticsContext.java
@@ -50,6 +50,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
+import org.jooq.Configuration;
import org.jooq.DiagnosticsContext;
import org.jooq.QueryPart;
import org.jooq.tools.JooqLogger;
@@ -57,7 +58,7 @@ import org.jooq.tools.JooqLogger;
/**
* @author Lukas Eder
*/
-final class DefaultDiagnosticsContext implements DiagnosticsContext {
+final class DefaultDiagnosticsContext extends AbstractScope implements DiagnosticsContext {
private static final JooqLogger log = JooqLogger.getLogger(DefaultDiagnosticsContext.class);
@@ -79,12 +80,13 @@ final class DefaultDiagnosticsContext implements DiagnosticsContext {
int resultSetColumnIndex;
final Throwable exception;
- DefaultDiagnosticsContext(String message, String actualStatement) {
- this(message, actualStatement, null);
+ DefaultDiagnosticsContext(Configuration configuration, String message, String actualStatement) {
+ this(configuration, message, actualStatement, null);
}
- DefaultDiagnosticsContext(String message, String actualStatement, Throwable exception) {
+ DefaultDiagnosticsContext(Configuration configuration, String message, String actualStatement, Throwable exception) {
this(
+ configuration,
message,
actualStatement,
actualStatement,
@@ -96,6 +98,7 @@ final class DefaultDiagnosticsContext implements DiagnosticsContext {
}
DefaultDiagnosticsContext(
+ Configuration configuration,
String message,
String actualStatement,
String normalisedStatement,
@@ -104,6 +107,8 @@ final class DefaultDiagnosticsContext implements DiagnosticsContext {
QueryPart part,
Throwable exception
) {
+ super(configuration);
+
this.message = message;
this.actualStatement = actualStatement;
this.normalisedStatement = normalisedStatement;
diff --git a/jOOQ/src/main/java/org/jooq/impl/DiagnosticsConnection.java b/jOOQ/src/main/java/org/jooq/impl/DiagnosticsConnection.java
index 625ea24396..700fd396d9 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DiagnosticsConnection.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DiagnosticsConnection.java
@@ -37,6 +37,7 @@
*/
package org.jooq.impl;
+import static java.lang.Boolean.FALSE;
// ...
import static org.jooq.conf.ParamType.FORCE_INDEXED;
@@ -51,6 +52,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.function.Predicate;
import java.util.Set;
import org.jooq.Configuration;
@@ -58,6 +60,7 @@ import org.jooq.Parser;
import org.jooq.Queries;
import org.jooq.QueryPart;
import org.jooq.RenderContext;
+import org.jooq.conf.Settings;
import org.jooq.impl.QOM.Eq;
import org.jooq.tools.jdbc.DefaultConnection;
@@ -161,6 +164,10 @@ final class DiagnosticsConnection extends DefaultConnection {
configuration.connectionProvider().release(getDelegate());
}
+ final boolean check(Predicate super Settings> test) {
+ return !FALSE.equals(test.test(configuration.settings()));
+ }
+
final String parse(String sql) {
Queries queries = null;
String normalised;
@@ -172,28 +179,37 @@ final class DiagnosticsConnection extends DefaultConnection {
catch (ParserException exception) {
normalised = sql;
listeners.exception(new DefaultDiagnosticsContext(
+ configuration,
"Query could not be parsed.", sql, exception
));
}
try {
- Set
+This feature is available in the commercial distribution only.]]>