Skip to content

Commit 37e3a86

Browse files
authored
Pass application_name to server (#73)
* Pass application_name to server * fmt
1 parent 61db13f commit 37e3a86

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ impl Client {
342342
server.address()
343343
);
344344

345+
// Set application_name if any.
346+
// TODO: investigate other parameters and set them too.
347+
if self.parameters.contains_key("application_name") {
348+
server
349+
.set_name(&self.parameters["application_name"])
350+
.await?;
351+
}
352+
345353
// Transaction loop. Multiple queries can be issued by the client here.
346354
// The connection belongs to the client until the transaction is over,
347355
// or until the client disconnects if we are in session mode.

tests/ruby/tests.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
username: 'sharding_user',
1717
password: 'sharding_user',
1818
database: 'rails_dev',
19+
application_name: 'testing_pgcat',
1920
prepared_statements: false, # Transaction mode
2021
advisory_locks: false # Same
2122
)
@@ -116,7 +117,7 @@ def down
116117

117118
# Test evil clients
118119
def poorly_behaved_client
119-
conn = PG::connect("postgres://sharding_user:sharding_user@127.0.0.1:6432/rails_dev")
120+
conn = PG::connect("postgres://sharding_user:sharding_user@127.0.0.1:6432/rails_dev?application_name=testing_pgcat")
120121
conn.async_exec 'BEGIN'
121122
conn.async_exec 'SELECT 1'
122123

0 commit comments

Comments
 (0)