Session parameter/variable tracking for PostgreSQL - v3.0#4799
Merged
renecannao merged 49 commits intov3.0from Mar 13, 2025
Merged
Session parameter/variable tracking for PostgreSQL - v3.0#4799renecannao merged 49 commits intov3.0from
renecannao merged 49 commits intov3.0from
Conversation
SET statements on the backend. * Added set_charset: Manage character set configuration. * Added connect_start_SetCharset: Enables character set initialization during the connection start process.
* client_encoding/names * datestyle * timezone/time zone * standard_conforming_strings
Contributor
|
Can one of the admins verify this patch? |
… yet) * New tracked variables added: - bytea_output - client_min_messages - escape_string_warning Few optimizations Code cleanup
2f2ac6f to
da166ac
Compare
- DateStyle consists of two values: a format and an order (e.g., ISO,
MDY). Unlike other parameters, DateStyle can be set with one or both
values, and the missing value retains its previous setting.
Examples:
SET DateStyle TO 'ISO, MDY' → Format: ISO, Order: MDY
SET DateStyle TO 'ISO' → Format: ISO, Order remains unchanged i.e MDY
SET DateStyle TO 'DMY' → Format remains unchanged i,e ISO, Order: DMY
SET DateStyle TO 'Postgres' → Format: Postgres, Order remains unchanged
i.e DMY
Improved RESET statements and DEFAULT parameter values handling
- Enhance RESET and DEFAULT value handling:
• When a parameter is RESET or set to DEFAULT, ProxySQL now first
checks if a value is provided in the connection options.
• If a connection value is specified, it is applied; otherwise,
the parameter falls back to the value defined by the
corresponding pgsql-default_* variable.
enable_bitmapscan enable_indexscan enable_seqscan maintenance_work_mem
Improved error handling
* Removed async_set_names * Removed async_set_option * Removed dead code
* Removed async_set_autocommit
PgSQL_Connection_Placeholder to PgSQL_Connection
Removed deadcode
Removed dead code Removed MySQL Prepare Statement related code lib/PgSQL_Session.cpp # # Untracked files: # .gitattributes # .vs/ # PR_proxysql_postg.txt # include/query_cache - Copy.hpp # lib/Query_Cache - Copy.cpp # tash qqq # test/tap/tests/pgsql-basic_tests-t - Copy.cpp # test/tap/tests/pgsql-connection_test-t.cpp # test/tap/tests/pgsql-set_parameter_test-t.cpp #
allow_in_place_tablespaces enable_sort extra_float_digits synchronous_commit
* Simplifyed regular expression, specifically targeting PostgreSQL SET statements.
…eSQL variables * Added validation checks when setting PostgreSQL variables to prevent invalid configurations. * Applied the same validation to default PostgreSQL variables to maintain consistency.
If the provided datestyle includes both style and order, ensure both values are valid.
…s decimal values too
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Implemented PostgreSQL session parameters tracking. It significantly improves connection multiplexing capabilities.
This enhancement allows ProxySQL to intelligently reuse connections and properly configure session parameters on that connection, reducing the overhead of creating new connections for each client session.
How It Works
The feature maintains two parameter trackers:
When a new query is received, ProxySQL:
Key Benefits
Currently tracks following session parameters:
Note:
If a client sets any other session parameter or provides non-literal value, that connection becomes locked to its specific host group to prevent any inconsistent behavior.
Added handling of RESET command and DEFAULT parameter values
When executed, run-time parameters are restored to their default values. These defaults are determined in similar manner as PostgreSQL
Special handling of DateStyle
DateStyle consists of two values: a format and an order (e.g., ISO, MDY). Unlike other parameters, DateStyle can be set with one or both values, and the missing value retains its previous setting.
Example:
SET DateStyle TO 'ISO, MDY' → Format: ISO, Order: MDYSET DateStyle TO 'ISO' → Format: ISO, Order remains unchanged i.e MDYSET DateStyle TO 'DMY' → Format remains unchanged i,e ISO, Order: DMYSET DateStyle TO 'Postgres' → Format: Postgres, Order remains unchanged i.e DMYExtra:
COPY ... FROM STDOUT, functioning similarly toCOPY ... FROM STDINCloses#4837
Closes#4865
Closes#4776