diff --git a/database/Config.php b/database/Config.php index 8779ea47351c1f4a55e14695dc61e3e78284b933..b463be25ce7da8595c5ed9e92011ad7102127a5d 100644 --- a/database/Config.php +++ b/database/Config.php @@ -29,6 +29,9 @@ class Config $options = []; if (defined(qrs_db_option_tsqueryfunction) && null !== 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) return new Config(qrs_path_prefix, qrs_db_connector, qrs_db_user, qrs_db_pass, qrs_backend, $options); else diff --git a/database/backends/PostgresSmartBackend.php b/database/backends/PostgresSmartBackend.php index 7c825c979cec0e818c6368d3a7aa09aa90de15b2..e08a1ca96049bee8473a2c369644a9a455f661ac 100644 --- a/database/backends/PostgresSmartBackend.php +++ b/database/backends/PostgresSmartBackend.php @@ -12,7 +12,8 @@ class PostgresSmartBackend implements Backend function __construct(\PDO $db, array $options) { $this->db = $db; - $this->db->exec("SET statement_timeout = 5000;"); + $timeout = $options["timeout"]; + $this->db->exec("SET statement_timeout = $timeout;"); $this->options = $options; } diff --git a/qrs_config.default.php b/qrs_config.default.php index 95539f3c28f4f7141d5325f72a7ffc15501dbbe8..5bc6425500a6badc98607aaa24349c36e9d1bff0 100644 --- a/qrs_config.default.php +++ b/qrs_config.default.php @@ -3,13 +3,15 @@ define('qrs_db_host', 'example.com'); define('qrs_db_port', 5432); define('qrs_db_name', 'quassel'); -//Only change this if you know what you are doing +// Only change this if you know what you are doing define('qrs_db_connector', null); define('qrs_db_user', 'quassel'); define('qrs_db_pass', 'password'); define('qrs_db_option_tsqueryfunction', "plainto_tsquery('english', :query)"); +// Timeout in milliseconds +define('qrs_db_option_timeout', 5000); define('qrs_backend', 'pgsql-smart');