File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 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
195195 public function close (): void
196196 {
197197 if ($ this ->handle instanceof \PgSql \Connection || \is_resource ($ this ->handle )) {
198+ \pg_cancel_query ($ this ->handle );
198199 \pg_close ($ this ->handle );
199200 $ this ->handle = null ;
200201 }
Original file line number Diff line number Diff line change @@ -66,4 +66,16 @@ public function testConnectInvalidUser(): Promise
6666
6767 return $ this ->connect (PostgresConnectionConfig::fromString ('host=localhost user=invalid ' ), new TimeoutCancellationToken (100 ));
6868 }
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+ }
6981}
You can’t perform that action at this time.
0 commit comments