Merge 5.5->5.5-mwl248.

This commit is contained in:
Igor Babaev 2012-08-29 18:50:38 -07:00
commit 98f239a849
154 changed files with 4548 additions and 2900 deletions

View File

@ -298,14 +298,16 @@ ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(regex)
ADD_SUBDIRECTORY(mysys)
ADD_SUBDIRECTORY(libmysql)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(libservices)
ADD_SUBDIRECTORY(scripts)
ADD_SUBDIRECTORY(sql/share)
ADD_SUBDIRECTORY(support-files)
IF(NOT WITHOUT_SERVER)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(sql)
ADD_SUBDIRECTORY(sql/share)
ADD_SUBDIRECTORY(libservices)
OPTION (WITH_EMBEDDED_SERVER "Compile MySQL with embedded server" OFF)
IF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(libmysqld)
@ -314,12 +316,11 @@ IF(NOT WITHOUT_SERVER)
ADD_SUBDIRECTORY(mysql-test)
ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
ADD_SUBDIRECTORY(support-files)
ADD_SUBDIRECTORY(scripts)
ADD_SUBDIRECTORY(sql-bench)
IF(UNIX)
ADD_SUBDIRECTORY(man)
ENDIF()
ENDIF()
IF(UNIX)
ADD_SUBDIRECTORY(man)
ENDIF()
INCLUDE(cmake/abi_check.cmake)

View File

@ -743,7 +743,7 @@ print_use_stmt(PRINT_EVENT_INFO* pinfo, const Query_log_event *ev)
return;
// In case of rewrite rule print USE statement for db_to
fprintf(result_file, "use %s%s\n", db_to, pinfo->delimiter);
my_fprintf(result_file, "use %`s%s\n", db_to, pinfo->delimiter);
// Copy the *original* db to pinfo to suppress emiting
// of USE stmts by log_event print-functions.

View File

@ -4180,6 +4180,7 @@ static int dump_all_databases()
if (dump_all_tables_in_db(row[0]))
result=1;
}
mysql_free_result(tableres);
if (seen_views)
{
if (mysql_query(mysql, "SHOW DATABASES") ||
@ -4202,6 +4203,7 @@ static int dump_all_databases()
if (dump_all_views_in_db(row[0]))
result=1;
}
mysql_free_result(tableres);
}
return result;
}
@ -4330,8 +4332,6 @@ static int init_dumping(char *database, int init_func(char*))
check_io(md_result_file);
}
}
if (extended_insert)
init_dynamic_string_checked(&extended_row, "", 1024, 1024);
return 0;
} /* init_dumping */
@ -4805,7 +4805,7 @@ static int add_slave_statements(void)
static int do_show_slave_status(MYSQL *mysql_con)
{
MYSQL_RES *slave;
MYSQL_RES *slave= 0;
const char *comment_prefix=
(opt_slave_data == MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL) ? "-- " : "";
if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
@ -5608,6 +5608,9 @@ int main(int argc, char **argv)
if (opt_alltspcs)
dump_all_tablespaces();
if (extended_insert)
init_dynamic_string_checked(&extended_row, "", 1024, 1024);
if (opt_alldbs)
{
if (!opt_alltspcs && !opt_notspcs)

View File

@ -56,10 +56,10 @@ ENDIF()
# Always enable -Wall for gnu C/C++
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter")
SET(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
SET(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
ENDIF()

View File

@ -284,9 +284,6 @@ static int DoTrace(CODE_STATE *cs);
/* Test to see if file is writable */
#if defined(HAVE_ACCESS)
static BOOLEAN Writable(const char *pathname);
/* Change file owner and group */
static void ChangeOwner(CODE_STATE *cs, char *pathname);
/* Allocate memory for runtime support */
#endif
static void DoPrefix(CODE_STATE *cs, uint line);

View File

@ -1,14 +1,3 @@
#ifdef DBUG_OFF /* We are testing dbug */
int factorial(register int value) {
if(value > 1) {
value *= factorial(value-1);
}
return value;
}
#else
#include <my_global.h>
int factorial (
@ -22,6 +11,3 @@ register int value)
DBUG_PRINT ("result", ("result is %d", value));
DBUG_RETURN (value);
}
#endif

View File

@ -37,6 +37,11 @@ case "${CODENAME}" in
*) LIBREADLINE_DEV=libreadline-gplv2-dev ;;
esac
case "${CODENAME}" in
etch|lenny|hardy|intrepid|jaunty|karmic) CMAKE_DEP='' ;;
*) CMAKE_DEP='cmake (>= 2.7), ' ;;
esac
# Clean up build file symlinks that are distro-specific. First remove all, then set
# new links.
DISTRODIRS="$(ls ./debian/dist)"
@ -53,7 +58,9 @@ echo "Copying distribution specific build files for ${DISTRO}"
DISTROFILES="$(ls ./debian/dist/${DISTRO})"
for distrofile in ${DISTROFILES}; do
rm -f "./debian/${distrofile}"
sed -e "s/\\\${LIBREADLINE_DEV}/${LIBREADLINE_DEV}/g" < "./debian/dist/${DISTRO}/${distrofile}" > "./debian/${distrofile}"
sed -e "s/\\\${LIBREADLINE_DEV}/${LIBREADLINE_DEV}/g" \
-e "s/\\\${CMAKE_DEP}/${CMAKE_DEP}/g" \
< "./debian/dist/${DISTRO}/${distrofile}" > "./debian/${distrofile}"
chmod --reference="./debian/dist/${DISTRO}/${distrofile}" "./debian/${distrofile}"
done;

View File

@ -4,7 +4,7 @@ Priority: optional
Maintainer: MariaDB Developers <maria-developers@lists.launchpad.net>
XSBC-Original-Maintainer: Maria Developers <maria-developers@lists.launchpad.net>
Uploaders: MariaDB Developers <maria-developers@lists.launchpad.net>
Build-Depends: libtool (>= 1.4.2-7), procps | hurd, debhelper, file (>= 3.28), libncurses5-dev (>= 5.0-6), perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libevent-dev, libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath, automake1.9, doxygen, texlive-latex-base, ghostscript | gs-gpl, dpatch, gawk, bison, lsb-release, hardening-wrapper
Build-Depends: libtool (>= 1.4.2-7), procps | hurd, debhelper, file (>= 3.28), libncurses5-dev (>= 5.0-6), perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libevent-dev, libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath, automake1.9, doxygen, texlive-latex-base, ghostscript | gs-gpl, dpatch, gawk, bison, lsb-release, hardening-wrapper, ${CMAKE_DEP}libaio-dev
Standards-Version: 3.8.3
Homepage: http://mariadb.org/
Vcs-Browser: http://bazaar.launchpad.net/~maria-captains/maria/5.5/files

View File

@ -4,7 +4,7 @@ Priority: optional
Maintainer: MariaDB Developers <maria-developers@lists.launchpad.net>
XSBC-Original-Maintainer: Maria Developers <maria-developers@lists.launchpad.net>
Uploaders: MariaDB Developers <maria-developers@lists.launchpad.net>
Build-Depends: libtool (>= 1.4.2-7), procps | hurd, debhelper, file (>= 3.28), libncurses5-dev (>= 5.0-6), perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libevent-dev, libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath, automake1.9, doxygen, texlive-latex-base, ghostscript | gs-gpl, dpatch, gawk, bison, lsb-release, hardening-wrapper
Build-Depends: libtool (>= 1.4.2-7), procps | hurd, debhelper, file (>= 3.28), libncurses5-dev (>= 5.0-6), perl (>= 5.6.0), libwrap0-dev (>= 7.6-8.3), zlib1g-dev (>= 1:1.1.3-5), ${LIBREADLINE_DEV}, libevent-dev, libssl-dev, libpam0g-dev, psmisc, po-debconf, chrpath, automake1.9, doxygen, texlive-latex-base, ghostscript | gs-gpl, dpatch, gawk, bison, lsb-release, hardening-wrapper, ${CMAKE_DEP}libaio-dev
Standards-Version: 3.8.2
Homepage: http://mariadb.org/
Vcs-Browser: http://bazaar.launchpad.net/~maria-captains/maria/5.5/files

View File

@ -11,6 +11,7 @@ usr/bin/mysqlimport
usr/bin/mysqlreport
usr/bin/mysqlshow
usr/bin/mysqlslap
usr/bin/mytop
usr/bin/mysql_waitpid
usr/share/lintian/overrides/mariadb-client-5.5
usr/share/man/man1/innotop.1

View File

@ -184,7 +184,7 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig,
s_ = (kInv * (H + x*r_)) % q;
if (!(!!r_ && !!s_))
return -1;
return (word32) -1;
int rSz = r_.ByteCount();

View File

@ -627,6 +627,7 @@ extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
extern int my_fclose(FILE *fd,myf MyFlags);
extern int my_vfprintf(FILE *stream, const char* format, va_list args);
extern int my_fprintf(FILE *stream, const char* format, ...);
extern File my_fileno(FILE *fd);
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
extern int my_chmod(const char *name, mode_t mode, myf my_flags);
@ -751,6 +752,8 @@ extern size_t my_b_fill(IO_CACHE *info);
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
extern my_off_t my_b_filelength(IO_CACHE *info);
extern size_t my_b_write_backtick_quote(IO_CACHE *info, const char *str,
size_t len);
extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,

View File

@ -21,7 +21,7 @@ SET(MAN1_SERVER innochecksum.1 my_print_defaults.1 myisam_ftdump.1 myisamchk.1
mysql_tzinfo_to_sql.1 mysql_upgrade.1 mysql_zap.1
mysqld_multi.1 mysqld_safe.1 mysqldumpslow.1 mysqlhotcopy.1
mysqlman.1 mysqltest.1 perror.1 replace.1 resolve_stack_dump.1
resolveip.1)
resolveip.1 mysqlbug.1)
SET(MAN8_SERVER mysqld.8 mysqlmanager.8)
SET(MAN1_CLIENT msql2mysql.1 mysql.1 mysql_find_rows.1 mysql_waitpid.1
mysqlaccess.1 mysqladmin.1 mysqlbinlog.1 mysqlcheck.1

View File

@ -220,6 +220,10 @@ a d
3 11120436154190595086
drop table t1, t2;
End of 5.0 tests
CREATE TABLE t1(a YEAR);
SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END;
1
DROP TABLE t1;
create table t1 (f1 time);
insert t1 values ('00:00:00'),('00:01:00');
select case t1.f1 when '00:00:00' then 1 end from t1;

View File

@ -96,3 +96,7 @@ SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00';
a
DROP TABLE t1;
End of 5.0 tests
CREATE TABLE t1(a INT ZEROFILL);
SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2;
1
DROP TABLE t1;

View File

@ -287,7 +287,7 @@ WHERE t1.f1 GROUP BY t1.f1));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
PREPARE stmt FROM
'EXPLAIN SELECT 1 FROM t1
WHERE 1 > ALL((SELECT t1.f1 FROM t1 RIGHT OUTER JOIN t1 a
@ -297,12 +297,12 @@ EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM
'EXPLAIN SELECT 1 FROM t1
@ -313,12 +313,12 @@ EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
End of 5.1 tests.

View File

@ -146,19 +146,6 @@ count(*) min(7) max(7)
0 NULL NULL
drop table t1m, t1i, t2m, t2i;
#
# Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN
#
CREATE TABLE t1(a BLOB, b VARCHAR(255) CHARSET LATIN1, c INT,
KEY(b, c, a(765))) ENGINE=INNODB;
INSERT INTO t1(a, b, c) VALUES ('', 'a', 0), ('', 'a', null), ('', 'a', 0);
SELECT MIN(c) FROM t1 GROUP BY b;
MIN(c)
0
EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL b 263 NULL 4 Using index for group-by
DROP TABLE t1;
#
# Bug #57954: BIT_AND function returns incorrect results when
# semijoin=on
CREATE TABLE c (
@ -230,4 +217,18 @@ SELECT member_id_to, COUNT(*) FROM t1 WHERE r_date =
member_id_to COUNT(*)
518491 2
DROP TABLE t1;
# End of test BUG#12713907
#
# Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN
#
CREATE TABLE t1(a BLOB, b VARCHAR(255) CHARSET LATIN1, c INT,
KEY(b, c, a(765))) ENGINE=INNODB;
INSERT INTO t1(a, b, c) VALUES ('', 'a', 0), ('', 'a', null), ('', 'a', 0);
SELECT MIN(c) FROM t1 GROUP BY b;
MIN(c)
0
EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL b 263 NULL 4 Using index for group-by
DROP TABLE t1;
End of 5.5 tests

View File

@ -2403,7 +2403,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
@ -2421,7 +2421,7 @@ AND t1_outer1.b = t1_outer2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join)
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
id select_type table type possible_keys key key_len ref rows Extra
@ -2757,7 +2757,7 @@ EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
id select_type table type possible_keys key key_len ref rows Extra
x x x x x x x x x Impossible WHERE noticed after reading const tables
x x x x x x x x x Using index
x x x x x x x x x Using where; Using index
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
MIN( a )
NULL
@ -2829,7 +2829,7 @@ EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
id select_type table type possible_keys key key_len ref rows Extra
x x x x x x x x x Impossible WHERE noticed after reading const tables
x x x x x x x x x Using index
x x x x x x x x x Using where; Using index
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
MIN( a )
NULL
@ -2908,7 +2908,7 @@ EXPLAIN
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
id select_type table type possible_keys key key_len ref rows Extra
x x x x x x x x x Impossible WHERE noticed after reading const tables
x x x x x x x x x Using index
x x x x x x x x x Using where; Using index
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
MIN( a )
NULL

View File

@ -599,7 +599,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
SELECT 1 as RES FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
RES

View File

@ -679,7 +679,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Distinct
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
SELECT DISTINCT a AS field1 FROM t1, t2
WHERE EXISTS (SELECT c FROM t3 LEFT JOIN t2 ON b = d)
HAVING field1 > 'aaa' LIMIT ROWS EXAMINED 20;

View File

@ -34,7 +34,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
INSERT INTO t1 VALUES (1)
/*!*/;
@ -65,7 +65,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use foo/*!*/;
use `foo`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
INSERT INTO t1 VALUES (1)
/*!*/;

View File

@ -18,7 +18,7 @@ flush logs;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -111,7 +111,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
/*!*/;
@ -202,7 +202,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 values ("Alas")
/*!*/;
@ -219,7 +219,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -312,7 +312,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
/*!*/;
@ -403,7 +403,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
insert into t1 values ("Alas")
/*!*/;
@ -427,7 +427,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1108844555/*!*/;
insert t1 values (1)
/*!*/;
@ -445,7 +445,7 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1108844555/*!*/;
insert t1 values (1)
/*!*/;
@ -498,7 +498,7 @@ ERROR 42000: PROCEDURE test.p1 does not exist
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -548,7 +548,7 @@ flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -725,7 +725,7 @@ FLUSH LOGS;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1253783037/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -825,7 +825,7 @@ BEGIN
SET TIMESTAMP=1266652094/*!*/;
SavePoint mixed_cases
/*!*/;
use db1/*!*/;
use `db1`/*!*/;
SET TIMESTAMP=1266652094/*!*/;
INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
/*!*/;

View File

@ -19,7 +19,7 @@ insert into t1 values(null, "f");
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -103,7 +103,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=1/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
insert into t1 values(null, "a")
/*!*/;
@ -172,7 +172,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -209,7 +209,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -263,7 +263,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -289,7 +289,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -326,7 +326,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -369,7 +369,7 @@ flush logs;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -445,7 +445,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -474,7 +474,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=1/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
insert into t1 values(null, "a")
/*!*/;
@ -535,7 +535,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -564,7 +564,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -605,7 +605,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -622,7 +622,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -720,7 +720,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -761,7 +761,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -778,7 +778,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -820,7 +820,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -904,7 +904,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=1/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
insert into t1 values(null, "a")
/*!*/;
@ -972,7 +972,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -1009,7 +1009,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -1062,7 +1062,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -1088,7 +1088,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -1125,7 +1125,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -1167,7 +1167,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -1243,7 +1243,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -1272,7 +1272,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=1/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
insert into t1 values(null, "a")
/*!*/;
@ -1333,7 +1333,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -1361,7 +1361,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -1402,7 +1402,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -1419,7 +1419,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -1516,7 +1516,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=3/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609944/*!*/;
insert into t1 values(null, "c")
/*!*/;
@ -1557,7 +1557,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET INSERT_ID=6/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609943/*!*/;
insert into t1 values(null, "f")
/*!*/;
@ -1574,7 +1574,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -1616,7 +1616,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1579609942/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

View File

@ -336,7 +336,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

View File

@ -2253,7 +2253,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -3876,7 +3876,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -4243,7 +4243,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -4804,7 +4804,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

View File

@ -2253,7 +2253,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -3898,7 +3898,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -4271,7 +4271,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -4842,7 +4842,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

View File

@ -132,7 +132,7 @@ DELIMITER /*!*/;
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

View File

@ -1813,3 +1813,135 @@ Warnings:
Note 1003 select `test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`a` = `test`.`t1`.`b`) group by `test`.`t2`.`b` order by `test`.`t1`.`b`
drop table t1,t2;
End of 5.2 tests
#
# Bug mdev-449: ORDER BY with small sort_buffer_size
#
CREATE TABLE t1(f0 int auto_increment primary key, f1 int, f2 varchar(200));
INSERT INTO t1(f1, f2) VALUES
(0,"0"),(1,"1"),(2,"2"),(3,"3"),(4,"4"),(5,"5"),
(6,"6"),(7,"7"),(8,"8"),(9,"9"),(10,"10"),
(11,"11"),(12,"12"),(13,"13"),(14,"14"),(15,"15"),
(16,"16"),(17,"17"),(18,"18"),(19,"19"),(20,"20"),
(21,"21"),(22,"22"),(23,"23"),(24,"24"),(25,"25"),
(26,"26"),(27,"27"),(28,"28"),(29,"29"),(30,"30"),
(31,"31"),(32,"32"),(33,"33"),(34,"34"),(35,"35"),
(36,"36"),(37,"37"),(38,"38"),(39,"39"),(40,"40"),
(41,"41"),(42,"42"),(43,"43"),(44,"44"),(45,"45"),
(46,"46"),(47,"47"),(48,"48"),(49,"49"),(50,"50"),
(51,"51"),(52,"52"),(53,"53"),(54,"54"),(55,"55"),
(56,"56"),(57,"57"),(58,"58"),(59,"59"),(60,"60"),
(61,"61"),(62,"62"),(63,"63"),(64,"64"),(65,"65"),
(66,"66"),(67,"67"),(68,"68"),(69,"69"),(70,"70"),
(71,"71"),(72,"72"),(73,"73"),(74,"74"),(75,"75"),
(76,"76"),(77,"77"),(78,"78"),(79,"79"),(80,"80"),
(81,"81"),(82,"82"),(83,"83"),(84,"84"),(85,"85"),
(86,"86"),(87,"87"),(88,"88"),(89,"89"),(90,"90"),
(91,"91"),(92,"92"),(93,"93"),(94,"94"),(95,"95"),
(96,"96"),(97,"97"),(98,"98"),(99,"99");
set @save_sort_buffer_size= @@sort_buffer_size;
set sort_buffer_size= 2000;
SELECT * FROM t1 ORDER BY f1 DESC, f0;
f0 f1 f2
100 99 99
99 98 98
98 97 97
97 96 96
96 95 95
95 94 94
94 93 93
93 92 92
92 91 91
91 90 90
90 89 89
89 88 88
88 87 87
87 86 86
86 85 85
85 84 84
84 83 83
83 82 82
82 81 81
81 80 80
80 79 79
79 78 78
78 77 77
77 76 76
76 75 75
75 74 74
74 73 73
73 72 72
72 71 71
71 70 70
70 69 69
69 68 68
68 67 67
67 66 66
66 65 65
65 64 64
64 63 63
63 62 62
62 61 61
61 60 60
60 59 59
59 58 58
58 57 57
57 56 56
56 55 55
55 54 54
54 53 53
53 52 52
52 51 51
51 50 50
50 49 49
49 48 48
48 47 47
47 46 46
46 45 45
45 44 44
44 43 43
43 42 42
42 41 41
41 40 40
40 39 39
39 38 38
38 37 37
37 36 36
36 35 35
35 34 34
34 33 33
33 32 32
32 31 31
31 30 30
30 29 29
29 28 28
28 27 27
27 26 26
26 25 25
25 24 24
24 23 23
23 22 22
22 21 21
21 20 20
20 19 19
19 18 18
18 17 17
17 16 16
16 15 15
15 14 14
14 13 13
13 12 12
12 11 11
11 10 10
10 9 9
9 8 8
8 7 7
7 6 6
6 5 5
5 4 4
4 3 3
3 2 2
2 1 1
1 0 0
set sort_buffer_size= @save_sort_buffer_size;
DROP TABLE t1;
End of 5.3 tests

View File

@ -2473,3 +2473,17 @@ SELECT * FROM vtmp;
1
DROP VIEW vtmp;
DROP TABLE t1;
#
# MDEV-365 "Got assertion when doing alter table on a partition"
#
CREATE TABLE t1 ( i INT ) ENGINE=Aria PARTITION BY HASH(i) PARTITIONS 2;
INSERT INTO t1 VALUES (1),(2),(2),(3),(4);
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
SELECT * from t1 order by i;
i
1
2
2
3
4
DROP TABLE t1;

View File

@ -3056,7 +3056,7 @@ DROP TABLE t1;
End of 5.1 tests.
#
# LP bug#1001500 Crash on the second execution of the PS for
# lp:1001500 Crash on the second execution of the PS for
# a query with degenerated conjunctive condition
# (see also mysql bug#12582849)
#
@ -3996,108 +3996,4 @@ Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
deallocate prepare st;
drop table t1;
#
# LP bug#993459 Execution of PS for a query with GROUP BY
# returns wrong result (see also mysql bug#13805127)
#
PREPARE s1 FROM
"
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2
";
SET @x = 1;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:99345900:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
c1 c2 count(c3)
2012-03-01 01:00:00 3 1
2012-03-01 01:99345900:00 2 1
2012-03-01 02:00:00 3 1
EXECUTE s1;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
SET @x = 2;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
EXECUTE s1;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
SET @x = 1;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
EXECUTE s1;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
DEALLOCATE PREPARE s1;
# End of 5.3 tests

View File

@ -7811,9 +7811,12 @@ DROP FUNCTION f1;
# -- End of 5.1 tests
# ------------------------------------------------------------------
#
# LP bug#993459 Execution of PS for a query with GROUP BY
# lp:993459 Execution of PS for a query with GROUP BY
# returns wrong result (see also mysql bug#13805127)
#
# Bug#13805127: Stored program cache produces wrong result in same THD
CREATE PROCEDURE p1(x INT UNSIGNED)
BEGIN
SELECT c1, t2.c2, count(c3)
@ -7850,7 +7853,7 @@ c1 c2 count(c3)
2012-03-01 02:00:00 3 1
DROP PROCEDURE p1;
#
# LP bug#1002157 : testing stored function
# lp:1002157 : testing stored function
# bug#62125 result for null incorrectly yields 1292 warning.
#
DROP FUNCTION IF EXISTS f1;

View File

@ -4196,7 +4196,7 @@ INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
INSERT INTO t1 VALUES
@ -5966,7 +5966,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
@ -6127,7 +6127,7 @@ set optimizer_switch=@tmp_optimizer_switch;
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
@ -6612,7 +6612,33 @@ SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 U
min_a a
drop table t1;
#
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
# MDEV-367: Different results with and without subquery_cache on
# a query with a constant NOT IN condition
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
set @mdev367_optimizer_switch = @@optimizer_switch;
set optimizer_switch = 'subquery_cache=on';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
set optimizer_switch = 'subquery_cache=off';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# lp:944706 Query with impossible or constant subquery in WHERE or HAVING is not
# precomputed and thus not part of optimization
#
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
@ -6806,5 +6832,30 @@ Table_schema Table_name Index_name Rows_read
test t2 b 1
set global userstat=@tmp_mdev410;
DROP TABLE t1,t2,t3,t4;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
#
# MDEV-430: Server crashes in select_describe on EXPLAIN with
# materialization+semijoin, 2 nested subqueries, aggregate functions
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
# MDEV-405: Server crashes in test_if_skip_sort_order on EXPLAIN with GROUP BY and HAVING in EXISTS subquery
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;

View File

@ -333,7 +333,7 @@ WHERE (SELECT DISTINCT b FROM t3) > 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 Using where; Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
3 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 0 Using temporary
3 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using temporary
SELECT *
FROM t1
WHERE t1.a = (
@ -386,7 +386,7 @@ select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 gr
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1
2 SUBQUERY t1 ALL NULL NULL NULL NULL 1
3 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
3 SUBQUERY t1 ALL NULL NULL NULL NULL 1 Using temporary; Using filesort
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
1
1

View File

@ -148,7 +148,7 @@ FROM t2 GROUP BY f1
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 SUBQUERY t1 system NULL NULL NULL NULL 1
3 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
drop table t1, t2, t3;
#
# LP BUG#715034 Item_sum_distinct::clear(): Assertion `tree != 0' failed

View File

@ -4200,7 +4200,7 @@ INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
INSERT INTO t1 VALUES
@ -5967,7 +5967,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
@ -6126,7 +6126,7 @@ set optimizer_switch=@tmp_optimizer_switch;
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
@ -6611,7 +6611,33 @@ SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 U
min_a a
drop table t1;
#
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
# MDEV-367: Different results with and without subquery_cache on
# a query with a constant NOT IN condition
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
set @mdev367_optimizer_switch = @@optimizer_switch;
set optimizer_switch = 'subquery_cache=on';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
set optimizer_switch = 'subquery_cache=off';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# lp:944706 Query with impossible or constant subquery in WHERE or HAVING is not
# precomputed and thus not part of optimization
#
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
@ -6804,8 +6830,33 @@ Table_schema Table_name Index_name Rows_read
test t2 b 1
set global userstat=@tmp_mdev410;
DROP TABLE t1,t2,t3,t4;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
#
# MDEV-430: Server crashes in select_describe on EXPLAIN with
# materialization+semijoin, 2 nested subqueries, aggregate functions
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
# MDEV-405: Server crashes in test_if_skip_sort_order on EXPLAIN with GROUP BY and HAVING in EXISTS subquery
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'

View File

@ -4196,7 +4196,7 @@ INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
INSERT INTO t1 VALUES
@ -5963,7 +5963,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
@ -6122,7 +6122,7 @@ set optimizer_switch=@tmp_optimizer_switch;
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
@ -6607,7 +6607,33 @@ SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 U
min_a a
drop table t1;
#
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
# MDEV-367: Different results with and without subquery_cache on
# a query with a constant NOT IN condition
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
set @mdev367_optimizer_switch = @@optimizer_switch;
set optimizer_switch = 'subquery_cache=on';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
set optimizer_switch = 'subquery_cache=off';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# lp:944706 Query with impossible or constant subquery in WHERE or HAVING is not
# precomputed and thus not part of optimization
#
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
@ -6801,6 +6827,31 @@ Table_schema Table_name Index_name Rows_read
test t2 b 1
set global userstat=@tmp_mdev410;
DROP TABLE t1,t2,t3,t4;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
#
# MDEV-430: Server crashes in select_describe on EXPLAIN with
# materialization+semijoin, 2 nested subqueries, aggregate functions
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
# MDEV-405: Server crashes in test_if_skip_sort_order on EXPLAIN with GROUP BY and HAVING in EXISTS subquery
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set @optimizer_switch_for_subselect_test=null;

View File

@ -4202,7 +4202,7 @@ INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
INSERT INTO t1 VALUES
@ -5972,7 +5972,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
@ -6133,7 +6133,7 @@ set optimizer_switch=@tmp_optimizer_switch;
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
@ -6618,7 +6618,33 @@ SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 U
min_a a
drop table t1;
#
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
# MDEV-367: Different results with and without subquery_cache on
# a query with a constant NOT IN condition
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
set @mdev367_optimizer_switch = @@optimizer_switch;
set optimizer_switch = 'subquery_cache=on';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
set optimizer_switch = 'subquery_cache=off';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# lp:944706 Query with impossible or constant subquery in WHERE or HAVING is not
# precomputed and thus not part of optimization
#
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
@ -6812,8 +6838,33 @@ Table_schema Table_name Index_name Rows_read
test t2 b 1
set global userstat=@tmp_mdev410;
DROP TABLE t1,t2,t3,t4;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
#
# MDEV-430: Server crashes in select_describe on EXPLAIN with
# materialization+semijoin, 2 nested subqueries, aggregate functions
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
# MDEV-405: Server crashes in test_if_skip_sort_order on EXPLAIN with GROUP BY and HAVING in EXISTS subquery
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set optimizer_switch=default;
select @@optimizer_switch like '%subquery_cache=on%';
@@optimizer_switch like '%subquery_cache=on%'

View File

@ -4196,7 +4196,7 @@ INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
INSERT INTO t1 VALUES
@ -5963,7 +5963,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
@ -6122,7 +6122,7 @@ set optimizer_switch=@tmp_optimizer_switch;
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 SUBQUERY t1 ref a a 5 const 1
2 SUBQUERY t1 ref a a 5 const 1 Using index
DROP TABLE t1;
#
@ -6607,7 +6607,33 @@ SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 U
min_a a
drop table t1;
#
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
# MDEV-367: Different results with and without subquery_cache on
# a query with a constant NOT IN condition
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
set @mdev367_optimizer_switch = @@optimizer_switch;
set optimizer_switch = 'subquery_cache=on';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
set optimizer_switch = 'subquery_cache=off';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
a
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
1 NULL
2 NULL
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# lp:944706 Query with impossible or constant subquery in WHERE or HAVING is not
# precomputed and thus not part of optimization
#
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
@ -6801,7 +6827,32 @@ Table_schema Table_name Index_name Rows_read
test t2 b 1
set global userstat=@tmp_mdev410;
DROP TABLE t1,t2,t3,t4;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
#
# MDEV-430: Server crashes in select_describe on EXPLAIN with
# materialization+semijoin, 2 nested subqueries, aggregate functions
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
# MDEV-405: Server crashes in test_if_skip_sort_order on EXPLAIN with GROUP BY and HAVING in EXISTS subquery
#
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set @optimizer_switch_for_subselect_test=null;
set @join_cache_level_for_subselect_test=NULL;

View File

@ -34,7 +34,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=10000/*!*/;
INSERT INTO t1 VALUES(@`a b`)
/*!*/;

View File

@ -35,7 +35,7 @@ DELIMITER /*!*/;
# at 4
<#>ROLLBACK/*!*/;
# at 102
<#>use test/*!*/;
<#>use `test`/*!*/;
SET TIMESTAMP=1196959712/*!*/;
<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;

View File

@ -35,7 +35,7 @@ DELIMITER /*!*/;
#010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
ROLLBACK/*!*/;
# at #
use new_test1/*!*/;
use `new_test1`/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
@ -72,7 +72,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
use test2/*!*/;
use `test2`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t2 (a INT)
/*!*/;
@ -115,7 +115,7 @@ SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
# at #
use new_test3/*!*/;
use `new_test3`/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t3 (a INT)
@ -229,7 +229,7 @@ DELIMITER /*!*/;
#010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
ROLLBACK/*!*/;
# at #
use new_test1/*!*/;
use `new_test1`/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
@ -266,7 +266,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
use test2/*!*/;
use `test2`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t2 (a INT)
/*!*/;
@ -309,7 +309,7 @@ SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
# at #
use new_test3/*!*/;
use `new_test3`/*!*/;
#010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t3 (a INT)

View File

@ -26,7 +26,7 @@ SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=10000/*!*/;
insert into t2 values (@v)
/*!*/;

View File

@ -698,7 +698,7 @@ master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=10
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
master-bin.000001 # Intvar # # INSERT_ID=10
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`= @b + bug27417(2) ;file_id=#
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= @b + bug27417(2) ;file_id=#
master-bin.000001 # Query # # ROLLBACK
/* the output must denote there is the query */;
drop trigger trg_del_t2;
@ -950,7 +950,7 @@ master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
master-bin.000001 # Intvar # # INSERT_ID=10
master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`= @b + bug27417(2) ;file_id=#
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= @b + bug27417(2) ;file_id=#
master-bin.000001 # Query # # ROLLBACK
drop trigger trg_del_t2;
drop table t1,t2,t3,t4,t5;

View File

@ -738,3 +738,55 @@ SELECT c2 FROM t1;
c2
0
DROP TABLE t1;
CREATE TABLE t1 (a int, index(a)) engine=heap min_rows=10 max_rows=100;
insert into t1 values(1);
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
1600 2400
drop table t1;
CREATE TABLE t1 (a int, index(a)) engine=heap min_rows=10 max_rows=10000;
insert into t1 values(1);
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
16000 24000
drop table t1;
CREATE TABLE t1 (a int, index(a)) engine=heap min_rows=3000 max_rows=3000;
insert into t1 values(1);
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
48000 72000
drop table t1;
CREATE TABLE t1 (a int, index(a)) engine=heap max_rows=15000;
insert into t1 values(1);
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
24000 36000
drop table t1;
create table t1 (c1 int, index(c1)) engine=heap max_rows=10000;
insert into t1 select rand(100000000);
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1 limit 488;
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
16000 24000
insert into t1 select rand(100000000) from t1 limit 1;
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
33024 49024
insert into t1 select rand(100000000) from t1 limit 1000;
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
49024 73024
insert into t1 select rand(100000000) from t1;
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
data_length index_length
81024 121024
drop table t1;

View File

@ -485,3 +485,55 @@ INSERT INTO t1 VALUES('', 0);
ALTER TABLE t1 MODIFY c1 VARCHAR(101);
SELECT c2 FROM t1;
DROP TABLE t1;
#
# Show that MIN_ROWS and MAX_ROWS have an effect on how data_length
# and index_length are allocated.
# Result is different for 32 / 64 bit machines as pointer lengths are different
#
CREATE TABLE t1 (a int, index(a)) engine=heap min_rows=10 max_rows=100;
insert into t1 values(1);
--replace_result 800 1600 1200 2400
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
drop table t1;
CREATE TABLE t1 (a int, index(a)) engine=heap min_rows=10 max_rows=10000;
insert into t1 values(1);
--replace_result 8000 16000 12000 24000
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
drop table t1;
CREATE TABLE t1 (a int, index(a)) engine=heap min_rows=3000 max_rows=3000;
insert into t1 values(1);
--replace_result 24000 48000 36000 72000
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
drop table t1;
CREATE TABLE t1 (a int, index(a)) engine=heap max_rows=15000;
insert into t1 values(1);
--replace_result 12000 24000 18000 36000
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
drop table t1;
create table t1 (c1 int, index(c1)) engine=heap max_rows=10000;
insert into t1 select rand(100000000);
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1;
insert into t1 select rand(100000000) from t1 limit 488;
--replace_result 8000 16000 12000 24000
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
insert into t1 select rand(100000000) from t1 limit 1;
--replace_result 16512 33024 24512 49024
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
insert into t1 select rand(100000000) from t1 limit 1000;
--replace_result 24512 49024 36512 73024
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
insert into t1 select rand(100000000) from t1;
--replace_result 40512 81024 60512 121024
select data_length,index_length from information_schema.tables where table_schema="test" and table_name="t1";
drop table t1;

View File

@ -1,9 +1,9 @@
--source include/have_innodb.inc
--source include/have_debug.inc
if (`select plugin_auth_version <= "1.1.8-26.0" from information_schema.plugins where plugin_name='innodb'`)
if (`select plugin_auth_version <= "1.0.17-13.01" from information_schema.plugins where plugin_name='innodb'`)
{
--skip Not fixed in XtraDB 1.1.8-26.0 or earlier
--skip Not fixed in XtraDB 1.0.17-13.01 or earlier
}
create table t1 (

View File

@ -27,3 +27,6 @@ i
drop table t2;
unlock tables;
drop table t1;
CREATE TABLE t1 (i INT) ENGINE=Aria;
LOCK TABLES t1 WRITE, t1 AS t1a WRITE;
DROP TABLE t1;

View File

@ -42,3 +42,11 @@ select * from t1;
drop table t2;
unlock tables;
drop table t1;
#
# MDEV-366: lock table twice with LOCK TABLES and then drop it
#
CREATE TABLE t1 (i INT) ENGINE=Aria;
LOCK TABLES t1 WRITE, t1 AS t1a WRITE;
DROP TABLE t1;

View File

@ -30,7 +30,7 @@ include/rpl_end.inc
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1293832861/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

View File

@ -0,0 +1,369 @@
include/master-slave.inc
[connection master]
create table t1 (a int primary key) engine=innodb;
create table t2 (a int primary key) engine=myisam;
begin;
insert into t1 values (1);
SET sql_mode = 'ANSI_QUOTES';
savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
insert into t1 values (2);
insert into t2 values (1);
SET sql_mode = '';
rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
insert into t1 values (3);
commit;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t1 (a int primary key) engine=innodb
master-bin.000001 # Query # # use `test`; create table t2 (a int primary key) engine=myisam
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; insert into t2 values (1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; insert into t1 values (1)
master-bin.000001 # Query # # SAVEPOINT "a`; create database couldbebadthingshere; savepoint `dummy"
master-bin.000001 # Query # # use `test`; insert into t1 values (2)
master-bin.000001 # Query # # ROLLBACK TO `a``; create database couldbebadthingshere; savepoint ``dummy`
master-bin.000001 # Query # # use `test`; insert into t1 values (3)
master-bin.000001 # Xid # # COMMIT /* XID */
BEGIN;
insert into t1 values(10);
set sql_mode = 'ANSI_QUOTES';
set sql_quote_show_create = 1;
savepoint a;
insert into t1 values(11);
savepoint "a""a";
insert into t1 values(12);
set sql_quote_show_create = 0;
savepoint b;
insert into t1 values(13);
savepoint "b""b";
insert into t1 values(14);
set sql_mode = '';
set sql_quote_show_create = 1;
savepoint c;
insert into t1 values(15);
savepoint `c``c`;
insert into t1 values(16);
set sql_quote_show_create = 0;
savepoint d;
insert into t1 values(17);
savepoint `d``d`;
insert into t1 values(18);
COMMIT;
set sql_quote_show_create = 1;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; insert into t1 values(10)
master-bin.000001 # Query # # SAVEPOINT "a"
master-bin.000001 # Query # # use `test`; insert into t1 values(11)
master-bin.000001 # Query # # SAVEPOINT "a""a"
master-bin.000001 # Query # # use `test`; insert into t1 values(12)
master-bin.000001 # Query # # SAVEPOINT b
master-bin.000001 # Query # # use `test`; insert into t1 values(13)
master-bin.000001 # Query # # SAVEPOINT "b""b"
master-bin.000001 # Query # # use `test`; insert into t1 values(14)
master-bin.000001 # Query # # SAVEPOINT `c`
master-bin.000001 # Query # # use `test`; insert into t1 values(15)
master-bin.000001 # Query # # SAVEPOINT `c``c`
master-bin.000001 # Query # # use `test`; insert into t1 values(16)
master-bin.000001 # Query # # SAVEPOINT d
master-bin.000001 # Query # # use `test`; insert into t1 values(17)
master-bin.000001 # Query # # SAVEPOINT `d``d`
master-bin.000001 # Query # # use `test`; insert into t1 values(18)
master-bin.000001 # Xid # # COMMIT /* XID */
*** Test correct USE statement in SHOW BINLOG EVENTS ***
set sql_mode = 'ANSI_QUOTES';
CREATE DATABASE "db1`; SELECT 'oops!'";
use "db1`; SELECT 'oops!'";
CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
INSERT INTO t1 VALUES (1);
set sql_mode = '';
INSERT INTO t1 VALUES (2);
set sql_mode = 'ANSI_QUOTES';
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # COMMIT
set sql_mode = '';
set sql_quote_show_create = 0;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # COMMIT
set sql_quote_show_create = 1;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # COMMIT
DROP TABLE t1;
use test;
***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
use `db1``; SELECT 'oops!'`;
set timestamp=1000000000;
CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
`c``3` VARCHAR(7));
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
LINES TERMINATED BY '\n'
(`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
SELECT * FROM `t``1`;
a`1 b`2 c`3
fo\o bar |b"a'z!
truncate `t``1`;
use test;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt'
INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
LINES TERMINATED BY '\n'
(`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
a`1 b`2 c`3
fo\o bar |b"a'z!
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
`c``3` VARCHAR(7))
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
master-bin.000001 # Execute_load_query # # use `db1``; SELECT 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!") ;file_id=#
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; truncate `t``1`
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=#
master-bin.000001 # Query # # COMMIT
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use `db1``; SELECT 'oops!'`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
`c``3` VARCHAR(7))
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
LOAD DATA LOCAL INFILE '<name>' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!")
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
truncate `t``1`
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!")
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
a`1 b`2 c`3
fo\o bar |b"a'z!
DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
drop table t1,t2;
*** Test truncation of long SET expression in LOAD DATA ***
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE t1
FIELDS TERMINATED BY ','
(a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
SELECT * FROM t1 ORDER BY a;
a b
1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b) ;file_id=#
master-bin.000001 # Query # # COMMIT
SELECT * FROM t1 ORDER BY a;
a b
1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
DROP TABLE t1;
*** Test user variables whose names require correct quoting ***
use `db1``; SELECT 'oops!'`;
CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
@`a``1`:=a1 @`a``2`:=a2 @`a``3`:=a3 @`a``4`:=a4 @`b```:=b @```c`:=c @```d```:=d
-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.234560123456789e125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # User var # # @`a``1`=-9223372036854775808
master-bin.000001 # User var # # @`a``2`=42
master-bin.000001 # User var # # @`a``3`=9223372036854775807
master-bin.000001 # User var # # @`a``4`=18446744073709551615
master-bin.000001 # User var # # @`b```=-1.234560123456789e125
master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
master-bin.000001 # Query # # COMMIT
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use `db1``; SELECT 'oops!'`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
SET @`a``1`:=-9223372036854775808/*!*/;
SET @`a``2`:=42/*!*/;
SET @`a``3`:=9223372036854775807/*!*/;
SET @`a``4`:=18446744073709551615/*!*/;
SET @`b```:=-1.2345601234568e+125/*!*/;
SET @```c`:=-1234501234567890123456789012345678901234567890123456789.0123456789/*!*/;
SET @```d```:=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE `latin1_swedish_ci`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
a1 a2 a3 a4 b c d
-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.234560123456789e125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-9223372036854775807 4200 9223372036854775806 18446744073709551614 -6.172800617283945e124 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DROP TABLE t1;
*** Test correct quoting in foreign key error message ***
use `db1``; SELECT 'oops!'`;
CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
TRUNCATE `t``1`;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`db1``; SELECT 'oops!'`.`t``2`, CONSTRAINT `INNODB_FOREIGN_KEY_NAME` FOREIGN KEY (`c```) REFERENCES `db1``; SELECT 'oops!'`.`t``1` (`a```))
DROP TABLE `t``2`;
DROP TABLE `t``1`;
*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
include/stop_slave.inc
CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
a`
1
2
5
set timestamp=1000000000;
# The table should be empty on the master.
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
a`
# The DELETE statement should be correctly quoted
show binlog events in 'master-bin.000002' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Query # # BEGIN
master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; SELECT 'oops!'`.`t``1`
master-bin.000002 # Query # # COMMIT
include/start_slave.inc
# The table should be empty on the slave also.
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
a`
DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
use test;
DROP DATABASE `db1``; SELECT 'oops!'`;
*** Test correct quoting of mysqlbinlog --rewrite-db option ***
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES(1);
show binlog events in 'master-bin.000002' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Query # # BEGIN
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES(1)
master-bin.000002 # Query # # COMMIT
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
use `ts``et`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
INSERT INTO t1 VALUES(1)
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
DROP TABLE t1;
include/rpl_end.inc

View File

@ -154,7 +154,7 @@ c1 c3 c4 c5
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -176,7 +176,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -287,7 +287,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
@ -318,7 +318,7 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
ROLLBACK/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=999999999/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

View File

@ -670,7 +670,7 @@ drop database if exists mysqltest1
SET TIMESTAMP=t/*!*/;
create database mysqltest1
/*!*/;
use mysqltest1/*!*/;
use `mysqltest1`/*!*/;
SET TIMESTAMP=t/*!*/;
create table t1 (a varchar(100))
/*!*/;
@ -1015,7 +1015,7 @@ drop database mysqltest1
SET TIMESTAMP=t/*!*/;
drop user "zedjzlcsjhd"@127.0.0.1
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=t/*!*/;
drop function if exists f1
/*!*/;
@ -1112,7 +1112,7 @@ create database mysqltest
SET TIMESTAMP=t/*!*/;
create database mysqltest2
/*!*/;
use mysqltest2/*!*/;
use `mysqltest2`/*!*/;
SET TIMESTAMP=t/*!*/;
create table t ( t integer )
/*!*/;
@ -1139,7 +1139,7 @@ end
SET TIMESTAMP=t/*!*/;
BEGIN
/*!*/;
use mysqltest/*!*/;
use `mysqltest`/*!*/;
SET TIMESTAMP=t/*!*/;
SELECT `mysqltest2`.`f1`()
/*!*/;
@ -1152,14 +1152,14 @@ drop database mysqltest
SET TIMESTAMP=t/*!*/;
drop database mysqltest2
/*!*/;
use test/*!*/;
use `test`/*!*/;
SET TIMESTAMP=t/*!*/;
CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltestbug36570_p1`()
begin
select 1;
end
/*!*/;
use mysql/*!*/;
use `mysql`/*!*/;
SET TIMESTAMP=t/*!*/;
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.` mysqltestbug36570_p2`( a int)
`label`:

View File

@ -0,0 +1,31 @@
include/master-slave.inc
[connection master]
# connection: slave
SET @save_slave_net_timeout = @@GLOBAL.slave_net_timeout;
STOP SLAVE;
include/wait_for_slave_to_stop.inc
# open an extra connection to the slave
# connection: slave2
# set debug synchronization point
SET DEBUG_SYNC='fix_slave_net_timeout SIGNAL parked WAIT_FOR go';
# attempt to set slave_net_timeout, will wait on sync point
SET @@GLOBAL.slave_net_timeout = 100;
# connection: slave
SET DEBUG_SYNC='now WAIT_FOR parked';
# connection: slave1
# attempt to start the SQL thread
START SLAVE SQL_THREAD;
# connection: slave
# wait until SQL thread has been started
# sleep a bit so that the SQL thread THD handle is initialized
# signal the set slave_net_timeout to continue
SET DEBUG_SYNC='now SIGNAL go';
# connection: slave2
# reap result of set slave_net_timeout
# connection: slave1
# reap result of starting the SQL thread
# disconnect: slave2
# connection: slave
# cleanup
SET @@GLOBAL.slave_net_timeout = @save_slave_net_timeout;
include/rpl_end.inc

View File

@ -0,0 +1,265 @@
--source include/have_innodb.inc
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
# MDEV-382: multiple SQL injections in replication code.
# Test previous SQL injection attack against binlog for SAVEPOINT statement.
# The test would cause syntax error on slave due to improper quoting of
# the savepoint name.
connection master;
create table t1 (a int primary key) engine=innodb;
create table t2 (a int primary key) engine=myisam;
begin;
insert into t1 values (1);
SET sql_mode = 'ANSI_QUOTES';
savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
insert into t1 values (2);
insert into t2 values (1);
SET sql_mode = '';
rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
insert into t1 values (3);
commit;
--source include/show_binlog_events.inc
# This failed due to syntax error in query when the bug was not fixed.
sync_slave_with_master;
connection slave;
# Test some more combinations of ANSI_QUOTES and sql_quote_show_create
connection master;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
BEGIN;
insert into t1 values(10);
set sql_mode = 'ANSI_QUOTES';
set sql_quote_show_create = 1;
savepoint a;
insert into t1 values(11);
savepoint "a""a";
insert into t1 values(12);
set sql_quote_show_create = 0;
savepoint b;
insert into t1 values(13);
savepoint "b""b";
insert into t1 values(14);
set sql_mode = '';
set sql_quote_show_create = 1;
savepoint c;
insert into t1 values(15);
savepoint `c``c`;
insert into t1 values(16);
set sql_quote_show_create = 0;
savepoint d;
insert into t1 values(17);
savepoint `d``d`;
insert into t1 values(18);
COMMIT;
set sql_quote_show_create = 1;
--source include/show_binlog_events.inc
--echo *** Test correct USE statement in SHOW BINLOG EVENTS ***
connection master;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
set sql_mode = 'ANSI_QUOTES';
CREATE DATABASE "db1`; SELECT 'oops!'";
use "db1`; SELECT 'oops!'";
CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
INSERT INTO t1 VALUES (1);
set sql_mode = '';
INSERT INTO t1 VALUES (2);
set sql_mode = 'ANSI_QUOTES';
--source include/show_binlog_events.inc
set sql_mode = '';
set sql_quote_show_create = 0;
--source include/show_binlog_events.inc
set sql_quote_show_create = 1;
--source include/show_binlog_events.inc
DROP TABLE t1;
use test;
--echo ***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
--let $load_file= $MYSQLTEST_VARDIR/tmp/f'le.txt
--write_file $load_file
'fo\\o','bar'
EOF
use `db1``; SELECT 'oops!'`;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
set timestamp=1000000000;
CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
`c``3` VARCHAR(7));
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
LINES TERMINATED BY '\\n'
(`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
SELECT * FROM `t``1`;
# Also test when code prefixes table name with database.
truncate `t``1`;
use test;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt'
INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
LINES TERMINATED BY '\\n'
(`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
--source include/show_binlog_events.inc
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /LOCAL INFILE '.*SQL_LOAD.*' INTO/LOCAL INFILE '<name>' INTO/
--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
sync_slave_with_master;
connection slave;
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
connection master;
DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
--remove_file $load_file
connection master;
drop table t1,t2;
--echo *** Test truncation of long SET expression in LOAD DATA ***
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
--let $load_file= $MYSQLTEST_VARDIR/tmp/file.txt
--write_file $load_file
1,X
2,A
EOF
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
# The bug was that the SET expression was truncated to 256 bytes, so test with
# an expression longer than that.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$load_file' INTO TABLE t1
FIELDS TERMINATED BY ','
(a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
SELECT * FROM t1 ORDER BY a;
--source include/show_binlog_events.inc
sync_slave_with_master;
connection slave;
SELECT * FROM t1 ORDER BY a;
connection master;
--remove_file $load_file
DROP TABLE t1;
--echo *** Test user variables whose names require correct quoting ***
use `db1``; SELECT 'oops!'`;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
--source include/show_binlog_events.inc
--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
sync_slave_with_master;
connection slave;
SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
connection master;
DROP TABLE t1;
--echo *** Test correct quoting in foreign key error message ***
use `db1``; SELECT 'oops!'`;
CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
--replace_regex /t@[0-9]+_ibfk_[0-9]+/INNODB_FOREIGN_KEY_NAME/
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE `t``1`;
DROP TABLE `t``2`;
DROP TABLE `t``1`;
--echo *** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
# Let's keep the slave stopped during master restart, to avoid any potential
# races between slave reconnect and master restart.
connection slave;
--source include/stop_slave.inc
connection master;
CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
# Restart the master mysqld.
# This will cause an implicit truncation of the memory-based table, which will
# cause logging of an explicit DELETE FROM to binlog.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait-rpl_mdev382.test
EOF
--shutdown_server 30
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart-rpl_mdev382.test
EOF
connection default;
--enable_reconnect
--source include/wait_until_connected_again.inc
# rpl_end.inc needs to use the connection server_1
connection server_1;
--enable_reconnect
--source include/wait_until_connected_again.inc
connection master;
--enable_reconnect
--source include/wait_until_connected_again.inc
set timestamp=1000000000;
--echo # The table should be empty on the master.
let $binlog_file= master-bin.000002;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
--echo # The DELETE statement should be correctly quoted
--source include/show_binlog_events.inc
connection slave;
--source include/start_slave.inc
connection master;
sync_slave_with_master;
connection slave;
--echo # The table should be empty on the slave also.
SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
connection master;
DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
sync_slave_with_master;
connection master;
use test;
DROP DATABASE `db1``; SELECT 'oops!'`;
--echo *** Test correct quoting of mysqlbinlog --rewrite-db option ***
CREATE TABLE t1 (a INT PRIMARY KEY);
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
INSERT INTO t1 VALUES(1);
--source include/show_binlog_events.inc
let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 --rewrite-db='test->ts`et' $MYSQLD_DATADIR/master-bin.000002
DROP TABLE t1;
--source include/rpl_end.inc

View File

@ -0,0 +1,57 @@
source include/have_debug_sync.inc;
source include/master-slave.inc;
--echo # connection: slave
connection slave;
SET @save_slave_net_timeout = @@GLOBAL.slave_net_timeout;
STOP SLAVE;
source include/wait_for_slave_to_stop.inc;
--echo # open an extra connection to the slave
connect(slave2,127.0.0.1,root,,test,$SLAVE_MYPORT,);
--echo # connection: slave2
--echo # set debug synchronization point
SET DEBUG_SYNC='fix_slave_net_timeout SIGNAL parked WAIT_FOR go';
--echo # attempt to set slave_net_timeout, will wait on sync point
--send SET @@GLOBAL.slave_net_timeout = 100
--echo # connection: slave
connection slave;
SET DEBUG_SYNC='now WAIT_FOR parked';
--echo # connection: slave1
connection slave1;
--echo # attempt to start the SQL thread
--send START SLAVE SQL_THREAD
--echo # connection: slave
connection slave;
--echo # wait until SQL thread has been started
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for slave thread to start" and info = "START SLAVE SQL_THREAD";
--source include/wait_condition.inc
--echo # sleep a bit so that the SQL thread THD handle is initialized
sleep 2;
--echo # signal the set slave_net_timeout to continue
SET DEBUG_SYNC='now SIGNAL go';
--echo # connection: slave2
connection slave2;
--echo # reap result of set slave_net_timeout
--reap
--echo # connection: slave1
connection slave1;
--echo # reap result of starting the SQL thread
--reap
--echo # disconnect: slave2
disconnect slave2;
--echo # connection: slave
connection slave;
--echo # cleanup
SET @@GLOBAL.slave_net_timeout = @save_slave_net_timeout;
source include/rpl_end.inc;

View File

@ -174,6 +174,16 @@ drop table t1, t2;
--echo End of 5.0 tests
#
# lp:1001510
# Bug #11764313 57135: CRASH IN ITEM_FUNC_CASE::FIND_ITEM WITH CASE WHEN
# ELSE CLAUSE
#
CREATE TABLE t1(a YEAR);
SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END;
DROP TABLE t1;
#
# lp:839387 Assertion `(Item_result)i != TIME_RESULT' failed with CASE + datetime
#
@ -182,3 +192,4 @@ create table t1 (f1 time);
insert t1 values ('00:00:00'),('00:01:00');
select case t1.f1 when '00:00:00' then 1 end from t1;
drop table t1;

View File

@ -86,3 +86,11 @@ SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00';
DROP TABLE t1;
--echo End of 5.0 tests
#
# Bug #11764818 57692: Crash in item_func_in::val_int() with ZEROFILL
#
CREATE TABLE t1(a INT ZEROFILL);
SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2;
DROP TABLE t1;

View File

@ -84,20 +84,6 @@ select count(*), min(7), max(7) from t2m, t1i;
drop table t1m, t1i, t2m, t2i;
--echo #
--echo # Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN
--echo #
CREATE TABLE t1(a BLOB, b VARCHAR(255) CHARSET LATIN1, c INT,
KEY(b, c, a(765))) ENGINE=INNODB;
INSERT INTO t1(a, b, c) VALUES ('', 'a', 0), ('', 'a', null), ('', 'a', 0);
SELECT MIN(c) FROM t1 GROUP BY b;
EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
DROP TABLE t1;
--echo #
--echo # Bug #57954: BIT_AND function returns incorrect results when
--echo # semijoin=on
@ -173,4 +159,19 @@ SELECT member_id_to, COUNT(*) FROM t1 WHERE r_date =
DROP TABLE t1;
--echo # End of test BUG#12713907
--echo #
--echo # Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN
--echo #
CREATE TABLE t1(a BLOB, b VARCHAR(255) CHARSET LATIN1, c INT,
KEY(b, c, a(765))) ENGINE=INNODB;
INSERT INTO t1(a, b, c) VALUES ('', 'a', 0), ('', 'a', null), ('', 'a', 0);
SELECT MIN(c) FROM t1 GROUP BY b;
EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
DROP TABLE t1;
--echo End of 5.5 tests

View File

@ -1613,3 +1613,42 @@ SELECT t2.b FROM t1, t2 WHERE t1.b = t2.a GROUP BY t2.b ORDER BY t1.b;
drop table t1,t2;
--echo End of 5.2 tests
--echo #
--echo # Bug mdev-449: ORDER BY with small sort_buffer_size
--echo #
CREATE TABLE t1(f0 int auto_increment primary key, f1 int, f2 varchar(200));
INSERT INTO t1(f1, f2) VALUES
(0,"0"),(1,"1"),(2,"2"),(3,"3"),(4,"4"),(5,"5"),
(6,"6"),(7,"7"),(8,"8"),(9,"9"),(10,"10"),
(11,"11"),(12,"12"),(13,"13"),(14,"14"),(15,"15"),
(16,"16"),(17,"17"),(18,"18"),(19,"19"),(20,"20"),
(21,"21"),(22,"22"),(23,"23"),(24,"24"),(25,"25"),
(26,"26"),(27,"27"),(28,"28"),(29,"29"),(30,"30"),
(31,"31"),(32,"32"),(33,"33"),(34,"34"),(35,"35"),
(36,"36"),(37,"37"),(38,"38"),(39,"39"),(40,"40"),
(41,"41"),(42,"42"),(43,"43"),(44,"44"),(45,"45"),
(46,"46"),(47,"47"),(48,"48"),(49,"49"),(50,"50"),
(51,"51"),(52,"52"),(53,"53"),(54,"54"),(55,"55"),
(56,"56"),(57,"57"),(58,"58"),(59,"59"),(60,"60"),
(61,"61"),(62,"62"),(63,"63"),(64,"64"),(65,"65"),
(66,"66"),(67,"67"),(68,"68"),(69,"69"),(70,"70"),
(71,"71"),(72,"72"),(73,"73"),(74,"74"),(75,"75"),
(76,"76"),(77,"77"),(78,"78"),(79,"79"),(80,"80"),
(81,"81"),(82,"82"),(83,"83"),(84,"84"),(85,"85"),
(86,"86"),(87,"87"),(88,"88"),(89,"89"),(90,"90"),
(91,"91"),(92,"92"),(93,"93"),(94,"94"),(95,"95"),
(96,"96"),(97,"97"),(98,"98"),(99,"99");
set @save_sort_buffer_size= @@sort_buffer_size;
set sort_buffer_size= 2000;
SELECT * FROM t1 ORDER BY f1 DESC, f0;
set sort_buffer_size= @save_sort_buffer_size;
DROP TABLE t1;
--echo End of 5.3 tests

View File

@ -2476,3 +2476,13 @@ SELECT 1 FROM t1 AS t1_0 JOIN t1 ON t1_0.a LIKE (SELECT 1 FROM t1);
SELECT * FROM vtmp;
DROP VIEW vtmp;
DROP TABLE t1;
--echo #
--echo # MDEV-365 "Got assertion when doing alter table on a partition"
--echo #
CREATE TABLE t1 ( i INT ) ENGINE=Aria PARTITION BY HASH(i) PARTITIONS 2;
INSERT INTO t1 VALUES (1),(2),(2),(3),(4);
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
SELECT * from t1 order by i;
DROP TABLE t1;

View File

@ -3125,7 +3125,7 @@ DROP TABLE t1;
--echo End of 5.1 tests.
--echo #
--echo # LP bug#1001500 Crash on the second execution of the PS for
--echo # lp:1001500 Crash on the second execution of the PS for
--echo # a query with degenerated conjunctive condition
--echo # (see also mysql bug#12582849)
--echo #
@ -3572,94 +3572,4 @@ show status like '%Handler_read%';
deallocate prepare st;
drop table t1;
--echo #
--echo # LP bug#993459 Execution of PS for a query with GROUP BY
--echo # returns wrong result (see also mysql bug#13805127)
--echo #
PREPARE s1 FROM
"
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2
";
--echo
SET @x = 1;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:99345900:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
--echo
EXECUTE s1;
--echo
SET @x = 2;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
--echo
EXECUTE s1;
--echo
SET @x = 1;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
--echo
EXECUTE s1;
DEALLOCATE PREPARE s1;
--echo # End of 5.3 tests

View File

@ -9111,9 +9111,14 @@ DROP FUNCTION f1;
--echo # ------------------------------------------------------------------
--echo #
--echo # LP bug#993459 Execution of PS for a query with GROUP BY
--echo # lp:993459 Execution of PS for a query with GROUP BY
--echo # returns wrong result (see also mysql bug#13805127)
--echo #
--echo
--echo # Bug#13805127: Stored program cache produces wrong result in same THD
--echo
delimiter |;
CREATE PROCEDURE p1(x INT UNSIGNED)
@ -9147,7 +9152,7 @@ CALL p1(1);
DROP PROCEDURE p1;
--echo #
--echo # LP bug#1002157 : testing stored function
--echo # lp:1002157 : testing stored function
--echo # bug#62125 result for null incorrectly yields 1292 warning.
--echo #

View File

@ -5576,7 +5576,28 @@ SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 U
drop table t1;
--echo #
--echo # LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
--echo # MDEV-367: Different results with and without subquery_cache on
--echo # a query with a constant NOT IN condition
--echo #
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
set @mdev367_optimizer_switch = @@optimizer_switch;
set optimizer_switch = 'subquery_cache=on';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
set optimizer_switch=@mdev367_optimizer_switch;
set optimizer_switch = 'subquery_cache=off';
SELECT * FROM t1 WHERE ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) OR a > 100;
SELECT *, ( 3, 3 ) NOT IN ( SELECT NULL, NULL ) FROM t1;
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
--echo #
--echo # lp:944706 Query with impossible or constant subquery in WHERE or HAVING is not
--echo # precomputed and thus not part of optimization
--echo #
@ -5721,5 +5742,30 @@ set global userstat=@tmp_mdev410;
DROP TABLE t1,t2,t3,t4;
--echo # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
--echo #
--echo # MDEV-430: Server crashes in select_describe on EXPLAIN with
--echo # materialization+semijoin, 2 nested subqueries, aggregate functions
--echo #
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
DROP TABLE t1,t2;
--echo #
--echo # MDEV-405: Server crashes in test_if_skip_sort_order on EXPLAIN with GROUP BY and HAVING in EXISTS subquery
--echo #
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(8);
CREATE TABLE t2 (b INT, KEY(b));
INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
DROP TABLE t1,t2;

View File

@ -287,6 +287,40 @@ my_off_t my_b_filelength(IO_CACHE *info)
}
size_t
my_b_write_backtick_quote(IO_CACHE *info, const char *str, size_t len)
{
const uchar *start;
const uchar *p= (const uchar *)str;
const uchar *end= p + len;
size_t count;
size_t total= 0;
if (my_b_write(info, (uchar *)"`", 1))
return (size_t)-1;
++total;
for (;;)
{
start= p;
while (p < end && *p != '`')
++p;
count= p - start;
if (count && my_b_write(info, start, count))
return (size_t)-1;
total+= count;
if (p >= end)
break;
if (my_b_write(info, (uchar *)"``", 2))
return (size_t)-1;
total+= 2;
++p;
}
if (my_b_write(info, (uchar *)"`", 1))
return (size_t)-1;
++total;
return total;
}
/*
Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu"
Used for logging in MySQL
@ -311,6 +345,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
uint minimum_width_sign;
uint precision; /* as yet unimplemented for anything but %b */
my_bool is_zero_padded;
my_bool backtick_quoting;
/*
Store the location of the beginning of a format directive, for the
@ -345,6 +380,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
fmt++;
is_zero_padded= FALSE;
backtick_quoting= FALSE;
minimum_width_sign= 1;
minimum_width= 0;
precision= 0;
@ -357,6 +393,8 @@ process_flags:
minimum_width_sign= -1; fmt++; goto process_flags;
case '0':
is_zero_padded= TRUE; fmt++; goto process_flags;
case '`':
backtick_quoting= TRUE; fmt++; goto process_flags;
case '#':
/** @todo Implement "#" conversion flag. */ fmt++; goto process_flags;
case ' ':
@ -400,9 +438,19 @@ process_flags:
reg2 char *par = va_arg(args, char *);
size_t length2 = strlen(par);
/* TODO: implement precision */
out_length+= length2;
if (my_b_write(info, (uchar*) par, length2))
goto err;
if (backtick_quoting)
{
size_t total= my_b_write_backtick_quote(info, (uchar *) par, length2);
if (total == (size_t)-1)
goto err;
out_length+= total;
}
else
{
out_length+= length2;
if (my_b_write(info, (uchar*) par, length2))
goto err;
}
}
else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */
{

View File

@ -193,7 +193,9 @@ uint32 wt_success_stats;
static my_atomic_rwlock_t cycle_stats_lock, wait_stats_lock, success_stats_lock;
#ifdef HAVE_PSI_INTERFACE
extern PSI_cond_key key_WT_RESOURCE_cond;
#endif
#ifdef SAFE_STATISTICS
#define incr(VAR, LOCK) \

View File

@ -107,7 +107,7 @@ static int conv(int n, const struct pam_message **msg,
#define DO(X) if ((status = (X)) != PAM_SUCCESS) goto end
#ifdef SOLARIS
#if defined(SOLARIS) || defined(__sun)
typedef void** pam_get_item_3_arg;
#else
typedef const void** pam_get_item_3_arg;

View File

@ -1049,10 +1049,11 @@ int ReplSemiSyncMaster::readSlaveReply(NET *net, uint32 server_id,
ulong log_file_len = 0;
ulong packet_len;
int result = -1;
struct timespec start_ts;
ulong trc_level = trace_level_;
LINT_INIT_STRUCT(start_ts);
function_enter(kWho);
assert((unsigned char)event_buf[1] == kPacketMagicNum);

View File

@ -283,6 +283,7 @@ SET(mysql_config_COMPONENT COMPONENT Development)
SET(msql2mysql_COMPONENT COMPONENT Client)
SET(mysqlaccess_COMPONENT COMPONENT Client)
SET(mysql_find_rows_COMPONENT COMPONENT Client)
SET(mytop_COMPONENT Client)
IF(WIN32)
# On Windows, some .sh and some .pl.in files are configured
@ -311,7 +312,6 @@ IF(WIN32)
ENDFOREACH()
ELSE()
# On Unix, most of the files end up in the bin directory
SET(mysql_config_COMPONENT COMPONENT Development)
SET(BIN_SCRIPTS
msql2mysql
mysql_config
@ -322,6 +322,7 @@ ELSE()
mysqlaccess
mysql_convert_table_format
mysql_find_rows
mytop
mysqlhotcopy
mysqldumpslow
mysqld_multi

File diff suppressed because one or more lines are too long

View File

@ -137,7 +137,10 @@ static bool set_one_value(ha_create_table_option *opt,
my_option optp=
{ opt->name, 1, 0, (uchar **)val, 0, 0, GET_ULL,
REQUIRED_ARG, opt->def_value, opt->min_value, opt->max_value,
REQUIRED_ARG,
(longlong) opt->def_value,
(longlong) opt->min_value,
opt->max_value,
0, (long) opt->block_size, 0};
ulonglong orig_val= strtoull(value->str, NULL, 10);

View File

@ -103,6 +103,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
int error;
ulong memory_available= thd->variables.sortbuff_size;
ulong min_sort_memory;
ulong sort_buff_sz;
uint maxbuffer;
BUFFPEK *buffpek;
ha_rows num_rows= HA_POS_ERROR;
@ -193,19 +194,21 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
goto err;
min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length * MERGEBUFF2);
set_if_bigger(min_sort_memory, sizeof(BUFFPEK*)*MERGEBUFF2);
if (!table_sort.sort_keys)
{
while (memory_available >= min_sort_memory)
{
ulong keys= memory_available / (param.rec_length + sizeof(char*));
table_sort.keys= (uint) min(num_rows, keys);
sort_buff_sz= table_sort.keys*(param.rec_length+sizeof(char*));
set_if_bigger(sort_buff_sz, param.rec_length * MERGEBUFF2);
DBUG_EXECUTE_IF("make_sort_keys_alloc_fail",
DBUG_SET("+d,simulate_out_of_memory"););
if ((table_sort.sort_keys=
(uchar**) my_malloc(table_sort.keys*(param.rec_length+sizeof(char*)),
MYF(0))))
(uchar**) my_malloc(sort_buff_sz, MYF(0))))
break;
ulong old_memory_available= memory_available;
memory_available= memory_available/4*3;
@ -1259,9 +1262,8 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
to_start_filepos= my_b_tell(to_file);
strpos= sort_buffer;
org_max_rows=max_rows= param->max_rows;
/* The following will fire if there is not enough space in sort_buffer */
DBUG_ASSERT(maxcount!=0);
set_if_bigger(maxcount, 1);
if (unique_buff)
{

View File

@ -1295,7 +1295,9 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share,
DBUG_RETURN(0);
}
char tmp_buf2[FN_REFLEN];
char tmp_buf2_mem[FN_REFLEN];
String tmp_buf2(tmp_buf2_mem, sizeof(tmp_buf2_mem), system_charset_info);
tmp_buf2.length(0);
const char *type_str;
switch (type)
{
@ -1304,17 +1306,24 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share,
if (thd->lex->sql_command == SQLCOM_DROP_DB)
DBUG_RETURN(0);
/* redo the drop table query as is may contain several tables */
query= tmp_buf2;
query_length= (uint) (strxmov(tmp_buf2, "drop table `",
table_name, "`", NullS) - tmp_buf2);
tmp_buf2.append(STRING_WITH_LEN("drop table "));
append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
query= tmp_buf2.c_ptr_safe();
query_length= tmp_buf2.length();
type_str= "drop table";
break;
case SOT_RENAME_TABLE:
/* redo the rename table query as is may contain several tables */
query= tmp_buf2;
query_length= (uint) (strxmov(tmp_buf2, "rename table `",
db, ".", table_name, "` to `",
new_db, ".", new_table_name, "`", NullS) - tmp_buf2);
tmp_buf2.append(STRING_WITH_LEN("rename table "));
append_identifier(thd, &tmp_buf2, db, strlen(db));
tmp_buf2.append(STRING_WITH_LEN("."));
append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
tmp_buf2.append(STRING_WITH_LEN(" to "));
append_identifier(thd, &tmp_buf2, new_db, strlen(new_db));
tmp_buf2.append(STRING_WITH_LEN("."));
append_identifier(thd, &tmp_buf2, new_table_name, strlen(new_table_name));
query= tmp_buf2.c_ptr_safe();
query_length= tmp_buf2.length();
type_str= "rename table";
break;
case SOT_CREATE_TABLE:

View File

@ -3837,7 +3837,7 @@ int ha_partition::truncate_partition(Alter_info *alter_info, bool *binlog_stmt)
{
List_iterator<partition_element>
subpart_it(part_elem->subpartitions);
partition_element *sub_elem;
partition_element *sub_elem __attribute__((unused));
uint j= 0, part;
do
{

View File

@ -3009,7 +3009,7 @@ void handler::print_error(int error, myf errflag)
textno=ER_TABLE_DEF_CHANGED;
break;
case HA_ERR_NO_SUCH_TABLE:
my_error(ER_NO_SUCH_TABLE, errflag, table_share->db.str,
my_error(ER_NO_SUCH_TABLE_IN_ENGINE, errflag, table_share->db.str,
table_share->table_name.str);
DBUG_VOID_RETURN;
case HA_ERR_RBR_LOGGING_FAILED:
@ -4800,10 +4800,14 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
db_type->show_status(db_type, thd, stat_print, stat) ? 1 : 0;
}
if (!result)
/*
We also check thd->is_error() as Innodb may return 0 even if
there was an error.
*/
if (!result && !thd->is_error())
my_eof(thd);
else if (!thd->is_error())
my_error(ER_GET_ERRNO, MYF(0), 0);
my_error(ER_GET_ERRNO, MYF(0), errno);
return result;
}

View File

@ -992,15 +992,31 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
if (!my_charset_same(cs, system_charset_info))
{
size_t res_length;
name= sql_strmake_with_convert(str, name_length= length, cs,
name= sql_strmake_with_convert(str, length, cs,
MAX_ALIAS_NAME, system_charset_info,
&res_length);
name_length= res_length;
}
else
name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
}
void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs)
{
if (!my_charset_same(cs, system_charset_info))
{
size_t res_length;
name= sql_strmake_with_convert(str, length, cs,
UINT_MAX, system_charset_info,
&res_length);
name_length= res_length;
}
else
name= sql_strmake(str, (name_length= length));
}
void Item::set_name_for_rollback(THD *thd, const char *str, uint length,
CHARSET_INFO *cs)
{

View File

@ -656,6 +656,7 @@ public:
#endif
} /*lint -e1509 */
void set_name(const char *str, uint length, CHARSET_INFO *cs);
void set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs);
void set_name_for_rollback(THD *thd, const char *str, uint length,
CHARSET_INFO *cs);
void rename(char *new_name);

View File

@ -3089,6 +3089,15 @@ void Item_func_case::fix_length_and_dec()
return;
}
}
/*
Set cmp_context of all WHEN arguments. This prevents
Item_field::equal_fields_propagator() from transforming a
zerofill argument into a string constant. Such a change would
require rebuilding cmp_items.
*/
for (i= 0; i < ncases; i+= 2)
args[i]->cmp_context= item_cmp_type(left_result_type,
args[i]->result_type());
}
if (else_expr_num == -1 || args[else_expr_num]->maybe_null)
@ -4069,6 +4078,16 @@ void Item_func_in::fix_length_and_dec()
}
}
}
/*
Set cmp_context of all arguments. This prevents
Item_field::equal_fields_propagator() from transforming a zerofill integer
argument into a string constant. Such a change would require rebuilding
cmp_itmes.
*/
for (arg= args + 1, arg_end= args + arg_count; arg != arg_end ; arg++)
{
arg[0]->cmp_context= item_cmp_type(left_result_type, arg[0]->result_type());
}
max_length= 1;
}

