Skip to content
Snippets Groups Projects
Commit 6d6b225e authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Implementing timeout options

parent 5da04236
Branches
No related tags found
No related merge requests found
...@@ -29,6 +29,9 @@ class Config ...@@ -29,6 +29,9 @@ class Config
$options = []; $options = [];
if (defined(qrs_db_option_tsqueryfunction) && null !== qrs_db_option_tsqueryfunction) if (defined(qrs_db_option_tsqueryfunction) && null !== qrs_db_option_tsqueryfunction)
$options['tsqueryfunction'] = qrs_db_option_tsqueryfunction; $options['tsqueryfunction'] = qrs_db_option_tsqueryfunction;
$options['timeout'] = (defined(qrs_db_option_timeout) && null !== qrs_db_option_timeout) ? qrs_db_option_timeout : 5000;
if (defined(qrs_db_connector) && null !== qrs_db_connector) if (defined(qrs_db_connector) && null !== qrs_db_connector)
return new Config(qrs_path_prefix, qrs_db_connector, qrs_db_user, qrs_db_pass, qrs_backend, $options); return new Config(qrs_path_prefix, qrs_db_connector, qrs_db_user, qrs_db_pass, qrs_backend, $options);
else else
......
...@@ -12,7 +12,8 @@ class PostgresSmartBackend implements Backend ...@@ -12,7 +12,8 @@ class PostgresSmartBackend implements Backend
function __construct(\PDO $db, array $options) function __construct(\PDO $db, array $options)
{ {
$this->db = $db; $this->db = $db;
$this->db->exec("SET statement_timeout = 5000;"); $timeout = $options["timeout"];
$this->db->exec("SET statement_timeout = $timeout;");
$this->options = $options; $this->options = $options;
} }
......
...@@ -10,6 +10,8 @@ define('qrs_db_user', 'quassel'); ...@@ -10,6 +10,8 @@ define('qrs_db_user', 'quassel');
define('qrs_db_pass', 'password'); define('qrs_db_pass', 'password');
define('qrs_db_option_tsqueryfunction', "plainto_tsquery('english', :query)"); define('qrs_db_option_tsqueryfunction', "plainto_tsquery('english', :query)");
// Timeout in milliseconds
define('qrs_db_option_timeout', 5000);
define('qrs_backend', 'pgsql-smart'); define('qrs_backend', 'pgsql-smart');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment