1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-06-02 22:57:34 +02:00

Set search_path = 'pg_catalog' on PostgreSQL connections.

Suggested by Stephen Frost.
This commit is contained in:
David Steele 2018-06-21 11:39:37 -04:00
parent 7fee739710
commit aa41e00c9c
3 changed files with 20 additions and 0 deletions

View File

@ -31,6 +31,16 @@
</release-item>
</release-feature-list>
<release-improvement-list>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="frost.stephen"/>
</release-item-contributor-list>
<p>Set <code>search_path = 'pg_catalog'</code> on <postgres/> connections.</p>
</release-item>
</release-improvement-list>
<release-development-list>
<release-item>
<p>Move cryptographic hash functions to C using <proper>OpenSSL</proper>.</p>

View File

@ -210,10 +210,15 @@ sub connect
if ($fDbVersion >= PG_VERSION_APPLICATION_NAME)
{
# Set application name for monitoring and debugging
$self->{hDb}->do(
"set application_name = '" . BACKREST_NAME . ' [' .
(cfgOptionValid(CFGOPT_COMMAND) ? cfgOption(CFGOPT_COMMAND) : cfgCommandName(cfgCommandGet())) . "]'")
or confess &log(ERROR, $self->{hDb}->errstr, ERROR_DB_QUERY);
# Clear search path to prevent possible function overrides
$self->{hDb}->do("set search_path = 'pg_catalog'")
or confess &log(ERROR, $self->{hDb}->errstr, ERROR_DB_QUERY);
}
}
}

View File

@ -10520,10 +10520,15 @@ static const EmbeddedModule embeddedModule[] =
"\n"
"if ($fDbVersion >= PG_VERSION_APPLICATION_NAME)\n"
"{\n"
"\n"
"$self->{hDb}->do(\n"
"\"set application_name = '\" . BACKREST_NAME . ' [' .\n"
"(cfgOptionValid(CFGOPT_COMMAND) ? cfgOption(CFGOPT_COMMAND) : cfgCommandName(cfgCommandGet())) . \"]'\")\n"
"or confess &log(ERROR, $self->{hDb}->errstr, ERROR_DB_QUERY);\n"
"\n"
"\n"
"$self->{hDb}->do(\"set search_path = 'pg_catalog'\")\n"
"or confess &log(ERROR, $self->{hDb}->errstr, ERROR_DB_QUERY);\n"
"}\n"
"}\n"
"}\n"