PyMySQL / PyMySQL/mysqlclient

Feature Request: Support session state tracking

Aperta
#372 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature-request
Lingua principale
Python
Stelle
2.5k
Fork
443
Merge medio
18h 21m
PR unite (30g)
4

Descrizione

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:

  1. A new constant in MySQLdb.constants.CLIENT: SESSION_TRACK = 1 << 23
  2. A new method on _mysql.connection named get_session_track_gtids which returns a list of GTIDs using C functions mysql_session_track_get_first/mysql_session_track_get_next and the enum value SESSION_TRACK_GTIDS.
  3. A new method on _mysql.connection named get_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 value SESSION_TRACK_SYSTEM_VARIABLES.
  4. A new method on _mysql.connection named get_session_track_tx_characteristics which returns a list of strings of the characteristics that changed using the same C functions and the enum value SESSION_TRACK_TRANSACTION_CHARACTERISTICS.
  5. A new method on _mysql.connection named get_session_track_tx_state which returns a list of namedtuples containing information parsed from the data as described in the documentation for SESSION_TRACK_TRANSACTION_STATE using the same C functions and the enum value SESSION_TRACK_TRANSACTION_STATE.

The bare minimum that we need is items 1 and 2, but implementing also 3 through 5 would be more complete.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Start with MySQLdb.constants.CLIENT and the _mysql.connection API, then review the MySQL session-tracking documentation linked in the issue. Implementing the minimum means supporting SESSION_TRACK and get_session_track_gtids; completion for the broader request also includes the three variable, transaction-characteristic, and transaction-state methods with their documented return data.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
mysql, python
Ambito
database
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.