Documentation
¶
Index ¶
- Constants
- type DBConnection
- type DBStatement
- type EmptyReplicationHandler
- type MySQLConnWrapper
- type MySQLStmtWrapper
- type StmtWithParsedDataContext
- type TC9Proxy
- func (p *TC9Proxy) ConnByRealm(realmID uint32) DBConnection
- func (p *TC9Proxy) HandleFieldList(table string, fieldWildcard string) ([]*mysql.Field, error)
- func (p *TC9Proxy) HandleOtherCommand(cmd byte, data []byte) error
- func (p *TC9Proxy) HandleQuery(query string) (*mysql.Result, error)
- func (p *TC9Proxy) HandleStmtClose(context interface{}) error
- func (p *TC9Proxy) HandleStmtExecute(ctx interface{}, query string, args []interface{}) (*mysql.Result, error)
- func (p *TC9Proxy) HandleStmtPrepare(query string) (int, int, interface{}, error)
- func (p *TC9Proxy) RunOnEveryConn(f func(db DBConnection))
- func (p *TC9Proxy) UseDB(string) error
- type TransactionState
Constants ¶
const ( StartTransaction = "START TRANSACTION" // Query to start a transaction CommitTransaction = "COMMIT" // Query to commit a transaction RollbackTransaction = "ROLLBACK" // Query to rollback a transaction DummyPreparedStmt = "SELECT ? AS no_op" // Dummy query used for no-op statements )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBConnection ¶
type DBConnection interface { Execute(query string, args ...interface{}) (*mysql.Result, error) Prepare(query string) (DBStatement, error) FieldList(table, fieldWildcard string) ([]*mysql.Field, error) }
DBConnection represents a generic database connection.
func NewMySQLConnWrapper ¶
func NewMySQLConnWrapper(conn *client.Conn) DBConnection
NewMySQLConnWrapper creates mysql connection wrapper.
type DBStatement ¶
type DBStatement interface { Execute(args ...interface{}) (*mysql.Result, error) Close() error ParamNum() int ColumnNum() int }
DBStatement represents a prepared statement.
type EmptyReplicationHandler ¶
type EmptyReplicationHandler struct{ TC9Proxy }
EmptyReplicationHandler is a no-op handler for replication commands.
func (*EmptyReplicationHandler) HandleBinlogDump ¶
func (h *EmptyReplicationHandler) HandleBinlogDump(mysql.Position) (*replication.BinlogStreamer, error)
HandleBinlogDump returns an error for unsupported binlog dump.
func (*EmptyReplicationHandler) HandleBinlogDumpGTID ¶
func (h *EmptyReplicationHandler) HandleBinlogDumpGTID(*mysql.MysqlGTIDSet) (*replication.BinlogStreamer, error)
HandleBinlogDumpGTID returns an error for unsupported binlog dump with GTID.
func (*EmptyReplicationHandler) HandleRegisterSlave ¶
func (h *EmptyReplicationHandler) HandleRegisterSlave([]byte) error
HandleRegisterSlave returns an error for unsupported slave registration.
type MySQLConnWrapper ¶
type MySQLConnWrapper struct {
// contains filtered or unexported fields
}
MySQLConnWrapper wraps a real MySQL client connection.
func (*MySQLConnWrapper) Execute ¶
func (c *MySQLConnWrapper) Execute(query string, args ...interface{}) (*mysql.Result, error)
Execute executes a query.
func (*MySQLConnWrapper) FieldList ¶
func (c *MySQLConnWrapper) FieldList(table, fieldWildcard string) ([]*mysql.Field, error)
FieldList retrieves field list metadata.
func (*MySQLConnWrapper) Prepare ¶
func (c *MySQLConnWrapper) Prepare(query string) (DBStatement, error)
Prepare prepares a statement.
type MySQLStmtWrapper ¶
type MySQLStmtWrapper struct {
// contains filtered or unexported fields
}
MySQLStmtWrapper wraps a real MySQL client statement.
func (*MySQLStmtWrapper) Close ¶
func (s *MySQLStmtWrapper) Close() error
Close closes the statement.
func (*MySQLStmtWrapper) ColumnNum ¶
func (s *MySQLStmtWrapper) ColumnNum() int
ColumnNum returns the number of columns.
func (*MySQLStmtWrapper) Execute ¶
func (s *MySQLStmtWrapper) Execute(args ...interface{}) (*mysql.Result, error)
Execute executes a prepared statement.
func (*MySQLStmtWrapper) ParamNum ¶
func (s *MySQLStmtWrapper) ParamNum() int
ParamNum returns the number of parameters.
type StmtWithParsedDataContext ¶
type StmtWithParsedDataContext struct { Stmts map[uint32]DBStatement // Mapped by realm ID GuidFinder *sqlparser.CharGUIDFinder // Helper to extract GUIDs from queries IsDummy bool // Flag indicating if it's a dummy statement }
StmtWithParsedDataContext holds data related to prepared statements and GUIDs for each statement context.
type TC9Proxy ¶
type TC9Proxy struct {
// contains filtered or unexported fields
}
TC9Proxy represents the proxy for handling database connections and transaction state.
func NewTC9Proxy ¶
func NewTC9Proxy(clientID int, connections map[uint32]DBConnection, parser *parser.Parser) *TC9Proxy
NewTC9Proxy creates a new instance of TC9Proxy.
func (*TC9Proxy) ConnByRealm ¶
func (p *TC9Proxy) ConnByRealm(realmID uint32) DBConnection
ConnByRealm retrieves the connection for a given realm ID, or a fallback connection.
func (*TC9Proxy) HandleFieldList ¶
HandleFieldList retrieves a list of fields for a given table.
func (*TC9Proxy) HandleOtherCommand ¶
HandleOtherCommand processes unsupported commands and returns an error.
func (*TC9Proxy) HandleQuery ¶
HandleQuery processes a query, handles transactions, and executes the query.
func (*TC9Proxy) HandleStmtClose ¶
HandleStmtClose closes a prepared statement.
func (*TC9Proxy) HandleStmtExecute ¶
func (p *TC9Proxy) HandleStmtExecute(ctx interface{}, query string, args []interface{}) (*mysql.Result, error)
HandleStmtExecute executes a prepared statement with given arguments.
func (*TC9Proxy) HandleStmtPrepare ¶
HandleStmtPrepare prepares a statement by parsing the query and extracting GUIDs.
func (*TC9Proxy) RunOnEveryConn ¶
func (p *TC9Proxy) RunOnEveryConn(f func(db DBConnection))
RunOnEveryConn runs a function on every database connection.
type TransactionState ¶
type TransactionState uint8
TransactionState represents the state of a transaction.
const ( TransactionNone TransactionState = iota // No transaction in progress TransactionRequested // Transaction has been requested (but not started) TransactionInProgress // Transaction is in progress )