List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:October 15 2010 10:13am
Subject:bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3418) Bug#42415
View as plain text  
#At file:///media/sdb2/hezx/work/mysql/bzr/b42415/5.1-bugteam/ based on revid:ramil@stripped

 3418 He Zhenxing	2010-10-15
      Bug #42415 UPDATE/DELETE with LIMIT clause unsafe for SBL even with ORDER BY PK clause
      
      Before the patch, when using STATEMENT mode, unsafe warnings were
      issued for all DML statements (INSERT...SELECT, UPDATE, DELETE)
      with LIMIT clause due to the possobility of non-deterministic result
      order, even when they also had a ORDER BY primary_key clause. In
      which case the order would be deterministic.
      
      This patch fixed the problem by checking the ORDER BY clause of the
      statement, and do not issue the warning if the result is ordered by
      the primary key (thus deterministic).
      ******
      BUG#42415 UPDATE/DELETE with LIMIT clause unsafe for SBL even with ORDER BY PK clause
      
      UPDATE/DELETE/INSERT..SELECT with LIMIT clause were considered unsafe
      unconditionally, even if there is an ORDER BY PK or WHERE condition
      that can guarantee the result to be deterministic.
      
      The problem is fixed by implementing a algorithm to do more elaborate
      analyzed on the nature of the query to determine whether the query
      will cause uncertainty for replication or not.
      
      The statement will not be considered unsafe for following cases:
       - single table UPDATE/DELETE/INSERT..SELECT with ORDER BY
         <non null unique key>
       - single table UPDATE/DELETE/INSERT..SELECT with WHERE clause
         that include <non null unique key> = <const value>, if it is
         a multi-part key, then it must be <keypart1>=<const1> AND
         <keypart2>=<const2> ..., and this condition is ANDed with
         other conditions if there is any.
       - single table INSERT..SELECT with WHERE clause
         that include some parts of the non null unique key compare to
         const values, and the ORDER BY clause includes all the other
         key pars of the same non null unique key. for example (a,b) is
         a non null unique key, then WHERE a=<const> ORDER b will make
         the query result deterministic.
       - for INSERT..SELECT ... JOIN ..., the join condition (ON,
         USING, or WHERE) must include equations between columns of
         non null unique key of tables from both side of the join.
         For example t1 JOIN t2 USING (a,b), if (a,b) is not a non null
         unique key for both t1 and t2, then the result will be non-
         deterministic. otherwise the result can be deterministic with
         appropirate WHERE/ORDER clauses, and in this case, the same
         rule for single table above applys. But there is a difference
         for INNER JOIN with OUTER JOIN, for OUTER JOIN, only one table
         of the two JOIN tables will be used when checking the WHERE/ORDER
         conditions, it's the left table for LEFT JOIN and the right one
         for RIGHT JOIN when checking the keys. On the other hand, for
         INNER JOIN, keys from both tables can be used when checking
         the conditions. For example:
           INSERT..SELECT * FROM t1 INNER JOIN t2 USING(pk) ORDER BY nnuk LIMIT 1;
         This can be safe if nnuk is a non null unique key of either
         t1 or t2. But if we change the INNER JOIN to LEFT JOIN or
         RIGHT JOIN, then nnuk must be a non null unique key key of
         t1 (LEFT JOIN) or t2 (RIGHT JOIN) respectively.
       - If JOIN are nested, the will be handled recursively from inner
         outside.

    added:
      mysql-test/suite/binlog/r/binlog_unsafe_limit.result
    modified:
      mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
      mysql-test/suite/binlog/r/binlog_unsafe.result
      sql/sql_delete.cc
      sql/sql_insert.cc
      sql/sql_select.cc
      sql/sql_select.h
      sql/sql_update.cc
=== modified file 'mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result	2009-07-31 13:00:35 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result	2010-10-15 10:12:56 +0000
@@ -3,11 +3,7 @@ DROP TABLE IF EXISTS t1;
 CREATE TABLE t1 (a int, b int, primary key (a));
 INSERT INTO t1 VALUES (1,2), (2,3);
 UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
-Warnings:
-Note	1592	Statement may not be safe to log in statement format.
 UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
-Warnings:
-Note	1592	Statement may not be safe to log in statement format.
 DROP TABLE t1;
 ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
 SET SQL_LOG_BIN= 0;

=== modified file 'mysql-test/suite/binlog/r/binlog_unsafe.result'
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result	2010-01-13 09:00:03 +0000
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result	2010-10-15 10:12:56 +0000
@@ -412,4 +412,53 @@ a
 13:46:40
 1970-01-12 13:46:40
 DROP TABLE t1;
