Download this Manual
EPUB - 0.8Mb


MySQL Internals Manual  /  ...  /  Rules for CREATE [TEMPORARY] TABLE...SELECT

18.4.3.4 Rules for CREATE [TEMPORARY] TABLE...SELECT

First, unsafeness is determined as above (R-unsafe-transaction). Then the logging format is decided. Then the following rules apply.

(R-log-create-select-statement-format) If logging in statement format (that is, one of the following holds: (1) @@session.binlog_format=STATEMENT; (2) @@session.binlog_format=MIXED and statement is safe):

  1. If there is an error, do not write anything.

  2. If there is no error and the TEMPORARY keyword is used, write the entire CREATE...SELECT statement to the TC.

  3. If there is no error and the TEMPORARY keyword is not used, write the entire CREATE...SELECT directly to the binlog.

(R-log-create-select-row-format) If logging in row format (that is, one of the following holds: (1) @@session.binlog_format=ROW; (2) @@session.binlog_format=MIXED and statement is unsafe):

  1. If the TEMPORARY keyword is used, do not write anything.

  2. If the TEMPORARY keyword is not used, write CREATE TABLE (without select) + BEGIN + row events + COMMIT to the TC. If there is an error, clear the TC; otherwise flush the TC to the binlog at the end of the statement and then clear the TC. (Note: currently Bug#47899 breaks this rule)

Note: this breaks D-rpl-correct rule, because the slave will have an intermediate state that never existed on the master (namely, a state where the new table exists and is empty).


User Comments
Sign Up Login You must be logged in to post a comment.