[9.x] Support connection to MySql with minimal interactions #43020
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reducing configuration statements issued to MySql Server on connect, like 'use db' or 'set names', helps taking full advantage of a connection proxy, minimizing chances of connection pinning [1].
Such configuration statements can also be executed once per connection, via proxy's initialization query, instead of once per Request lifecycle.
A support for a minimal interaction upon connection can also be useful in some conditions (es: tests, low resources).
Actually, on connect, MySqlConnector executes:
This PR:
also ensuring proper PDO::quote functionality, not affected by 'set names' statement [3].
'set names' will be executed necessarily if a collation is set but not as prepared statement, useful when not using the default one, but unsetting it allows skipping this step.
Setting these database options to NULL (isolation_level, collation, timezone, modes and strict) allows having a minimal interaction on a connect, like:
[1] - https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy-managing.html#rds-proxy-pinning
[2] - https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html
[3] - https://www.php.net/manual/en/mysqlinfo.concepts.charset.php