summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2006-02-02 23:27:06 +0300
committerunknown <konstantin@mysql.com>2006-02-02 23:27:06 +0300
commitd297a221fe57486f0fd82e0cf3e7b0e923adee93 (patch)
tree8b23d2acce88a26d289057d5119ca3944903d88f
parent5610e9ab8296f661b144bc64702bb612d2038050 (diff)
parent333b1f8594922647278808a4c114c16695551343 (diff)
downloadmariadb-git-d297a221fe57486f0fd82e0cf3e7b0e923adee93.tar.gz
Merge mysql.com:/home/kostja/mysql/tmp_merge
into mysql.com:/home/kostja/mysql/mysql-5.1-merge BitKeeper/etc/ignore: auto-union configure.in: Auto merged libmysql/libmysql.c: Auto merged mysql-test/ndb/ndbcluster.sh: Auto merged mysql-test/r/rpl_sp.result: Auto merged mysql-test/r/sp-error.result: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/r/type_float.result: Auto merged mysql-test/t/rpl_sp.test: Auto merged mysql-test/t/sp-error.test: Auto merged mysql-test/t/sp.test: Auto merged sql/field.cc: Auto merged sql/item_func.cc: Auto merged sql/mysqld.cc: Auto merged sql/protocol.cc: Auto merged sql/sp_head.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/myisam/ft_update.c: Auto merged storage/ndb/include/logger/LogHandler.hpp: Auto merged storage/ndb/include/logger/Logger.hpp: Auto merged storage/ndb/include/mgmapi/mgmapi.h: Auto merged storage/ndb/include/mgmcommon/ConfigRetriever.hpp: Auto merged storage/ndb/src/common/logger/FileLogHandler.cpp: Auto merged storage/ndb/src/common/logger/LogHandler.cpp: Auto merged storage/ndb/src/common/logger/Logger.cpp: Auto merged storage/ndb/src/common/logger/SysLogHandler.cpp: Auto merged storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp: Auto merged storage/ndb/src/common/util/SocketServer.cpp: Auto merged storage/ndb/src/kernel/main.cpp: Auto merged storage/ndb/src/kernel/vm/Configuration.cpp: Auto merged storage/ndb/src/kernel/vm/Configuration.hpp: Auto merged storage/ndb/src/mgmapi/mgmapi.cpp: Auto merged storage/ndb/src/mgmclient/CommandInterpreter.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/mgmsrv/Services.hpp: Auto merged storage/ndb/src/mgmsrv/main.cpp: Auto merged storage/ndb/tools/ndb_size.pl: Auto merged zlib/Makefile.am: Auto merged mysql-test/r/information_schema.result: SCCS merged mysql-test/t/information_schema.test: Manual merge. sql/ha_archive.cc: Manual merge. sql/share/errmsg.txt: SCCS merged tests/mysql_client_test.c: Manual merge.
-rw-r--r--.bzrignore3
-rw-r--r--configure.in11
-rw-r--r--libmysql/Makefile.shared2
-rw-r--r--libmysql/libmysql.c2
-rw-r--r--libmysql/libmysql.ver.in1
-rw-r--r--mysql-test/r/fulltext2.result5
-rw-r--r--mysql-test/r/information_schema.result13
-rw-r--r--mysql-test/r/rpl_sp.result13
-rw-r--r--mysql-test/r/sp-error.result19
-rw-r--r--mysql-test/r/sp-security.result21
-rw-r--r--mysql-test/r/sp.result58
-rw-r--r--mysql-test/r/sp_trans.result2
-rw-r--r--mysql-test/r/subselect.result6
-rw-r--r--mysql-test/r/type_float.result22
-rw-r--r--mysql-test/r/type_varchar.result7
-rw-r--r--mysql-test/t/fulltext2.test8
-rw-r--r--mysql-test/t/func_math.test2
-rw-r--r--mysql-test/t/information_schema.test23
-rw-r--r--mysql-test/t/rpl_sp.test36
-rw-r--r--mysql-test/t/sp-error.test27
-rw-r--r--mysql-test/t/sp-security.test44
-rw-r--r--mysql-test/t/sp.test49
-rw-r--r--mysql-test/t/sp_trans.test2
-rw-r--r--mysql-test/t/type_float.test17
-rw-r--r--mysql-test/t/type_varchar.test16
-rw-r--r--mysys/my_lib.c2
-rw-r--r--sql/field.cc4
-rw-r--r--sql/ha_archive.cc7
-rw-r--r--sql/item_func.cc13
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/protocol.cc18
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sp_head.cc54
-rw-r--r--sql/sp_head.h2
-rw-r--r--sql/spatial.h2
-rw-r--r--sql/sql_acl.cc2
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--sql/sql_select.cc8
-rw-r--r--sql/sql_show.cc12
-rw-r--r--sql/sql_yacc.yy15
-rw-r--r--sql/table.h1
-rw-r--r--storage/myisam/ft_update.c4
-rw-r--r--storage/ndb/include/logger/LogHandler.hpp13
-rw-r--r--storage/ndb/include/logger/Logger.hpp5
-rw-r--r--storage/ndb/include/mgmapi/mgmapi.h16
-rw-r--r--storage/ndb/include/mgmcommon/ConfigRetriever.hpp3
-rw-r--r--storage/ndb/src/common/logger/FileLogHandler.cpp17
-rw-r--r--storage/ndb/src/common/logger/LogHandler.cpp29
-rw-r--r--storage/ndb/src/common/logger/Logger.cpp11
-rw-r--r--storage/ndb/src/common/logger/SysLogHandler.cpp1
-rw-r--r--storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp3
-rw-r--r--storage/ndb/src/common/util/SocketServer.cpp2
-rw-r--r--storage/ndb/src/kernel/main.cpp5
-rw-r--r--storage/ndb/src/kernel/vm/Configuration.cpp3
-rw-r--r--storage/ndb/src/kernel/vm/Configuration.hpp2
-rw-r--r--storage/ndb/src/mgmapi/mgmapi.cpp19
-rw-r--r--storage/ndb/src/mgmclient/CommandInterpreter.cpp23
-rw-r--r--storage/ndb/src/mgmsrv/MgmtSrvr.cpp153
-rw-r--r--storage/ndb/src/mgmsrv/MgmtSrvr.hpp11
-rw-r--r--storage/ndb/src/mgmsrv/Services.cpp15
-rw-r--r--storage/ndb/src/mgmsrv/Services.hpp1
-rw-r--r--storage/ndb/src/mgmsrv/main.cpp61
-rw-r--r--storage/ndb/tools/ndb_size.pl2
-rw-r--r--support-files/MySQL-shared-compat.spec.sh11
-rw-r--r--tests/mysql_client_test.c84
-rw-r--r--zlib/Makefile.am2
-rw-r--r--zlib/README.MySQL9
-rw-r--r--zlib/gzio.c4
-rw-r--r--zlib/zconf.h6
69 files changed, 895 insertions, 175 deletions
diff --git a/.bzrignore b/.bzrignore
index 16211ff2ecf..50218bc2dc3 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -48,6 +48,7 @@
50
=6
BUILD/compile-pentium-maintainer
+BitKeeper/etc/RESYNC_TREE
BitKeeper/etc/config
BitKeeper/etc/csets
BitKeeper/etc/csets-in
@@ -295,6 +296,7 @@ libmysql/*.ds?
libmysql/*.vcproj
libmysql/conf_to_src
libmysql/debug/libmysql.exp
+libmysql/libmysql.ver
libmysql/my_static.h
libmysql/my_time.c
libmysql/mysys_priv.h
@@ -1611,4 +1613,3 @@ vio/viotest-sslconnect.cpp
vio/viotest.cpp
zlib/*.ds?
zlib/*.vcproj
-BitKeeper/etc/RESYNC_TREE
diff --git a/configure.in b/configure.in
index baed56cb914..f174704e81b 100644
--- a/configure.in
+++ b/configure.in
@@ -13,7 +13,8 @@ AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
DOT_FRM_VERSION=6
# See the libtool docs for information on how to do shared lib versions.
-SHARED_LIB_VERSION=15:0:0
+SHARED_LIB_MAJOR_VERSION=15
+SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0
# Set all version vars based on $VERSION. How do we do this more elegant ?
# Remember that regexps needs to quote [ and ] since this is run through m4
@@ -60,6 +61,7 @@ AC_DEFINE_UNQUOTED([PROTOCOL_VERSION], [$PROTOCOL_VERSION],
AC_SUBST(DOT_FRM_VERSION)
AC_DEFINE_UNQUOTED([DOT_FRM_VERSION], [$DOT_FRM_VERSION],
[Version of .frm files])
+AC_SUBST(SHARED_LIB_MAJOR_VERSION)
AC_SUBST(SHARED_LIB_VERSION)
AC_SUBST(AVAILABLE_LANGUAGES)
@@ -339,6 +341,13 @@ fi
MYSQL_PROG_AR
+# libmysqlclient versioning when linked with GNU ld.
+if $LD --version 2>/dev/null|grep -q GNU; then
+ LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_srcdir)/libmysql/libmysql.ver"
+ AC_CONFIG_FILES(libmysql/libmysql.ver)
+fi
+AC_SUBST(LD_VERSION_SCRIPT)
+
# Avoid bug in fcntl on some versions of linux
AC_MSG_CHECKING("if we should use 'skip-locking' as default for $target_os")
# Any variation of Linux
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index a4d616f936a..c4c9c0036e2 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -77,7 +77,7 @@ mysysobjects2 = my_lib.lo
mysysobjects = $(mysysobjects1) $(mysysobjects2)
target_libadd = $(mysysobjects) $(mystringsobjects) $(dbugobjects) \
$(sql_cmn_objects) $(vio_objects) $(sqlobjects)
-target_ldflags = -version-info @SHARED_LIB_VERSION@
+target_ldflags = -version-info @SHARED_LIB_VERSION@ @LD_VERSION_SCRIPT@
vio_objects= vio.lo viosocket.lo viossl.lo viosslfactories.lo
CLEANFILES = $(target_libadd) $(SHLIBOBJS) \
$(target)
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index de735e83e07..a77d1408383 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -2817,7 +2817,7 @@ my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
{
switch (attr_type) {
case STMT_ATTR_UPDATE_MAX_LENGTH:
- *(ulong*) value= stmt->update_max_length;
+ *(my_bool*) value= stmt->update_max_length;
break;
case STMT_ATTR_CURSOR_TYPE:
*(ulong*) value= stmt->flags;
diff --git a/libmysql/libmysql.ver.in b/libmysql/libmysql.ver.in
new file mode 100644
index 00000000000..20eb0fd41bb
--- /dev/null
+++ b/libmysql/libmysql.ver.in
@@ -0,0 +1 @@
+libmysqlclient_@SHARED_LIB_MAJOR_VERSION@ { global: *; };
diff --git a/mysql-test/r/fulltext2.result b/mysql-test/r/fulltext2.result
index 72c6b2d22ed..f6a4b20bc22 100644
--- a/mysql-test/r/fulltext2.result
+++ b/mysql-test/r/fulltext2.result
@@ -234,5 +234,10 @@ insert into t1 values('test test '),('test'),('test'),('test'),
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test');
delete from t1 limit 1;
+truncate table t1;
+insert into t1 values('ab c d');
+update t1 set a='ab c d';
+select * from t1 where match a against('ab c' in boolean mode);
+a
drop table t1;
set names latin1;
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index e367e063201..51d75e7ec41 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -1126,6 +1126,19 @@ DROP TABLE t1;
DROP VIEW v1;
DROP FUNCTION func1;
DROP FUNCTION func2;
+create database mysqltest;
+create table mysqltest.t1(a int);
+select table_schema from information_schema.tables where table_schema='mysqltest';
+table_schema
+drop database mysqltest;
+select column_type, group_concat(table_schema, '.', table_name), count(*) as num
+from information_schema.columns where
+table_schema='information_schema' and
+(column_type = 'varchar(7)' or column_type = 'varchar(20)')
+group by column_type order by num;
+column_type group_concat(table_schema, '.', table_name) num
+varchar(20) information_schema.COLUMNS 1
+varchar(7) information_schema.ROUTINES,information_schema.VIEWS 2
select * from information_schema.engines WHERE ENGINE="MyISAM";
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
MyISAM ENABLED Default engine as of MySQL 3.23 with great performance NO NO NO
diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result
index 1acb57f67d5..8aa0f445438 100644
--- a/mysql-test/r/rpl_sp.result
+++ b/mysql-test/r/rpl_sp.result
@@ -401,5 +401,18 @@ drop function f1;
select * from t1;
a
1
+DROP PROCEDURE IF EXISTS p1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(col VARCHAR(10));
+CREATE PROCEDURE p1(arg VARCHAR(10))
+INSERT INTO t1 VALUES(arg);
+CALL p1('test');
+SELECT * FROM t1;
+col
+test
+SELECT * FROM t1;
+col
+test
+DROP PROCEDURE p1;
drop table t1;
reset master;
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index a74a18375d5..d26f0029001 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1115,3 +1115,22 @@ ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function
drop function bug11555_1;
drop table t1;
drop view v1;
+drop procedure if exists ` bug15658`;
+create procedure ``() select 1;
+ERROR 42000: Incorrect routine name ''
+create procedure ` `() select 1;
+ERROR 42000: Incorrect routine name ' '
+create procedure `bug15658 `() select 1;
+ERROR 42000: Incorrect routine name 'bug15658 '
+create procedure ``.bug15658() select 1;
+ERROR 42000: Incorrect database name ''
+create procedure `x `.bug15658() select 1;
+ERROR 42000: Incorrect database name 'x '
+create procedure ` bug15658`() select 1;
+call ` bug15658`();
+1
+1
+show procedure status;
+Db Name Type Definer Modified Created Security_type Comment
+test bug15658 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+drop procedure ` bug15658`;
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 614e670f25d..fbc6d64f9c9 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -263,3 +263,24 @@ CREATE VIEW v1 AS SELECT test.bug12812()|
ERROR 42000: execute command denied to user 'user_bug12812'@'localhost' for routine 'test.bug12812'
DROP USER user_bug12812@localhost|
drop function bug12812|
+create database db_bug14834;
+create user user1_bug14834@localhost identified by '';
+grant all on `db\_bug14834`.* to user1_bug14834@localhost;
+create user user2_bug14834@localhost identified by '';
+grant all on `db\_bug14834`.* to user2_bug14834@localhost;
+create user user3_bug14834@localhost identified by '';
+grant all on `db__ug14834`.* to user3_bug14834@localhost;
+create procedure p_bug14834() select user(), current_user();
+call p_bug14834();
+user() current_user()
+user1_bug14834@localhost user1_bug14834@localhost
+call p_bug14834();
+user() current_user()
+user2_bug14834@localhost user1_bug14834@localhost
+call p_bug14834();
+user() current_user()
+user3_bug14834@localhost user1_bug14834@localhost
+drop user user1_bug14834@localhost;
+drop user user2_bug14834@localhost;
+drop user user3_bug14834@localhost;
+drop database db_bug14834;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index a025c0503cd..ea4420c8e70 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -1178,8 +1178,8 @@ drop view v2|
delete from t1 |
delete from t2 |
drop table t4|
-drop table if exists fac|
-create table fac (n int unsigned not null primary key, f bigint unsigned)|
+drop table if exists t3|
+create table t3 (n int unsigned not null primary key, f bigint unsigned)|
drop procedure if exists ifac|
create procedure ifac(n int unsigned)
begin
@@ -1189,13 +1189,13 @@ set n = 20; # bigint overflow otherwise
end if;
while i <= n do
begin
-insert into test.fac values (i, fac(i));
+insert into test.t3 values (i, fac(i));
set i = i + 1;
end;
end while;
end|
call ifac(20)|
-select * from fac|
+select * from t3|
n f
1 1
2 2
@@ -1217,7 +1217,7 @@ n f
18 6402373705728000
19 121645100408832000
20 2432902008176640000
-drop table fac|
+drop table t3|
show function status like '%f%'|
Db Name Type Definer Modified Created Security_type Comment
test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
@@ -1225,12 +1225,12 @@ drop procedure ifac|
drop function fac|
show function status like '%f%'|
Db Name Type Definer Modified Created Security_type Comment
-drop table if exists primes|
-create table primes (
+drop table if exists t3|
+create table t3 (
i int unsigned not null primary key,
p bigint unsigned not null
)|
-insert into primes values
+insert into t3 values
( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13),
( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31),
(10, 37), (11, 41), (12, 43), (13, 47), (14, 53),
@@ -1253,7 +1253,7 @@ set b = b+200, s = 0;
else
begin
declare p bigint unsigned;
-select t.p into p from test.primes t where t.i = s;
+select t.p into p from test.t3 t where t.i = s;
if b+p > r then
set pp = 1;
leave again;
@@ -1278,7 +1278,7 @@ begin
declare pp bool default 0;
call opp(p, pp);
if pp then
-insert into test.primes values (i, p);
+insert into test.t3 values (i, p);
set i = i+1;
end if;
set p = p+2;
@@ -1299,7 +1299,7 @@ set b = b+200, s = 0;
else
begin
declare p bigint unsigned;
-select t.p into p from test.primes t where t.i = s;
+select t.p into p from test.t3 t where t.i = s;
if b+p > r then
set pp = 1;
leave again;
@@ -1318,47 +1318,47 @@ Db Name Type Definer Modified Created Security_type Comment
test ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
call ip(200)|
-select * from primes where i=45 or i=100 or i=199|
+select * from t3 where i=45 or i=100 or i=199|
i p
45 211
100 557
199 1229
-drop table primes|
+drop table t3|
drop procedure opp|
drop procedure ip|
show procedure status like '%p%'|
Db Name Type Definer Modified Created Security_type Comment
-drop table if exists fib|
-create table fib ( f bigint unsigned not null )|
+drop table if exists t3|
+create table t3 ( f bigint unsigned not null )|
drop procedure if exists fib|
create procedure fib(n int unsigned)
begin
if n > 1 then
begin
declare x, y bigint unsigned;
-declare c cursor for select f from fib order by f desc limit 2;
+declare c cursor for select f from t3 order by f desc limit 2;
open c;
fetch c into y;
fetch c into x;
close c;
-insert into fib values (x+y);
+insert into t3 values (x+y);
call fib(n-1);
end;
end if;
end|
set @@max_sp_recursion_depth= 20|
-insert into fib values (0), (1)|
+insert into t3 values (0), (1)|
call fib(3)|
-select * from fib order by f asc|
+select * from t3 order by f asc|
f
0
1
1
2
-delete from fib|
-insert into fib values (0), (1)|
-call fib(20)|
-select * from fib order by f asc|
+delete from t3|
+insert into t3 values (0), (1)|
+call fib(10)|
+select * from t3 order by f asc|
f
0
1
@@ -1371,17 +1371,7 @@ f
21
34
55
-89
-144
-233
-377
-610
-987
-1597
-2584
-4181
-6765
-drop table fib|
+drop table t3|
drop procedure fib|
set @@max_sp_recursion_depth= 0|
drop procedure if exists bar|
diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result
index 8f2bd9985fc..e9289cf01c7 100644
--- a/mysql-test/r/sp_trans.result
+++ b/mysql-test/r/sp_trans.result
@@ -1,4 +1,4 @@
-drop table if exists t1, t2;
+drop table if exists t1, t2, t3;
drop procedure if exists bug8850|
create table t1 (a int) engine=innodb|
create procedure bug8850()
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 6094d23b0d0..85976c211c5 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -215,9 +215,9 @@ select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from
a
select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)
-8 7.5000
-8 4.5000
-9 7.5000
+8 7.5
+8 4.5
+9 7.5
explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t4 ALL NULL NULL NULL NULL 3
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index 352dd55653b..1e5373ba766 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -240,6 +240,28 @@ t3 CREATE TABLE `t3` (
`d` double(22,9) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2, t3;
+create table t1 select 105213674794682365.00 + 0.0 x;
+show warnings;
+Level Code Message
+desc t1;
+Field Type Null Key Default Extra
+x decimal(21,2) unsigned NO 0.00
+drop table t1;
+create table t1 select 0.0 x;
+desc t1;
+Field Type Null Key Default Extra
+x decimal(2,1) unsigned NO 0.0
+create table t2 select 105213674794682365.00 y;
+desc t2;
+Field Type Null Key Default Extra
+y decimal(20,2) unsigned NO 0.00
+create table t3 select x+y a from t1,t2;
+show warnings;
+Level Code Message
+desc t3;
+Field Type Null Key Default Extra
+a decimal(21,2) unsigned NO 0.00
+drop table t1,t2,t3;
create table t1 (s1 float(0,2));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
create table t1 (s1 float(1,2));
diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result
index e3b12cc36e3..e74850bba33 100644
--- a/mysql-test/r/type_varchar.result
+++ b/mysql-test/r/type_varchar.result
@@ -415,3 +415,10 @@ t1 CREATE TABLE `t1` (
KEY `index1` (`f1`(10))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(f1 VARCHAR(100) DEFAULT 'test');
+INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test');
+INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test
index 7a7b572d58f..fd97f795534 100644
--- a/mysql-test/t/fulltext2.test
+++ b/mysql-test/t/fulltext2.test
@@ -209,6 +209,14 @@ insert into t1 values('test test '),('test'),('test'),('test'),
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test');
delete from t1 limit 1;
+
+#
+# BUG#16489: utf8 + fulltext leads to corrupt index file.
+#
+truncate table t1;
+insert into t1 values('ab c d');
+update t1 set a='ab c d';
+select * from t1 where match a against('ab c' in boolean mode);
drop table t1;
set names latin1;
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index 24dd18daab1..9cf0ee452cd 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -121,7 +121,9 @@ drop table t1;
#
# InnoDB is required to reproduce the fault, but it is okay if we default to
# MyISAM when testing.
+--disable_warnings
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
+--enable_warnings
insert into t1 values ('http://www.foo.com/', now());
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
drop table t1;
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 7f61b4f080a..36374683e24 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -794,6 +794,29 @@ DROP TABLE t1;
DROP VIEW v1;
DROP FUNCTION func1;
DROP FUNCTION func2;
+
+#
+# Bug #15851 Unlistable directories yield no info from information_schema
+#
+create database mysqltest;
+create table mysqltest.t1(a int);
+--exec chmod -r $MYSQL_TEST_DIR/var/master-data/mysqltest
+select table_schema from information_schema.tables where table_schema='mysqltest';
+--exec chmod +r $MYSQL_TEST_DIR/var/master-data/mysqltest
+drop database mysqltest;
+
+#
+# Bug#15307 GROUP_CONCAT() with ORDER BY returns empty set on information_schema
+#
+select column_type, group_concat(table_schema, '.', table_name), count(*) as num
+from information_schema.columns where
+table_schema='information_schema' and
+(column_type = 'varchar(7)' or column_type = 'varchar(20)')
+group by column_type order by num;
+
+#
+# End of 5.0 tests.
+#
# Show engines
#
diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test
index 64f99f3d8b9..708a3e0acaa 100644
--- a/mysql-test/t/rpl_sp.test
+++ b/mysql-test/t/rpl_sp.test
@@ -403,6 +403,42 @@ sync_slave_with_master;
connection slave;
select * from t1;
+#
+# Bug#16621 "INSERTs in Stored Procedures causes data corruption in the Binary
+# Log for 5.0.18"
+#
+
+# Prepare environment.
+
+connection master;
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Test case.
+
+CREATE TABLE t1(col VARCHAR(10));
+
+CREATE PROCEDURE p1(arg VARCHAR(10))
+ INSERT INTO t1 VALUES(arg);
+
+CALL p1('test');
+
+SELECT * FROM t1;
+
+sync_slave_with_master;
+connection slave;
+
+SELECT * FROM t1;
+
+# Cleanup.
+
+connection master;
+
+DROP PROCEDURE p1;
+
# cleanup
connection master;
drop table t1;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index cabd00fe5f9..d7044bee632 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -1534,6 +1534,7 @@ drop procedure bug13012_1|
drop function bug13012_2|
delimiter ;|
+#
# BUG#11555 "Stored procedures: current SP tables locking make
# impossible view security". We should not expose names of tables
# which are implicitly used by view (via stored routines/triggers).
@@ -1594,7 +1595,33 @@ drop function bug11555_1;
drop table t1;
drop view v1;
+#
+# BUG#15658: Server crashes after creating function as empty string
+#
+--disable_warnings
+drop procedure if exists ` bug15658`;
+--enable_warnings
+
+--error ER_SP_WRONG_NAME
+create procedure ``() select 1;
+--error ER_SP_WRONG_NAME
+create procedure ` `() select 1;
+--error ER_SP_WRONG_NAME
+create procedure `bug15658 `() select 1;
+--error ER_WRONG_DB_NAME
+create procedure ``.bug15658() select 1;
+--error ER_WRONG_DB_NAME
+create procedure `x `.bug15658() select 1;
+# This should work
+create procedure ` bug15658`() select 1;
+call ` bug15658`();
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show procedure status;
+drop procedure ` bug15658`;
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index 8d4f99abd71..0b24881a056 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -437,4 +437,48 @@ disconnect test_user_12812|
DROP USER user_bug12812@localhost|
drop function bug12812|
delimiter ;|
+
+
+#
+# BUG#14834: Server denies to execute Stored Procedure
+#
+# The problem here was with '_' in the database name.
+#
+create database db_bug14834;
+
+create user user1_bug14834@localhost identified by '';
+# The exact name of the database (no wildcard)
+grant all on `db\_bug14834`.* to user1_bug14834@localhost;
+
+create user user2_bug14834@localhost identified by '';
+# The exact name of the database (no wildcard)
+grant all on `db\_bug14834`.* to user2_bug14834@localhost;
+
+create user user3_bug14834@localhost identified by '';
+# Wildcards in the database name
+grant all on `db__ug14834`.* to user3_bug14834@localhost;
+
+connect (user1_bug14834,localhost,user1_bug14834,,db_bug14834);
+# Create the procedure and check that we can call it
+create procedure p_bug14834() select user(), current_user();
+call p_bug14834();
+
+connect (user2_bug14834,localhost,user2_bug14834,,db_bug14834);
+# This didn't work before
+call p_bug14834();
+
+connect (user3_bug14834,localhost,user3_bug14834,,db_bug14834);
+# Should also work
+call p_bug14834();
+
+# Cleanup
+connection default;
+disconnect user1_bug14834;
+disconnect user2_bug14834;
+disconnect user3_bug14834;
+drop user user1_bug14834@localhost;
+drop user user2_bug14834@localhost;
+drop user user3_bug14834@localhost;
+drop database db_bug14834;
+
# End of 5.0 bugs.
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 836d24340ef..02772313d01 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1419,9 +1419,9 @@ drop table t4|
# fac
--disable_warnings
-drop table if exists fac|
+drop table if exists t3|
--enable_warnings
-create table fac (n int unsigned not null primary key, f bigint unsigned)|
+create table t3 (n int unsigned not null primary key, f bigint unsigned)|
--disable_warnings
drop procedure if exists ifac|
@@ -1435,15 +1435,15 @@ begin
end if;
while i <= n do
begin
- insert into test.fac values (i, fac(i));
+ insert into test.t3 values (i, fac(i));
set i = i + 1;
end;
end while;
end|
call ifac(20)|
-select * from fac|
-drop table fac|
+select * from t3|
+drop table t3|
--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show function status like '%f%'|
drop procedure ifac|
@@ -1455,15 +1455,15 @@ show function status like '%f%'|
# primes
--disable_warnings
-drop table if exists primes|
+drop table if exists t3|
--enable_warnings
-create table primes (
+create table t3 (
i int unsigned not null primary key,
p bigint unsigned not null
)|
-insert into primes values
+insert into t3 values
( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13),
( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31),
(10, 37), (11, 41), (12, 43), (13, 47), (14, 53),
@@ -1492,7 +1492,7 @@ begin
begin
declare p bigint unsigned;
- select t.p into p from test.primes t where t.i = s;
+ select t.p into p from test.t3 t where t.i = s;
if b+p > r then
set pp = 1;
leave again;
@@ -1523,7 +1523,7 @@ begin
call opp(p, pp);
if pp then
- insert into test.primes values (i, p);
+ insert into test.t3 values (i, p);
set i = i+1;
end if;
set p = p+2;
@@ -1545,8 +1545,8 @@ call ip(200)|
# 45 211
# 100 557
# 199 1229
-select * from primes where i=45 or i=100 or i=199|
-drop table primes|
+select * from t3 where i=45 or i=100 or i=199|
+drop table t3|
drop procedure opp|
drop procedure ip|
--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
@@ -1556,9 +1556,9 @@ show procedure status like '%p%'|
# Fibonacci, for recursion test. (Yet Another Numerical series :)
#
--disable_warnings
-drop table if exists fib|
+drop table if exists t3|
--enable_warnings
-create table fib ( f bigint unsigned not null )|
+create table t3 ( f bigint unsigned not null )|
# We deliberately do it the awkward way, fetching the last two
# values from the table, in order to exercise various statements
@@ -1571,13 +1571,13 @@ begin
if n > 1 then
begin
declare x, y bigint unsigned;
- declare c cursor for select f from fib order by f desc limit 2;
+ declare c cursor for select f from t3 order by f desc limit 2;
open c;
fetch c into y;
fetch c into x;
close c;
- insert into fib values (x+y);
+ insert into t3 values (x+y);
call fib(n-1);
end;
end if;
@@ -1588,22 +1588,23 @@ set @@max_sp_recursion_depth= 20|
# Minimum test: recursion of 3 levels
-insert into fib values (0), (1)|
+insert into t3 values (0), (1)|
call fib(3)|
-select * from fib order by f asc|
+select * from t3 order by f asc|
-delete from fib|
+delete from t3|
-# Original test: 20 levels (may run into memory limits!)
+# The original test, 20 levels, ran into memory limits on some machines
+# and builds. Try 10 instead...
-insert into fib values (0), (1)|
+insert into t3 values (0), (1)|
-call fib(20)|
+call fib(10)|
-select * from fib order by f asc|
-drop table fib|
+select * from t3 order by f asc|
+drop table t3|
drop procedure fib|
set @@max_sp_recursion_depth= 0|
diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test
index 308d4ad5c33..b9bd4c938b3 100644
--- a/mysql-test/t/sp_trans.test
+++ b/mysql-test/t/sp_trans.test
@@ -5,7 +5,7 @@
-- source include/have_innodb.inc
--disable_warnings
-drop table if exists t1, t2;
+drop table if exists t1, t2, t3;
--enable_warnings
delimiter |;
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 6a0814ef113..79f29624e89 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -159,6 +159,23 @@ show create table t3;
drop table t1, t2, t3;
+#
+# Bug #9855 (inconsistent column type for create select
+#
+create table t1 select 105213674794682365.00 + 0.0 x;
+show warnings;
+desc t1;
+drop table t1;
+
+create table t1 select 0.0 x;
+desc t1;
+create table t2 select 105213674794682365.00 y;
+desc t2;
+create table t3 select x+y a from t1,t2;
+show warnings;
+desc t3;
+drop table t1,t2,t3;
+
# End of 4.1 tests
#
diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test
index 1a3a93018a4..2d2314f0a29 100644
--- a/mysql-test/t/type_varchar.test
+++ b/mysql-test/t/type_varchar.test
@@ -130,3 +130,19 @@ show create table t1;
alter table t1 modify f1 tinytext;
show create table t1;
drop table t1;
+
+#
+# BUG#15588: String overrun
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(f1 VARCHAR(100) DEFAULT 'test');
+INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
+DROP TABLE IF EXISTS t1;
+
+CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test');
+INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
+DROP TABLE IF EXISTS t1;
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 1908c70f407..4ca343064d3 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -170,6 +170,8 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
bzero(finfo.mystat, sizeof(MY_STAT));
VOID(strmov(tmp_file,dp->d_name));
VOID(my_stat(tmp_path, finfo.mystat, MyFlags));
+ if (!(finfo.mystat->st_mode & MY_S_IREAD))
+ continue;
}
else
finfo.mystat= NULL;
diff --git a/sql/field.cc b/sql/field.cc
index 48f8f7f8f32..3d983bb4d12 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5877,7 +5877,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
field_length/
field_charset->mbmaxlen,
&well_formed_error);
- memcpy(ptr,from,copy_length);
+ memmove(ptr, from, copy_length);
/* Append spaces if the string was shorter than the field. */
if (copy_length < field_length)
@@ -6293,7 +6293,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
field_length/
field_charset->mbmaxlen,
&well_formed_error);
- memcpy(ptr + length_bytes, from, copy_length);
+ memmove(ptr + length_bytes, from, copy_length);
if (length_bytes == 1)
*ptr= (uchar) copy_length;
else
diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc
index 65049bac135..2a2ac475c0b 100644
--- a/sql/ha_archive.cc
+++ b/sql/ha_archive.cc
@@ -139,6 +139,10 @@ static HASH archive_open_tables;
/* Static declarations for handerton */
static handler *archive_create_handler(TABLE_SHARE *table);
+/*
+ Number of rows that will force a bulk insert.
+*/
+#define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2
/* dummy handlerton - only to have something to return from archive_db_init */
@@ -1302,7 +1306,8 @@ void ha_archive::info(uint flag)
void ha_archive::start_bulk_insert(ha_rows rows)
{
DBUG_ENTER("ha_archive::start_bulk_insert");
- bulk_insert= TRUE;
+ if (!rows || rows >= ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT)
+ bulk_insert= TRUE;
DBUG_VOID_RETURN;
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index c4c03e1cbf2..60b0dafefc5 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -431,12 +431,19 @@ my_decimal *Item_real_func::val_decimal(my_decimal *decimal_value)
void Item_func::fix_num_length_and_dec()
{
- decimals= 0;
+ uint fl_length= 0;
+ decimals=0;
for (uint i=0 ; i < arg_count ; i++)
{
- set_if_bigger(decimals, args[i]->decimals);
+ set_if_bigger(decimals,args[i]->decimals);
+ set_if_bigger(fl_length, args[i]->max_length);
+ }
+ max_length=float_length(decimals);
+ if (fl_length > max_length)
+ {
+ decimals= NOT_FIXED_DEC;
+ max_length= float_length(NOT_FIXED_DEC);
}
- max_length= float_length(decimals);
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f5b93e6a5e5..119b75a7fe6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -5120,7 +5120,7 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
"Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second).",
(gptr*) &innobase_flush_log_at_trx_commit,
(gptr*) &innobase_flush_log_at_trx_commit,
- 0, GET_UINT, OPT_ARG, 1, 0, 2, 0, 0, 0},
+ 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
{"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
"With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
(gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 98cded56871..650bd8fc58f 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -601,9 +601,23 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
else
{
/* With conversion */
+ uint max_char_len;
int2store(pos, thd_charset->number);
- uint char_len= field.length / item->collation.collation->mbmaxlen;
- int4store(pos+2, char_len * thd_charset->mbmaxlen);
+ /*
+ For TEXT/BLOB columns, field_length describes the maximum data
+ length in bytes. There is no limit to the number of characters
+ that a TEXT column can store, as long as the data fits into
+ the designated space.
+ For the rest of textual columns, field_length is evaluated as
+ char_count * mbmaxlen, where character count is taken from the
+ definition of the column. In other words, the maximum number
+ of characters here is limited by the column definition.
+ */
+ max_char_len= (field.type >= (int) MYSQL_TYPE_TINY_BLOB &&
+ field.type <= (int) MYSQL_TYPE_BLOB) ?
+ field.length / item->collation.collation->mbminlen :
+ field.length / item->collation.collation->mbmaxlen;
+ int4store(pos+2, max_char_len * thd_charset->mbmaxlen);
}
pos[6]= field.type;
int2store(pos+7,field.flags);
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 084ab31c459..1099b410290 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5798,3 +5798,5 @@ ER_CANT_WRITE_LOCK_LOG_TABLE
eng "You can't write-lock a log table. Only read access is possible."
ER_CANT_READ_LOCK_LOG_TABLE
eng "You can't use usual read lock with log tables. Try READ LOCAL instead."
+ER_SP_WRONG_NAME 42000
+ eng "Incorrect routine name '%-.64s'"
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index e1af0b7d939..e4e87eb5620 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -105,21 +105,27 @@ sp_get_item_value(Item *item, String *str)
case STRING_RESULT:
{
- char buf_holder[STRING_BUFFER_USUAL_SIZE];
- String buf(buf_holder, sizeof(buf_holder), &my_charset_latin1);
String *result= item->val_str(str);
if (!result)
return NULL;
- buf.append('_');
- buf.append(result->charset()->csname);
- buf.append('\'');
- buf.append(*result);
- buf.append('\'');
- str->copy(buf);
-
- return str;
+ {
+ char buf_holder[STRING_BUFFER_USUAL_SIZE];
+ String buf(buf_holder, sizeof(buf_holder), result->charset());
+
+ /* We must reset length of the buffer, because of String specificity. */
+ buf.length(0);
+
+ buf.append('_');
+ buf.append(result->charset()->csname);
+ buf.append('\'');
+ buf.append(*result);
+ buf.append('\'');
+ str->copy(buf);
+
+ return str;
+ }
}
case ROW_RESULT:
@@ -389,6 +395,23 @@ sp_name_current_db_new(THD *thd, LEX_STRING name)
return qname;
}
+/*
+ Check that the name 'ident' is ok. It's assumed to be an 'ident'
+ from the parser, so we only have to check length and trailing spaces.
+ The former is a standard requirement (and 'show status' assumes a
+ non-empty name), the latter is a mysql:ism as trailing spaces are
+ removed by get_field().
+
+ RETURN
+ TRUE - bad name
+ FALSE - name is ok
+*/
+
+bool
+check_routine_name(LEX_STRING ident)
+{
+ return (!ident.str || !ident.str[0] || ident.str[ident.length-1] == ' ');
+}
/* ------------------------------------------------------------------ */
@@ -3083,9 +3106,16 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
void
sp_instr_set_case_expr::print(String *str)
{
- str->append(STRING_WITH_LEN("set_case_expr "));
+ const char CASE_EXPR_TAG[]= "set_case_expr ";
+ const int CASE_EXPR_TAG_LEN= sizeof(CASE_EXPR_TAG) - 1;
+ const int INT_STRING_MAX_LEN= 10;
+
+ /* We must call reserve(), because qs_append() doesn't care about memory. */
+ str->reserve(CASE_EXPR_TAG_LEN + INT_STRING_MAX_LEN + 2);
+
+ str->qs_append(CASE_EXPR_TAG, CASE_EXPR_TAG_LEN);
str->qs_append(m_case_expr_id);
- str->append(' ');
+ str->qs_append(' ');
m_case_expr->print(str);
}
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 37ab486c6f3..c4b6cb36090 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -103,6 +103,8 @@ public:
sp_name *
sp_name_current_db_new(THD *thd, LEX_STRING name);
+bool
+check_routine_name(LEX_STRING name);
class sp_head :private Query_arena
{
diff --git a/sql/spatial.h b/sql/spatial.h
index 4253689c078..527dc750bdc 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -142,7 +142,7 @@ struct MBR
bool inner_point(double x, double y) const
{
/* The following should be safe, even if we compare doubles */
- return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>x);
+ return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>y);
}
int overlaps(const MBR *mbr)
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 10599729672..cfcdd6d9e61 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1001,7 +1001,7 @@ bool acl_getroot_no_password(Security_context *sctx, char *user, char *host,
{
if (compare_hostname(&acl_db->host, host, ip))
{
- if (!acl_db->db || (db && !strcmp(acl_db->db, db)))
+ if (!acl_db->db || (db && !wild_compare(db, acl_db->db, 0)))
{
sctx->db_access= acl_db->access;
break;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index b66e617c06e..cb080ba68e0 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2120,6 +2120,8 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
were closed in the end of previous prepare or execute call.
*/
tables->table= 0;
+ /* Reset is_schema_table_processed value(needed for I_S tables */
+ tables->is_schema_table_processed= FALSE;
if (tables->prep_on_expr)
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 47f970a4f82..47aa53d25e2 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -9117,7 +9117,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list)
field++;
}
- *field= NULL; /* mark the end of the list */
+ *field= NULL; /* mark the end of the list */
share->blob_field[blob_count]= 0; /* mark the end of the list */
share->blob_fields= blob_count;
@@ -11659,6 +11659,12 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
goto err;
}
}
+
+ /* Fill schema tables with data before filesort if it's necessary */
+ if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
+ get_schema_tables_result(join))
+ goto err;
+
if (table->s->tmp_table)
table->file->info(HA_STATUS_VARIABLE); // Get record count
table->sort.found_records=filesort(thd, table,sortorder, length,
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index b381c6198c0..d30ce8d6b59 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4550,7 +4550,16 @@ bool get_schema_tables_result(JOIN *join)
TABLE_LIST *table_list= tab->table->pos_in_table_list;
if (table_list->schema_table && thd->fill_derived_tables())
{
- if (&lex->unit != lex->current_select->master_unit()) // is subselect
+ bool is_subselect= (&lex->unit != lex->current_select->master_unit());
+ /*
+ The schema table is already processed and
+ the statement is not a subselect.
+ So we don't need to handle this table again.
+ */
+ if (table_list->is_schema_table_processed && !is_subselect)
+ continue;
+
+ if (is_subselect) // is subselect
{
table_list->table->file->extra(HA_EXTRA_RESET_STATE);
table_list->table->file->delete_all_rows();
@@ -4563,6 +4572,7 @@ bool get_schema_tables_result(JOIN *join)
if (table_list->schema_table->fill_table(thd, table_list,
tab->select_cond))
result= 1;
+ table_list->is_schema_table_processed= TRUE;
}
}
thd->no_warnings_for_error= 0;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a116dc27891..f83d7b28d6f 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1642,11 +1642,26 @@ clear_privileges:
sp_name:
ident '.' ident
{
+ if (!$1.str || check_db_name($1.str))
+ {
+ my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
+ YYABORT;
+ }
+ if (check_routine_name($3))
+ {
+ my_error(ER_SP_WRONG_NAME, MYF(0), $3.str);
+ YYABORT;
+ }
$$= new sp_name($1, $3);
$$->init_qname(YYTHD);
}
| ident
{
+ if (check_routine_name($1))
+ {
+ my_error(ER_SP_WRONG_NAME, MYF(0), $1.str);
+ YYABORT;
+ }
$$= sp_name_current_db_new(YYTHD, $1);
}
;
diff --git a/sql/table.h b/sql/table.h
index bcc2f89655b..a799d4389fb 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -560,6 +560,7 @@ typedef struct st_table_list
st_select_lex_unit *derived; /* SELECT_LEX_UNIT of derived table */
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
st_select_lex *schema_select_lex;
+ bool is_schema_table_processed;
/*
True when the view field translation table is used to convert
schema table fields for backwards compatibility with SHOW command.
diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c
index a280a98cf90..1ec91b41218 100644
--- a/storage/myisam/ft_update.c
+++ b/storage/myisam/ft_update.c
@@ -174,6 +174,10 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2)
FT_SEG_ITERATOR ftsi1, ftsi2;
CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset;
DBUG_ENTER("_mi_ft_cmp");
+#ifndef MYSQL_HAS_TRUE_CTYPE_IMPLEMENTATION
+ if (cs->mbmaxlen > 1)
+ DBUG_RETURN(THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT);
+#endif
_mi_ft_segiterator_init(info, keynr, rec1, &ftsi1);
_mi_ft_segiterator_init(info, keynr, rec2, &ftsi2);
diff --git a/storage/ndb/include/logger/LogHandler.hpp b/storage/ndb/include/logger/LogHandler.hpp
index 7df6ad864e5..8b9aa43d7a9 100644
--- a/storage/ndb/include/logger/LogHandler.hpp
+++ b/storage/ndb/include/logger/LogHandler.hpp
@@ -126,6 +126,18 @@ public:
void setErrorCode(int code);
/**
+ * Returns the error string.
+ */
+ char* getErrorStr();
+
+ /**
+ * Sets the error string.
+ *
+ * @param str the error string.
+ */
+ void setErrorStr(char* str);
+
+ /**
* Parse logstring parameters
*
* @param params list of parameters, formatted as "param=value",
@@ -195,6 +207,7 @@ private:
const char* m_pDateTimeFormat;
int m_errorCode;
+ char* m_errorStr;
// for handling repeated messages
unsigned m_count_repeated_messages;
diff --git a/storage/ndb/include/logger/Logger.hpp b/storage/ndb/include/logger/Logger.hpp
index ee762098fb6..3414468d42d 100644
--- a/storage/ndb/include/logger/Logger.hpp
+++ b/storage/ndb/include/logger/Logger.hpp
@@ -178,8 +178,11 @@ public:
* Add a new handler
*
* @param logstring string describing the handler to add
+ * @param err OS errno in event of error
+ * @param len max length of errStr buffer
+ * @param errStr logger error string in event of error
*/
- bool addHandler(const BaseString &logstring);
+ bool addHandler(const BaseString &logstring, int *err, int len, char* errStr);
/**
* Remove a log handler.
diff --git a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h
index 2675502b6ad..9d74be5d603 100644
--- a/storage/ndb/include/mgmapi/mgmapi.h
+++ b/storage/ndb/include/mgmapi/mgmapi.h
@@ -992,6 +992,22 @@ extern "C" {
int ndb_mgm_alloc_nodeid(NdbMgmHandle handle,
unsigned version, int nodetype);
+ /**
+ * End Session
+ *
+ * This function tells the mgm server to free all resources associated with
+ * this connection. It will also close it.
+ *
+ * This differs from just disconnecting as we now synchronously clean up,
+ * so that a quickly restarting server that needs the same node id can
+ * get it when it restarts.
+ *
+ * @param handle NDB management handle
+ * @return 0 on success
+ *
+ * @note you still have to destroy the NdbMgmHandle.
+ */
+ int ndb_mgm_end_session(NdbMgmHandle handle);
/**
* Get the node id of the mgm server we're connected to
diff --git a/storage/ndb/include/mgmcommon/ConfigRetriever.hpp b/storage/ndb/include/mgmcommon/ConfigRetriever.hpp
index c0b877af07d..1b4ecd56f80 100644
--- a/storage/ndb/include/mgmcommon/ConfigRetriever.hpp
+++ b/storage/ndb/include/mgmcommon/ConfigRetriever.hpp
@@ -78,6 +78,7 @@ public:
const char *get_connectstring(char *buf, int buf_sz) const;
NdbMgmHandle get_mgmHandle() { return m_handle; };
NdbMgmHandle* get_mgmHandlePtr() { return &m_handle; };
+ void end_session(bool end) { m_end_session= end; };
Uint32 get_configuration_nodeid() const;
private:
@@ -92,6 +93,8 @@ private:
void setError(ErrorType, const char * errorMsg);
Uint32 _ownNodeId;
+ bool m_end_session;
+
/*
Uint32 m_mgmd_port;
const char *m_mgmd_host;
diff --git a/storage/ndb/src/common/logger/FileLogHandler.cpp b/storage/ndb/src/common/logger/FileLogHandler.cpp
index 8678b999b6f..3d29e63ac1f 100644
--- a/storage/ndb/src/common/logger/FileLogHandler.cpp
+++ b/storage/ndb/src/common/logger/FileLogHandler.cpp
@@ -187,6 +187,7 @@ FileLogHandler::setParam(const BaseString &param, const BaseString &value){
return setMaxSize(value);
if(param == "maxfiles")
return setMaxFiles(value);
+ setErrorStr("Invalid parameter");
return false;
}
@@ -196,16 +197,18 @@ FileLogHandler::setFilename(const BaseString &filename) {
if(m_pLogFile)
delete m_pLogFile;
m_pLogFile = new File_class(filename.c_str(), "a+");
- open();
- return true;
+ return open();
}
bool
FileLogHandler::setMaxSize(const BaseString &size) {
char *end;
long val = strtol(size.c_str(), &end, 0); /* XXX */
- if(size.c_str() == end)
+ if(size.c_str() == end || val < 0)
+ {
+ setErrorStr("Invalid file size");
return false;
+ }
if(end[0] == 'M')
val *= 1024*1024;
if(end[0] == 'k')
@@ -220,8 +223,11 @@ bool
FileLogHandler::setMaxFiles(const BaseString &files) {
char *end;
long val = strtol(files.c_str(), &end, 0);
- if(files.c_str() == end)
+ if(files.c_str() == end || val < 1)
+ {
+ setErrorStr("Invalid maximum number of files");
return false;
+ }
m_maxNoFiles = val;
return true;
@@ -230,6 +236,9 @@ FileLogHandler::setMaxFiles(const BaseString &files) {
bool
FileLogHandler::checkParams() {
if(m_pLogFile == NULL)
+ {
+ setErrorStr("Log file cannot be null.");
return false;
+ }
return true;
}
diff --git a/storage/ndb/src/common/logger/LogHandler.cpp b/storage/ndb/src/common/logger/LogHandler.cpp
index 521bd346fd3..c11f962d4fb 100644
--- a/storage/ndb/src/common/logger/LogHandler.cpp
+++ b/storage/ndb/src/common/logger/LogHandler.cpp
@@ -23,7 +23,8 @@
//
LogHandler::LogHandler() :
m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"),
- m_errorCode(0)
+ m_errorCode(0),
+ m_errorStr(NULL)
{
m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds
m_count_repeated_messages= 0;
@@ -155,6 +156,19 @@ LogHandler::setErrorCode(int code)
m_errorCode = code;
}
+
+char*
+LogHandler::getErrorStr()
+{
+ return m_errorStr;
+}
+
+void
+LogHandler::setErrorStr(char* str)
+{
+ m_errorStr= str;
+}
+
bool
LogHandler::parseParams(const BaseString &_params) {
Vector<BaseString> v_args;
@@ -165,9 +179,18 @@ LogHandler::parseParams(const BaseString &_params) {
for(size_t i=0; i < v_args.size(); i++) {
Vector<BaseString> v_param_value;
if(v_args[i].split(v_param_value, "=", 2) != 2)
+ {
ret = false;
- else if (!setParam(v_param_value[0], v_param_value[1]))
- ret = false;
+ setErrorStr("Can't find key=value pair.");
+ }
+ else
+ {
+ v_param_value[0].trim(" \t");
+ if (!setParam(v_param_value[0], v_param_value[1]))
+ {
+ ret = false;
+ }
+ }
}
if(!checkParams())
diff --git a/storage/ndb/src/common/logger/Logger.cpp b/storage/ndb/src/common/logger/Logger.cpp
index 4a48236053d..48e084a782b 100644
--- a/storage/ndb/src/common/logger/Logger.cpp
+++ b/storage/ndb/src/common/logger/Logger.cpp
@@ -167,7 +167,7 @@ Logger::addHandler(LogHandler* pHandler)
}
bool
-Logger::addHandler(const BaseString &logstring) {
+Logger::addHandler(const BaseString &logstring, int *err, int len, char* errStr) {
size_t i;
Vector<BaseString> logdest;
Vector<LogHandler *>loghandlers;
@@ -200,9 +200,18 @@ Logger::addHandler(const BaseString &logstring) {
handler = new ConsoleLogHandler();
if(handler == NULL)
+ {
+ snprintf(errStr,len,"Could not create log destination: %s",
+ logdest[i].c_str());
DBUG_RETURN(false);
+ }
if(!handler->parseParams(params))
+ {
+ *err= handler->getErrorCode();
+ if(handler->getErrorStr())
+ strncpy(errStr, handler->getErrorStr(), len);
DBUG_RETURN(false);
+ }
loghandlers.push_back(handler);
}
diff --git a/storage/ndb/src/common/logger/SysLogHandler.cpp b/storage/ndb/src/common/logger/SysLogHandler.cpp
index 5b1b8d85ca7..c7fcb102dd4 100644
--- a/storage/ndb/src/common/logger/SysLogHandler.cpp
+++ b/storage/ndb/src/common/logger/SysLogHandler.cpp
@@ -154,5 +154,6 @@ SysLogHandler::setFacility(const BaseString &facility) {
return true;
}
}
+ setErrorStr("Invalid syslog facility name");
return false;
}
diff --git a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index 3b843b6708b..97de5c7f83d 100644
--- a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -52,6 +52,7 @@ ConfigRetriever::ConfigRetriever(const char * _connect_string,
m_version = version;
m_node_type = node_type;
_ownNodeId= 0;
+ m_end_session= true;
m_handle= ndb_mgm_create_handle();
@@ -76,6 +77,8 @@ ConfigRetriever::~ConfigRetriever()
{
DBUG_ENTER("ConfigRetriever::~ConfigRetriever");
if (m_handle) {
+ if(m_end_session)
+ ndb_mgm_end_session(m_handle);
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
}
diff --git a/storage/ndb/src/common/util/SocketServer.cpp b/storage/ndb/src/common/util/SocketServer.cpp
index 15dca2d96b1..481c656b78b 100644
--- a/storage/ndb/src/common/util/SocketServer.cpp
+++ b/storage/ndb/src/common/util/SocketServer.cpp
@@ -42,6 +42,8 @@ SocketServer::~SocketServer() {
delete m_sessions[i].m_session;
}
for(i = 0; i<m_services.size(); i++){
+ if(m_services[i].m_socket)
+ NDB_CLOSE_SOCKET(m_services[i].m_socket);
delete m_services[i].m_service;
}
}
diff --git a/storage/ndb/src/kernel/main.cpp b/storage/ndb/src/kernel/main.cpp
index 2374cce5f35..4bc9fbf76e5 100644
--- a/storage/ndb/src/kernel/main.cpp
+++ b/storage/ndb/src/kernel/main.cpp
@@ -307,8 +307,11 @@ int main(int argc, char** argv)
/**
* We no longer need the mgm connection in this process
* (as we are the angel, not ndb)
+ *
+ * We don't want to purge any allocated resources (nodeid), so
+ * we set that option to false
*/
- theConfig->closeConfiguration();
+ theConfig->closeConfiguration(false);
int status = 0, error_exit = 0, signum = 0;
while(waitpid(child, &status, 0) != child);
diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp
index fe7d474b578..771fa6f5fe4 100644
--- a/storage/ndb/src/kernel/vm/Configuration.cpp
+++ b/storage/ndb/src/kernel/vm/Configuration.cpp
@@ -172,7 +172,8 @@ Configuration::~Configuration(){
}
void
-Configuration::closeConfiguration(){
+Configuration::closeConfiguration(bool end_session){
+ m_config_retriever->end_session(end_session);
if (m_config_retriever) {
delete m_config_retriever;
}
diff --git a/storage/ndb/src/kernel/vm/Configuration.hpp b/storage/ndb/src/kernel/vm/Configuration.hpp
index 5043d1f0bee..243ecbee4e7 100644
--- a/storage/ndb/src/kernel/vm/Configuration.hpp
+++ b/storage/ndb/src/kernel/vm/Configuration.hpp
@@ -35,7 +35,7 @@ public:
void fetch_configuration();
void setupConfiguration();
- void closeConfiguration();
+ void closeConfiguration(bool end_session= true);
bool lockPagesInMainMemory() const;
diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp
index 79284964186..eb93ec88b6f 100644
--- a/storage/ndb/src/mgmapi/mgmapi.cpp
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp
@@ -2321,4 +2321,23 @@ int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length)
DBUG_RETURN(0);
}
+extern "C"
+int ndb_mgm_end_session(NdbMgmHandle handle)
+{
+ DBUG_ENTER("ndb_mgm_end_session");
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ SocketOutputStream s_output(handle->socket);
+ s_output.println("end session");
+ s_output.println("");
+
+ SocketInputStream in(handle->socket, handle->read_timeout);
+ char buf[32];
+
+ in.gets(buf, sizeof(buf));
+
+ DBUG_RETURN(0);
+}
+
template class Vector<const ParserRow<ParserDummy>*>;
diff --git a/storage/ndb/src/mgmclient/CommandInterpreter.cpp b/storage/ndb/src/mgmclient/CommandInterpreter.cpp
index b398ed46514..5496b2dadc3 100644
--- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp
+++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp
@@ -928,26 +928,21 @@ CommandInterpreter::executeShutdown(char* parameters)
int result = 0;
result = ndb_mgm_stop(m_mgmsrv, 0, 0);
if (result < 0) {
- ndbout << "Shutdown off NDB Cluster storage node(s) failed." << endl;
+ ndbout << "Shutdown of NDB Cluster node(s) failed." << endl;
printError();
return result;
}
- ndbout << result << " NDB Cluster storage node(s) have shutdown." << endl;
+ ndbout << result << " NDB Cluster node(s) have shutdown." << endl;
int mgm_id= 0;
- for(int i=0; i < state->no_of_nodes; i++) {
- if(state->node_states[i].node_type == NDB_MGM_NODE_TYPE_MGM &&
- state->node_states[i].version != 0){
- if (mgm_id == 0)
- mgm_id= state->node_states[i].node_id;
- else {
- ndbout << "Unable to locate management server, "
- << "shutdown manually with <id> STOP"
- << endl;
- return 1;
- }
- }
+ mgm_id= ndb_mgm_get_mgmd_nodeid(m_mgmsrv);
+ if (mgm_id == 0)
+ {
+ ndbout << "Unable to locate management server, "
+ << "shutdown manually with <id> STOP"
+ << endl;
+ return 1;
}
result = ndb_mgm_stop(m_mgmsrv, 1, &mgm_id);
diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
index cf9965b94e0..b60679f700e 100644
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp
@@ -60,6 +60,9 @@
#include <SignalSender.hpp>
+extern bool g_StopServer;
+extern bool g_RestartServer;
+
//#define MGM_SRV_DEBUG
#ifdef MGM_SRV_DEBUG
#define DEBUG(x) do ndbout << x << endl; while(0)
@@ -179,6 +182,8 @@ MgmtSrvr::startEventLog()
}
const char * tmp;
+ char errStr[100];
+ int err= 0;
BaseString logdest;
char *clusterLog= NdbConfig_ClusterLogFileName(_ownNodeId);
NdbAutoPtr<char> tmp_aptr(clusterLog);
@@ -192,9 +197,17 @@ MgmtSrvr::startEventLog()
logdest.assfmt("FILE:filename=%s,maxsize=1000000,maxfiles=6",
clusterLog);
}
- if(!g_eventLogger.addHandler(logdest)) {
+ errStr[0]='\0';
+ if(!g_eventLogger.addHandler(logdest, &err, sizeof(errStr), errStr)) {
ndbout << "Warning: could not add log destination \""
- << logdest.c_str() << "\"" << endl;
+ << logdest.c_str() << "\". Reason: ";
+ if(err)
+ ndbout << strerror(err);
+ if(err && errStr[0]!='\0')
+ ndbout << ", ";
+ if(errStr[0]!='\0')
+ ndbout << errStr;
+ ndbout << endl;
}
}
@@ -373,7 +386,8 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server,
_ownReference(0),
theSignalIdleList(NULL),
theWaitState(WAIT_SUBSCRIBE_CONF),
- m_event_listner(this)
+ m_event_listner(this),
+ m_local_mgm_handle(0)
{
DBUG_ENTER("MgmtSrvr::MgmtSrvr");
@@ -537,6 +551,8 @@ MgmtSrvr::check_start()
bool
MgmtSrvr::start(BaseString &error_string)
{
+ int mgm_connect_result;
+
DBUG_ENTER("MgmtSrvr::start");
if (_props == NULL) {
if (!check_start()) {
@@ -574,6 +590,13 @@ MgmtSrvr::start(BaseString &error_string)
DBUG_RETURN(false);
}
+ if((mgm_connect_result= connect_to_self()) < 0)
+ {
+ ndbout_c("Unable to connect to our own ndb_mgmd (Error %d)",
+ mgm_connect_result);
+ ndbout_c("This is probably a bug.");
+ }
+
TransporterRegistry *reg = theFacade->get_registry();
for(unsigned int i=0;i<reg->m_transporter_interface.size();i++) {
BaseString msg;
@@ -831,9 +854,81 @@ MgmtSrvr::sendVersionReq(int v_nodeId, Uint32 &version, const char **address)
return 0;
}
+int MgmtSrvr::sendStopMgmd(NodeId nodeId,
+ bool abort,
+ bool stop,
+ bool restart,
+ bool nostart,
+ bool initialStart)
+{
+ const char* hostname;
+ Uint32 port;
+ BaseString connect_string;
+
+ {
+ Guard g(m_configMutex);
+ {
+ ndb_mgm_configuration_iterator
+ iter(* _config->m_configValues, CFG_SECTION_NODE);
+
+ if(iter.first()) return SEND_OR_RECEIVE_FAILED;
+ if(iter.find(CFG_NODE_ID, nodeId)) return SEND_OR_RECEIVE_FAILED;
+ if(iter.get(CFG_NODE_HOST, &hostname)) return SEND_OR_RECEIVE_FAILED;
+ }
+ {
+ ndb_mgm_configuration_iterator
+ iter(* _config->m_configValues, CFG_SECTION_NODE);
+
+ if(iter.first()) return SEND_OR_RECEIVE_FAILED;
+ if(iter.find(CFG_NODE_ID, nodeId)) return SEND_OR_RECEIVE_FAILED;
+ if(iter.get(CFG_MGM_PORT, &port)) return SEND_OR_RECEIVE_FAILED;
+ }
+ if( strlen(hostname) == 0 )
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ connect_string.assfmt("%s:%u",hostname,port);
+
+ DBUG_PRINT("info",("connect string: %s",connect_string.c_str()));
+
+ NdbMgmHandle h= ndb_mgm_create_handle();
+ if ( h && connect_string.length() > 0 )
+ {
+ ndb_mgm_set_connectstring(h,connect_string.c_str());
+ if(ndb_mgm_connect(h,1,0,0))
+ {
+ DBUG_PRINT("info",("failed ndb_mgm_connect"));
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ if(!restart)
+ {
+ if(ndb_mgm_stop(h, 1, (const int*)&nodeId) < 0)
+ {
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ }
+ else
+ {
+ int nodes[1];
+ nodes[0]= (int)nodeId;
+ if(ndb_mgm_restart2(h, 1, nodes, initialStart, nostart, abort) < 0)
+ {
+ return SEND_OR_RECEIVE_FAILED;
+ }
+ }
+ }
+ ndb_mgm_destroy_handle(&h);
+
+ return 0;
+}
+
/*
* Common method for handeling all STOP_REQ signalling that
* is used by Stopping, Restarting and Single user commands
+ *
+ * In the event that we need to stop a mgmd, we create a mgm
+ * client connection to that mgmd and stop it that way.
+ * This allows us to stop mgm servers when there isn't any real
+ * distributed communication up.
*/
int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
@@ -845,6 +940,8 @@ int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
bool nostart,
bool initialStart)
{
+ int error = 0;
+
stoppedNodes.clear();
SignalSender ss(theFacade);
@@ -883,18 +980,34 @@ int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
NodeBitmask nodes;
if (nodeId)
{
+ if(nodeId==getOwnNodeId())
{
- int r;
- if((r = okToSendTo(nodeId, true)) != 0)
- return r;
+ if(restart)
+ g_RestartServer= true;
+ g_StopServer= true;
+ return 0;
}
+ if(getNodeType(nodeId) == NDB_MGM_NODE_TYPE_NDB)
{
+ int r;
+ if((r= okToSendTo(nodeId, true)) != 0)
+ return r;
if (ss.sendSignal(nodeId, &ssig) != SEND_OK)
return SEND_OR_RECEIVE_FAILED;
}
+ else if(getNodeType(nodeId) == NDB_MGM_NODE_TYPE_MGM)
+ {
+ error= sendStopMgmd(nodeId, abort, stop, restart, nostart, initialStart);
+ if(error==0)
+ stoppedNodes.set(nodeId);
+ return error;
+ }
+ else
+ return WRONG_PROCESS_TYPE;
nodes.set(nodeId);
}
else
+ {
while(getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB))
{
if(okToSendTo(nodeId, true) == 0)
@@ -904,9 +1017,17 @@ int MgmtSrvr::sendSTOP_REQ(NodeId nodeId,
nodes.set(nodeId);
}
}
+ nodeId= 0;
+ while(getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_MGM))
+ {
+ if(nodeId==getOwnNodeId())
+ continue;
+ if(sendStopMgmd(nodeId, abort, stop, restart, nostart, initialStart)==0)
+ stoppedNodes.set(nodeId);
+ }
+ }
// now wait for the replies
- int error = 0;
while (!nodes.isclear())
{
SimpleSignal *signal = ss.waitFor();
@@ -2552,9 +2673,23 @@ void MgmtSrvr::transporter_connect(NDB_SOCKET_TYPE sockfd)
}
}
-int MgmtSrvr::set_connect_string(const char *str)
+int MgmtSrvr::connect_to_self(void)
{
- return ndb_mgm_set_connectstring(m_config_retriever->get_mgmHandle(),str);
+ int r= 0;
+ m_local_mgm_handle= ndb_mgm_create_handle();
+ snprintf(m_local_mgm_connect_string,sizeof(m_local_mgm_connect_string),
+ "localhost:%u",getPort());
+ ndb_mgm_set_connectstring(m_local_mgm_handle, m_local_mgm_connect_string);
+
+ if((r= ndb_mgm_connect(m_local_mgm_handle, 0, 0, 0)) < 0)
+ {
+ ndb_mgm_destroy_handle(&m_local_mgm_handle);
+ return r;
+ }
+ // TransporterRegistry now owns this NdbMgmHandle and will destroy it.
+ theFacade->get_registry()->set_mgm_handle(m_local_mgm_handle);
+
+ return 0;
}
diff --git a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp
index ec6ab47bc2a..20e6ff1bc43 100644
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp
@@ -466,7 +466,7 @@ public:
int getConnectionDbParameter(int node1, int node2, int param,
int *value, BaseString& msg);
- int set_connect_string(const char *str);
+ int connect_to_self(void);
void transporter_connect(NDB_SOCKET_TYPE sockfd);
@@ -482,6 +482,13 @@ private:
int send(SignalSender &ss, SimpleSignal &ssig, Uint32 node, Uint32 node_type);
+ int sendStopMgmd(NodeId nodeId,
+ bool abort,
+ bool stop,
+ bool restart,
+ bool nostart,
+ bool initialStart);
+
int sendSTOP_REQ(NodeId nodeId,
NodeBitmask &stoppedNodes,
Uint32 singleUserNodeId,
@@ -625,6 +632,8 @@ private:
// signal arrives.
// We wait in receiveOptimisedResponse and signal in handleReceivedSignal.
+ NdbMgmHandle m_local_mgm_handle;
+ char m_local_mgm_connect_string[20];
class TransporterFacade * theFacade;
int sendVersionReq( int processId, Uint32 &version, const char **address);
diff --git a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp
index ee24cf18941..80f0aa2eda8 100644
--- a/storage/ndb/src/mgmsrv/Services.cpp
+++ b/storage/ndb/src/mgmsrv/Services.cpp
@@ -203,6 +203,8 @@ ParserRow<MgmApiSession> commands[] = {
MGM_CMD("bye", &MgmApiSession::bye, ""),
+ MGM_CMD("end session", &MgmApiSession::endSession, ""),
+
MGM_CMD("set loglevel", &MgmApiSession::setLogLevel, ""),
MGM_ARG("node", Int, Mandatory, "Node"),
MGM_ARG("category", Int, Mandatory, "Event category"),
@@ -719,11 +721,22 @@ MgmApiSession::dumpState(Parser<MgmApiSession>::Context &,
void
MgmApiSession::bye(Parser<MgmApiSession>::Context &,
- Properties const &) {
+ Properties const &) {
m_stop = true;
}
void
+MgmApiSession::endSession(Parser<MgmApiSession>::Context &,
+ Properties const &) {
+ if(m_allocated_resources)
+ delete m_allocated_resources;
+
+ m_allocated_resources= new MgmtSrvr::Allocated_resources(m_mgmsrv);
+
+ m_output->println("end session reply");
+}
+
+void
MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
Properties const &args) {
const char *reply= "set cluster loglevel reply";
diff --git a/storage/ndb/src/mgmsrv/Services.hpp b/storage/ndb/src/mgmsrv/Services.hpp
index 30f220cd060..f97223750a1 100644
--- a/storage/ndb/src/mgmsrv/Services.hpp
+++ b/storage/ndb/src/mgmsrv/Services.hpp
@@ -79,6 +79,7 @@ public:
void start(Parser_t::Context &ctx, const class Properties &args);
void startAll(Parser_t::Context &ctx, const class Properties &args);
void bye(Parser_t::Context &ctx, const class Properties &args);
+ void endSession(Parser_t::Context &ctx, const class Properties &args);
void setLogLevel(Parser_t::Context &ctx, const class Properties &args);
void setClusterLogLevel(Parser_t::Context &ctx,
const class Properties &args);
diff --git a/storage/ndb/src/mgmsrv/main.cpp b/storage/ndb/src/mgmsrv/main.cpp
index f0c2ac298a5..5960a3517b5 100644
--- a/storage/ndb/src/mgmsrv/main.cpp
+++ b/storage/ndb/src/mgmsrv/main.cpp
@@ -132,6 +132,7 @@ static MgmGlobals *glob= 0;
* Global variables
*/
bool g_StopServer;
+bool g_RestartServer;
extern EventLogger g_eventLogger;
extern int global_mgmt_server_check;
@@ -191,7 +192,22 @@ static void usage()
*/
int main(int argc, char** argv)
{
+ int mgm_connect_result;
+
NDB_INIT(argv[0]);
+
+ const char *load_default_groups[]= { "mysql_cluster","ndb_mgmd",0 };
+ load_defaults("my",load_default_groups,&argc,&argv);
+
+ int ho_error;
+#ifndef DBUG_OFF
+ opt_debug= "d:t:O,/tmp/ndb_mgmd.trace";
+#endif
+ if ((ho_error=handle_options(&argc, &argv, my_long_options,
+ ndb_std_get_one_option)))
+ exit(ho_error);
+
+start:
glob= new MgmGlobals;
/**
@@ -204,17 +220,6 @@ int main(int argc, char** argv)
#endif
global_mgmt_server_check = 1;
-
- const char *load_default_groups[]= { "mysql_cluster","ndb_mgmd",0 };
- load_defaults("my",load_default_groups,&argc,&argv);
-
- int ho_error;
-#ifndef DBUG_OFF
- opt_debug= "d:t:O,/tmp/ndb_mgmd.trace";
-#endif
- if ((ho_error=handle_options(&argc, &argv, my_long_options,
- ndb_std_get_one_option)))
- exit(ho_error);
if (opt_interactive ||
opt_non_interactive ||
@@ -293,34 +298,12 @@ int main(int argc, char** argv)
goto error_end;
}
- /* Construct a fake connectstring to connect back to ourselves */
- char connect_str[20];
- if(!opt_connect_str) {
- snprintf(connect_str,20,"localhost:%u",glob->mgmObject->getPort());
- opt_connect_str= connect_str;
- }
- glob->mgmObject->set_connect_string(opt_connect_str);
-
if(!glob->mgmObject->check_start()){
ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
goto error_end;
}
- /*
- * Connect back to ourselves so we can use mgmapi to fetch
- * config info
- */
- int mgm_connect_result;
- mgm_connect_result = glob->mgmObject->get_config_retriever()->
- do_connect(0,0,0);
-
- if(mgm_connect_result<0) {
- ndbout_c("Unable to connect to our own ndb_mgmd (Error %d)",
- mgm_connect_result);
- ndbout_c("This is probably a bug.");
- }
-
if (opt_daemon) {
// Become a daemon
char *lockfile= NdbConfig_PidFileName(glob->localNodeId);
@@ -361,6 +344,7 @@ int main(int argc, char** argv)
g_eventLogger.info(msg);
g_StopServer = false;
+ g_RestartServer= false;
glob->socketServer->startServer();
#if ! defined NDB_OSE && ! defined NDB_SOFTOSE
@@ -378,14 +362,19 @@ int main(int argc, char** argv)
while(g_StopServer != true)
NdbSleep_MilliSleep(500);
}
-
- g_eventLogger.info("Shutting down server...");
+
+ if(g_RestartServer)
+ g_eventLogger.info("Restarting server...");
+ else
+ g_eventLogger.info("Shutting down server...");
glob->socketServer->stopServer();
- glob->mgmObject->get_config_retriever()->disconnect();
+ // We disconnect from the ConfigRetreiver mgmd when we delete glob below
glob->socketServer->stopSessions(true);
g_eventLogger.info("Shutdown complete");
the_end:
delete glob;
+ if(g_RestartServer)
+ goto start;
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return 0;
error_end:
diff --git a/storage/ndb/tools/ndb_size.pl b/storage/ndb/tools/ndb_size.pl
index e0085c619f0..c285a7590fd 100644
--- a/storage/ndb/tools/ndb_size.pl
+++ b/storage/ndb/tools/ndb_size.pl
@@ -147,7 +147,7 @@ foreach(@{$tables})
{
my $fixed= 1+$size;
my @dynamic=$dbh->selectrow_array("select avg(length(`"
- .$name.
+ .$name
."`)) from `".$table.'`');
$dynamic[0]=0 if !$dynamic[0];
@realsize= ($fixed,$fixed,ceil($dynamic[0]));
diff --git a/support-files/MySQL-shared-compat.spec.sh b/support-files/MySQL-shared-compat.spec.sh
index ffc96fd6fff..72ebf4d4d2b 100644
--- a/support-files/MySQL-shared-compat.spec.sh
+++ b/support-files/MySQL-shared-compat.spec.sh
@@ -23,16 +23,19 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# For 5.0 and up, this is needed because of "libndbclient".
+%define _unpackaged_files_terminate_build 0
+
#
# Change this to match the version of the shared libs you want to include
#
%define version50 @MYSQL_NO_DASH_VERSION@
-%define version41 4.1.9
-%define version40 4.0.23
+%define version41 4.1.16
+%define version40 4.0.26
%define version3 3.23.58
Name: MySQL-shared-compat
-Packager: Lenz Grimmer <build@mysql.com>
+Packager: MySQL Product Engineering team <build@mysql.com>
Vendor: MySQL AB
License: GPL
Group: Applications/Databases
@@ -47,7 +50,7 @@ Summary: MySQL shared client libraries for MySQL %{version}, %{version41},
# We simply use the "MySQL-shared" subpackages as input sources instead of
# rebuilding all from source
Source0: MySQL-shared-%{version50}-0.%{_arch}.rpm
-Source1: MySQL-shared-%{version41}-0.%{_arch}.rpm
+Source1: MySQL-shared-%{version41}-1.%{_arch}.rpm
Source2: MySQL-shared-%{version40}-0.%{_arch}.rpm
Source3: MySQL-shared-%{version3}-1.%{_arch}.rpm
# No need to include the RPMs once more - they can be downloaded seperately
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index d33654d8810..e118289101e 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -14697,8 +14697,87 @@ static void test_opt_reconnect()
mysql_close(lmysql);
}
+/* Bug #16144: mysql_stmt_attr_get type error */
+
+static void test_bug16144()
+{
+ const my_bool flag_orig= (my_bool) 0xde;
+ my_bool flag= flag_orig;
+ MYSQL_STMT *stmt;
+ myheader("test_bug16144");
+
+ /* Check that attr_get returns correct data on little and big endian CPUs */
+ stmt= mysql_stmt_init(mysql);
+ mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (const void*) &flag);
+ mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &flag);
+ DIE_UNLESS(flag == flag_orig);
+ mysql_stmt_close(stmt);
+}
/*
+ Bug #15613: "libmysqlclient API function mysql_stmt_prepare returns wrong
+ field length"
+*/
+
+static void test_bug15613()
+{
+ MYSQL_STMT *stmt;
+ const char *stmt_text;
+ MYSQL_RES *metadata;
+ MYSQL_FIELD *field;
+ int rc;
+ myheader("test_bug15613");
+
+ /* I. Prepare the table */
+ rc= mysql_query(mysql, "set names latin1");
+ myquery(rc);
+ mysql_query(mysql, "drop table if exists t1");
+ rc= mysql_query(mysql,
+ "create table t1 (t text character set utf8, "
+ "tt tinytext character set utf8, "
+ "mt mediumtext character set utf8, "
+ "lt longtext character set utf8, "
+ "vl varchar(255) character set latin1,"
+ "vb varchar(255) character set binary,"
+ "vu varchar(255) character set utf8)");
+ myquery(rc);
+
+ stmt= mysql_stmt_init(mysql);
+
+ /* II. Check SELECT metadata */
+ stmt_text= ("select t, tt, mt, lt, vl, vb, vu from t1");
+ rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ metadata= mysql_stmt_result_metadata(stmt);
+ field= mysql_fetch_fields(metadata);
+ if (!opt_silent)
+ {
+ printf("Field lengths (client character set is latin1):\n"
+ "text character set utf8:\t\t%lu\n"
+ "tinytext character set utf8:\t\t%lu\n"
+ "mediumtext character set utf8:\t\t%lu\n"
+ "longtext character set utf8:\t\t%lu\n"
+ "varchar(255) character set latin1:\t%lu\n"
+ "varchar(255) character set binary:\t%lu\n"
+ "varchar(255) character set utf8:\t%lu\n",
+ field[0].length, field[1].length, field[2].length, field[3].length,
+ field[4].length, field[5].length, field[6].length);
+ }
+ DIE_UNLESS(field[0].length == 65535);
+ DIE_UNLESS(field[1].length == 255);
+ DIE_UNLESS(field[2].length == 16777215);
+ DIE_UNLESS(field[3].length == 4294967295UL);
+ DIE_UNLESS(field[4].length == 255);
+ DIE_UNLESS(field[5].length == 255);
+ DIE_UNLESS(field[6].length == 255);
+
+ /* III. Cleanup */
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "set names default");
+ myquery(rc);
+ mysql_stmt_close(stmt);
+}
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -14957,9 +15036,10 @@ static struct my_tests_st my_tests[]= {
{ "test_bug13488", test_bug13488 },
{ "test_bug13524", test_bug13524 },
{ "test_bug14845", test_bug14845 },
- { "test_bug15510", test_bug15510 },
{ "test_opt_reconnect", test_opt_reconnect },
-
+ { "test_bug15510", test_bug15510},
+ { "test_bug16144", test_bug16144 },
+ { "test_bug15613", test_bug15613 },
{ 0, 0 }
};
diff --git a/zlib/Makefile.am b/zlib/Makefile.am
index 11b1991fa62..71619ce40c1 100644
--- a/zlib/Makefile.am
+++ b/zlib/Makefile.am
@@ -16,6 +16,8 @@
# Process this file with automake to create Makefile.in
+INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include
+
pkglib_LTLIBRARIES=libz.la
libz_la_LDFLAGS= -version-info 3:3:2
diff --git a/zlib/README.MySQL b/zlib/README.MySQL
index 355dfb62d71..c17d3eeb6f9 100644
--- a/zlib/README.MySQL
+++ b/zlib/README.MySQL
@@ -5,3 +5,12 @@ original zlib distribution. You can find the original distribution at
http://www.gzip.org/zlib/
or
http://www.zlib.net/
+
+Revision history:
+
+20.01.2006. The following files were changed as part of #15787 fix:
+ makefile.am
+ gzio.c
+ zconf.h
+ README.mysql
+
diff --git a/zlib/gzio.c b/zlib/gzio.c
index 7e90f4928fc..afac5352323 100644
--- a/zlib/gzio.c
+++ b/zlib/gzio.c
@@ -7,10 +7,10 @@
/* @(#) $Id$ */
-#include <stdio.h>
-
#include "zutil.h"
+#include <stdio.h>
+
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS
#endif
diff --git a/zlib/zconf.h b/zlib/zconf.h
index 03a9431c8be..d983fa3eed4 100644
--- a/zlib/zconf.h
+++ b/zlib/zconf.h
@@ -8,6 +8,10 @@
#ifndef ZCONF_H
#define ZCONF_H
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
@@ -284,7 +288,7 @@ typedef uLong FAR uLongf;
typedef Byte *voidp;
#endif
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
+#ifdef HAVE_UNISTD_H
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS