File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ private function fetchTypes(string $id): Promise
195
195
public function close (): void
196
196
{
197
197
if ($ this ->handle instanceof \PgSql \Connection || \is_resource ($ this ->handle )) {
198
+ \pg_cancel_query ($ this ->handle );
198
199
\pg_close ($ this ->handle );
199
200
$ this ->handle = null ;
200
201
}
Original file line number Diff line number Diff line change @@ -66,4 +66,16 @@ public function testConnectInvalidUser(): Promise
66
66
67
67
return $ this ->connect (PostgresConnectionConfig::fromString ('host=localhost user=invalid ' ), new TimeoutCancellationToken (100 ));
68
68
}
69
+
70
+ public function testConnectionClose (): \Generator
71
+ {
72
+ $ connection = yield $ this ->connect (PostgresConnectionConfig::fromString ('host=localhost user=postgres ' ));
73
+ $ this ->assertInstanceOf (Connection::class, $ connection );
74
+
75
+ $ connection ->execute ('SELECT pg_sleep(10) ' );
76
+
77
+ $ start = microtime (true );
78
+ $ connection ->close ();
79
+ $ this ->assertEquals (0 , round (microtime (true ) - $ start ));
80
+ }
69
81
}
You can’t perform that action at this time.
0 commit comments