View File

@ -5443,10 +5443,10 @@ my_decimal* Item_user_var_as_out_param::val_decimal(my_decimal *decimal_buffer)
}
void Item_user_var_as_out_param::print(String *str, enum_query_type query_type)
void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
{
str->append('@');
str->append(name.str,name.length);
append_identifier(thd, str, name.str, name.length);
}

View File

@ -1670,7 +1670,7 @@ public:
my_decimal *val_decimal(my_decimal *decimal_buffer);
/* fix_fields() binds variable name with its entry structure */
bool fix_fields(THD *thd, Item **ref);
virtual void print(String *str, enum_query_type query_type);
void print_for_load(THD *thd, String *str);
void set_null_value(CHARSET_INFO* cs);
void set_value(const char *str, uint length, CHARSET_INFO* cs);
};

View File

@ -819,7 +819,9 @@ table_map Item_subselect::used_tables() const
bool Item_subselect::const_item() const
{
return thd->lex->context_analysis_only ? FALSE : const_item_cache;
return (thd->lex->context_analysis_only ?
FALSE :
forced_const || const_item_cache);
}
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
@ -1272,7 +1274,7 @@ bool Item_singlerow_subselect::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
else
{
reset();
return 0;
return 1;
}
}
@ -1538,6 +1540,10 @@ double Item_in_subselect::val_real()
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
if (forced_const)
return value;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
! engine->is_executed());
null_value= was_null= FALSE;
if (exec())
{
@ -1558,6 +1564,10 @@ longlong Item_in_subselect::val_int()
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
if (forced_const)
return value;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
! engine->is_executed());
null_value= was_null= FALSE;
if (exec())
{
@ -1578,6 +1588,10 @@ String *Item_in_subselect::val_str(String *str)
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
if (forced_const)
goto value_is_ready;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
! engine->is_executed());
null_value= was_null= FALSE;
if (exec())
{
@ -1589,6 +1603,7 @@ String *Item_in_subselect::val_str(String *str)
null_value= TRUE;
return 0;
}
value_is_ready:
str->set((ulonglong)value, &my_charset_bin);
return str;
}
@ -1599,6 +1614,8 @@ bool Item_in_subselect::val_bool()
DBUG_ASSERT(fixed == 1);
if (forced_const)
return value;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
! engine->is_executed());
null_value= was_null= FALSE;
if (exec())
{
@ -1617,6 +1634,10 @@ my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value)
method should not be used
*/
DBUG_ASSERT(0);
if (forced_const)
goto value_is_ready;
DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) ||
! engine->is_executed());
null_value= was_null= FALSE;
DBUG_ASSERT(fixed == 1);
if (exec())
@ -1626,6 +1647,7 @@ my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value)
}
if (was_null && !value)
null_value= TRUE;
value_is_ready:
int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value);
return decimal_value;
}
@ -3176,6 +3198,8 @@ int subselect_single_select_engine::exec()
tab->read_record.read_record= tab->save_read_record;
}
executed= 1;
if (!(uncacheable() & ~UNCACHEABLE_EXPLAIN))
item->make_const();
thd->where= save_where;
thd->lex->current_select= save_select;
DBUG_RETURN(join->error || thd->is_fatal_error || thd->is_error());
@ -5167,10 +5191,20 @@ Ordered_key::cmp_keys_by_row_data(ha_rows a, ha_rows b)
rowid_a= row_num_to_rowid + a * rowid_length;
rowid_b= row_num_to_rowid + b * rowid_length;
/* Fetch the rows for comparison. */
error= tbl->file->ha_rnd_pos(tbl->record[0], rowid_a);
DBUG_ASSERT(!error);
error= tbl->file->ha_rnd_pos(tbl->record[1], rowid_b);
DBUG_ASSERT(!error);
if ((error= tbl->file->ha_rnd_pos(tbl->record[0], rowid_a)))
{
/* purecov: begin inspected */
tbl->file->print_error(error, MYF(ME_FATALERROR)); // Sets fatal_error
return 0;
/* purecov: end */
}
if ((error= tbl->file->ha_rnd_pos(tbl->record[1], rowid_b)))
{
/* purecov: begin inspected */
tbl->file->print_error(error, MYF(ME_FATALERROR)); // Sets fatal_error
return 0;
/* purecov: end */
}
/*
Compare the two rows by the corresponding values of the indexed
columns.
@ -5245,8 +5279,13 @@ int Ordered_key::cmp_key_with_search_key(rownum_t row_num)
uchar *cur_rowid= row_num_to_rowid + row_num * rowid_length;
int error, cmp_res;
error= tbl->file->ha_rnd_pos(tbl->record[0], cur_rowid);
DBUG_ASSERT(!error);
if ((error= tbl->file->ha_rnd_pos(tbl->record[0], cur_rowid)))
{
/* purecov: begin inspected */
tbl->file->print_error(error, MYF(ME_FATALERROR)); // Sets fatal_error
return 0;
/* purecov: end */
}
for (uint i= 0; i < key_column_count; i++)
{

View File

@ -52,6 +52,7 @@
#include "sql_plugin.h"
#include "rpl_handler.h"
#include "debug_sync.h"
#include "sql_show.h"
/* max size of the log message */
#define MAX_LOG_BUFFER_SIZE 1024
@ -2073,9 +2074,8 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
String log_query;
if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
log_query.append("`") ||
log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
log_query.append("`"))
append_identifier(thd, &log_query,
thd->lex->ident.str, thd->lex->ident.length))
DBUG_RETURN(1);
int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
@ -2097,9 +2097,8 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
{
String log_query;
if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
log_query.append("`") ||
log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
log_query.append("`"))
append_identifier(thd, &log_query,
thd->lex->ident.str, thd->lex->ident.length))
DBUG_RETURN(1);
int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),

