-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Support session state tracking #372
Labels
Comments
beamerblvd
added a commit
to beamerblvd/mysqlclient-python
that referenced
this issue
Jul 27, 2019
beamerblvd
added a commit
to beamerblvd/mysqlclient-python
that referenced
this issue
Jul 27, 2019
I have created #373, which is a rough first-pass at implementing items 1 and 2 above (but no more). It may need some refinement, it may have memory leaks. I'm looking for initial feedback about the above proposal and the approach I'm taking with the PR, and then I can take it further. |
beamerblvd
added a commit
to beamerblvd/mysqlclient-python
that referenced
this issue
Feb 17, 2020
…ma, variables, TX state Add several methods and two new types for session state tracking: - `session_state_changed` indicates whether session state has changed - `get_session_gtids` returns a list of GTIDs created by the just-committed transaction, if applicable - `get_session_new_schema` returns the new schema, if the schema changed - `get_session_changed_variables` returns any changed session variables, if any - `get_session_transaction_state` returns the transaction state, if any and available - `get_session_transaction_characteristics` returns the transaction characteristics, if any and available
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: I may be able to work on putting together a pull request for this feature request, but I wanted to make sure you were okay with this feature request and the approach I'm taking before doing all that work, hence I am filing this feature request for discussion and approval.
MySQL has a feature enabling server tracking of client session state changes. When this is enabled on the server and client, the server can actually notify the connected client about changes to its session state. This enables the client to, for example (our use case), determine which Global Transaction ID (GTID) or GTIDs were created when the client commits a transaction.
You can read more about this here:
Here's what is needed to support this:
MySQLdb.constants.CLIENT
:SESSION_TRACK = 1 << 23
_mysql.connection
namedget_session_track_gtids
which returns a list of GTIDs using C functionsmysql_session_track_get_first
/mysql_session_track_get_next
and the enum valueSESSION_TRACK_GTIDS
._mysql.connection
namedget_session_track_variables
which returns a list of namedtuples containing the session variable names and values for changed variables using the same C functions and the enum valueSESSION_TRACK_SYSTEM_VARIABLES
._mysql.connection
namedget_session_track_tx_characteristics
which returns a list of strings of the characteristics that changed using the same C functions and the enum valueSESSION_TRACK_TRANSACTION_CHARACTERISTICS
._mysql.connection
namedget_session_track_tx_state
which returns a list of namedtuples containing information parsed from the data as described in the documentation forSESSION_TRACK_TRANSACTION_STATE
using the same C functions and the enum valueSESSION_TRACK_TRANSACTION_STATE
.The bare minimum that we need is items 1 and 2, but implementing also 3 through 5 would be more complete.
The text was updated successfully, but these errors were encountered: