public class QueryLogEvent extends LogEvent
| Name | Format | Description |
|---|---|---|
| slave_proxy_id | 4 byte unsigned integer | An integer identifying the client thread that issued the query. The id is unique per server. (Note, however, that two threads on different servers may have the same slave_proxy_id.) This is used when a client thread creates a temporary table local to the client. The slave_proxy_id is used to distinguish temporary tables that belong to different clients. |
| exec_time | 4 byte unsigned integer | The time from when the query started to when it was logged in the binlog, in seconds. |
| db_len | 1 byte integer | The length of the name of the currently selected database. |
| error_code | 2 byte unsigned integer | Error code generated by the master. If the master fails, the slave will fail with the same error code, except for the error codes ER_DB_CREATE_EXISTS == 1007 and ER_DB_DROP_EXISTS == 1008. |
| status_vars_len | 2 byte unsigned integer | The length of the status_vars block of the Body, in bytes. See query_log_event_status_vars "below". |
| Name | Format | Description |
|---|---|---|
| query_log_event_status_vars status_vars | status_vars_len bytes | Zero or more status variables. Each status variable consists of one byte identifying the variable stored, followed by the value of the variable. The possible variables are listed separately in the table Table_query_log_event_status_vars "below". MySQL always writes events in the order defined below; however, it is capable of reading them in any order. |
| db | db_len+1 | The currently selected database, as a null-terminated string. (The trailing zero is redundant since the length is already known; it is db_len from Post-Header.) |
| query | variable length string without trailing zero, extending to the end of the event (determined by the length field of the Common-Header) | The SQL query. |
| Status variable | 1 byte identifier | Format | Description |
|---|---|---|---|
| flags2 | Q_FLAGS2_CODE == 0 | 4 byte bitfield | The flags in thd-options, binary AND-ed with OPTIONS_WRITTEN_TO_BIN_LOG. The thd-options bitfield contains options for "SELECT". OPTIONS_WRITTEN identifies those options that need to be written to the binlog (not all do). Specifically, OPTIONS_WRITTEN_TO_BIN_LOG equals (OPTION_AUTO_IS_NULL | OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NOT_AUTOCOMMIT), or 0x0c084000 in hex. These flags correspond to the SQL variables SQL_AUTO_IS_NULL, FOREIGN_KEY_CHECKS, UNIQUE_CHECKS, and AUTOCOMMIT, documented in the "SET Syntax" section of the MySQL Manual. This field is always written to the binlog in version ge 5.0, and never written in version lt 5.0. |
| sql_mode | Q_SQL_MODE_CODE == 1 | 8 byte bitfield | The sql_mode variable. See the section "SQL Modes" in the MySQL manual,
and see mysql_priv.h for a list of the possible flags. Currently
(2007-10-04), the following flags are available:
MODE_REAL_AS_FLOAT==0x1
MODE_PIPES_AS_CONCAT==0x2
MODE_ANSI_QUOTES==0x4
MODE_IGNORE_SPACE==0x8
MODE_NOT_USED==0x10
MODE_ONLY_FULL_GROUP_BY==0x20
MODE_NO_UNSIGNED_SUBTRACTION==0x40
MODE_NO_DIR_IN_CREATE==0x80
MODE_POSTGRESQL==0x100
MODE_ORACLE==0x200
MODE_MSSQL==0x400
MODE_DB2==0x800
MODE_MAXDB==0x1000
MODE_NO_KEY_OPTIONS==0x2000
MODE_NO_TABLE_OPTIONS==0x4000
MODE_NO_FIELD_OPTIONS==0x8000
MODE_MYSQL323==0x10000
MODE_MYSQL323==0x20000
MODE_MYSQL40==0x40000
MODE_ANSI==0x80000
MODE_NO_AUTO_VALUE_ON_ZERO==0x100000
MODE_NO_BACKSLASH_ESCAPES==0x200000
MODE_STRICT_TRANS_TABLES==0x400000
MODE_STRICT_ALL_TABLES==0x800000
MODE_NO_ZERO_IN_DATE==0x1000000
MODE_NO_ZERO_DATE==0x2000000
MODE_INVALID_DATES==0x4000000
MODE_ERROR_FOR_DIVISION_BY_ZERO==0x8000000
MODE_TRADITIONAL==0x10000000
MODE_NO_AUTO_CREATE_USER==0x20000000
MODE_HIGH_NOT_PRECEDENCE==0x40000000
MODE_PAD_CHAR_TO_FULL_LENGTH==0x80000000
All these flags are replicated from the server. However, all flags except
MODE_NO_DIR_IN_CREATE are honored by the slave; the slave always preserves
its old value of MODE_NO_DIR_IN_CREATE. For a rationale, see comment in
Query_log_event::do_apply_event in log_event.cc. This field is always written
to the binlog. |
| catalog | Q_CATALOG_NZ_CODE == 6 | Variable-length string: the length in bytes (1 byte) followed by the characters (at most 255 bytes) | Stores the client's current catalog. Every database belongs to a catalog, the same way that every table belongs to a database. Currently, there is only one catalog, "std". This field is written if the length of the catalog is gt 0; otherwise it is not written. |
| auto_increment | Q_AUTO_INCREMENT == 3 | two 2 byte unsigned integers, totally 2+2=4 bytes | The two variables auto_increment_increment and auto_increment_offset, in that order. For more information, see "System variables" in the MySQL manual. This field is written if auto_increment gt 1. Otherwise, it is not written. |
| charset | Q_CHARSET_CODE == 4 | three 2 byte unsigned integers, totally 2+2+2=6 bytes | The three variables character_set_client, collation_connection, and collation_server, in that order. character_set_client is a code identifying the character set and collation used by the client to encode the query. collation_connection identifies the character set and collation that the master converts the query to when it receives it; this is useful when comparing literal strings. collation_server is the default character set and collation used when a new database is created. See also "Connection Character Sets and Collations" in the MySQL 5.1 manual. All three variables are codes identifying a (character set, collation) pair. To see which codes map to which pairs, run the query "SELECT id, character_set_name, collation_name FROM COLLATIONS". Cf. Q_CHARSET_DATABASE_CODE below. This field is always written. |
| time_zone | Q_TIME_ZONE_CODE == 5 | Variable-length string: the length in bytes (1 byte) followed by the characters (at most 255 bytes). | The time_zone of the master. See also "System Variables" and "MySQL Server Time Zone Support" in the MySQL manual. This field is written if the length of the time zone string is gt 0; otherwise, it is not written. |
| lc_time_names_number | Q_LC_TIME_NAMES_CODE == 7 | 2 byte integer | A code identifying a table of month and day names. The mapping from codes to languages is defined in sql_locale.cc. This field is written if it is not 0, i.e., if the locale is not en_US. |
| charset_database_number | Q_CHARSET_DATABASE_CODE == 8 | 2 byte integer | The value of the collation_database system variable (in the source code stored in thd-variables.collation_database), which holds the code for a (character set, collation) pair as described above (see Q_CHARSET_CODE). collation_database was used in old versions (???WHEN). Its value was loaded when issuing a "use db" query and could be changed by issuing a "SET collation_database=xxx" query. It used to affect the "LOAD DATA INFILE" and "CREATE TABLE" commands. In newer versions, "CREATE TABLE" has been changed to take the character set from the database of the created table, rather than the character set of the current database. This makes a difference when creating a table in another database than the current one. "LOAD DATA INFILE" has not yet changed to do this, but there are plans to eventually do it, and to make collation_database read-only. This field is written if it is not 0. |
| table_map_for_update | Q_TABLE_MAP_FOR_UPDATE_CODE == 9 | 8 byte integer | The value of the table map that is to be updated by the multi-table update query statement. Every bit of this variable represents a table, and is set to 1 if the corresponding table is to be updated by this statement. The value of this variable is set when executing a multi-table update statement and used by slave to apply filter rules without opening all the tables on slave. This is required because some tables may not exist on slave because of the filter rules. |
| 限定符和类型 | 字段和说明 |
|---|---|
protected String |
catalog |
protected String |
dbname |
static int |
MAX_DBS_IN_EVENT_MTS
The maximum number of updated databases that a status of Query-log-event
can carry.
|
static int |
MAX_SIZE_LOG_EVENT_STATUS
Max number of possible extra bytes in a replication event compared to a
packet (i.e. a query) sent from client to master; First, an auxiliary
log_event status vars estimation:
|
static int |
NAME_CHAR_LEN |
static int |
NAME_LEN |
static int |
OPTION_AUTO_IS_NULL |
static int |
OPTION_NO_FOREIGN_KEY_CHECKS |
static int |
OPTION_NOT_AUTOCOMMIT |
static int |
OPTION_RELAXED_UNIQUE_CHECKS |
static int |
OVER_MAX_DBS_IN_EVENT_MTS
When the actual number of databases exceeds MAX_DBS_IN_EVENT_MTS the
value of OVER_MAX_DBS_IN_EVENT_MTS is is put into the mts_accessed_dbs
status.
|
static int |
Q_AUTO_INCREMENT |
static int |
Q_CATALOG_CODE
Q_CATALOG_CODE is catalog with end zero stored; it is used only by MySQL
5.0.x where 0 le x le 3.
|
static int |
Q_CATALOG_NZ_CODE
Q_CATALOG_NZ_CODE is catalog withOUT end zero stored; it is used by MySQL
5.0.x where x ge 4.
|
static int |
Q_CHARSET_CODE |
static int |
Q_CHARSET_DATABASE_CODE |
static int |
Q_DATA_OFFSET |
static int |
Q_DB_LEN_OFFSET |
static int |
Q_ERR_CODE_OFFSET |
static int |
Q_EXEC_TIME_OFFSET |
static int |
Q_FLAGS2_CODE |
static int |
Q_HRNOW
FROM MariaDB 5.5.34
|
static int |
Q_INVOKER |
static int |
Q_LC_TIME_NAMES_CODE |
static int |
Q_MASTER_DATA_WRITTEN_CODE |
static int |
Q_MICROSECONDS |
static int |
Q_SQL_MODE_CODE |
static int |
Q_STATUS_VARS_LEN_OFFSET |
static int |
Q_TABLE_MAP_FOR_UPDATE_CODE |
static int |
Q_THREAD_ID_OFFSET |
static int |
Q_TIME_ZONE_CODE |
static int |
Q_UPDATED_DB_NAMES
Q_UPDATED_DB_NAMES status variable collects of the updated databases
total number and their names to be propagated to the slave in order to
facilitate the parallel applying of the Query events.
|
protected String |
query |
static int |
SYSTEM_CHARSET_MBMAXLEN |
ANNOTATE_ROWS_EVENT, ANONYMOUS_GTID_LOG_EVENT, APPEND_BLOCK_EVENT, BEGIN_LOAD_QUERY_EVENT, BINLOG_CHECKPOINT_EVENT, BINLOG_CHECKSUM_ALG_CRC32, BINLOG_CHECKSUM_ALG_DESC_LEN, BINLOG_CHECKSUM_ALG_ENUM_END, BINLOG_CHECKSUM_ALG_OFF, BINLOG_CHECKSUM_ALG_UNDEF, BINLOG_CHECKSUM_LEN, BINLOG_VERSION, CHECKSUM_CRC32_SIGNATURE_LEN, CREATE_FILE_EVENT, DELETE_FILE_EVENT, DELETE_ROWS_EVENT, DELETE_ROWS_EVENT_V1, ENUM_END_EVENT, EVENT_LEN_OFFSET, EVENT_TYPE_OFFSET, EXEC_LOAD_EVENT, EXECUTE_LOAD_QUERY_EVENT, EXTRA_ROW_INFO_FORMAT_OFFSET, EXTRA_ROW_INFO_HDR_BYTES, EXTRA_ROW_INFO_LEN_OFFSET, EXTRA_ROW_INFO_MAX_PAYLOAD, FLAGS_OFFSET, FORMAT_DESCRIPTION_EVENT, GTID_EVENT, GTID_LIST_EVENT, GTID_LOG_EVENT, header, HEARTBEAT_LOG_EVENT, IGNORABLE_LOG_EVENT, INCIDENT_EVENT, INTVAR_EVENT, LOAD_EVENT, LOG_EVENT_IGNORABLE_F, LOG_POS_OFFSET, logger, MARIA_EVENTS_BEGIN, MARIA_SLAVE_CAPABILITY_ANNOTATE, MARIA_SLAVE_CAPABILITY_BINLOG_CHECKPOINT, MARIA_SLAVE_CAPABILITY_GTID, MARIA_SLAVE_CAPABILITY_MINE, MARIA_SLAVE_CAPABILITY_TOLERATE_HOLES, MARIA_SLAVE_CAPABILITY_UNKNOWN, MYSQL_EVENTS_END, MYSQL_TYPE_BIT, MYSQL_TYPE_BLOB, MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_DATETIME2, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_ENUM, MYSQL_TYPE_FLOAT, MYSQL_TYPE_GEOMETRY, MYSQL_TYPE_INT24, MYSQL_TYPE_JSON, MYSQL_TYPE_LONG, MYSQL_TYPE_LONG_BLOB, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_MEDIUM_BLOB, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_NULL, MYSQL_TYPE_SET, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TIME, MYSQL_TYPE_TIME2, MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_TIMESTAMP2, MYSQL_TYPE_TINY, MYSQL_TYPE_TINY_BLOB, MYSQL_TYPE_VAR_STRING, MYSQL_TYPE_VARCHAR, MYSQL_TYPE_YEAR, NEW_LOAD_EVENT, PRE_GA_DELETE_ROWS_EVENT, PRE_GA_UPDATE_ROWS_EVENT, PRE_GA_WRITE_ROWS_EVENT, PREVIOUS_GTIDS_LOG_EVENT, QUERY_EVENT, QUERY_HEADER_LEN, QUERY_HEADER_MINIMAL_LEN, RAND_EVENT, ROTATE_EVENT, ROWS_QUERY_LOG_EVENT, SERVER_ID_OFFSET, SERVER_VERSION, SLAVE_EVENT, START_EVENT_V3, STOP_EVENT, TABLE_MAP_EVENT, UNKNOWN_EVENT, UPDATE_ROWS_EVENT, UPDATE_ROWS_EVENT_V1, USER_VAR_EVENT, WRITE_ROWS_EVENT, WRITE_ROWS_EVENT_V1, XID_EVENT| 构造器和说明 |
|---|
QueryLogEvent(LogHeader header,
LogBuffer buffer,
FormatDescriptionLogEvent descriptionEvent) |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
getAutoIncrementIncrement() |
long |
getAutoIncrementOffset() |
String |
getCatalog() |
String |
getCharsetName() |
int |
getClientCharset()
Returns the charsetID value.
|
int |
getClientCollation()
Returns the clientCollationId value.
|
String |
getDbName() |
int |
getErrorCode() |
long |
getExecTime()
The number of seconds the query took to run on the master.
|
long |
getFlags2() |
String |
getHost() |
String |
getQuery() |
int |
getServerCollation()
Returns the serverCollationId value.
|
long |
getSessionId() |
long |
getSqlMode()
Returns the sql_mode value.
|
String |
getTimezone() |
String |
getUser() |
boolean |
isAutocommit()
Returns the OPTION_NOT_AUTOCOMMIT flag.
|
boolean |
isAutoIsNull()
Returns the OPTION_AUTO_IS_NULL flag.
|
boolean |
isForeignKeyChecks()
Returns the OPTION_NO_FOREIGN_KEY_CHECKS flag.
|
boolean |
isUniqueChecks()
Returns the OPTION_NO_FOREIGN_KEY_CHECKS flag.
|
getEventLen, getHeader, getLogPos, getServerId, getTypeName, getWhenpublic static final int MAX_DBS_IN_EVENT_MTS
public static final int OVER_MAX_DBS_IN_EVENT_MTS
public static final int SYSTEM_CHARSET_MBMAXLEN
public static final int NAME_CHAR_LEN
public static final int NAME_LEN
public static final int MAX_SIZE_LOG_EVENT_STATUS
protected String query
protected String catalog
protected final String dbname
public static final int Q_THREAD_ID_OFFSET
public static final int Q_EXEC_TIME_OFFSET
public static final int Q_DB_LEN_OFFSET
public static final int Q_ERR_CODE_OFFSET
public static final int Q_STATUS_VARS_LEN_OFFSET
public static final int Q_DATA_OFFSET
public static final int Q_FLAGS2_CODE
public static final int Q_SQL_MODE_CODE
public static final int Q_CATALOG_CODE
public static final int Q_AUTO_INCREMENT
public static final int Q_CHARSET_CODE
public static final int Q_TIME_ZONE_CODE
public static final int Q_CATALOG_NZ_CODE
public static final int Q_LC_TIME_NAMES_CODE
public static final int Q_CHARSET_DATABASE_CODE
public static final int Q_TABLE_MAP_FOR_UPDATE_CODE
public static final int Q_MASTER_DATA_WRITTEN_CODE
public static final int Q_INVOKER
public static final int Q_UPDATED_DB_NAMES
public static final int Q_MICROSECONDS
public static final int Q_HRNOW
public static final int OPTION_AUTO_IS_NULL
public static final int OPTION_NOT_AUTOCOMMIT
public static final int OPTION_NO_FOREIGN_KEY_CHECKS
public static final int OPTION_RELAXED_UNIQUE_CHECKS
public QueryLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent) throws IOException
IOExceptionpublic final String getUser()
public final String getHost()
public final String getQuery()
public final String getCatalog()
public final String getDbName()
public final long getExecTime()
public final int getErrorCode()
public final long getSessionId()
public final long getAutoIncrementIncrement()
public final long getAutoIncrementOffset()
public final String getCharsetName()
public final String getTimezone()
public final int getClientCharset()
public final int getClientCollation()
public final int getServerCollation()
public final long getSqlMode()
The sql_mode variable. See the section "SQL Modes" in the MySQL manual, and see mysql_priv.h for a list of the possible flags. Currently (2007-10-04), the following flags are available:
public final long getFlags2()
public final boolean isAutoIsNull()
public final boolean isForeignKeyChecks()
public final boolean isAutocommit()
public final boolean isUniqueChecks()
Copyright © 2017. All rights reserved.