+DROP TABLE IF EXISTS t1,t2,t3,t4;
+Warnings:
+Note	1051	Unknown table 't1'
+Note	1051	Unknown table 't2'
+Note	1051	Unknown table 't3'
+Note	1051	Unknown table 't4'
+CREATE TABLE t1 (a INT PRIMARY KEY);
+CREATE TABLE t2 (a INT);
+CREATE TABLE t3 (a INT);
+CREATE TABLE t4 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t2 VALUES (1),(2),(3);
+#
+# Unsafe statements
+#
+UPDATE t1 SET a = a+10 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+UPDATE t2 SET a = a+10 ORDER BY a LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+INSERT INTO t3 SELECT * FROM t1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+INSERT INTO t4 SELECT * FROM t2 ORDER BY a LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+INSERT INTO t4 SELECT t1.a FROM t2,t1 ORDER BY t1.a LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+INSERT INTO t4 SELECT t2.a FROM t1,t2 ORDER BY t2.a LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+DELETE FROM t1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+DELETE FROM t2 ORDER BY a LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+#
+# Safe statements
+#
+UPDATE t1 SET a = a+10 ORDER BY a LIMIT 1;
+INSERT INTO t3 SELECT * FROM t1 ORDER BY a LIMIT 1;
+DELETE FROM t1 ORDER BY a LIMIT 1;
+UPDATE t2 SET a = a+10 LIMIT 0;
+INSERT INTO t4 SELECT * FROM t2 LIMIT 0;
+DELETE FROM t2 LIMIT 0;
+DROP TABLE t1, t2, t3, t4;
 "End of tests"