View File

@ -863,7 +863,7 @@ int query_error_code(THD *thd, bool not_killed);
uint purge_log_get_error_code(int res);
int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
void sql_print_error(const char *format, ...);
void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
void sql_print_information(const char *format, ...)
ATTRIBUTE_FORMAT(printf, 1, 2);

View File

@ -46,6 +46,7 @@
#include "rpl_record.h"
#include "transaction.h"
#include <my_dir.h>
#include "sql_show.h"
#endif /* MYSQL_CLIENT */
@ -471,29 +472,28 @@ inline bool unexpected_error_code(int unexpected_error)
pretty_print_str()
*/
static char *pretty_print_str(char *packet, const char *str, int len)
static void
pretty_print_str(String *packet, const char *str, int len)
{
const char *end= str + len;
char *pos= packet;
*pos++= '\'';
packet->append(STRING_WITH_LEN("'"));
while (str < end)
{
char c;
switch ((c=*str++)) {
case '\n': *pos++= '\\'; *pos++= 'n'; break;
case '\r': *pos++= '\\'; *pos++= 'r'; break;
case '\\': *pos++= '\\'; *pos++= '\\'; break;
case '\b': *pos++= '\\'; *pos++= 'b'; break;
case '\t': *pos++= '\\'; *pos++= 't'; break;
case '\'': *pos++= '\\'; *pos++= '\''; break;
case 0 : *pos++= '\\'; *pos++= '0'; break;
case '\n': packet->append(STRING_WITH_LEN("\\n")); break;
case '\r': packet->append(STRING_WITH_LEN("\\r")); break;
case '\\': packet->append(STRING_WITH_LEN("\\\\")); break;
case '\b': packet->append(STRING_WITH_LEN("\\b")); break;
case '\t': packet->append(STRING_WITH_LEN("\\t")); break;
case '\'': packet->append(STRING_WITH_LEN("\\'")); break;
case 0 : packet->append(STRING_WITH_LEN("\\0")); break;
default:
*pos++= c;
packet->append(&c, 1);
break;
}
}
*pos++= '\'';
return pos;
packet->append(STRING_WITH_LEN("'"));
}
#endif /* !MYSQL_CLIENT */
@ -926,7 +926,7 @@ Log_event::do_shall_skip(Relay_log_info *rli)
Log_event::pack_info()
*/
void Log_event::pack_info(Protocol *protocol)
void Log_event::pack_info(THD *thd, Protocol *protocol)
{
protocol->store("", &my_charset_bin);
}
@ -935,7 +935,8 @@ void Log_event::pack_info(Protocol *protocol)
/**
Only called by SHOW BINLOG EVENTS
*/
int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name,
my_off_t pos)
{
const char *p= strrchr(log_name, FN_LIBCHAR);
const char *event_type;
@ -949,7 +950,7 @@ int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
protocol->store(event_type, strlen(event_type), &my_charset_bin);
protocol->store((uint32) server_id);
protocol->store((ulonglong) log_pos);
pack_info(protocol);
pack_info(thd, protocol);
return protocol->write();
}
#endif /* HAVE_REPLICATION */
@ -2448,27 +2449,22 @@ Log_event::continue_group(Relay_log_info *rli)
show the catalog ??
*/
void Query_log_event::pack_info(Protocol *protocol)
void Query_log_event::pack_info(THD *thd, Protocol *protocol)
{
// TODO: show the catalog ??
char *buf, *pos;
if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME))))
return;
pos= buf;
char buf_mem[1024];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
buf.real_alloc(9 + db_len + q_len);
if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
&& db && db_len)
{
pos= strmov(buf, "use `");
memcpy(pos, db, db_len);
pos= strmov(pos+db_len, "`; ");
buf.append(STRING_WITH_LEN("use "));
append_identifier(thd, &buf, db, db_len);
buf.append("; ");
}
if (query && q_len)
{
memcpy(pos, query, q_len);
pos+= q_len;
}
protocol->store(buf, pos-buf, &my_charset_bin);
my_free(buf);
buf.append(query, q_len);
protocol->store(&buf);
}
#endif
@ -3334,11 +3330,17 @@ void Query_log_event::print_query_header(IO_CACHE* file,
}
else if (db)
{
/* Room for expand ` to `` + initial/final ` + \0 */
char buf[FN_REFLEN*2+3];
different_db= memcmp(print_event_info->db, db, db_len + 1);
if (different_db)
memcpy(print_event_info->db, db, db_len + 1);
if (db[0] && different_db)
my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
{
my_snprintf(buf, sizeof(buf), "%`s", db);
my_b_printf(file, "use %s%s\n", buf, print_event_info->delimiter);
}
}
end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
@ -3534,6 +3536,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
LEX_STRING new_db;
int expected_error,actual_error= 0;
HA_CREATE_INFO db_options;
DBUG_ENTER("Query_log_event::do_apply_event");
/*
Colleagues: please never free(thd->catalog) in MySQL. This would
@ -3929,7 +3932,7 @@ end:
thd->first_successful_insert_id_in_prev_stmt= 0;
thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
return thd->is_slave_error;
DBUG_RETURN(thd->is_slave_error);
}
int Query_log_event::do_update_pos(Relay_log_info *rli)
@ -4002,7 +4005,7 @@ Start_log_event_v3::Start_log_event_v3()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Start_log_event_v3::pack_info(Protocol *protocol)
void Start_log_event_v3::pack_info(THD *thd, Protocol *protocol)
{
char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
pos= strmov(buf, "Server ver: ");
@ -4778,131 +4781,113 @@ uint8 get_checksum_alg(const char* buf, ulong len)
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
uint Load_log_event::get_query_buffer_length()
void Load_log_event::print_query(THD *thd, bool need_db, const char *cs,
String *buf, my_off_t *fn_start,
my_off_t *fn_end, const char *qualify_db)
{
return
5 + db_len + 3 + // "use DB; "
18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
11 + // "CONCURRENT "
7 + // LOCAL
9 + // " REPLACE or IGNORE "
13 + table_name_len*2 + // "INTO TABLE `table`"
21 + sql_ex.field_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
21 + sql_ex.line_term_len*4 + 2 + // " LINES TERMINATED BY 'str'"
19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
15 + 22 + // " IGNORE xxx LINES"
3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
}
void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
char **end, char **fn_start, char **fn_end)
{
char *pos= buf;
if (need_db && db && db_len)
{
pos= strmov(pos, "use `");
memcpy(pos, db, db_len);
pos= strmov(pos+db_len, "`; ");
buf->append(STRING_WITH_LEN("use "));
append_identifier(thd, buf, db, db_len);
buf->append(STRING_WITH_LEN("; "));
}
pos= strmov(pos, "LOAD DATA ");
buf->append(STRING_WITH_LEN("LOAD DATA "));
if (is_concurrent)
pos= strmov(pos, "CONCURRENT ");
buf->append(STRING_WITH_LEN("CONCURRENT "));
if (fn_start)
*fn_start= pos;
*fn_start= buf->length();
if (check_fname_outside_temp_buf())
pos= strmov(pos, "LOCAL ");
pos= strmov(pos, "INFILE '");
memcpy(pos, fname, fname_len);
pos= strmov(pos+fname_len, "' ");
buf->append(STRING_WITH_LEN("LOCAL "));
buf->append(STRING_WITH_LEN("INFILE '"));
buf->append_for_single_quote(fname, fname_len);
buf->append(STRING_WITH_LEN("' "));
if (sql_ex.opt_flags & REPLACE_FLAG)
pos= strmov(pos, "REPLACE ");
buf->append(STRING_WITH_LEN("REPLACE "));
else if (sql_ex.opt_flags & IGNORE_FLAG)
pos= strmov(pos, "IGNORE ");
buf->append(STRING_WITH_LEN("IGNORE "));
pos= strmov(pos ,"INTO");
buf->append(STRING_WITH_LEN("INTO"));
if (fn_end)
*fn_end= pos;
*fn_end= buf->length();
pos= strmov(pos ," TABLE `");
memcpy(pos, table_name, table_name_len);
pos+= table_name_len;
buf->append(STRING_WITH_LEN(" TABLE "));
if (qualify_db)
{
append_identifier(thd, buf, qualify_db, strlen(qualify_db));
buf->append(STRING_WITH_LEN("."));
}
append_identifier(thd, buf, table_name, table_name_len);
if (cs != NULL)
{
pos= strmov(pos ,"` CHARACTER SET ");
pos= strmov(pos , cs);
buf->append(STRING_WITH_LEN(" CHARACTER SET "));
buf->append(cs, strlen(cs));
}
else
pos= strmov(pos, "`");
/* We have to create all optional fields as the default is not empty */
pos= strmov(pos, " FIELDS TERMINATED BY ");
pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
buf->append(STRING_WITH_LEN(" FIELDS TERMINATED BY "));
pretty_print_str(buf, sql_ex.field_term, sql_ex.field_term_len);
if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
pos= strmov(pos, " OPTIONALLY ");
pos= strmov(pos, " ENCLOSED BY ");
pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len);
buf->append(STRING_WITH_LEN(" OPTIONALLY "));
buf->append(STRING_WITH_LEN(" ENCLOSED BY "));
pretty_print_str(buf, sql_ex.enclosed, sql_ex.enclosed_len);
pos= strmov(pos, " ESCAPED BY ");
pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len);
buf->append(STRING_WITH_LEN(" ESCAPED BY "));
pretty_print_str(buf, sql_ex.escaped, sql_ex.escaped_len);
pos= strmov(pos, " LINES TERMINATED BY ");
pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len);
buf->append(STRING_WITH_LEN(" LINES TERMINATED BY "));
pretty_print_str(buf, sql_ex.line_term, sql_ex.line_term_len);
if (sql_ex.line_start_len)
{
pos= strmov(pos, " STARTING BY ");
pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len);
buf->append(STRING_WITH_LEN(" STARTING BY "));
pretty_print_str(buf, sql_ex.line_start, sql_ex.line_start_len);
}
if ((long) skip_lines > 0)
{
pos= strmov(pos, " IGNORE ");
pos= longlong10_to_str((longlong) skip_lines, pos, 10);
pos= strmov(pos," LINES ");
buf->append(STRING_WITH_LEN(" IGNORE "));
buf->append_ulonglong(skip_lines);
buf->append(STRING_WITH_LEN(" LINES "));
}
if (num_fields)
{
uint i;
const char *field= fields;
pos= strmov(pos, " (");
buf->append(STRING_WITH_LEN(" ("));
for (i = 0; i < num_fields; i++)
{
if (i)
{
*pos++= ' ';
*pos++= ',';
/*
Yes, the space and comma is reversed here. But this is mostly dead
code, at most used when reading really old binlogs from old servers,
so better just leave it as is...
*/
buf->append(STRING_WITH_LEN(" ,"));
}
memcpy(pos, field, field_lens[i]);
pos+= field_lens[i];
append_identifier(thd, buf, field, field_lens[i]);
field+= field_lens[i] + 1;
}
*pos++= ')';
buf->append(STRING_WITH_LEN(")"));
}
*end= pos;
}
void Load_log_event::pack_info(Protocol *protocol)
void Load_log_event::pack_info(THD *thd, Protocol *protocol)
{
char *buf, *end;
char query_buffer[1024];
String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
return;
print_query(TRUE, NULL, buf, &end, 0, 0);
protocol->store(buf, end-buf, &my_charset_bin);
my_free(buf);
query_str.length(0);
print_query(thd, TRUE, NULL, &query_str, 0, 0, NULL);
protocol->store(query_str.ptr(), query_str.length(), &my_charset_bin);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@ -5284,6 +5269,8 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
bool use_rli_only_for_errors)
{
LEX_STRING new_db;
DBUG_ENTER("Load_log_event::do_apply_event");
new_db.length= db_len;
new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length);
thd->set_db(new_db.str, new_db.length);
@ -5358,16 +5345,20 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
else
{
char llbuff[22];
char *end;
enum enum_duplicates handle_dup;
bool ignore= 0;
char query_buffer[1024];
String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
char *load_data_query;
query_str.length(0);
/*
Forge LOAD DATA INFILE query which will be used in SHOW PROCESS LIST
and written to slave's binlog if binlogging is on.
*/
if (!(load_data_query= (char *)thd->alloc(get_query_buffer_length() + 1)))
print_query(thd, FALSE, NULL, &query_str, NULL, NULL, NULL);
if (!(load_data_query= (char *)thd->strmake(query_str.ptr(),
query_str.length())))
{
/*
This will set thd->fatal_error in case of OOM. So we surely will notice
@ -5376,9 +5367,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
goto error;
}
print_query(FALSE, NULL, load_data_query, &end, NULL, NULL);
*end= 0;
thd->set_query(load_data_query, (uint) (end - load_data_query));
thd->set_query(load_data_query, (uint) (query_str.length()));
if (sql_ex.opt_flags & REPLACE_FLAG)
handle_dup= DUP_REPLACE;
@ -5524,7 +5513,7 @@ error:
Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'",
err, (char*)table_name, print_slave_db_safe(remember_db));
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
return 1;
DBUG_RETURN(1);
}
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
@ -5539,10 +5528,10 @@ Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'",
rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
ER(ER_SLAVE_FATAL_ERROR), buf);
return 1;
DBUG_RETURN(1);
}
return ( use_rli_only_for_errors ? 0 : Log_event::do_apply_event(rli) );
DBUG_RETURN( use_rli_only_for_errors ? 0 : Log_event::do_apply_event(rli) );
}
#endif
@ -5556,7 +5545,7 @@ Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'",
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Rotate_log_event::pack_info(Protocol *protocol)
void Rotate_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf1[256], buf[22];
String tmp(buf1, sizeof(buf1), log_cs);
@ -5774,7 +5763,7 @@ Rotate_log_event::do_shall_skip(Relay_log_info *rli)
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Intvar_log_event::pack_info(Protocol *protocol)
void Intvar_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256], *pos;
pos= strmake(buf, get_var_type_name(), sizeof(buf)-23);
@ -5928,7 +5917,7 @@ Intvar_log_event::do_shall_skip(Relay_log_info *rli)
**************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Rand_log_event::pack_info(Protocol *protocol)
void Rand_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf1[256], *pos;
pos= strmov(buf1,"rand_seed1=");
@ -6053,7 +6042,7 @@ bool slave_execute_deferred_events(THD *thd)
**************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Xid_log_event::pack_info(Protocol *protocol)
void Xid_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[128], *pos;
pos= strmov(buf, "COMMIT /* xid=");
@ -6150,84 +6139,117 @@ Xid_log_event::do_shall_skip(Relay_log_info *rli)
**************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void User_var_log_event::pack_info(Protocol* protocol)
static bool
user_var_append_name_part(THD *thd, String *buf,
const char *name, size_t name_len)
{
char *buf= 0;
uint val_offset= 4 + name_len;
uint event_len= val_offset;
return buf->append("@") ||
append_identifier(thd, buf, name, name_len) ||
buf->append("=");
}
void User_var_log_event::pack_info(THD *thd, Protocol* protocol)
{
if (is_null)
{
if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME))))
char buf_mem[FN_REFLEN+7];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
buf.length(0);
if (user_var_append_name_part(thd, &buf, name, name_len) ||
buf.append("NULL"))
return;
strmov(buf + val_offset, "NULL");
event_len= val_offset + 4;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
}
else
{
switch (type) {
case REAL_RESULT:
{
double real_val;
char buf2[MY_GCVT_MAX_FIELD_WIDTH+1];
char buf_mem[FN_REFLEN + MY_GCVT_MAX_FIELD_WIDTH + 1];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
float8get(real_val, val);
if (!(buf= (char*) my_malloc(val_offset + MY_GCVT_MAX_FIELD_WIDTH + 1,
MYF(MY_WME))))
buf.length(0);
if (user_var_append_name_part(thd, &buf, name, name_len) ||
buf.append(buf2, my_gcvt(real_val, MY_GCVT_ARG_DOUBLE,
MY_GCVT_MAX_FIELD_WIDTH, buf2, NULL)))
return;
event_len+= my_gcvt(real_val, MY_GCVT_ARG_DOUBLE, MY_GCVT_MAX_FIELD_WIDTH,
buf + val_offset, NULL);
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
break;
}
case INT_RESULT:
if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
{
char buf2[22];
char buf_mem[FN_REFLEN + 22];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
buf.length(0);
if (user_var_append_name_part(thd, &buf, name, name_len) ||
buf.append(buf2,
longlong10_to_str(uint8korr(val), buf2,
((flags & User_var_log_event::UNSIGNED_F) ? 10 : -10))-buf2))
return;
event_len= longlong10_to_str(uint8korr(val), buf + val_offset,
((flags & User_var_log_event::UNSIGNED_F) ?
10 : -10))-buf;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
break;
}
case DECIMAL_RESULT:
{
if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH,
MYF(MY_WME))))
return;
String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin);
char buf_mem[FN_REFLEN + DECIMAL_MAX_STR_LENGTH];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
char buf2[DECIMAL_MAX_STR_LENGTH+1];
String str(buf2, sizeof(buf2), &my_charset_bin);
my_decimal dec;
buf.length(0);
binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0],
val[1]);
my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str);
event_len= str.length() + val_offset;
break;
}
case STRING_RESULT:
/* 15 is for 'COLLATE' and other chars */
buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
MYF(MY_WME));
CHARSET_INFO *cs;
if (!buf)
if (user_var_append_name_part(thd, &buf, name, name_len) ||
buf.append(buf2))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
break;
}
case STRING_RESULT:
{
/* 15 is for 'COLLATE' and other chars */
char buf_mem[FN_REFLEN + 512 + 1 + 2*MY_CS_NAME_SIZE+15];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
CHARSET_INFO *cs;
buf.length(0);
if (!(cs= get_charset(charset_number, MYF(0))))
{
strmov(buf+val_offset, "???");
event_len+= 3;
if (buf.append("???"))
return;
}
else
{
char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS);
p= str_to_hex(p, val, val_len);
p= strxmov(p, " COLLATE ", cs->name, NullS);
event_len= p-buf;
size_t old_len;
char *beg, *end;
if (user_var_append_name_part(thd, &buf, name, name_len) ||
buf.append("_") ||
buf.append(cs->csname) ||
buf.append(" "))
return;
old_len= buf.length();
if (buf.reserve(old_len + val_len*2 + 2 + sizeof(" COLLATE ") +
MY_CS_NAME_SIZE))
return;
beg= const_cast<char *>(buf.ptr()) + old_len;
end= str_to_hex(beg, val, val_len);
buf.length(old_len + (end - beg));
if (buf.append(" COLLATE ") ||
buf.append(cs->name))
return;
}
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
break;
}
case ROW_RESULT:
default:
DBUG_ASSERT(0);
return;
}
}
buf[0]= '@';
buf[1]= '`';
memcpy(buf+2, name, name_len);
buf[2+name_len]= '`';
buf[3+name_len]= '=';
protocol->store(buf, event_len, &my_charset_bin);
my_free(buf);
}
#endif /* !MYSQL_CLIENT */
@ -6385,9 +6407,8 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
my_b_printf(&cache, "\tUser_var\n");
}
my_b_printf(&cache, "SET @`");
my_b_write(&cache, (uchar*) name, (uint) (name_len));
my_b_printf(&cache, "`");
my_b_printf(&cache, "SET @");
my_b_write_backtick_quote(&cache, name, name_len);
if (is_null)
{
@ -6486,15 +6507,16 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
{
Item *it= 0;
CHARSET_INFO *charset;
DBUG_ENTER("User_var_log_event::do_apply_event");
if (rli->deferred_events_collecting)
{
set_deferred();
return rli->deferred_events->add(this);
DBUG_RETURN(rli->deferred_events->add(this));
}
if (!(charset= get_charset(charset_number, MYF(MY_WME))))
return 1;
DBUG_RETURN(1);
LEX_STRING user_var_name;
user_var_name.str= name;
user_var_name.length= name_len;
@ -6540,7 +6562,7 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
case ROW_RESULT:
default:
DBUG_ASSERT(0);
return 0;
DBUG_RETURN(0);
}
}
@ -6554,7 +6576,7 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
error.
*/
if (e->fix_fields(thd, 0))
return 1;
DBUG_RETURN(1);
/*
A variable can just be considered as a table with
@ -6566,7 +6588,7 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
if (!is_deferred())
free_root(thd->mem_root, 0);
return 0;
DBUG_RETURN(0);
}
int User_var_log_event::do_update_pos(Relay_log_info *rli)
@ -6609,7 +6631,7 @@ void Unknown_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info
#endif
#ifndef MYSQL_CLIENT
void Slave_log_event::pack_info(Protocol *protocol)
void Slave_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256+HOSTNAME_LENGTH], *pos;
pos= strmov(buf, "host=");
@ -6991,7 +7013,7 @@ void Create_file_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Create_file_log_event::pack_info(Protocol *protocol)
void Create_file_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[SAFE_NAME_LEN*2 + 30 + 21*2], *pos;
pos= strmov(buf, "db=");
@ -7177,7 +7199,7 @@ void Append_block_log_event::print(FILE* file,
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Append_block_log_event::pack_info(Protocol *protocol)
void Append_block_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256];
uint length;
@ -7334,7 +7356,7 @@ void Delete_file_log_event::print(FILE* file,
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Delete_file_log_event::pack_info(Protocol *protocol)
void Delete_file_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[64];
uint length;
@ -7433,7 +7455,7 @@ void Execute_load_log_event::print(FILE* file,
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Execute_load_log_event::pack_info(Protocol *protocol)
void Execute_load_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[64];
uint length;
@ -7695,27 +7717,24 @@ void Execute_load_query_log_event::print(FILE* file,
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Execute_load_query_log_event::pack_info(Protocol *protocol)
void Execute_load_query_log_event::pack_info(THD *thd, Protocol *protocol)
{
char *buf, *pos;
if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
return;
pos= buf;
char buf_mem[1024];
String buf(buf_mem, sizeof(buf_mem), system_charset_info);
buf.real_alloc(9 + db_len + q_len + 10 + 21);
if (db && db_len)
{
pos= strmov(buf, "use `");
memcpy(pos, db, db_len);
pos= strmov(pos+db_len, "`; ");
if (buf.append("use ") ||
append_identifier(thd, &buf, db, db_len) ||
buf.append("; "))
return;
}
if (query && q_len)
{
memcpy(pos, query, q_len);
pos+= q_len;
}
pos= strmov(pos, " ;file_id=");
pos= int10_to_str((long) file_id, pos, 10);
protocol->store(buf, pos-buf, &my_charset_bin);
my_free(buf);
if (query && q_len && buf.append(query, q_len))
return;
if (buf.append(" ;file_id=") ||
buf.append_ulonglong(file_id))
return;
protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
}
@ -8678,7 +8697,7 @@ bool Rows_log_event::write_data_body(IO_CACHE*file)
#endif
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Rows_log_event::pack_info(Protocol *protocol)
void Rows_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256];
char const *const flagstr=
@ -8782,7 +8801,7 @@ bool Annotate_rows_log_event::write_data_body(IO_CACHE *file)
#endif
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
void Annotate_rows_log_event::pack_info(Protocol* protocol)
void Annotate_rows_log_event::pack_info(THD *thd, Protocol* protocol)
{
if (m_query_txt && m_query_len)
protocol->store(m_query_txt, m_query_len, &my_charset_bin);
@ -9526,7 +9545,7 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file)
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Table_map_log_event::pack_info(Protocol *protocol)
void Table_map_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256];
size_t bytes= my_snprintf(buf, sizeof(buf),
@ -9547,7 +9566,7 @@ void Table_map_log_event::print(FILE *, PRINT_EVENT_INFO *print_event_info)
{
print_header(&print_event_info->head_cache, print_event_info, TRUE);
my_b_printf(&print_event_info->head_cache,
"\tTable_map: `%s`.`%s` mapped to number %lu\n",
"\tTable_map: %`s.%`s mapped to number %lu\n",
m_dbnam, m_tblnam, m_table_id);
print_base64(&print_event_info->body_cache, print_event_info, TRUE);
}
@ -10880,7 +10899,7 @@ Incident_log_event::description() const
#ifndef MYSQL_CLIENT
void Incident_log_event::pack_info(Protocol *protocol)
void Incident_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256];
size_t bytes;

View File

@ -1065,14 +1065,15 @@ public:
*/
static void init_show_field_list(List<Item>* field_list);
#ifdef HAVE_REPLICATION
int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
int net_send(THD *thd, Protocol *protocol, const char* log_name,
my_off_t pos);
/*
pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
a string to display to the user, so it resembles print().
*/
virtual void pack_info(Protocol *protocol);
virtual void pack_info(THD *thd, Protocol *protocol);
#endif /* HAVE_REPLICATION */
virtual const char* get_db()
@ -1809,7 +1810,7 @@ public:
bool using_trans, bool direct, bool suppress_use, int error);
const char* get_db() { return db; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
@ -1939,7 +1940,7 @@ public:
#ifdef MYSQL_SERVER
Slave_log_event(THD* thd_arg, Relay_log_info* rli);
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
@ -2172,9 +2173,9 @@ protected:
const Format_description_log_event* description_event);
public:
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 print_query(THD *thd, bool need_db, const char *cs, String *buf,
my_off_t *fn_start, my_off_t *fn_end,
const char *qualify_db);
ulong thread_id;
ulong slave_proxy_id;
uint32 table_name_len;
@ -2235,7 +2236,7 @@ public:
Name_resolution_context *context);
const char* get_db() { return db; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -2332,7 +2333,7 @@ public:
#ifdef MYSQL_SERVER
Start_log_event_v3();
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
Start_log_event_v3() {}
@ -2496,7 +2497,7 @@ Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg,
cache_type= Log_event::EVENT_NO_CACHE;
}
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -2576,7 +2577,7 @@ class Rand_log_event: public Log_event
cache_type= Log_event::EVENT_NO_CACHE;
}
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -2625,7 +2626,7 @@ class Xid_log_event: public Log_event
cache_type= Log_event::EVENT_NO_CACHE;
}
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -2687,7 +2688,7 @@ public:
if (direct)
cache_type= Log_event::EVENT_NO_CACHE;
}
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
@ -2825,7 +2826,7 @@ public:
uint ident_len_arg,
ulonglong pos_arg, uint flags);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -2886,7 +2887,7 @@ public:
uchar* block_arg, uint block_len_arg,
bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -2958,7 +2959,7 @@ public:
Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
uint block_len_arg, bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
virtual int get_create_or_append() const;
#endif /* HAVE_REPLICATION */
#else
@ -2999,7 +3000,7 @@ public:
#ifdef MYSQL_SERVER
Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -3040,7 +3041,7 @@ public:
#ifdef MYSQL_SERVER
Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -3136,7 +3137,7 @@ public:
bool using_trans, bool direct,
bool suppress_use, int errcode);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
void pack_info(THD *thd, Protocol* protocol);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@ -3222,7 +3223,7 @@ public:
#endif
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual void pack_info(Protocol*);
virtual void pack_info(THD *thd, Protocol*);
#endif
#ifdef MYSQL_CLIENT
@ -3636,7 +3637,7 @@ public:
#endif
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual void pack_info(Protocol *protocol);
virtual void pack_info(THD *thd, Protocol *protocol);
#endif
#ifdef MYSQL_CLIENT
@ -3748,7 +3749,7 @@ public:
flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual void pack_info(Protocol *protocol);
virtual void pack_info(THD *thd, Protocol *protocol);
#endif
#ifdef MYSQL_CLIENT
@ -4195,7 +4196,7 @@ public:
#endif
#ifdef MYSQL_SERVER
void pack_info(Protocol*);
void pack_info(THD *thd, Protocol*);
#endif
Incident_log_event(const char *buf, uint event_len,
@ -4294,6 +4295,16 @@ bool event_checksum_test(uchar *buf, ulong event_len, uint8 alg);
uint8 get_checksum_alg(const char* buf, ulong len);
extern TYPELIB binlog_checksum_typelib;
#ifndef MYSQL_CLIENT
/**
The function is called by slave applier in case there are
active table filtering rules to force gathering events associated
with Query-log-event into an array to execute
them once the fate of the Query is determined for execution.
*/
bool slave_execute_deferred_events(THD *thd);
#endif
/**
@} (end of group Replication)
*/

View File

@ -1935,7 +1935,7 @@ bool Old_rows_log_event::write_data_body(IO_CACHE*file)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Old_rows_log_event::pack_info(Protocol *protocol)
void Old_rows_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256];
char const *const flagstr=

