diff --git a/cmd-line-utils/libedit/makelist.sh b/cmd-line-utils/libedit/makelist.sh index fdd3f934e15..5d25b4776c9 100644 --- a/cmd-line-utils/libedit/makelist.sh +++ b/cmd-line-utils/libedit/makelist.sh @@ -84,7 +84,7 @@ case $FLAG in cat $FILES | $AWK ' BEGIN { printf("/* Automatically generated file, do not edit */\n"); - printf("#include \"sys.h\"\n#include \"el.h\"\n"); + printf("#include \"config.h\"\n#include \"el.h\"\n"); printf("private const struct el_bindings_t el_func_help[] = {\n"); low = "abcdefghijklmnopqrstuvwxyz_"; high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; @@ -169,7 +169,7 @@ case $FLAG in cat $FILES | $AWK '/el_action_t/ { print $3 }' | sort | $AWK ' BEGIN { printf("/* Automatically generated file, do not edit */\n"); - printf("#include \"sys.h\"\n#include \"el.h\"\n"); + printf("#include \"config.h\"\n#include \"el.h\"\n"); printf("private const el_func_t el_func[] = {"); maxlen = 80; needn = 1; diff --git a/cmd-line-utils/libedit/readline.c b/cmd-line-utils/libedit/readline.c index ca8796fbd37..1f1b18c97d8 100644 --- a/cmd-line-utils/libedit/readline.c +++ b/cmd-line-utils/libedit/readline.c @@ -51,13 +51,10 @@ #else #include "np/vis.h" #endif -#ifdef HAVE_ALLOCA_H -#include -#endif +#include "readline/readline.h" #include "el.h" #include "fcns.h" /* for EL_NUM_FCNS */ #include "histedit.h" -#include "readline/readline.h" #include "filecomplete.h" void rl_prep_terminal(int); diff --git a/cmd-line-utils/libedit/readline/readline.h b/cmd-line-utils/libedit/readline/readline.h index c4806734bc5..0e300faed89 100644 --- a/cmd-line-utils/libedit/readline/readline.h +++ b/cmd-line-utils/libedit/readline/readline.h @@ -66,7 +66,7 @@ typedef KEYMAP_ENTRY *Keymap; #ifndef CTRL #include -#if !defined(__sun__) && !defined(__hpux__) +#if !defined(__sun) && !defined(__hpux) && !defined(_AIX) && !defined(__QNXNTO__) && !defined(__USLC__) #include #endif #ifndef CTRL diff --git a/cmd-line-utils/libedit/vi.c b/cmd-line-utils/libedit/vi.c index 602383f3231..00a9f493a9b 100644 --- a/cmd-line-utils/libedit/vi.c +++ b/cmd-line-utils/libedit/vi.c @@ -914,14 +914,14 @@ vi_comment_out(EditLine *el, int c) * NB: posix implies that we should enter insert mode, however * this is against historical precedent... */ -#ifdef __weak_reference +#if defined(__weak_reference) && !defined(__FreeBSD__) extern char *get_alias_text(const char *) __weak_reference(get_alias_text); #endif protected el_action_t /*ARGSUSED*/ vi_alias(EditLine *el, int c) { -#ifdef __weak_reference +#if defined(__weak_reference) && !defined(__FreeBSD__) char alias_name[3]; char *alias_text; diff --git a/include/my_global.h b/include/my_global.h index 53b5deaffb1..31bcb771c4d 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -486,40 +486,6 @@ typedef unsigned short ushort; #define test_all_bits(a,b) (((a) & (b)) == (b)) #define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1)) #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) -#ifndef HAVE_RINT -/** - All integers up to this number can be represented exactly as double precision - values (DBL_MANT_DIG == 53 for IEEE 754 hardware). -*/ -#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1) - -/** - rint(3) implementation for platforms that do not have it. - Always rounds to the nearest integer with ties being rounded to the nearest - even integer to mimic glibc's rint() behavior in the "round-to-nearest" - FPU mode. Hardware-specific optimizations are possible (frndint on x86). - Unlike this implementation, hardware will also honor the FPU rounding mode. -*/ - -static inline double rint(double x) -{ - double f, i; - f = modf(x, &i); - /* - All doubles with absolute values > MAX_EXACT_INTEGER are even anyway, - no need to check it. - */ - if (x > 0.0) - i += (double) ((f > 0.5) || (f == 0.5 && - i <= (double) MAX_EXACT_INTEGER && - (longlong) i % 2)); - else - i -= (double) ((f < -0.5) || (f == -0.5 && - i >= (double) -MAX_EXACT_INTEGER && - (longlong) i % 2)); - return i; -} -#endif /* HAVE_RINT */ /* Define some general constants */ #ifndef TRUE @@ -1401,4 +1367,39 @@ do { doubleget_union _tmp; \ #define MY_INT64_NUM_DECIMAL_DIGITS 21 +#ifndef HAVE_RINT +/** + All integers up to this number can be represented exactly as double precision + values (DBL_MANT_DIG == 53 for IEEE 754 hardware). +*/ +#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1) + +/** + rint(3) implementation for platforms that do not have it. + Always rounds to the nearest integer with ties being rounded to the nearest + even integer to mimic glibc's rint() behavior in the "round-to-nearest" + FPU mode. Hardware-specific optimizations are possible (frndint on x86). + Unlike this implementation, hardware will also honor the FPU rounding mode. +*/ + +static inline double rint(double x) +{ + double f, i; + f = modf(x, &i); + /* + All doubles with absolute values > MAX_EXACT_INTEGER are even anyway, + no need to check it. + */ + if (x > 0.0) + i += (double) ((f > 0.5) || (f == 0.5 && + i <= (double) MAX_EXACT_INTEGER && + (longlong) i % 2)); + else + i -= (double) ((f < -0.5) || (f == -0.5 && + i >= (double) -MAX_EXACT_INTEGER && + (longlong) i % 2)); + return i; +} +#endif /* HAVE_RINT */ + #endif /* my_global_h */ diff --git a/myisam/CMakeLists.txt b/myisam/CMakeLists.txt index a557d61b87f..225c04ff457 100755 --- a/myisam/CMakeLists.txt +++ b/myisam/CMakeLists.txt @@ -41,6 +41,8 @@ TARGET_LINK_LIBRARIES(myisamlog myisam mysys debug dbug strings zlib wsock32) ADD_EXECUTABLE(myisampack myisampack.c) TARGET_LINK_LIBRARIES(myisampack myisam mysys debug dbug strings zlib wsock32) +SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj") + IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker") MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker") diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index df9a4d18a6c..68911d7f129 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -208,10 +208,17 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) This segment will be reallocated after construction of the tables. */ length=(uint) (elements*2+trees*(1 << myisam_quick_table_bits)); + /* + To keep some algorithms simpler, we accept that they access + bytes beyond the end of the input data. This can affect up to + one byte less than the "word size" size used in this file, + which is BITS_SAVED / 8. To avoid accessing non-allocated + data, we add (BITS_SAVED / 8) - 1 bytes to the buffer size. + */ if (!(share->decode_tables=(uint16*) my_malloc((length + OFFSET_TABLE_SIZE) * sizeof(uint16) + - (uint) (share->pack.header_length - sizeof(header)), - MYF(MY_WME | MY_ZEROFILL)))) + (uint) (share->pack.header_length - sizeof(header) + + (BITS_SAVED / 8) - 1), MYF(MY_WME | MY_ZEROFILL)))) goto err1; tmp_buff=share->decode_tables+length; disk_cache=(byte*) (tmp_buff+OFFSET_TABLE_SIZE); @@ -1430,31 +1437,6 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff) bit_buff->current_byte=0; return; } - else - { - uint len= 0; - uint i= 0; - /* - Check if the remaining buffer/record to read is less than the word size. - If so read byte by byte - - Note: if this branch becomes a bottleneck it can be removed, assuming - that the second memory segment allocates 7 extra bytes (see - _mi_read_pack_info()). - */ - len= bit_buff->end - bit_buff->pos; - if (len < (BITS_SAVED / 8)) - { - bit_buff->current_byte= 0; - for (i=0 ; i < len ; i++) - { - bit_buff->current_byte+= (((uint) ((uchar) bit_buff->pos[len - i - 1])) - << (8 * i)); - } - bit_buff->pos= bit_buff->end; - return; - } - } #if BITS_SAVED == 64 bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) + diff --git a/mysql-test/r/binlog.result b/mysql-test/r/binlog.result index 80890a19b86..baab30ebbdd 100644 --- a/mysql-test/r/binlog.result +++ b/mysql-test/r/binlog.result @@ -604,6 +604,8 @@ END// CALL p1(); c1 c2 c3 d1 d2 d3 utf8_general_ci utf8_unicode_ci utf8_unicode_ci 2 2 2 +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. SHOW BINLOG EVENTS FROM 1285; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 1285 Query 1 1483 use `bug39182`; CREATE TEMPORARY TABLE tmp1 @@ -613,4 +615,42 @@ DROP PROCEDURE p1; DROP TABLE t1; DROP DATABASE bug39182; USE test; +CREATE PROCEDURE p1(IN v1 INT) +BEGIN +CREATE TABLE t1 SELECT v1; +DROP TABLE t1; +END// +CREATE PROCEDURE p2() +BEGIN +DECLARE v1 INT; +CREATE TABLE t1 SELECT v1+1; +DROP TABLE t1; +END// +CREATE PROCEDURE p3(IN v1 INT) +BEGIN +CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0; +DROP TABLE t1; +END// +CREATE PROCEDURE p4(IN v1 INT) +BEGIN +DECLARE v2 INT; +CREATE TABLE t1 SELECT 1, v1, v2; +DROP TABLE t1; +CREATE TABLE t1 SELECT 1, v1+1, v2; +DROP TABLE t1; +END// +CALL p1(1); +CALL p2(); +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. +CALL p3(0); +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. +CALL p4(0); +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; End of 5.0 tests diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 85ddfaac4e0..d892deba63c 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1448,4 +1448,41 @@ COUNT(*) 0 SET SQL_MODE=default; DROP TABLE t1; +CREATE TABLE derived1 (a bigint(21)); +INSERT INTO derived1 VALUES (2); +CREATE TABLE D ( +pk int(11) NOT NULL AUTO_INCREMENT, +int_nokey int(11) DEFAULT NULL, +int_key int(11) DEFAULT NULL, +filler blob, +PRIMARY KEY (pk), +KEY int_key (int_key) +); +INSERT INTO D VALUES +(39,40,4,repeat(' X', 42)), +(43,56,4,repeat(' X', 42)), +(47,12,4,repeat(' X', 42)), +(71,28,4,repeat(' X', 42)), +(76,54,4,repeat(' X', 42)), +(83,45,4,repeat(' X', 42)), +(105,53,12,NULL); +SELECT +(SELECT COUNT( int_nokey ) +FROM derived1 AS X +WHERE +X.int_nokey < 61 +GROUP BY pk +LIMIT 1) +FROM D AS X +WHERE X.int_key < 13 +GROUP BY int_nokey LIMIT 1; +(SELECT COUNT( int_nokey ) +FROM derived1 AS X +WHERE +X.int_nokey < 61 +GROUP BY pk +LIMIT 1) +1 +DROP TABLE derived1; +DROP TABLE D; End of 5.0 tests diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 682cc2e82e2..d95499fe3ba 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1267,4 +1267,28 @@ CREATE INDEX i1 on t1 (a(3)); SELECT * FROM t1 WHERE a = 'abcde'; a DROP TABLE t1; +# +# BUG #26288: savepoint are not deleted on comit, if the transaction +# was otherwise empty +# +BEGIN; +SAVEPOINT s1; +COMMIT; +RELEASE SAVEPOINT s1; +ERROR 42000: SAVEPOINT s1 does not exist +BEGIN; +SAVEPOINT s2; +COMMIT; +ROLLBACK TO SAVEPOINT s2; +ERROR 42000: SAVEPOINT s2 does not exist +BEGIN; +SAVEPOINT s3; +ROLLBACK; +RELEASE SAVEPOINT s3; +ERROR 42000: SAVEPOINT s3 does not exist +BEGIN; +SAVEPOINT s4; +ROLLBACK; +ROLLBACK TO SAVEPOINT s4; +ERROR 42000: SAVEPOINT s4 does not exist End of 5.0 tests diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index d1b50a0080c..037b375fe0b 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -133,3 +133,58 @@ ALTER TABLE t1 ADD COLUMN a INT; # 2.2.1. normal mode # 2.2.2. PS mode DROP TABLE t1; +create table t1 (a int); +create table t2 like t1; +# con1 +lock tables t1 write; +# con2 +flush tables with read lock; +# con5 +# global read lock is taken +# con3 +select * from t2 for update; +# waiting for release of read lock +# con4 +# would hang and later cause a deadlock +flush tables t2; +# clean up +unlock tables; +unlock tables; +a +drop table t1,t2; +# +# Lightweight version: +# Ensure that the wait for a GRL is done before opening tables. +# +create table t1 (a int); +create table t2 like t1; +# +# UPDATE +# +# default +flush tables with read lock; +# con1 +update t2 set a = 1; +# default +# statement is waiting for release of read lock +# con2 +flush table t2; +# default +unlock tables; +# con1 +# +# LOCK TABLES .. WRITE +# +# default +flush tables with read lock; +# con1 +lock tables t2 write; +# default +# statement is waiting for release of read lock +# con2 +flush table t2; +# default +unlock tables; +# con1 +unlock tables; +drop table t1,t2; diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result index b4b200549a5..736a550e32b 100644 --- a/mysql-test/r/myisampack.result +++ b/mysql-test/r/myisampack.result @@ -38,3 +38,25 @@ SELECT COUNT(*) FROM t1; COUNT(*) 1024 DROP TABLE t1; +# +# Bug #43973 - backup_myisam.test fails on 6.0-bugteam +# +CREATE DATABASE mysql_db1; +CREATE TABLE mysql_db1.t1 (c1 VARCHAR(5), c2 int); +CREATE INDEX i1 ON mysql_db1.t1 (c1, c2); +INSERT INTO mysql_db1.t1 VALUES ('A',1); +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1; +FLUSH TABLE mysql_db1.t1; +# Compress the table using MYISAMPACK tool +# Run MYISAMCHK tool on the compressed table +SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5; +COUNT(*) +128 +DROP TABLE mysql_db1.t1; +DROP DATABASE mysql_db1; diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index 83dcbc61e68..5e951b866f7 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -418,17 +418,17 @@ prepare stmt3 from ' lock tables t1 read ' ; ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt3 from ' unlock tables ' ; ERROR HY000: This command is not supported in the prepared statement protocol yet -prepare stmt1 from ' load data infile ''data.txt'' -into table t1 fields terminated by ''\t'' '; +prepare stmt1 from ' load data infile ''/tmp/data.txt'' + into table t1 fields terminated by ''\t'' '; ERROR HY000: This command is not supported in the prepared statement protocol yet -prepare stmt1 from ' select * into outfile ''data.txt'' from t1 '; +prepare stmt1 from ' select * into outfile ''/tmp/data.txt'' from t1 '; execute stmt1 ; prepare stmt1 from ' optimize table t1 ' ; prepare stmt1 from ' analyze table t1 ' ; prepare stmt1 from ' checksum table t1 ' ; ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' repair table t1 ' ; -prepare stmt1 from ' restore table t1 from ''data.txt'' ' ; +prepare stmt1 from ' restore table t1 from ''/tmp/data.txt'' ' ; ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' handler t1 open '; ERROR HY000: This command is not supported in the prepared statement protocol yet diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 84a4166a45d..236fa3d8681 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4390,9 +4390,9 @@ drop procedure if exists bug13012| create procedure bug13012() BEGIN REPAIR TABLE t1; -BACKUP TABLE t1 to '../tmp'; +BACKUP TABLE t1 to '/tmp/'; DROP TABLE t1; -RESTORE TABLE t1 FROM '../tmp'; +RESTORE TABLE t1 FROM '/tmp/'; END| call bug13012()| Table Op Msg_type Msg_text diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index a07318435f6..a88a6973d61 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1961,4 +1961,24 @@ select * from t2; s1 drop table t1; drop temporary table t2; +#------------------------------------------------------------------------ +# Bug#39953 Triggers are not working properly with multi table updates +#------------------------------------------------------------------------ +DROP TABLE IF EXISTS t1; +DROP TRIGGER IF EXISTS t_insert; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 (a int, date_insert timestamp, PRIMARY KEY (a)); +INSERT INTO t1 (a) VALUES (2),(5); +CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +CREATE TRIGGER t_insert AFTER INSERT ON t2 FOR EACH ROW BEGIN UPDATE t1,t2 SET +date_insert=NOW() WHERE t1.a=t2.b AND t2.a=NEW.a; END | +INSERT INTO t2 (a,b) VALUES (1,2); +DROP TRIGGER t_insert; +CREATE TRIGGER t_insert AFTER INSERT ON t2 FOR EACH ROW BEGIN UPDATE t1,t2 SET +date_insert=NOW(),b=b+1 WHERE t1.a=t2.b AND t2.a=NEW.a; END | +INSERT INTO t2 (a,b) VALUES (3,5); +ERROR HY000: Can't update table 't2' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. +DROP TABLE t1; +DROP TRIGGER t_insert; +DROP TABLE t2; End of 5.0 tests diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 04bd818df89..a5f49eef8d1 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1506,4 +1506,16 @@ DESC t6; Field Type Null Key Default Extra NULL int(11) YES NULL DROP TABLE t1, t2, t3, t4, t5, t6; +CREATE TABLE t1 (f FLOAT(9,6)); +CREATE TABLE t2 AS SELECT f FROM t1 UNION SELECT f FROM t1; +SHOW FIELDS FROM t2; +Field Type Null Key Default Extra +f float(9,6) YES NULL +DROP TABLE t1, t2; +CREATE TABLE t1(d DOUBLE(9,6)); +CREATE TABLE t2 AS SELECT d FROM t1 UNION SELECT d FROM t1; +SHOW FIELDS FROM t2; +Field Type Null Key Default Extra +d double(9,6) YES NULL +DROP TABLE t1, t2; End of 5.0 tests diff --git a/mysql-test/r/variables-big.result b/mysql-test/r/variables-big.result index c441f27d82d..960fc6d22f4 100644 --- a/mysql-test/r/variables-big.result +++ b/mysql-test/r/variables-big.result @@ -1,24 +1,20 @@ -set session transaction_prealloc_size=1024*1024*1024*1; -show processlist; +SET SESSION transaction_prealloc_size=1024*1024*1024*1; +SHOW PROCESSLIST; Id User Host db Command Time State Info -6 root localhost test Query 0 NULL show processlist -set session transaction_prealloc_size=1024*1024*1024*2; -show processlist; + root localhost test Query