diff --git a/admin/tool/log/store/database/classes/log/store.php b/admin/tool/log/store/database/classes/log/store.php index cddf3f99c4a..10398df2cd3 100644 --- a/admin/tool/log/store/database/classes/log/store.php +++ b/admin/tool/log/store/database/classes/log/store.php @@ -88,6 +88,7 @@ class store implements \tool_log\log\writer, \core\log\sql_reader { $dboptions['dbport'] = $this->get_config('dbport', ''); $dboptions['dbschema'] = $this->get_config('dbschema', ''); $dboptions['dbcollation'] = $this->get_config('dbcollation', ''); + $dboptions['dbhandlesoptions'] = $this->get_config('dbhandlesoptions', false); try { $db->connect($this->get_config('dbhost'), $this->get_config('dbuser'), $this->get_config('dbpass'), $this->get_config('dbname'), false, $dboptions); diff --git a/admin/tool/log/store/database/lang/en/logstore_database.php b/admin/tool/log/store/database/lang/en/logstore_database.php index 4e81a4af970..0873229bf63 100644 --- a/admin/tool/log/store/database/lang/en/logstore_database.php +++ b/admin/tool/log/store/database/lang/en/logstore_database.php @@ -31,6 +31,8 @@ $string['databasesettings_help'] = 'Connection details for the external log data $string['databasepersist'] = 'Persistent database connections'; $string['databaseschema'] = 'Database schema'; $string['databasecollation'] = 'Database collation'; +$string['databasehandlesoptions'] = 'Database handles options'; +$string['databasehandlesoptions_help'] = 'Does the remote database handle its own options.'; $string['databasetable'] = 'Database table'; $string['databasetable_help'] = 'Name of the table where logs will be stored. This table should have a structure identical to the one used by logstore_standard (mdl_logstore_standard_log).'; $string['includeactions'] = 'Include actions of these types'; diff --git a/admin/tool/log/store/database/settings.php b/admin/tool/log/store/database/settings.php index 5b930f4dadf..4e450383ccb 100644 --- a/admin/tool/log/store/database/settings.php +++ b/admin/tool/log/store/database/settings.php @@ -54,6 +54,8 @@ if ($hassiteconfig) { 'logstore_database'), '', '')); $settings->add(new admin_setting_configtext('logstore_database/dbcollation', get_string('databasecollation', 'logstore_database'), '', '')); + $settings->add(new admin_setting_configcheckbox('logstore_database/dbhandlesoptions', get_string('databasehandlesoptions', + 'logstore_database'), get_string('databasehandlesoptions_help', 'logstore_database'), '0')); $settings->add(new admin_setting_configtext('logstore_database/buffersize', get_string('buffersize', 'logstore_database'), get_string('buffersize_help', 'logstore_database'), 50)); diff --git a/admin/tool/log/store/database/tests/store_test.php b/admin/tool/log/store/database/tests/store_test.php index e40a8a4ab21..a05c33f8b9c 100644 --- a/admin/tool/log/store/database/tests/store_test.php +++ b/admin/tool/log/store/database/tests/store_test.php @@ -83,6 +83,11 @@ class logstore_database_store_testcase extends advanced_testcase { } else { set_config('dbcollation', '', 'logstore_database'); } + if (!empty($CFG->dboptions['dbhandlesoptions'])) { + set_config('dbhandlesoptions', $CFG->dboptions['dbhandlesoptions'], 'logstore_database'); + } else { + set_config('dbhandlesoptions', false, 'logstore_database'); + } // Enable logging plugin. set_config('enabled_stores', 'logstore_database', 'tool_log'); diff --git a/admin/tool/log/store/database/upgrade.txt b/admin/tool/log/store/database/upgrade.txt new file mode 100644 index 00000000000..a8fa834c542 --- /dev/null +++ b/admin/tool/log/store/database/upgrade.txt @@ -0,0 +1,11 @@ +This files describes API changes in the logstore_database code. + +=== 3.4 === +* PostgreSQL connections now use advanced options to reduce connection overhead. These options are not compatible + with some connection poolers. The dbhandlesoptions parameter has been added to allow the database to configure the + required defaults. The parameters that are required in the database are; + ALTER DATABASE moodle SET client_encoding = UTF8; + ALTER DATABASE moodle SET standard_conforming_strings = on; + ALTER DATABASE moodle SET search_path = 'moodle,public'; -- Optional, if you wish to use a custom schema. + You can set these options against the database or the moodle user who connects. + diff --git a/admin/tool/log/store/database/version.php b/admin/tool/log/store/database/version.php index 40d4db17691..31057167a87 100644 --- a/admin/tool/log/store/database/version.php +++ b/admin/tool/log/store/database/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2017062600; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2017050500; // Requires this Moodle version. $plugin->component = 'logstore_database'; // Full name of the plugin (used for diagnostics).