View File

@ -108,7 +108,7 @@ public:
flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual void pack_info(Protocol *protocol);
virtual void pack_info(THD *thd, Protocol *protocol);
#endif
#ifdef MYSQL_CLIENT

View File

@ -1404,7 +1404,7 @@ ha_rows DsMrr_impl::dsmrr_info(uint keyno, uint n_ranges, uint rows,
uint key_parts,
uint *bufsz, uint *flags, COST_VECT *cost)
{
ha_rows res;
ha_rows res __attribute__((unused));
uint def_flags= *flags;
uint def_bufsz= *bufsz;

View File

@ -2001,7 +2001,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
{
handler *save_file= file, *org_file;
my_bool org_key_read;
THD *thd;
THD *thd= head->in_use;
DBUG_ENTER("QUICK_RANGE_SELECT::init_ror_merged_scan");
in_ror_merged_scan= 1;
@ -2023,7 +2023,6 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
DBUG_RETURN(0);
}
thd= head->in_use;
if (!(file= head->file->clone(head->s->normalized_path.str, thd->mem_root)))
{
/*

View File

@ -160,18 +160,18 @@
3.2.1 Non-merged semi-joins and join optimization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For join optimization purposes, non-merged semi-join nests are similar to
base tables - they've got one JOIN_TAB, which can be accessed with one of
two methods:
base tables. Each such nest is represented by one one JOIN_TAB, which has
two possible access strategies:
- full table scan (representing SJ-Materialization-Scan strategy)
- eq_ref-like table lookup (representing SJ-Materialization-Lookup)
Unlike regular base tables, non-merged semi-joins have:
- non-zero JOIN_TAB::startup_cost, and
- join_tab->table->is_filled_at_execution()==TRUE, which means one
cannot do const table detection or range analysis or other table data-
dependent inferences
// instead, get_delayed_table_estimates() runs optimization on the nest so that
// we get an idea about temptable size
cannot do const table detection, range analysis or other dataset-dependent
optimizations.
Instead, get_delayed_table_estimates() will run optimization for the
subquery and produce an E(materialized table size).
3.2.2 Merged semi-joins and join optimization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -35,7 +35,6 @@
#include "rpl_mi.h"
#include "rpl_filter.h"
#include "log_event.h"
#include "sql_db.h" // mysql_create_db
#include <mysql.h>
#define SLAVE_LIST_CHUNK 128

View File

@ -314,7 +314,7 @@ unpack_row(Relay_log_info const *rli,
if (!pack_ptr)
{
rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT,
"Could not read field `%s` of table `%s`.`%s`",
"Could not read field '%s' of table '%s.%s'",
f->field_name, table->s->db.str,
table->s->table_name.str);
DBUG_RETURN(ER_SLAVE_CORRUPT_EVENT);

View File

@ -15,11 +15,10 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "rpl_utility.h"
#ifndef MYSQL_CLIENT
#include "unireg.h" // REQUIRED by later includes
#include "rpl_rli.h"
#include "log_event.h"
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
#include "rpl_rli.h"
#include "sql_select.h"
/**
@ -954,7 +953,6 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *
target_table->s->table_name.str);
DBUG_RETURN(conv_table);
}
#endif /* MYSQL_CLIENT */
table_def::table_def(unsigned char *types, ulong size,
@ -1115,7 +1113,6 @@ bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg)
return DBUG_EVALUATE_IF("simulate_checksum_test_failure", TRUE, res);
}
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
Deferred_log_events::Deferred_log_events(Relay_log_info *rli) : last_added(NULL)

View File

@ -6585,3 +6585,6 @@ ER_STORED_FUNCTION_PREVENTS_SWITCH_SKIP_REPLICATION
eng "Cannot modify @@session.skip_replication inside a stored function or trigger"
ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT
eng "Query execution was interrupted. The query examined at least %llu rows, which exceeds LIMIT ROWS EXAMINED (%llu). The query result may be incomplete."
ER_NO_SUCH_TABLE_IN_ENGINE 42S02
eng "Table '%-.192s.%-.192s' doesn't exist in engine"
swe "Det finns ingen tabell som heter '%-.192s.%-.192s' i handlern"

View File

@ -3005,6 +3005,8 @@ pthread_handler_t handle_slave_io(void *arg)
mysql= NULL ;
retry_count= 0;
thd= new THD; // note that contructor of THD uses DBUG_ !
mysql_mutex_lock(&mi->run_lock);
/* Inform waiting threads that slave has started */
mi->slave_run_id++;
@ -3013,7 +3015,6 @@ pthread_handler_t handle_slave_io(void *arg)
mi->events_till_disconnect = disconnect_slave_event_count;
#endif
thd= new THD; // note that contructor of THD uses DBUG_ !
THD_CHECK_SENTRY(thd);
mi->io_thd = thd;

View File

@ -1429,6 +1429,7 @@ public:
MYSQL_ERROR ** cond_hdl)
{
if (sql_errno == ER_NO_SUCH_TABLE ||
sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE ||
sql_errno == ER_CANNOT_LOAD_FROM_TABLE ||
sql_errno == ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE ||
sql_errno == ER_COL_COUNT_DOESNT_MATCH_CORRUPTED)

View File

@ -3032,6 +3032,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
if (!res || !thd->is_error() ||
(thd->stmt_da->sql_errno() != ER_CANT_REOPEN_TABLE &&
thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE &&
thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE_IN_ENGINE &&
thd->stmt_da->sql_errno() != ER_UPDATE_TABLE_USED))
thd->stmt_arena->state= Query_arena::STMT_EXECUTED;

View File

@ -286,6 +286,7 @@ end:
static inline bool table_not_corrupt_error(uint sql_errno)
{
return (sql_errno == ER_NO_SUCH_TABLE ||
sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE ||
sql_errno == ER_FILE_NOT_FOUND ||
sql_errno == ER_LOCK_WAIT_TIMEOUT ||
sql_errno == ER_LOCK_DEADLOCK ||

View File

@ -70,7 +70,7 @@ No_such_table_error_handler::handle_condition(THD *,
MYSQL_ERROR ** cond_hdl)
{
*cond_hdl= NULL;
if (sql_errno == ER_NO_SUCH_TABLE)
if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE)
{
m_handled_errors++;
return TRUE;
@ -144,7 +144,9 @@ Repair_mrg_table_error_handler::handle_condition(THD *,
MYSQL_ERROR ** cond_hdl)
{
*cond_hdl= NULL;
if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_WRONG_MRG_TABLE)
if (sql_errno == ER_NO_SUCH_TABLE ||
sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE ||
sql_errno == ER_WRONG_MRG_TABLE)
{
m_handled_errors= true;
return TRUE;
@ -717,7 +719,9 @@ get_table_share_with_discover(THD *thd, TABLE_LIST *table_list,
@todo Rework alternative ways to deal with ER_NO_SUCH TABLE.
*/
if (share || (thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE))
if (share ||
(thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE &&
thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE_IN_ENGINE))
DBUG_RETURN(share);
*error= 0;
@ -3897,22 +3901,22 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
entry->file->implicit_emptied= 0;
if (mysql_bin_log.is_open())
{
char *query, *end;
uint query_buf_size= 20 + share->db.length + share->table_name.length +1;
if ((query= (char*) my_malloc(query_buf_size,MYF(MY_WME))))
char query_buf[2*FN_REFLEN + 21];
String query(query_buf, sizeof(query_buf), system_charset_info);
query.length(0);
if (query.ptr())
{
/* this DELETE FROM is needed even with row-based binlogging */
end = strxmov(strmov(query, "DELETE FROM `"),
share->db.str,"`.`",share->table_name.str,"`", NullS);
query.append("DELETE FROM ");
append_identifier(thd, &query, share->db.str, share->db.length);
query.append(".");
append_identifier(thd, &query, share->table_name.str,
share->table_name.length);
int errcode= query_error_code(thd, TRUE);
if (thd->binlog_query(THD::STMT_QUERY_TYPE,
query, (ulong)(end-query),
query.ptr(), query.length(),
FALSE, FALSE, FALSE, errcode))
{
my_free(query);
return TRUE;
}
my_free(query);
}
else
{
@ -3922,7 +3926,7 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
because of MYF(MY_WME) in my_malloc() above).
*/
sql_print_error("When opening HEAP table, could not allocate memory "
"to write 'DELETE FROM `%s`.`%s`' to the binary log",
"to write 'DELETE FROM %`s.%`s' to the binary log",
share->db.str, share->table_name.str);
delete entry->triggers;
return TRUE;

View File

@ -1813,7 +1813,10 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
goto err;
if (query_cache_size == 0)
{
thd->query_cache_is_applicable= 0; // Query can't be cached
goto err_unlock;
}
Query_cache_block *query_block;
if (thd->variables.query_cache_strip_comments)

View File

@ -1845,6 +1845,7 @@ public:
MEM_ROOT mem_root; // Transaction-life memory allocation pool
void cleanup()
{
DBUG_ENTER("thd::cleanup");
changed_tables= 0;
savepoints= 0;
/*
@ -1856,6 +1857,7 @@ public:
if (!xid_state.rm_error)
xid_state.xid.null();
free_root(&mem_root,MYF(MY_KEEP_PREALLOC));
DBUG_VOID_RETURN;
}
my_bool is_active()
{

Some files were not shown because too many files have changed in this diff Show More