Skip to content

Commit

Permalink
postgres: randomize prepared statement names to avoid collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Nov 17, 2023
1 parent e9aa60e commit ad0451a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- This avoids the creation of single-use prepared statements, which should slightly improve performance
- This allows multiple statements in a single call to sqlx::query in MySQL
- In MySQL, fix "zero dates" being recognized as NULL only when transmitted as binary, not as text
- In postgres, randomize the initial prepared statement name to avoid collisions when multiple network connections are initiated in parallel and end up using the same final database tcp connection. This can happen when using a connection pooler in front of the database.

## 0.6.17

Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/postgres/connection/establish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl PgConnection {
transaction_status,
transaction_depth: 0,
pending_ready_for_query_count: 0,
next_statement_id: Oid(1),
next_statement_id: Oid(rand::random()),
cache_statement: StatementCache::new(options.statement_cache_capacity),
cache_type_oid: HashMap::new(),
cache_type_info: HashMap::new(),
Expand Down

0 comments on commit ad0451a

Please sign in to comment.