WL#5370: Keep forward-compatibility when changing 'CREATE TABLE IF NOT EXISTS ... SELECT' behaviour

Affects: Server-5.5   —   Status: Complete

Change behavior of 'CREATE TABLE IF NOT EXISTS  SELECT ...'
statement on MySQL 5.5 when the destination table exists.
 
The original behavior:
  If the table exists, CREATE TABLE IF NOT EXISTS ... SELECT
  is converted to
  INSERT ... SELECT, i.e. the result of 'SELECT ...' is inserted
  into the existing table.
Behavior in 5.5+:
  If the table exists, do nothing.

Example
========

mysql> create table t1 (a varchar(10));
Query OK, 0 rows affected (0.01 sec)

-- Current behaviour
-- ---------------

mysql> create table if not exists t1 select "hello" as a;
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1  Duplicates: 0  Warnings: 1

mysql> show warnings;
+-------+------+---------------------------+
| Level | Code | Message                   |
+-------+------+---------------------------+
| Note  | 1050 | Table 't1' already exists | 
+-------+------+---------------------------+
1 row in set (0.00 sec)

mysql> select * from  t1;
+-------+
| a     |
+-------+
| hello | 
+-------+
1 row in set (0.00 sec)

-- New behaviour
-- -----------

mysql> create table if not exists t1 select "hello" as a;
Query OK, 0 row affected, 1 warning (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 1

mysql> show warnings;
+-------+------+---------------------------+
| Level | Code | Message                   |
+-------+------+---------------------------+
| Note  | 1050 | Table 't1' already exists | 
+-------+------+---------------------------+
1 row in set (0.00 sec)

mysql> select * from  t1;
Empty set (0.00 sec)

This change in implementation of CREATE TABLE ... SELECT introduces
a potential failure of statement based replication when a 5.5 
instance is set as a slave for a pre-5.5 master.
Indeed, rows inserted on the master will not appear in the table
on the slave.
To address the potential statement based replication failure,
replication of CREATE TABLE ... SELECT in 5.1 will be changed
to be forward-compatible.