[jOOQ/jOOQ#7398] Added Settings.diagnosticsConnection

So far, OFF is implemented. ON will follow shortly
This commit is contained in:
Lukas Eder 2022-11-11 12:38:56 +01:00
parent 577f080fe1
commit fe5def0b3e
5 changed files with 77 additions and 3 deletions

View File

@ -314,6 +314,9 @@ public class Settings
protected Boolean executeLogging = true;
@XmlElement(defaultValue = "true")
protected Boolean diagnosticsLogging = true;
@XmlElement(defaultValue = "DEFAULT")
@XmlSchemaType(name = "string")
protected DiagnosticsConnection diagnosticsConnection = DiagnosticsConnection.DEFAULT;
@XmlElement(defaultValue = "true")
protected Boolean updateRecordVersion = true;
@XmlElement(defaultValue = "true")
@ -3763,6 +3766,22 @@ public class Settings
this.diagnosticsLogging = value;
}
/**
* Whether to activate the DiagnosticsConnection, explicit by <code>DEFAULT</code>, implicit if <code>ON</code>, or turned <code>OFF</code> entirely.
*
*/
public DiagnosticsConnection getDiagnosticsConnection() {
return diagnosticsConnection;
}
/**
* Whether to activate the DiagnosticsConnection, explicit by <code>DEFAULT</code>, implicit if <code>ON</code>, or turned <code>OFF</code> entirely.
*
*/
public void setDiagnosticsConnection(DiagnosticsConnection value) {
this.diagnosticsConnection = value;
}
/**
* Whether store(), insert(), and update() methods should update the record version prior to the operation, for use with {@link #executeWithOptimisticLocking}.
*
@ -6173,6 +6192,15 @@ public class Settings
return this;
}
/**
* Whether to activate the DiagnosticsConnection, explicit by <code>DEFAULT</code>, implicit if <code>ON</code>, or turned <code>OFF</code> entirely.
*
*/
public Settings withDiagnosticsConnection(DiagnosticsConnection value) {
setDiagnosticsConnection(value);
return this;
}
public Settings withUpdateRecordVersion(Boolean value) {
setUpdateRecordVersion(value);
return this;
@ -6875,6 +6903,7 @@ public class Settings
builder.append("executeListenerEndInvocationOrder", executeListenerEndInvocationOrder);
builder.append("executeLogging", executeLogging);
builder.append("diagnosticsLogging", diagnosticsLogging);
builder.append("diagnosticsConnection", diagnosticsConnection);
builder.append("updateRecordVersion", updateRecordVersion);
builder.append("updateRecordTimestamp", updateRecordTimestamp);
builder.append("executeWithOptimisticLocking", executeWithOptimisticLocking);
@ -8069,6 +8098,15 @@ public class Settings
return false;
}
}
if (diagnosticsConnection == null) {
if (other.diagnosticsConnection!= null) {
return false;
}
} else {
if (!diagnosticsConnection.equals(other.diagnosticsConnection)) {
return false;
}
}
if (updateRecordVersion == null) {
if (other.updateRecordVersion!= null) {
return false;
@ -8873,6 +8911,7 @@ public class Settings
result = ((prime*result)+((executeListenerEndInvocationOrder == null)? 0 :executeListenerEndInvocationOrder.hashCode()));
result = ((prime*result)+((executeLogging == null)? 0 :executeLogging.hashCode()));
result = ((prime*result)+((diagnosticsLogging == null)? 0 :diagnosticsLogging.hashCode()));
result = ((prime*result)+((diagnosticsConnection == null)? 0 :diagnosticsConnection.hashCode()));
result = ((prime*result)+((updateRecordVersion == null)? 0 :updateRecordVersion.hashCode()));
result = ((prime*result)+((updateRecordTimestamp == null)? 0 :updateRecordTimestamp.hashCode()));
result = ((prime*result)+((executeWithOptimisticLocking == null)? 0 :executeWithOptimisticLocking.hashCode()));

View File

@ -42,6 +42,7 @@ import static java.util.Collections.synchronizedMap;
// ...
// ...
// ...
import static org.jooq.conf.DiagnosticsConnection.OFF;
import static org.jooq.conf.ParamType.FORCE_INDEXED;
import static org.jooq.impl.DSL.count;
import static org.jooq.impl.DSL.noCondition;
@ -194,7 +195,16 @@ final class DiagnosticsConnection extends DefaultConnection {
);
}
final boolean disabled() {
return configuration.settings().getDiagnosticsConnection() == OFF;
}
final String parse(String sql) {
// [#7398] Don't do anything if the feature is turned OFF
if (disabled())
return sql;
Queries queries = null;
Queries transformed = null;
String normalised;

View File

@ -59,7 +59,10 @@ final class DiagnosticsStatement extends DefaultCallableStatement {
@Override
public final ResultSet executeQuery(String sql) throws SQLException {
return new DiagnosticsResultSet(super.executeQuery(connection.parse(sql)), sql, this, connection);
if (connection.disabled())
return super.executeQuery(sql);
else
return new DiagnosticsResultSet(super.executeQuery(connection.parse(sql)), sql, this, connection);
}
@Override

View File

@ -548,7 +548,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
result.groupByDistinct = groupByDistinct;
result.having.setWhere(having.getWhere());
if (window != null)
result.addWindow(window);
result.addWindow0(window);
result.qualify.setWhere(qualify.getWhere());
}
@ -4250,11 +4250,15 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
@Override
public final void addWindow(WindowDefinition... definitions) {
addWindow(Arrays.asList(definitions));
addWindow0(Arrays.asList(definitions));
}
@Override
public final void addWindow(Collection<? extends WindowDefinition> definitions) {
addWindow0(definitions);
}
final void addWindow0(Collection<? extends WindowDefinition> definitions) {
if (window == null)
window = new WindowList();

View File

@ -1088,6 +1088,10 @@ case of which, this defaults to INLINED]]></jxb:javadoc></jxb:property></appinfo
<element name="diagnosticsLogging" type="boolean" minOccurs="0" maxOccurs="1" default="true">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[When set to true, this will add jOOQ's default logging DiagnosticsListeners.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="diagnosticsConnection" type="jooq-runtime:DiagnosticsConnection" minOccurs="0" maxOccurs="1" default="DEFAULT">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether to activate the DiagnosticsConnection, explicit by <code>DEFAULT</code>, implicit if <code>ON</code>, or turned <code>OFF</code> entirely.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="updateRecordVersion" type="boolean" minOccurs="0" maxOccurs="1" default="true">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether store(), insert(), and update() methods should update the record version prior to the operation, for use with {@link #executeWithOptimisticLocking}.]]></jxb:javadoc></jxb:property></appinfo></annotation>
@ -1826,6 +1830,20 @@ Either &lt;input/&gt; or &lt;inputExpression/&gt; must be provided]]></jxb:javad
</element>
</all>
</complexType>
<simpleType name="DiagnosticsConnection">
<restriction base="string">
<!-- The DiagnosticsConnection is turned on if used explicitly. -->
<enumeration value="DEFAULT"/>
<!-- The DiagnosticsConnection is always turned on for any user connection. -->
<enumeration value="ON"/>
<!-- The DiagnosticsConnection is turned off, even when used explicitly. -->
<enumeration value="OFF"/>
</restriction>
</simpleType>
<simpleType name="BackslashEscaping">
<restriction base="string">