Merge pull request #2556 from Lartza/fix-setup-pgsql-quotes
Quote database and role in queries
This commit is contained in:
commit
880121d310
|
@ -111,7 +111,7 @@ class PostgreSQL extends AbstractDatabase {
|
||||||
private function createDatabase(IDBConnection $connection) {
|
private function createDatabase(IDBConnection $connection) {
|
||||||
if (!$this->databaseExists($connection)) {
|
if (!$this->databaseExists($connection)) {
|
||||||
//The database does not exists... let's create it
|
//The database does not exists... let's create it
|
||||||
$query = $connection->prepare("CREATE DATABASE " . addslashes($this->dbName) . " OWNER " . addslashes($this->dbUser));
|
$query = $connection->prepare("CREATE DATABASE \"" . addslashes($this->dbName) . "\" OWNER '" . addslashes($this->dbUser) . "'");
|
||||||
try {
|
try {
|
||||||
$query->execute();
|
$query->execute();
|
||||||
} catch (DatabaseException $e) {
|
} catch (DatabaseException $e) {
|
||||||
|
@ -119,7 +119,7 @@ class PostgreSQL extends AbstractDatabase {
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE " . addslashes($this->dbName) . " FROM PUBLIC");
|
$query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE \"" . addslashes($this->dbName) . "\" FROM PUBLIC");
|
||||||
try {
|
try {
|
||||||
$query->execute();
|
$query->execute();
|
||||||
} catch (DatabaseException $e) {
|
} catch (DatabaseException $e) {
|
||||||
|
@ -153,10 +153,10 @@ class PostgreSQL extends AbstractDatabase {
|
||||||
try {
|
try {
|
||||||
if ($this->userExists($connection)) {
|
if ($this->userExists($connection)) {
|
||||||
// change the password
|
// change the password
|
||||||
$query = $connection->prepare("ALTER ROLE " . addslashes($this->dbUser) . " WITH CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
$query = $connection->prepare("ALTER ROLE \"" . addslashes($this->dbUser) . "\" WITH CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
||||||
} else {
|
} else {
|
||||||
// create the user
|
// create the user
|
||||||
$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
$query = $connection->prepare("CREATE USER \"" . addslashes($this->dbUser) . "\" CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
||||||
}
|
}
|
||||||
$query->execute();
|
$query->execute();
|
||||||
} catch (DatabaseException $e) {
|
} catch (DatabaseException $e) {
|
||||||
|
|
Loading…
Reference in New Issue