Closed uasan closed 7 years ago
Hi! This code simulates remote aborted connection, while waiting query result.
<?php $c = new pq\Connection('user=postgres', pq\Connection::ASYNC); $w = [$c->socket]; $r = $e = null; if(stream_select($r, $w, $e, null)) { while(true) { switch($c->poll()) { case pq\Connection::POLLING_READING: $r = [$c->socket]; stream_select($r, $w, $e, null); break; case pq\Connection::POLLING_OK: if($c->busy) { $c->getResult(); } else { $c->execAsync('SELECT pg_terminate_backend(pg_backend_pid())'); } break; } } }
PHP 7.1.4 (cli) (built: Apr 11 2017 18:59:26) ( NTS )
Thank.
Hi! This code simulates remote aborted connection, while waiting query result.
Thank.