diff --git a/jOOQ/src/main/java/org/jooq/Configuration.java b/jOOQ/src/main/java/org/jooq/Configuration.java
index dde8902133..5c7594205b 100644
--- a/jOOQ/src/main/java/org/jooq/Configuration.java
+++ b/jOOQ/src/main/java/org/jooq/Configuration.java
@@ -50,6 +50,7 @@ import javax.sql.DataSource;
import org.jooq.conf.Settings;
import org.jooq.impl.DataSourceConnectionProvider;
import org.jooq.impl.DefaultConnectionProvider;
+import org.jooq.impl.DefaultDiagnosticsListenerProvider;
import org.jooq.impl.DefaultExecuteListenerProvider;
import org.jooq.impl.DefaultExecutorProvider;
import org.jooq.impl.DefaultRecordListenerProvider;
@@ -293,6 +294,12 @@ public interface Configuration extends Serializable {
*/
TransactionListenerProvider[] transactionListenerProviders();
+ /**
+ * Get the configured DiagnosticsListenerProviders from this
+ * configuration.
+ */
+ DiagnosticsListenerProvider[] diagnosticsListenerProviders();
+
/**
* Get this configuration's underlying record mapper provider.
*/
@@ -651,6 +658,33 @@ public interface Configuration extends Serializable {
*/
Configuration set(TransactionListenerProvider... newTransactionListenerProviders);
+ /**
+ * Change this configuration to hold a new diagnostics listeners.
+ *
+ * This will wrap the argument {@link DiagnosticsListener} in a
+ * {@link DefaultDiagnosticsListenerProvider} for convenience.
+ *
+ * This method is not thread-safe and should not be used in globally
+ * available Configuration objects.
+ *
+ * @param newDiagnosticsListeners The new diagnostics listeners to be
+ * contained in the changed configuration.
+ * @return The changed configuration.
+ */
+ Configuration set(DiagnosticsListener... newDiagnosticsListeners);
+
+ /**
+ * Change this configuration to hold a new diagnostics listener providers.
+ *
+ * This method is not thread-safe and should not be used in globally
+ * available Configuration objects.
+ *
+ * @param newDiagnosticsListenerProviders The new diagnostics listener
+ * providers to be contained in the changed configuration.
+ * @return The changed configuration.
+ */
+ Configuration set(DiagnosticsListenerProvider... newDiagnosticsListenerProviders);
+
/**
* Change this configuration to hold a new converter provider.
*
@@ -907,6 +941,26 @@ public interface Configuration extends Serializable {
*/
Configuration derive(TransactionListenerProvider... newTransactionListenerProviders);
+ /**
+ * Create a derived configuration from this one, with new diagnostics
+ * listeners.
+ *
+ * @param newDiagnosticsListeners The new diagnostics listeners to be
+ * contained in the derived configuration.
+ * @return The derived configuration.
+ */
+ Configuration derive(DiagnosticsListener... newDiagnosticsListeners);
+
+ /**
+ * Create a derived configuration from this one, with new diagnostics
+ * listener providers.
+ *
+ * @param newDiagnosticsListenerProviders The new diagnostics listener
+ * providers to be contained in the derived configuration.
+ * @return The derived configuration.
+ */
+ Configuration derive(DiagnosticsListenerProvider... newDiagnosticsListenerProviders);
+
/**
* Create a derived configuration from this one, with new converter
* provider.
diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java
index 88feb87d58..aaf8655162 100644
--- a/jOOQ/src/main/java/org/jooq/DSLContext.java
+++ b/jOOQ/src/main/java/org/jooq/DSLContext.java
@@ -216,6 +216,14 @@ public interface DSLContext extends Scope , AutoCloseable {
*/
Connection parsingConnection();
+ /**
+ * A JDBC connection that proxies the underlying connection to run the jOOQ
+ * Diagnostics Pack on executed queries.
+ *
+ * This is experimental functionality.
+ */
+ Connection diagnosticsConnection();
+
/**
* Access the database meta data.
*
diff --git a/jOOQ/src/main/java/org/jooq/DiagnosticsContext.java b/jOOQ/src/main/java/org/jooq/DiagnosticsContext.java
new file mode 100644
index 0000000000..d53379d456
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/DiagnosticsContext.java
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+import java.sql.ResultSet;
+
+/**
+ * A parameter object that is passed to {@link DiagnosticsListener} methods.
+ *
+ * @author Lukas Eder
+ */
+public interface DiagnosticsContext {
+
+ /**
+ * The {@link ResultSet} available in this context, or null, if
+ * there was no result set.
+ */
+ ResultSet resultSet();
+
+ /**
+ * The number of rows that were fetched from {@link #resultSet()}, or
+ * -1 if there was no result set.
+ */
+ int resultSetFetchedRows();
+
+ /**
+ * The number of rows that were actually available from
+ * {@link #resultSet()}, or -1 if there was no result set.
+ *
+ * Calling this method will try to scroll to the end of the
+ * {@link #resultSet()}, in order to count the number of rows, which incurs
+ * overhead!
+ *
+ * If the result set is still being consumed (i.e. prior to the
+ * {@link ResultSet#close()} call), and scrolling back to the current row
+ * after scrolling to the end of {@link #resultSet()} is not possible (e.g.
+ * because the driver supports only {@link ResultSet#TYPE_FORWARD_ONLY}),
+ * then this will return the same value as {@link #resultSetFetchedRows()}.
+ */
+ int resultSetActualRows();
+}
diff --git a/jOOQ/src/main/java/org/jooq/DiagnosticsListener.java b/jOOQ/src/main/java/org/jooq/DiagnosticsListener.java
new file mode 100644
index 0000000000..89287aba9c
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/DiagnosticsListener.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import java.sql.ResultSet;
+
+/**
+ * A diagnostics listener.
+ *
+ * @author Lukas Eder
+ */
+public interface DiagnosticsListener {
+
+ /**
+ * The fetched JDBC {@link ResultSet} was too large.
+ *
+ * An event indicating that a JDBC {@link ResultSet} was fetched with
+ * A rows, but only B rows (B < A)
+ * were consumed.
+ *
+ * Typically, this problem can be remedied by applying the appropriate
+ * LIMIT clause in SQL, or {@link SelectLimitStep#limit(int)}
+ * clause in jOOQ.
+ */
+ void resultSetTooLarge(DiagnosticsContext ctx);
+
+}
diff --git a/jOOQ/src/main/java/org/jooq/DiagnosticsListenerProvider.java b/jOOQ/src/main/java/org/jooq/DiagnosticsListenerProvider.java
new file mode 100644
index 0000000000..9d1f9dc63f
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/DiagnosticsListenerProvider.java
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+import org.jooq.impl.DefaultDiagnosticsListenerProvider;
+
+/**
+ * A provider for {@link TransactionListener} instances.
+ *
+ * In order to facilitate the lifecycle management of
+ * TransactionListener instances that are provided to a jOOQ
+ * {@link Configuration}, clients can implement this API. To jOOQ, it is thus
+ * irrelevant, if transaction listeners are stateful or stateless, local to an
+ * execution, or global to an application.
+ *
+ * @author Lukas Eder
+ * @see TransactionListener
+ * @see Configuration
+ */
+
+@FunctionalInterface
+
+public interface DiagnosticsListenerProvider {
+
+ /**
+ * Provide an DiagnosticsListener instance.
+ *
+ * Implementations are free to choose whether this method returns new
+ * instances at every call or whether the same instance is returned
+ * repetitively.
+ *
+ * The lifecycle of the DiagnosticsListener is not specified.
+ * New instances can be provided any time clients want to reset their
+ * diagnostics.
+ *
+ * @return A DiagnosticsListener instance.
+ * @see DiagnosticsListener
+ * @see DefaultDiagnosticsListenerProvider
+ */
+ DiagnosticsListener provide();
+}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java b/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java
index 3caccff44e..e85288a36b 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java
@@ -59,6 +59,8 @@ import org.jooq.Configuration;
import org.jooq.ConnectionProvider;
import org.jooq.ConverterProvider;
import org.jooq.DSLContext;
+import org.jooq.DiagnosticsListener;
+import org.jooq.DiagnosticsListenerProvider;
import org.jooq.ExecuteListener;
import org.jooq.ExecuteListenerProvider;
import org.jooq.ExecutorProvider;
@@ -115,6 +117,7 @@ public class DefaultConfiguration implements Configuration {
private transient ExecuteListenerProvider[] executeListenerProviders;
private transient VisitListenerProvider[] visitListenerProviders;
private transient TransactionListenerProvider[] transactionListenerProviders;
+ private transient DiagnosticsListenerProvider[] diagnosticsListenerProviders;
private transient ConverterProvider converterProvider;
// [#7062] Apart from the possibility of containing user defined objects, the data
@@ -462,6 +465,7 @@ public class DefaultConfiguration implements Configuration {
executeListenerProviders,
visitListenerProviders,
transactionListenerProviders,
+ null,
converterProvider,
null,
@@ -472,6 +476,60 @@ public class DefaultConfiguration implements Configuration {
);
}
+ /**
+ * Create the actual configuration object.
+ *
+ * This constructor has been made package-private to allow for adding new
+ * configuration properties in the future, without breaking client code.
+ * Consider creating a configuration by chaining calls to various
+ * derive() methods.
+ *
+ * @deprecated Use
+ * {@link #DefaultConfiguration(ConnectionProvider, ExecutorProvider, TransactionProvider, RecordMapperProvider, RecordUnmapperProvider, RecordListenerProvider[], ExecuteListenerProvider[], VisitListenerProvider[], TransactionListenerProvider[], DiagnosticsListenerProvider[], ConverterProvider, SQLDialect, Settings, Map)}
+ * instead. This constructor is maintained to provide jOOQ 3.2,
+ * 3.3, 3.7, 3.8, 3.9, 3.10 backwards-compatibility if called with
+ * reflection from Spring configurations.
+ */
+ @Deprecated
+ DefaultConfiguration(
+ ConnectionProvider connectionProvider,
+ ExecutorProvider executorProvider,
+ TransactionProvider transactionProvider,
+ RecordMapperProvider recordMapperProvider,
+ RecordUnmapperProvider recordUnmapperProvider,
+ RecordListenerProvider[] recordListenerProviders,
+ ExecuteListenerProvider[] executeListenerProviders,
+ VisitListenerProvider[] visitListenerProviders,
+ TransactionListenerProvider[] transactionListenerProviders,
+ ConverterProvider converterProvider,
+
+ Clock clock,
+
+ SQLDialect dialect,
+ Settings settings,
+ Map