File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,21 +233,11 @@ class MysqlTableDataDelegate extends TableDataMutationDelegate {
233233 });
234234 }
235235
236+ /// Pooled sessions are shared with every other view of this database, so
237+ /// cancelling never closes them: a statement that is still running finishes
238+ /// or times out on its own, and the lease is released by [dispose] .
236239 @override
237- void cancel ({bool interruptIfBusy = false }) {
238- if (interruptIfBusy) {
239- MysqlService .instance.interrupt (
240- connectionRow,
241- database: database,
242- mode: MysqlSessionMode .readOnly,
243- );
244- MysqlService .instance.interrupt (
245- connectionRow,
246- database: database,
247- mode: MysqlSessionMode .tableWrite,
248- );
249- }
250- }
240+ void cancel ({bool interruptIfBusy = false }) {}
251241
252242 @override
253243 void dispose () {
Original file line number Diff line number Diff line change @@ -234,21 +234,11 @@ class PostgresTableDataDelegate extends TableDataMutationDelegate {
234234 });
235235 }
236236
237+ /// Pooled sessions are shared with every other view of this database, so
238+ /// cancelling never closes them: a statement that is still running finishes
239+ /// or times out on its own, and the lease is released by [dispose] .
237240 @override
238- void cancel ({bool interruptIfBusy = false }) {
239- if (interruptIfBusy) {
240- PostgresService .instance.interrupt (
241- connectionRow,
242- database: database,
243- mode: PgSessionMode .readOnly,
244- );
245- PostgresService .instance.interrupt (
246- connectionRow,
247- database: database,
248- mode: PgSessionMode .tableWrite,
249- );
250- }
251- }
241+ void cancel ({bool interruptIfBusy = false }) {}
252242
253243 @override
254244 void dispose () {
Original file line number Diff line number Diff line change @@ -221,19 +221,11 @@ class SqliteTableDataDelegate extends TableDataMutationDelegate {
221221 });
222222 }
223223
224+ /// Pooled sessions are shared with every other view of this database, so
225+ /// cancelling never closes them: a statement that is still running finishes
226+ /// or times out on its own, and the lease is released by [dispose] .
224227 @override
225- void cancel ({bool interruptIfBusy = false }) {
226- if (interruptIfBusy) {
227- SqliteService .instance.interrupt (
228- connectionRow,
229- mode: SqliteSessionMode .readOnly,
230- );
231- SqliteService .instance.interrupt (
232- connectionRow,
233- mode: SqliteSessionMode .tableWrite,
234- );
235- }
236- }
228+ void cancel ({bool interruptIfBusy = false }) {}
237229
238230 @override
239231 void dispose () {
Original file line number Diff line number Diff line change @@ -286,7 +286,8 @@ class GenericTableViewState extends material.State<GenericTableView> {
286286 void dispose () {
287287 TableViewCommandBridge .instance.unregister (owner: this );
288288 _resetStaging ();
289- widget.delegate.cancel (interruptIfBusy: true );
289+ // Closing the tab releases its lease. It must not interrupt the shared
290+ // session: other views of the database may be using it.
290291 widget.delegate.dispose ();
291292 super .dispose ();
292293 }
Original file line number Diff line number Diff line change @@ -86,4 +86,15 @@ void main() {
8686 await t.pump ();
8787 expect (find.byType (ErdView ), findsNothing);
8888 });
89+
90+ testWidgets ('closing a table tab releases its delegate without cancelling it' ,
91+ (t) async {
92+ final delegate = FakeTableDataDelegate ();
93+ await pumpGenericTableView (t, delegate);
94+ await t.pumpWidget (const material.SizedBox ());
95+ await t.pump ();
96+ // The session is shared with other views: closing must not interrupt it.
97+ expect (delegate.cancelCount, 0 );
98+ expect (delegate.disposeCount, 1 );
99+ });
89100}
You can’t perform that action at this time.
0 commit comments