From 07602532b54661d996552de078d0a33ce7109917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Sat, 14 Sep 2024 00:13:09 +0200 Subject: [PATCH] Revert timeout notes and deprecations. (#379) --- CHANGELOG.md | 8 -------- lib/postgres.dart | 14 +------------- lib/src/pool/pool_impl.dart | 14 ++++---------- lib/src/v3/connection.dart | 16 +++++----------- 4 files changed, 10 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d0e5d6..ac7f56c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,14 +18,6 @@ - Deprecated some logical replication message parsing method. - Removed `@internal`-annotated methods from the public API of `ServerException` and `Severity`. - `ServerException` may be transformed into `_PgTimeoutException` which is both `PgException` and `TimeoutException` (but no longer `ServerException`). - - The `timeout` parameters and the `SessionSettings.queryTimeout` has only a somewhat - acceptable behaviour: it triggers a timeout only in the local `Future` object, but - keeps the statement running on the server. Updated documentation, deprecated the - parameter where it doesn't make long-term sense. - - **Do not rely on the combination of timeouts and query statement queueing!** - We are planning to adopt a `statement_timeout`-based implementation, which will be a - breaking change for queuing-related timeouts. ## 3.3.0 diff --git a/lib/postgres.dart b/lib/postgres.dart index b063def..c83d806 100644 --- a/lib/postgres.dart +++ b/lib/postgres.dart @@ -145,12 +145,7 @@ abstract class Session { /// /// When the returned future completes, the statement must eventually be freed /// using [Statement.dispose] to avoid resource leaks. - Future prepare( - Object /* String | Sql */ query, { - /// NOTE: setting the timeout here affects only the local [Future] object and - /// it does not cancel the pending statement. This may change in the future. - Duration? timeout, - }); + Future prepare(Object /* String | Sql */ query); /// Executes the [query] with the given [parameters]. /// @@ -178,9 +173,6 @@ abstract class Session { parameters, bool ignoreRows = false, QueryMode? queryMode, - - /// NOTE: setting the timeout here affects only the local [Future] object and - /// it does not cancel the pending statement. This may change in the future. Duration? timeout, }); } @@ -258,10 +250,6 @@ abstract class Statement { Future run( Object? /* List | Map */ parameters, { - /// NOTE: setting the timeout here affects only the local [Future] object and - /// it does not cancel the pending statement. This may change in the future. - @Deprecated('Use the `prepare` methods\'s `timeout` parameter instead. ' - 'Setting this parameter may throw an error in the future, and it may be removed in a future version.') Duration? timeout, }); diff --git a/lib/src/pool/pool_impl.dart b/lib/src/pool/pool_impl.dart index cd74756..320f87e 100644 --- a/lib/src/pool/pool_impl.dart +++ b/lib/src/pool/pool_impl.dart @@ -71,17 +71,14 @@ class PoolImplementation implements Pool { } @override - Future prepare( - Object query, { - Duration? timeout, - }) async { + Future prepare(Object query) async { final statementCompleter = Completer(); unawaited(withConnection((connection) async { _PoolStatement? poolStatement; try { - final statement = await connection.prepare(query, timeout: timeout); + final statement = await connection.prepare(query); poolStatement = _PoolStatement(statement); } on Object catch (e, s) { // Could not prepare the statement, inform the caller and stop occupying @@ -303,11 +300,8 @@ class _PoolConnection implements Connection { } @override - Future prepare( - Object query, { - Duration? timeout, - }) { - return _connection.prepare(query, timeout: timeout); + Future prepare(Object query) { + return _connection.prepare(query); } @override diff --git a/lib/src/v3/connection.dart b/lib/src/v3/connection.dart index 39e9e7c..253deca 100644 --- a/lib/src/v3/connection.dart +++ b/lib/src/v3/connection.dart @@ -168,7 +168,7 @@ abstract class _PgSessionBase implements Session { } else { // The simple query protocol does not support variables. So when we have // parameters, we need an explicit prepare. - final prepared = await _prepare(description, timeout: timeout); + final prepared = await _prepare(description); try { return await prepared.run(variables, timeout: timeout); } finally { @@ -178,18 +178,12 @@ abstract class _PgSessionBase implements Session { } @override - Future prepare( - Object query, { - Duration? timeout, - }) async { + Future prepare(Object query) async { _verifyStateBeforeQuery(); - return await _prepare(query, timeout: timeout); + return await _prepare(query); } - Future<_PreparedStatement> _prepare( - Object query, { - Duration? timeout, - }) async { + Future<_PreparedStatement> _prepare(Object query) async { final conn = _connection; final name = 's/${conn._statementCounter++}'; final description = InternalQueryDescription.wrap( @@ -201,7 +195,7 @@ abstract class _PgSessionBase implements Session { description.transformedSql, statementName: name, typeOids: description.parameterTypes?.map((e) => e?.oid).toList(), - )).optionalTimeout(timeout); + )); return _PreparedStatement(description, name, this); }