Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/postgres_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ PGconn *PostgresUtils::PGConnect(const string &dsn, const string &attach_path) {

// both PQStatus and PQerrorMessage check for nullptr
if (PQstatus(conn) == CONNECTION_BAD) {
throw IOException("Unable to connect to Postgres at \"%s\": %s", attach_path, string(PQerrorMessage(conn)));
char *msg_cstr = PQerrorMessage(conn);
std::string msg = msg_cstr != nullptr ? std::string(msg_cstr) : std::string();
PQfinish(conn);
throw IOException("Unable to connect to Postgres at \"%s\": %s", attach_path, msg);
}
PQsetNoticeProcessor(conn, PGNoticeProcessor, nullptr);
return conn;
Expand Down
17 changes: 13 additions & 4 deletions test/sql/storage/attach_connection_pool_configure.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@ require postgres_scanner

require-env POSTGRES_TEST_DATABASE_AVAILABLE

statement ok
PRAGMA enable_verification

statement ok
SET pg_pool_max_connections = 8

statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES);

statement ok
ATTACH 'dbname=postgresscanner' AS s1 (TYPE POSTGRES);

query I
SELECT catalog_name
statement ok
RESET GLOBAL pg_pool_max_connections

query II
SELECT catalog_name, max_connections
FROM postgres_configure_pool()
ORDER BY catalog_name
----
s
s1
s 8
s1 8

query II
SELECT catalog_name, acquire_mode
Expand Down
13 changes: 3 additions & 10 deletions test/sql/storage/attach_connection_pool_options.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ require postgres_scanner

require-env POSTGRES_TEST_DATABASE_AVAILABLE

statement ok
PRAGMA enable_verification

statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES);

Expand Down Expand Up @@ -189,11 +192,6 @@ SELECT current_setting('pg_pool_max_connections')
statement ok
RESET GLOBAL pg_connection_limit

query I
SELECT current_setting('pg_pool_max_connections')
----
8

statement ok
DETACH s

Expand All @@ -217,10 +215,5 @@ SELECT current_setting('pg_pool_max_connections')
statement ok
RESET GLOBAL pg_connection_cache

query I
SELECT current_setting('pg_pool_max_connections')
----
8

statement ok
DETACH s
Loading