My Project
Public Member Functions | Public Attributes | Protected Member Functions
Load_log_event Class Reference

#include <log_event.h>

Inheritance diagram for Load_log_event:
Log_event Create_file_log_event

List of all members.

Public Member Functions

uint get_query_buffer_length ()
void print_query (bool need_db, const char *cs, char *buf, char **end, char **fn_start, char **fn_end)
void set_fname_outside_temp_buf (const char *afname, uint alen)
int check_fname_outside_temp_buf ()
void print (FILE *file, PRINT_EVENT_INFO *print_event_info)
void print (FILE *file, PRINT_EVENT_INFO *print_event_info, bool commented)
 Load_log_event (const char *buf, uint event_len, const Format_description_log_event *description_event)
Log_event_type get_type_code ()
bool is_valid () const
int get_data_size ()

Public Attributes

ulong thread_id
ulong slave_proxy_id
uint32 table_name_len
uint32 db_len
uint32 fname_len
uint32 num_fields
const char * fields
const uchar * field_lens
uint32 field_block_len
const char * table_name
const char * db
const char * fname
uint32 skip_lines
sql_ex_info sql_ex
bool local_fname
bool is_concurrent

Protected Member Functions

int copy_log_event (const char *buf, ulong event_len, int body_offset, const Format_description_log_event *description_event)

Detailed Description

This log event corresponds to a "LOAD DATA INFILE" SQL query on the following form:

   (1)    USE db;
   (2)    LOAD DATA [CONCURRENT] [LOCAL] INFILE 'file_name'
   (3)    [REPLACE | IGNORE]
   (4)    INTO TABLE 'table_name'
   (5)    [FIELDS
   (6)      [TERMINATED BY 'field_term']
   (7)      [[OPTIONALLY] ENCLOSED BY 'enclosed']
   (8)      [ESCAPED BY 'escaped']
   (9)    ]
  (10)    [LINES
  (11)      [TERMINATED BY 'line_term']
  (12)      [LINES STARTING BY 'line_start']
  (13)    ]
  (14)    [IGNORE skip_lines LINES]
  (15)    (field_1, field_2, ..., field_n)

Binary Format

The Post-Header consists of the following six components.

Post-Header for Load_log_event
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.

skip_lines 4 byte unsigned integer

The number on line (14) above, if present, or 0 if line (14) is left out.

table_name_len 1 byte unsigned integer

The length of 'table_name' on line (4) above.

db_len 1 byte unsigned integer

The length of 'db' on line (1) above.

num_fields 4 byte unsigned integer The number n of fields on line (15) above.

The Body contains the following components.

Body of Load_log_event
Name Format

Description

sql_ex

variable length

Describes the part of the query on lines (3) and (5)–(13) above. More precisely, it stores the five strings (on lines) field_term (6), enclosed (7), escaped (8), line_term (11), and line_start (12); as well as a bitfield indicating the presence of the keywords REPLACE (3), IGNORE (3), and OPTIONALLY (7).

The data is stored in one of two formats, called "old" and "new". The type field of Common-Header determines which of these two formats is used: type LOAD_EVENT means that the old format is used, and type NEW_LOAD_EVENT means that the new format is used. When MySQL writes a Load_log_event, it uses the new format if at least one of the five strings is two or more bytes long. Otherwise (i.e., if all strings are 0 or 1 bytes long), the old format is used.

The new and old format differ in the way the five strings are stored.

  • In the new format, the strings are stored in the order field_term, enclosed, escaped, line_term, line_start. Each string consists of a length (1 byte), followed by a sequence of characters (0-255 bytes). Finally, a boolean combination of the following flags is stored in 1 byte: REPLACE_FLAG==0x4, IGNORE_FLAG==0x8, and OPT_ENCLOSED_FLAG==0x2. If a flag is set, it indicates the presence of the corresponding keyword in the SQL query.

  • In the old format, we know that each string has length 0 or 1. Therefore, only the first byte of each string is stored. The order of the strings is the same as in the new format. These five bytes are followed by the same 1 byte bitfield as in the new format. Finally, a 1 byte bitfield called empty_flags is stored. The low 5 bits of empty_flags indicate which of the five strings have length 0. For each of the following flags that is set, the corresponding string has length 0; for the flags that are not set, the string has length 1: FIELD_TERM_EMPTY==0x1, ENCLOSED_EMPTY==0x2, LINE_TERM_EMPTY==0x4, LINE_START_EMPTY==0x8, ESCAPED_EMPTY==0x10.

Thus, the size of the new format is 6 bytes + the sum of the sizes of the five strings. The size of the old format is always 7 bytes.

field_lens num_fields 1 byte unsigned integers

An array of num_fields integers representing the length of each field in the query. (num_fields is from the Post-Header).

fields num_fields null-terminated strings

An array of num_fields null-terminated strings, each representing a field in the query. (The trailing zero is redundant, since the length are stored in the num_fields array.) The total length of all strings equals to the sum of all field_lens, plus num_fields bytes for all the trailing zeros.

table_name null-terminated string of length table_len+1 bytes

The 'table_name' from the query, as a null-terminated string. (The trailing zero is actually redundant since the table_len is known from Post-Header.)

db null-terminated string of length db_len+1 bytes

The 'db' from the query, as a null-terminated string. (The trailing zero is actually redundant since the db_len is known from Post-Header.)

file_name variable length string without trailing zero, extending to the end of the event (determined by the length field of the Common-Header)

The 'file_name' from the query.

Notes on Previous Versions

This event type is understood by current versions, but only generated by MySQL 3.23 and earlier.


Constructor & Destructor Documentation

Load_log_event::Load_log_event ( const char *  buf,
uint  event_len,
const Format_description_log_event description_event 
)
Note:
The caller must do buf[event_len] = 0 before he starts using the constructed event.

Member Data Documentation

Indicates that this event corresponds to LOAD DATA CONCURRENT,

Note:
Since Load_log_event event coming from the binary log lacks information whether LOAD DATA on master was concurrent or not, this flag is only set to TRUE for an auxiliary Load_log_event object which is used in mysql_load() to re-construct LOAD DATA statement from function parameters, for logging.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines