Documentation
¶
Overview ¶
Package mysql is the MariaDB and MySQL engine, on the go-mysql-org client (chosen because it reports each result column's origin schema, table and column). It registers itself as "mariadb" and "mysql".
A session holds two connections: the main one, which runs everything, and a control one, opened at the same time, whose only job is to send KILL QUERY for the main one when a context is cancelled (the driver's Execute takes no context). Keeping it open means the secret is not needed again after Connect.
Tier read sets SET SESSION TRANSACTION READ ONLY and runs every statement inside START TRANSACTION READ ONLY, so a write fails on the server even if it got past the classifier. The statement timeout is enforced by the server (max_statement_time on MariaDB, max_execution_time for SELECT on MySQL) and, as a backstop, by a client deadline that kills the query.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DriverOptions ¶
DriverOptions are the client options of every connection locksql opens: no multi-statements and no LOCAL INFILE. Exported so that integration tests can check what the driver itself accepts.
func ParsePlan ¶
ParsePlan normalises the output of EXPLAIN FORMAT=JSON, in either the MariaDB or the MySQL 8 shape, into an engine.Plan whose Raw is the server's plan, unchanged but for MariaDB's \' escapes (see validJSON).
Both shapes nest a "query_block" holding the tables of one SELECT, either as "table" or as an ordered "nested_loop" list, wrapped in operation objects (MariaDB: filesort, temporary_table, read_sorted_file, block-nl-join; MySQL: ordering_operation, grouping_operation, duplicates_removal with using_filesort/using_temporary_table flags). Subqueries hang off "*subqueries" lists, derived tables off "materialized" (MariaDB) or "materialized_from_subquery" (MySQL), and UNION arms off "union_result.query_specifications".
Rows: MySQL's rows_examined_per_scan, MariaDB's rows. Correlated: MySQL's "dependent": true, MariaDB's expression_cache / subquery_cache wrapper (the cache only exists for dependent subqueries).
Types ¶
type Engine ¶
type Engine struct{}
Engine opens MariaDB and MySQL sessions.