=== added file 'mysql-test/suite/binlog/r/binlog_unsafe_limit.result'
--- a/mysql-test/suite/binlog/r/binlog_unsafe_limit.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_unsafe_limit.result	2010-10-15 10:12:56 +0000
@@ -0,0 +1,1246 @@
+CREATE TABLE t (nokey INT, pk INT PRIMARY KEY, nnuk INT NOT NULL UNIQUE KEY, nuk INT UNIQUE KEY, nnuk1 INT NOT NULL, nnuk2 INT NOT NULL, UNIQUE KEY(nnuk1, nnuk2));
+CREATE TABLE t1 LIKE t;
+CREATE TABLE t2 LIKE t;
+CREATE TABLE t3 LIKE t;
+CREATE TABLE t4 LIKE t;
+CREATE TABLE queries (query VARCHAR(1024) NOT NULL);
+CREATE TABLE result_queries (id INT AUTO_INCREMENT PRIMARY KEY, query VARCHAR(1024) NOT NULL);
+CREATE TABLE limits (`limit` VARCHAR(256) NOT NULL);
+INSERT INTO queries(query) VALUES
+('UPDATE t1 SET nokey = nokey + 10 [LIMIT_1]'),
+('UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 [LIMIT_1]'),
+('UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   [LIMIT_1]'),
+('UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  [LIMIT_1]'),
+('UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    [LIMIT_1]'),
+('DELETE FROM t1 [LIMIT_1]'),
+('DELETE FROM t1 WHERE nokey=1 [LIMIT_1]'),
+('DELETE FROM t1 WHERE nuk=1   [LIMIT_1]'),
+('DELETE FROM t1 WHERE nnuk=1  [LIMIT_1]'),
+('DELETE FROM t1 WHERE pk=1    [LIMIT_1]'),
+('REPLACE INTO t SELECT * FROM t1 [LIMIT_1]'),
+('REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 [LIMIT_1]'),
+('REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   [LIMIT_1]'),
+('REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  [LIMIT_1]'),
+('REPLACE INTO t SELECT * FROM t1 WHERE pk=1    [LIMIT_1]'),
+('INSERT INTO t SELECT * FROM t1 [LIMIT_1]'),
+('INSERT INTO t SELECT * FROM t1 WHERE nokey=1 [LIMIT_1]'),
+('INSERT INTO t SELECT * FROM t1 WHERE nuk=1   [LIMIT_1]'),
+('INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  [LIMIT_1]'),
+('INSERT INTO t SELECT * FROM t1 WHERE pk=1    [LIMIT_1]'),
+('INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) [LIMIT_1]'),
+('INSERT INTO t (SELECT * FROM t1 [LIMIT_1]) UNION (SELECT * FROM t2)'),
+('INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 [LIMIT_1])'),
+('INSERT INTO t (SELECT * FROM t1 [LIMIT_1]) UNION (SELECT * FROM t2 [LIMIT_2])'),
+('INSERT INTO t SELECT * FROM (SELECT * FROM t1 [LIMIT_1]) AS subselect [LIMIT_2]'),
+('INSERT INTO t SELECT t1.* FROM t1, t2 [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk [LIMIT_1]'),
+('INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk [LIMIT_1]');
+INSERT INTO limits (`limit`) VALUES
+('LIMIT 0'),
+('LIMIT 1'),
+('ORDER BY nokey LIMIT 1'),
+('ORDER BY nuk LIMIT 1'),
+('ORDER BY nnuk1 LIMIT 1'),
+('ORDER BY nnuk LIMIT 1'),
+('ORDER BY pk LIMIT 1'),
+('ORDER BY nnuk1, nnuk2 LIMIT 1'),
+('ORDER BY nnuk1, nnuk2, nokey LIMIT 1'),
+('ORDER BY nnuk1, nokey, nnuk2 LIMIT 1');
+CREATE PROCEDURE gen_queries()
+BEGIN
+DECLARE done INT DEFAULT 0;
+DECLARE q VARCHAR(1024);
+DECLARE limit1, limit2 VARCHAR(256);
+DECLARE qcur CURSOR FOR SELECT * FROM queries;
+DECLARE lcur1 CURSOR FOR SELECT * FROM limits;
+DECLARE lcur2 CURSOR FOR SELECT * FROM limits;
+DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
+OPEN qcur;
+FETCH qcur INTO q;
+WHILE done <> 1 DO
+OPEN lcur1;
+FETCH lcur1 INTO limit1;
+WHILE done <> 1 DO
+IF LOCATE('[LIMIT_2]', q) > 0 THEN
+OPEN lcur2;
+FETCH lcur2 INTO limit2;
+WHILE done <> 1 DO
+SELECT REPLACE(REPLACE(q, '[LIMIT_1]', limit1), '[LIMIT_2]', limit2) INTO @query;
+FETCH lcur2 INTO limit2;
+END WHILE;
+CLOSE lcur2;
+SET done = 0;
+ELSE
+SELECT REPLACE(q, '[LIMIT_1]', limit1) INTO @query;
+END IF;
+INSERT INTO result_queries set query=@query;
+FETCH lcur1 INTO limit1;
+END WHILE;
+CLOSE lcur1;
+SET done = 0;
+FETCH qcur INTO q;
+END WHILE;
+CLOSE qcur;
+END|
+call gen_queries();
+UPDATE t1 SET nokey = nokey + 10 LIMIT 0;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 LIMIT 0;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nokey=1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   LIMIT 0;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nuk=1   ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  LIMIT 0;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE nnuk=1  ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    LIMIT 0;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+UPDATE t1 SET nokey = nokey + 10 WHERE pk=1    ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 LIMIT 0;
+ROWS in table t: 2
+DELETE FROM t1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 LIMIT 0;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nokey=1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   LIMIT 0;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nuk=1   ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  LIMIT 0;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    LIMIT 0;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+DELETE FROM t1 WHERE pk=1    ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 LIMIT 0;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY pk LIMIT 1;
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 3
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 LIMIT 0;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   LIMIT 0;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  LIMIT 0;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    LIMIT 0;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+REPLACE INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY pk LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nokey=1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nuk=1   ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE nnuk=1  ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM t1 WHERE pk=1    ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY nnuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY pk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY nnuk1, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2) ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1 LIMIT 0) UNION (SELECT * FROM t2);
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 LIMIT 1) UNION (SELECT * FROM t2);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY nokey LIMIT 1) UNION (SELECT * FROM t2);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY nuk LIMIT 1) UNION (SELECT * FROM t2);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1 LIMIT 1) UNION (SELECT * FROM t2);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk LIMIT 1) UNION (SELECT * FROM t2);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY pk LIMIT 1) UNION (SELECT * FROM t2);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1, nnuk2 LIMIT 1) UNION (SELECT * FROM t2);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1) UNION (SELECT * FROM t2);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1) UNION (SELECT * FROM t2);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 LIMIT 0);
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY nokey LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY nuk LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY nnuk1 LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY nnuk LIMIT 1);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY pk LIMIT 1);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nnuk2 LIMIT 1);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nnuk2, nokey LIMIT 1);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+ROWS in table t: 5
+INSERT INTO t (SELECT * FROM t1 LIMIT 0) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+ROWS in table t: 3
+INSERT INTO t (SELECT * FROM t1 LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY nokey LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY nuk LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1 LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY pk LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1, nnuk2 LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+ROWS in table t: 4
+INSERT INTO t (SELECT * FROM t1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1) UNION (SELECT * FROM t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1);
+ROWS in table t: 4
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 LIMIT 0) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY nokey LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY nuk LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY nnuk1 LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY nnuk LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY pk LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY nnuk1, nnuk2 LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT * FROM (SELECT * FROM t1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1) AS subselect ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY nnuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY pk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY nnuk1, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY nnuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY pk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY nnuk1, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nokey=t2.nokey ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY nnuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY pk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY nnuk1, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nuk=t2.nuk     ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.nnuk=t2.nnuk   ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1, t2 WHERE t1.pk=t2.pk       ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 NATURAL JOIN t2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 USING(pk) ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk1 AND t1.nnuk2=t2.nnuk2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN t2 ON t1.nnuk1=t2.nnuk2 AND t1.nnuk2=t2.nnuk1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN t3 USING (pk)) USING(pk) ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.pk=t3.pk) ON t1.pk=t4.pk ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY nuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY nnuk1 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY nnuk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY pk LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING (pk)) ON t2.nnuk=t3.nnuk) ON t1.nnuk1=t4.nnuk1 AND t1.nnuk2=t4.nnuk2 AND t2.pk=1 ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY nokey LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY nuk LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY pk LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1, nnuk2 LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk LIMIT 0;
+ROWS in table t: 2
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY nokey LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY nuk LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1 LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY pk LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1, nnuk2 LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1, nnuk2, nokey LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+INSERT INTO t SELECT t1.* FROM t1 RIGHT JOIN t2 ON t1.pk=t2.pk ORDER BY nnuk1, nokey, nnuk2 LIMIT 1;
+Warnings:
+Warning	1048	Column 'pk' cannot be null
+Warning	1048	Column 'nnuk' cannot be null
+Warning	1048	Column 'nnuk1' cannot be null
+Warning	1048	Column 'nnuk2' cannot be null
+Note	1592	Statement may not be safe to log in statement format.
+ROWS in table t: 3
+DROP TABLE t, t1, t2, t3, t4;
+DROP TABLE queries, result_queries, limits;
+DROP PROCEDURE gen_queries;

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2010-05-14 11:36:27 +0000
+++ b/sql/sql_delete.cc	2010-10-15 10:12:56 +0000
@@ -92,6 +92,18 @@ bool mysql_delete(THD *thd, TABLE_LIST *
     }
   }
 
+  /*
+    Statement-based replication of DELETE ... LIMIT is not safe as
+    order of rows is not defined unless ORDER BY primary_key, so in
+    mixed mode we go to row-based.
+  */
+  if (thd->lex->current_select->select_limit &&
+      select_lex->select_limit->val_int() &&
+      !is_order_deterministic(table_list, conds, (ORDER*)order->first))
+  {
+    thd->lex->set_stmt_unsafe();
+  }
+
   const_cond= (!conds || conds->const_item());
   safe_update=test(thd->options & OPTION_SAFE_UPDATES);
   if (safe_update && const_cond)
@@ -475,19 +487,6 @@ int mysql_prepare_delete(THD *thd, TABLE
   DBUG_ENTER("mysql_prepare_delete");
   List<Item> all_fields;
 
-  /*
-    Statement-based replication of DELETE ... LIMIT is not safe as order of
-    rows is not defined, so in mixed mode we go to row-based.
-
-    Note that we may consider a statement as safe if ORDER BY primary_key
-    is present. However it may confuse users to see very similiar statements
-    replicated differently.
-  */
-  if (thd->lex->current_select->select_limit)
-  {
-    thd->lex->set_stmt_unsafe();
-    thd->set_current_stmt_binlog_row_based_if_mixed();
-  }
   thd->lex->allow_sum_func= 0;
   if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
                                     &thd->lex->select_lex.top_join_list,

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2010-03-29 02:32:30 +0000
+++ b/sql/sql_insert.cc	2010-10-15 10:12:56 +0000
@@ -2881,19 +2881,6 @@ bool mysql_insert_select_prepare(THD *th
   DBUG_ENTER("mysql_insert_select_prepare");
 
   /*
-    Statement-based replication of INSERT ... SELECT ... LIMIT is not safe
-    as order of rows is not defined, so in mixed mode we go to row-based.
-
-    Note that we may consider a statement as safe if ORDER BY primary_key
-    is present or we SELECT a constant. However it may confuse users to
-    see very similiar statements replicated differently.
-  */
-  if (lex->current_select->select_limit)
-  {
-    lex->set_stmt_unsafe();
-    thd->set_current_stmt_binlog_row_based_if_mixed();
-  }
-  /*
     SELECT_LEX do not belong to INSERT statement, so we can't add WHERE
     clause if table is VIEW
   */

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-05-27 15:13:53 +0000
+++ b/sql/sql_select.cc	2010-10-15 10:12:56 +0000
@@ -910,6 +910,27 @@ JOIN::optimize()
     }
   }
 
+  if (thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
+      thd->lex->sql_command == SQLCOM_REPLACE_SELECT)
+  {
+    /*
+      Statement-based replication of INSERT ... SELECT ... LIMIT is
+      not safe as order of rows is not defined unless ORDER BY
+      primary_key, so in mixed mode we go to row-based.
+
+      NOTE: When more than one tables are joined in the SELECT part,
+      it will very hard to figure out whether the result order will be
+      deterministic or not, so they are always considered unsafe to
+      simplify the logic.
+    */
+    if (!thd->lex->is_stmt_unsafe() && select_lex->select_limit &&
+        select_lex->select_limit->val_int() &&
+        !is_order_deterministic(join_list, conds, order))
+    {
+      thd->lex->set_stmt_unsafe();
+    }
+  }
+
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   {
     TABLE_LIST *tbl;
@@ -17162,6 +17183,505 @@ bool JOIN::change_result(select_result *
   DBUG_RETURN(FALSE);
 }
 
+bool is_cond_equal(COND *cond)
+{
+  if (cond->type() == Item::FUNC_ITEM &&
+      (((Item_func*)cond)->functype() == Item_func::EQ_FUNC ||
+       ((Item_func*)cond)->functype() == Item_func::EQUAL_FUNC))
+    return TRUE;
+  return FALSE;
+}
+
+bool is_cond_mult_equal(COND *cond)
+{
+  if (cond->type() == Item::FUNC_ITEM &&
+      (((Item_func*)cond)->functype() == Item_func::MULT_EQUAL_FUNC))
+    return TRUE;
+  return FALSE;
+}
+
+static bool covers_unique_key(MY_BITMAP *bitmap, TABLE *table)
+{
+  uint key;
+  MY_BITMAP key_set;
+
+  if (table->s->primary_key == MAX_KEY && !table->s->uniques)
+    return FALSE;
+
+  bitmap_init(&key_set, NULL, table->s->fields, FALSE);
+  for (key=0; key < table->s->keys; key++)
+  {
+    if ((table->s->key_info[key].flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME)
+    {
+      table->mark_columns_used_by_index_no_reset(key, &key_set);
+      if (bitmap_is_subset(&key_set, bitmap))
+      {
+        bitmap_free(&key_set);
+        return TRUE;
+      }
+      bitmap_clear_all(&key_set);
+    }
+  }
+  bitmap_free(&key_set);
+  return FALSE;
+}
+
+/*
+  This class is used to calculate the equation bitmaps for JOIN table
+  lists.
+
+  When there is an equation 't1.a=t2.b' in the WHERE condition or ON
+  expression, both the bit of the bitmap for field 'a' in table 't1'
+  and the bit for field 'b' in table 't2' will be set. The bit will be
+  first set in the 'tmp_bitmap' when iterating over each item, and
+  after iterated over all the items of the condition, the value of
+  'tmp_bitmap' will be merged if the fields of the equation are from
+  tables of both side of the JOIN.
+
+  Please check calc_equation_bitmap_* functions for more detail.
+ */
+class TABLE_BITMAP_LIST {
+public:
+  TABLE_BITMAP_LIST(TABLE_LIST *t)
+    :table(t->table)
+  {
+    bitmap_init(&bitmap, NULL, table->s->fields, FALSE);
+    bitmap_init(&tmp_bitmap, NULL, table->s->fields, FALSE);
+  }
+
+  TABLE* get_table() { return table; }
+
+  void set_tmp_bit(uint16 field_index)
+  {
+    bitmap_set_bit(&tmp_bitmap, field_index);
+  }
+
+  void clear_all()
+  {
+    bitmap_clear_all(&bitmap);
+  }
+
+  void clear_tmp_all()
+  {
+    bitmap_clear_all(&tmp_bitmap);
+  }
+
+  void merge_tmp()
+  {
+    bitmap_union(&bitmap, &tmp_bitmap);
+  }
+
+  bool is_owner_of(Field *field)
+  {
+    return field->table == table;
+  }
+
+  bool covers_unique_key()
+  {
+    return ::covers_unique_key(&bitmap, table);
+  }
+
+private:
+  TABLE *table;
+  MY_BITMAP bitmap;
+
+  /*
+    tmp_bitmap is used to temporary save the result when tranversing
+    all items of the condition. it will be throw away or merged to
+    bitmap at the end
+  */
+  MY_BITMAP tmp_bitmap;
+};
+
+static TABLE_BITMAP_LIST* find_field_owner(List<TABLE_BITMAP_LIST> *tbls,
+                                                         Field *field)
+{
+  List_iterator<TABLE_BITMAP_LIST> it(*tbls);
+  TABLE_BITMAP_LIST *tbl;
+  while ((tbl= it++))
+  {
+    if (tbl->is_owner_of(field))
+      return tbl;
+  }
+  return NULL;
+}
+
+static bool list_covers_unique_key(List<TABLE_BITMAP_LIST> *tbls)
+{
+  List_iterator<TABLE_BITMAP_LIST> it(*tbls);
+  TABLE_BITMAP_LIST *tbl;
+  while ((tbl= it++))
+  {
+    if(tbl->covers_unique_key())
+      return TRUE;
+  }
+  return FALSE;
+}
+
+static void list_clear_all(List<TABLE_BITMAP_LIST> *tbls)
+{
+  List_iterator<TABLE_BITMAP_LIST> it(*tbls);
+  TABLE_BITMAP_LIST *tbl;
+  while ((tbl= it++))
+    tbl->clear_all();
+}
+
+static void list_clear_tmp_all(List<TABLE_BITMAP_LIST> *tbls)
+{
+  List_iterator<TABLE_BITMAP_LIST> it(*tbls);
+  TABLE_BITMAP_LIST *tbl;
+  while ((tbl= it++))
+    tbl->clear_tmp_all();
+}
+
+static void list_merge_tmp(List<TABLE_BITMAP_LIST> *tbls)
+{
+  List_iterator<TABLE_BITMAP_LIST> it(*tbls);
+  TABLE_BITMAP_LIST *tbl;
+  while ((tbl= it++))
+    tbl->merge_tmp();
+}
+
+static bool calc_equation_bitmap_for_single_equal(List<TABLE_BITMAP_LIST> *first_list,
+                                                  List<TABLE_BITMAP_LIST> *second_list,
+                                                  COND *cond)
+{
+  if (is_cond_equal(cond))
+  {
+    uint i;
+    Item **args= ((Item_func*)cond)->arguments();
+    uint arg_count= ((Item_func*)cond)->argument_count();
+    bool from_first= FALSE, from_second= FALSE;
+
+    list_clear_tmp_all(first_list);
+    list_clear_tmp_all(second_list);
+    
+    for (i=0; i<arg_count; i++)
+    {
+      if (args[i]->real_item()->type() == Item::FIELD_ITEM)
+      {
+        TABLE_BITMAP_LIST *tbl= NULL;
+        Field *field= ((Item_field*)args[i]->real_item())->field;
+        if ((tbl= find_field_owner(first_list, field)))
+        {
+          from_first= TRUE;
+          tbl->set_tmp_bit(field->field_index);
+        }
+        else if ((tbl= find_field_owner(second_list, field)))
+        {
+          from_second= TRUE;
+          tbl->set_tmp_bit(field->field_index);
+        }
+      }
+    }
+    if (from_first && from_second)
+    {
+      list_merge_tmp(first_list);
+      list_merge_tmp(second_list);
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+static bool calc_equation_bitmap_for_mult_equal(List<TABLE_BITMAP_LIST> *first_list,
+                                         List<TABLE_BITMAP_LIST> *second_list,
+                                         Item_equal *item_equal)
+{
+  Item_equal_iterator it(*item_equal);
+  Item_field *item= NULL;
+  
+  list_clear_tmp_all(first_list);
+  list_clear_tmp_all(second_list);
+  
+  bool from_first= FALSE, from_second= FALSE;
+
+  while ((item= it++))
+  {
+    Field *field= item->field;
+    TABLE_BITMAP_LIST *tbl= NULL;
+    if ((tbl= find_field_owner(first_list, field)))
+    {
+      tbl->set_tmp_bit(field->field_index);
+      from_first= TRUE;
+    }
+    else if ((tbl= find_field_owner(second_list, field)))
+    {
+      tbl->set_tmp_bit(field->field_index);
+      from_second= TRUE;
+    }
+  }
+  if(from_first && from_second)
+  {
+    list_merge_tmp(first_list);
+    list_merge_tmp(second_list);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static bool calc_equation_bitmap_for_cond_equal(List<TABLE_BITMAP_LIST> *first_list,
+                                                List<TABLE_BITMAP_LIST> *second_list,
+                                                COND_EQUAL *cond_equal)
+{
+  if (!cond_equal || cond_equal->current_level.is_empty())
+    return FALSE;
+
+  bool ret= FALSE;
+  while (cond_equal)
+  {
+    Item_equal *item_equal;
+    List_iterator<Item_equal> equal_it(cond_equal->current_level);
+    while ((item_equal= equal_it++))
+    {
+      ret|= calc_equation_bitmap_for_mult_equal(first_list, second_list, item_equal);
+    }
+    cond_equal= cond_equal->upper_levels;
+  }
+  return ret;
+}
+
+static bool calc_equation_bitmap_for_cond(List<TABLE_BITMAP_LIST> *first_list,
+                                          List<TABLE_BITMAP_LIST> *second_list,
+                                          COND *cond);
+
+static bool calc_equation_bitmap_for_and(List<TABLE_BITMAP_LIST> *first_list,
+                                         List<TABLE_BITMAP_LIST> *second_list,
+                                         Item_cond_and *cond_and)
+{
+  bool ret= calc_equation_bitmap_for_cond_equal(first_list, second_list,
+                                                &cond_and->cond_equal);
+  List<Item> *args= cond_and->argument_list();
+  List_iterator<COND> it(*args);
+  COND *cond;
+  while ((cond= it++))
+  {
+    ret|= calc_equation_bitmap_for_cond(first_list, second_list, cond);
+  }
+  return ret;
+}
+
+static bool calc_equation_bitmap_for_cond(List<TABLE_BITMAP_LIST> *first_list,
+                                          List<TABLE_BITMAP_LIST> *second_list,
+                                          COND *cond)
+{
+  if (!cond)
+    return FALSE;
+
+  if (is_cond_equal(cond))
+    return calc_equation_bitmap_for_single_equal(first_list,
+                                                 second_list,
+                                                 cond);
+
+  if (is_cond_mult_equal(cond))
+    return calc_equation_bitmap_for_mult_equal(first_list,
+                                               second_list,
+                                               (Item_equal*)cond);
+
+  if (is_cond_and(cond))
+    return calc_equation_bitmap_for_and(first_list, second_list,
+                                        (Item_cond_and*)cond);
+  return FALSE;
+}
+
+
+/*
+  Mark all the fields in the condition that is an equality comparison
+  between a field and a const value (i.e. col1=const1 [and col2=const2]).
+ */
+static void mark_cond_field_const_equations(TABLE *table,
+                                            COND *cond, MY_BITMAP *cond_set)
+{
+  if (is_cond_and(cond))
+  {
+    List<Item> *args= ((Item_cond*) cond)->argument_list();
+
+    List_iterator<COND> it(*args);
+    COND *c;
+    while ((c= it++))
+    {
+      mark_cond_field_const_equations(table, c, cond_set);
+    }
+  }
+
+  if (is_cond_equal(cond))
+  {
+    uint i;
+    Field *field= NULL;
+    Item **args= ((Item_func*)cond)->arguments();
+    uint arg_count= ((Item_func*)cond)->argument_count();
+    bool const_value= FALSE;
+    
+    for (i=0; i<arg_count; i++)
+    {
+      if (args[i]->real_item()->type() == Item::FIELD_ITEM)
+      {
+        field= ((Item_field*)args[i]->real_item())->field;
+      }
+      else if (args[i]->real_item()->basic_const_item())
+      {
+        const_value = TRUE;
+      }
+    }
+    if (field && const_value && field->table == table)
+      bitmap_set_bit(cond_set, field->field_index);
+  }
+  else if (is_cond_mult_equal(cond) &&
+           ((Item_equal*)cond)->get_const())
+  {
+    Item_equal_iterator it(*((Item_equal*)cond));
+    Item_field *item;
+    while ((item= it++))
+    {
+      if (item->field->table == table)
+        bitmap_set_bit(cond_set, item->field->field_index);
+    }
+  }
+  return;
+}
+
+/*
+  Mark all the columns used by the order clause.
+ */
+static void mark_order_fields(TABLE *table, ORDER *order, MY_BITMAP *order_set)
+{
+  for (; order; order=order->next)
+  {
+    if ((*order->item)->real_item()->type() == Item::FIELD_ITEM)
+    {
+      Field *field=((Item_field*) (*order->item)->real_item())->field;
+      if (field->table == table)
+        bitmap_set_bit(order_set, field->field_index);
+    }
+  }
+  return;
+}
+
+inline bool is_nested_join_table(TABLE_LIST *table)
+{
+  return table->nested_join ? TRUE : FALSE;
+}
+
+static List<TABLE_BITMAP_LIST>* join_on_unique_key(TABLE_LIST *table, COND *cond);
+
+static List<TABLE_BITMAP_LIST>* join_on_unique_key(List<TABLE_LIST> *join_list, COND *cond)
+{
+  if (join_list->is_empty())
+    return NULL;
+
+  List_iterator<TABLE_LIST> it(*join_list);
+  TABLE_LIST *table= it++;
+  COND* on_expr= table->on_expr;
+  uint outer_join= table->outer_join;
+
+  List<TABLE_BITMAP_LIST> *first_list, *second_list;
+  first_list= join_on_unique_key(table, cond);
+
+  if (!first_list)
+    return NULL;
+  
+  if (join_list->elements == 1)
+    return first_list;
+
+  while ((table= it++))
+  {
+    second_list= join_on_unique_key(table, cond);
+    if (!second_list)
+      return NULL;
+
+    list_clear_all(first_list);
+    list_clear_all(second_list);
+
+    if (!calc_equation_bitmap_for_cond(first_list, second_list, on_expr) &&
+        !calc_equation_bitmap_for_cond(first_list, second_list, cond))
+      return NULL;
+    
+    if (!list_covers_unique_key(first_list) ||
+        !list_covers_unique_key(second_list))
+      return NULL;
+    if (!outer_join)
+      first_list->concat(second_list);
+  }
+
+  if (outer_join)
+    return second_list;
+  return first_list;
+}
+
+static List<TABLE_BITMAP_LIST>* join_on_unique_key(TABLE_LIST *table, COND *cond)
+{
+  if (!is_nested_join_table(table))
+  {
+    TABLE_BITMAP_LIST *tbl= new TABLE_BITMAP_LIST(table);
+    List<TABLE_BITMAP_LIST> *tbls= new List<TABLE_BITMAP_LIST>;
+    tbls->push_back(tbl);
+    return tbls;
+  }
+
+  return join_on_unique_key(&table->nested_join->join_list, cond);
+}
+
+/*
+  Helper function to check if the result order is deterministic.
+ */
+static bool is_order_deterministic(List<TABLE_BITMAP_LIST> *tbls, COND *cond, ORDER *order)
+{
+  if (!tbls || tbls->is_empty())
+    return FALSE;
+
+  List_iterator<TABLE_BITMAP_LIST> tbls_it(*tbls);
+  TABLE_BITMAP_LIST *tbl;
+  while ((tbl= tbls_it++))
+  {
+    MY_BITMAP check_set;
+    TABLE *table= tbl->get_table();
+    bitmap_init(&check_set, NULL, table->s->fields, FALSE);
+      
+    if (order)
+      mark_order_fields(table, order, &check_set);
+    if (cond)
+      mark_cond_field_const_equations(table, cond, &check_set);
+    
+    bool ret= covers_unique_key(&check_set, table);
+    
+    bitmap_free(&check_set);
+    if (ret)
+      return ret;
+  }
+  return FALSE;
+}
+
+/*
+  Test if the result order is deterministic for a JOIN table list.
+
+  @retval FALSE not deterministic
+  @retval TRUE deterministic
+ */
+bool is_order_deterministic(List<TABLE_LIST>* join_list,
+                                      COND* cond, ORDER* order)
+{
+  List<TABLE_BITMAP_LIST> *tbls= join_on_unique_key(join_list, cond);
+
+  return is_order_deterministic(tbls, cond, order);
+}
+
+/*
+  Test if the result order is deterministic for a single table.
+
+  @retval FALSE not deterministic
+  @retval TRUE deterministic
+ */
+bool is_order_deterministic(TABLE_LIST *table_list, COND *cond, ORDER *order)
+{
+  if (order == NULL && cond == NULL)
+    return FALSE;
+
+  List<TABLE_BITMAP_LIST> *tbls= join_on_unique_key(table_list, cond);
+
+  return is_order_deterministic(tbls, cond, order);
+}
+
+
 /**
   @} (end of group Query_Optimizer)
 */

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2010-02-26 13:16:46 +0000
+++ b/sql/sql_select.h	2010-10-15 10:12:56 +0000
@@ -794,3 +794,5 @@ inline bool optimizer_flag(THD *thd, uin
   return (thd->variables.optimizer_switch & flag);
 }
 
+bool is_order_deterministic(TABLE_LIST *table_list, COND *cond, ORDER *order);
+bool is_order_deterministic(List<TABLE_LIST> *join_list, COND *cond, ORDER *order);

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2010-05-27 20:07:40 +0000
+++ b/sql/sql_update.cc	2010-10-15 10:12:56 +0000
@@ -248,6 +248,18 @@ int mysql_update(THD *thd,
   if (mysql_prepare_update(thd, table_list, &conds, order_num, order))
     DBUG_RETURN(1);
 
+  /*
+    Statement-based replication of UPDATE ... LIMIT is not safe as
+    order of rows is not defined unless ORDER BY primary_key, so in
+    mixed mode we go to row-based.
+  */
+  if (thd->lex->current_select->select_limit &&
+      select_lex->select_limit->val_int() &&
+      !is_order_deterministic(table_list, conds, order))
+  {
+    thd->lex->set_stmt_unsafe();
+  }
+
   old_covering_keys= table->covering_keys;		// Keys used in WHERE
   /* Check the fields we are going to modify */
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -875,19 +887,6 @@ bool mysql_prepare_update(THD *thd, TABL
   SELECT_LEX *select_lex= &thd->lex->select_lex;
   DBUG_ENTER("mysql_prepare_update");
 
-  /*
-    Statement-based replication of UPDATE ... LIMIT is not safe as order of
-    rows is not defined, so in mixed mode we go to row-based.
-
-    Note that we may consider a statement as safe if ORDER BY primary_key
-    is present. However it may confuse users to see very similiar statements
-    replicated differently.
-  */
-  if (thd->lex->current_select->select_limit)
-  {
-    thd->lex->set_stmt_unsafe();
-    thd->set_current_stmt_binlog_row_based_if_mixed();
-  }
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   table_list->grant.want_privilege= table->grant.want_privilege= 
     (SELECT_ACL & ~table->grant.privilege);


Attachment: [text/bzr-bundle] bzr/zhenxing.he@sun.com-20101015101256-0esqur3shsqq8lp0.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3418) Bug#42415He Zhenxing15 Oct