Skip to content

set_time_limit() counts time while pg_get_result() waiting for asynchronous PostgreSQL query #14769

Closed
@lezso6

Description

@lezso6

Description

The following code:

<?php
// Connect
$conn = pg_connect("dbname='somedb'");
// Send a postgres sleep query (or anything long running query)
pg_send_query($conn, "SELECT pg_sleep(5)");
// Set PHP max execution time less than above
set_time_limit(2);
// Waiting for query to complete (but fails and error is shown)
$res = pg_get_result($conn); 
// Never printed
echo "OK"; 

Resulted in this output:

PHP Fatal error: maximum execution time of 2 seconds exceeded

But I expected this output instead:

OK

PHP Version

8.3.8

Operating System

Gentoo Linux

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions