Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
f7bf60a4
Commit
f7bf60a4
authored
Jan 10, 2016
by
Steve Müller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #798 from malapronta/pg_application_name
Add application_name to PostgreSQL driver fixes #1089
parents
a2701b52
252975ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
configuration.rst
docs/en/reference/configuration.rst
+3
-1
Driver.php
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
+5
-1
DriverTest.php
...rine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php
+17
-0
No files found.
docs/en/reference/configuration.rst
View file @
f7bf60a4
...
...
@@ -259,6 +259,8 @@ pdo\_pgsql
the server's certificate will be verified to be signed by one of these
authorities.
See http://www.postgresql.org/docs/9.0/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT
- ``application_name`` (string): Name of the application that is
connecting to database. Optional. It will be displayed at ``pg_stat_activity``.
PostgreSQL behaves differently with regard to booleans when you use
``PDO::ATTR_EMULATE_PREPARES`` or not. To switch from using ``'true'``
...
...
@@ -290,7 +292,7 @@ pdo\_oci / oci8
database.
- ``instancename`` (string): Optional parameter, complete whether to
add the INSTANCE_NAME parameter in the connection. It is generally used
to connect to an Oracle RAC server to select the name of a particular instance.
to connect to an Oracle RAC server to select the name of a particular instance.
pdo\_sqlsrv / sqlsrv
...
...
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
View file @
f7bf60a4
...
...
@@ -91,7 +91,7 @@ class Driver extends AbstractPostgreSQLDriver
}
else
{
// Used for temporary connections to allow operations like dropping the database currently connected to.
// Connecting without an explicit database does not work, therefore "postgres" database is used
// as it is certainly present in every server setup.
// as it is certainly present in every server setup.
$dsn
.=
'dbname=postgres'
.
' '
;
}
...
...
@@ -103,6 +103,10 @@ class Driver extends AbstractPostgreSQLDriver
$dsn
.=
'sslrootcert='
.
$params
[
'sslrootcert'
]
.
' '
;
}
if
(
isset
(
$params
[
'application_name'
]))
{
$dsn
.=
'application_name='
.
$params
[
'application_name'
]
.
' '
;
}
return
$dsn
;
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php
View file @
f7bf60a4
...
...
@@ -20,6 +20,23 @@ class DriverTest extends AbstractDriverTest
}
}
/**
* @group DBAL-1146
*/
public
function
testConnectsWithApplicationNameParameter
()
{
$parameters
=
$this
->
_conn
->
getParams
();
$parameters
[
'application_name'
]
=
'doctrine'
;
$user
=
isset
(
$parameters
[
'user'
])
?
$parameters
[
'user'
]
:
null
;
$password
=
isset
(
$parameters
[
'password'
])
?
$parameters
[
'password'
]
:
null
;
$connection
=
$this
->
driver
->
connect
(
$parameters
,
$user
,
$password
);
$statement
=
$connection
->
query
(
'SELECT application_name FROM pg_stat_activity'
);
$this
->
assertSame
(
'doctrine'
,
$statement
->
fetchColumn
());
}
/**
* {@inheritdoc}
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment