@@ -5,8 +5,8 @@ import 'dart:typed_data';
55
66import 'package:async/async.dart' as async;
77import 'package:charcode/ascii.dart' ;
8+ import 'package:meta/meta.dart' ;
89import 'package:pool/pool.dart' as pool;
9- import 'package:postgres/src/v3/resolved_settings.dart' ;
1010import 'package:stream_channel/stream_channel.dart' ;
1111
1212import '../../postgres.dart' ;
@@ -15,10 +15,11 @@ import '../binary_codec.dart';
1515import '../text_codec.dart' ;
1616import 'protocol.dart' ;
1717import 'query_description.dart' ;
18+ import 'resolved_settings.dart' ;
1819
1920const _debugLog = false ;
2021
21- String identifier (String source) {
22+ String _identifier (String source) {
2223 // To avoid complex ambiguity rules, we always wrap identifier in double
2324 // quotes. That means the only character we need to escape are double quotes
2425 // in the source.
@@ -110,6 +111,7 @@ abstract class _PgSessionBase implements Session {
110111 }
111112
112113 if (isSimple || (ignoreRows && variables.isEmpty)) {
114+ _connection._queryCount++ ;
113115 // Great, we can just run a simple query.
114116 final controller = StreamController <ResultRow >();
115117 final items = < ResultRow > [];
@@ -294,9 +296,13 @@ class PgConnectionImplementation extends _PgSessionBase implements Connection {
294296
295297 var _statementCounter = 0 ;
296298 var _portalCounter = 0 ;
299+ var _queryCount = 0 ;
297300
298301 late final _channels = _Channels (this );
299302
303+ @internal
304+ int get queryCount => _queryCount;
305+
300306 @override
301307 Channels get channels => _channels;
302308
@@ -472,6 +478,7 @@ class _PreparedStatement extends Statement {
472478 Object ? parameters, {
473479 Duration ? timeout,
474480 }) async {
481+ _session._connection._queryCount++ ;
475482 timeout ?? = _session._settings.queryTimeout;
476483 final items = < ResultRow > [];
477484 final subscription = bind (parameters).listen (items.add);
@@ -763,7 +770,7 @@ class _Channels implements Channels {
763770
764771 void _subscribe (String channel, MultiStreamController firstListener) {
765772 Future (() async {
766- await _connection.execute (Sql ('LISTEN ${identifier (channel )}' ),
773+ await _connection.execute (Sql ('LISTEN ${_identifier (channel )}' ),
767774 ignoreRows: true );
768775 }).onError <Object >((error, stackTrace) {
769776 _activeListeners[channel]? .remove (firstListener);
@@ -782,7 +789,7 @@ class _Channels implements Channels {
782789 _activeListeners.remove (channel);
783790
784791 // Send unlisten command
785- await _connection.execute (Sql ('UNLISTEN ${identifier (channel )}' ),
792+ await _connection.execute (Sql ('UNLISTEN ${_identifier (channel )}' ),
786793 ignoreRows: true );
787794 }
788795 }
0 commit comments