Permalink
Browse files

MDL-37420 rework pg schema (partial backport of 92b00c3)

  • Loading branch information...
1 parent 43bfcff commit 9b7b6fa33c5dbfc86efd3a9dff8a23c77d76fecd @stronk7 stronk7 committed Jan 10, 2013
Showing with 8 additions and 12 deletions.
  1. +7 −11 enrol/database/tests/sync_test.php
  2. +1 −1 lib/dml/pgsql_native_moodle_database.php
@@ -73,7 +73,11 @@ protected function init_enrol_database() {
case 'pgsql_native_moodle_database':
set_config('dbtype', 'postgres7', 'enrol_database');
- set_config('dbsetupsql', "SET NAMES 'UTF-8'", 'enrol_database');
+ $setupsql = "SET NAMES 'UTF-8'";
+ if (!empty($CFG->dboptions['dbschema'])) {
+ $setupsql .= "; SET search_path = '".$CFG->dboptions['dbschema']."'";
+ }
+ set_config('dbsetupsql', $setupsql, 'enrol_database');
set_config('dbsybasequoting', '0', 'enrol_database');
if (!empty($CFG->dboptions['dbsocket']) and ($CFG->dbhost === 'localhost' or $CFG->dbhost === '127.0.0.1')) {
if (strpos($CFG->dboptions['dbsocket'], '/') !== false) {
@@ -107,11 +111,7 @@ protected function init_enrol_database() {
$dbman->drop_table($table);
}
$dbman->create_table($table);
- if (!empty($CFG->dboptions['dbschema'])) {
- set_config('remoteenroltable', $CFG->dboptions['dbschema'].'.'.$CFG->prefix.'enrol_database_test_enrols', 'enrol_database');
- } else {
- set_config('remoteenroltable', $CFG->prefix.'enrol_database_test_enrols', 'enrol_database');
- }
+ set_config('remoteenroltable', $CFG->prefix.'enrol_database_test_enrols', 'enrol_database');
set_config('remotecoursefield', 'courseid', 'enrol_database');
set_config('remoteuserfield', 'userid', 'enrol_database');
set_config('remoterolefield', 'roleid', 'enrol_database');
@@ -127,11 +127,7 @@ protected function init_enrol_database() {
$dbman->drop_table($table);
}
$dbman->create_table($table);
- if (!empty($CFG->dboptions['dbschema'])) {
- set_config('newcoursetable', $CFG->dboptions['dbschema'].'.'.$CFG->prefix.'enrol_database_test_courses', 'enrol_database');
- } else {
- set_config('newcoursetable', $CFG->prefix.'enrol_database_test_courses', 'enrol_database');
- }
+ set_config('newcoursetable', $CFG->prefix.'enrol_database_test_courses', 'enrol_database');
set_config('newcoursefullname', 'fullname', 'enrol_database');
set_config('newcourseshortname', 'shortname', 'enrol_database');
set_config('newcourseidnumber', 'idnumber', 'enrol_database');
@@ -185,7 +185,7 @@ public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dbop
}
// Select schema if specified, otherwise the first one wins.
- if (isset($this->dboptions['dbschema'])) {
+ if (!empty($this->dboptions['dbschema'])) {
$sql .= "SET search_path = '".$this->dboptions['dbschema']."'; ";
}

0 comments on commit 9b7b6fa

Please sign in to comment.