Commit 082de8df authored by baker@bk-internal.mysql.com's avatar baker@bk-internal.mysql.com

Merge bk-internal.mysql.com:/data0/bk/mysql-5.1

into  bk-internal.mysql.com:/data0/bk/mysql-5.1-arch
parents 94dc5d53 931cf68b
......@@ -15,7 +15,8 @@
45214442pBGT9KuZEGixBH71jTzbOA
45214a07hVsIGwvwa-WrO-jpeaSwVw
452a92d0-31-8wSzSfZi165fcGcXPA
452c6c6dAjuNghfc1ObZ_UQ5SCl85g
4538a7b0EbDHHkWPbIwxO6ZIDdg6Dg
454a7ef8gdvE_ddMlJyghvOAkKPNOQ
454f8960jsVT_kMKJtZ9OCgXoba0xQ
4561b2ecZbhuAc0TTDdCdultxUYaMw
4561bde4qWhz1I8tkItXKex5uniipA
4562ba016dYH0JzszOqZ8p6psbKfnQ
......@@ -28,10 +28,9 @@ AC_DEFUN([MYSQL_USE_BUNDLED_YASSL], [
yassl_dir="yassl"
AC_SUBST([yassl_dir])
yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt"
yassl_libs="\$(top_builddir)/extra/yassl/src/libyassl.la \
\$(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la"
AC_SUBST(yassl_libs)
yassl_includes="-I\$(top_srcdir)/extra/yassl/include"
AC_SUBST(yassl_includes)
AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for SSL.])
AC_DEFINE([HAVE_YASSL], [1], [Defined by configure. Using yaSSL for SSL.])
......
......@@ -130,6 +130,9 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
#define pthread_kill(A,B) pthread_dummy(0)
#define pthread_join(A,B) \
((WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0) || !CloseHandle(A))
/* Dummy defines for easier code */
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
......
......@@ -2471,6 +2471,8 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
NET *net= &mysql->net;
char buff[4 /* size of stmt id */ +
5 /* execution flags */];
my_bool res;
DBUG_ENTER("execute");
DBUG_DUMP("packet", packet, length);
......@@ -2478,16 +2480,18 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
int4store(buff, stmt->stmt_id); /* Send stmt id to server */
buff[4]= (char) stmt->flags;
int4store(buff+5, 1); /* iteration count */
if (cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
packet, length, 1, NULL) ||
(*mysql->methods->read_query_result)(mysql))
res= test(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
packet, length, 1, NULL) ||
(*mysql->methods->read_query_result)(mysql));
stmt->affected_rows= mysql->affected_rows;
stmt->server_status= mysql->server_status;
stmt->insert_id= mysql->insert_id;
if (res)
{
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
DBUG_RETURN(1);
}
stmt->affected_rows= mysql->affected_rows;
stmt->server_status= mysql->server_status;
stmt->insert_id= mysql->insert_id;
DBUG_RETURN(0);
}
......
......@@ -94,8 +94,8 @@ INC_LIB= $(top_builddir)/regex/libregex.a \
$(yassl_inc_libs)
if HAVE_YASSL
yassl_inc_libs= $(top_srcdir)/extra/yassl/src/.libs/libyassl.a \
$(top_srcdir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
$(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
endif
# Storage engine specific compilation options
......
......@@ -279,24 +279,26 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
DBUG_ENTER("emb_stmt_execute");
char header[5];
THD *thd;
my_bool res;
int4store(header, stmt->stmt_id);
header[4]= stmt->flags;
thd= (THD*)stmt->mysql->thd;
thd->client_param_count= stmt->param_count;
thd->client_params= stmt->params;
if (emb_advanced_command(stmt->mysql, COM_STMT_EXECUTE,0,0,
header, sizeof(header), 1, stmt) ||
emb_read_query_result(stmt->mysql))
res= test(emb_advanced_command(stmt->mysql, COM_STMT_EXECUTE, 0, 0,
header, sizeof(header), 1, stmt) ||
emb_read_query_result(stmt->mysql));
stmt->affected_rows= stmt->mysql->affected_rows;
stmt->insert_id= stmt->mysql->insert_id;
stmt->server_status= stmt->mysql->server_status;
if (res)
{
NET *net= &stmt->mysql->net;
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate);
DBUG_RETURN(1);
}
stmt->affected_rows= stmt->mysql->affected_rows;
stmt->insert_id= stmt->mysql->insert_id;
stmt->server_status= stmt->mysql->server_status;
DBUG_RETURN(0);
}
......
......@@ -582,7 +582,7 @@ sub mtr_im_start($$) {
mtr_add_arg($args, $opt);
}
$im->{'pid'} =
$im->{'spawner_pid'} =
mtr_spawn(
$::exe_im, # path to the executable
$args, # cmd-line args
......@@ -593,7 +593,7 @@ sub mtr_im_start($$) {
{ append_log_file => 1 } # append log files
);
unless ( $im->{'pid'} )
unless ( $im->{'spawner_pid'} )
{
mtr_error('Could not start Instance Manager.')
}
......
......@@ -39,6 +39,7 @@ sub mtr_get_pid_from_file ($) {
# Read pid number from file
my $pid= <FILE>;
chomp $pid;
close FILE;
return $pid if $pid=~ /^(\d+)/;
......
......@@ -937,6 +937,12 @@ sub check_expected_crash_and_restart($)
}
}
}
if ($::instance_manager->{'spawner_pid'} eq $ret_pid)
{
return;
}
mtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid");
}
......
......@@ -202,6 +202,14 @@ select count(*) from t1 where id not in (1,2);
count(*)
1
drop table t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 SELECT 1 IN (2, NULL);
SELECT should return NULL.
SELECT * FROM t1;
1 IN (2, NULL)
NULL
DROP TABLE t1;
End of 4.1 tests
CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 VALUES (44), (45), (46);
SELECT * FROM t1 WHERE a IN (45);
......@@ -343,6 +351,7 @@ some_id
1
2
drop table t1;
End of 5.0 tests
create table t1(f1 char(1));
insert into t1 values ('a'),('b'),('1');
select f1 from t1 where f1 in ('a',1);
......@@ -411,3 +420,4 @@ explain select f2 from t2 where f2 in (1,'b');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL t2f2 5 NULL 3 Using where; Using index
drop table t1, t2;
End of 5.1 tests
This diff is collapsed.
......@@ -6,7 +6,7 @@ instance_name state
mysqld1 XXXXX
mysqld2 offline
Killing the process...
Sleeping...
Waiting...
Success: the process was restarted.
Success: server is ready to accept connection on socket.
......@@ -16,7 +16,7 @@ Success: server is ready to accept connection on socket.
START INSTANCE mysqld2;
Success: the process has been started.
Killing the process...
Sleeping...
Waiting...
Success: the process was restarted.
Success: server is ready to accept connection on socket.
SHOW INSTANCE STATUS mysqld1;
......
......@@ -39,7 +39,7 @@ ERROR HY000: Unknown instance name
-- 1.1.6.
--------------------------------------------------------------------
Killing the process...
Sleeping...
Waiting...
Success: the process was restarted.
SHOW INSTANCES;
instance_name state
......@@ -52,7 +52,7 @@ mysqld2 offline
START INSTANCE mysqld2;
Success: the process has been started.
Killing the process...
Sleeping...
Waiting...
Success: the process was killed.
--------------------------------------------------------------------
......
......@@ -296,11 +296,6 @@ select atan();
ERROR 42000: Incorrect parameter count in the call to native function 'atan'
select atan2(1, 2, 3);
ERROR 42000: Incorrect parameter count in the call to native function 'atan2'
select benchmark(10, 1+1);
benchmark(10, 1+1)
0
select benchmark(5+5, 2);
ERROR 42000: Incorrect parameters in the call to native function 'BENCHMARK'
select concat();
ERROR 42000: Incorrect parameter count in the call to native function 'concat'
select concat("foo");
......@@ -310,11 +305,6 @@ select concat_ws();
ERROR 42000: Incorrect parameter count in the call to native function 'concat_ws'
select concat_ws("foo");
ERROR 42000: Incorrect parameter count in the call to native function 'concat_ws'
set @pwd="my password";
select encode("secret", @pwd);
ERROR 42000: Incorrect parameters in the call to native function 'ENCODE'
select decode("encoded-secret", @pwd);
ERROR 42000: Incorrect parameters in the call to native function 'DECODE'
select encrypt();
ERROR 42000: Incorrect parameter count in the call to native function 'encrypt'
select encrypt(1, 2, 3);
......@@ -339,9 +329,6 @@ select field();
ERROR 42000: Incorrect parameter count in the call to native function 'field'
select field("p1");
ERROR 42000: Incorrect parameter count in the call to native function 'field'
set @dec=2;
select format(pi(), @dec);
ERROR 42000: Incorrect parameters in the call to native function 'FORMAT'
select from_unixtime();
ERROR 42000: Incorrect parameter count in the call to native function 'from_unixtime'
select from_unixtime(1, 2, 3);
......
......@@ -796,12 +796,12 @@ set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
show variables like 'max_prepared_stmt_count';
Variable_name Value
max_prepared_stmt_count 16382
show variables like 'prepared_stmt_count';
show status like 'prepared_stmt_count';
Variable_name Value
prepared_stmt_count 0
select @@max_prepared_stmt_count, @@prepared_stmt_count;
@@max_prepared_stmt_count @@prepared_stmt_count
16382 0
Prepared_stmt_count 0
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
16382
set global max_prepared_stmt_count=-1;
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
......@@ -820,67 +820,70 @@ set max_prepared_stmt_count=1;
ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL
set local max_prepared_stmt_count=1;
ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL
set local prepared_stmt_count=0;
ERROR HY000: Variable 'prepared_stmt_count' is a read only variable
set @@prepared_stmt_count=0;
ERROR HY000: Variable 'prepared_stmt_count' is a read only variable
set global prepared_stmt_count=1;
ERROR HY000: Variable 'prepared_stmt_count' is a read only variable
set global max_prepared_stmt_count=1;
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
1
set global max_prepared_stmt_count=0;
select @@max_prepared_stmt_count, @@prepared_stmt_count;
@@max_prepared_stmt_count @@prepared_stmt_count
0 0
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
0
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
prepare stmt from "select 1";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
select @@prepared_stmt_count;
@@prepared_stmt_count
0
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
set global max_prepared_stmt_count=1;
prepare stmt from "select 1";
select @@prepared_stmt_count;
@@prepared_stmt_count
1
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 1
prepare stmt1 from "select 1";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 1)
select @@prepared_stmt_count;
@@prepared_stmt_count
1
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 1
deallocate prepare stmt;
select @@prepared_stmt_count;
@@prepared_stmt_count
0
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
prepare stmt from "select 1";
select @@prepared_stmt_count;
@@prepared_stmt_count
1
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 1
prepare stmt from "select 2";
select @@prepared_stmt_count;
@@prepared_stmt_count
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 1
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 1
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
1
select @@prepared_stmt_count, @@max_prepared_stmt_count;
@@prepared_stmt_count @@max_prepared_stmt_count
1 1
set global max_prepared_stmt_count=0;
prepare stmt from "select 1";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
execute stmt;
ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE
select @@prepared_stmt_count;
@@prepared_stmt_count
0
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
prepare stmt from "select 1";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0)
select @@prepared_stmt_count;
@@prepared_stmt_count
0
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
set global max_prepared_stmt_count=3;
select @@max_prepared_stmt_count, @@prepared_stmt_count;
@@max_prepared_stmt_count @@prepared_stmt_count
3 0
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
3
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
prepare stmt from "select 1";
prepare stmt from "select 2";
prepare stmt1 from "select 3";
......@@ -888,13 +891,19 @@ prepare stmt2 from "select 4";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
prepare stmt2 from "select 4";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
select @@max_prepared_stmt_count, @@prepared_stmt_count;
@@max_prepared_stmt_count @@prepared_stmt_count
3 3
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
3
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 3
deallocate prepare stmt;
select @@max_prepared_stmt_count, @@prepared_stmt_count;
@@max_prepared_stmt_count @@prepared_stmt_count
3 0
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
3
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
drop table if exists t1;
create temporary table if not exists t1 (a1 int);
......@@ -2377,3 +2386,49 @@ Level Code Message
Note 1051 Unknown table 't1'
Note 1051 Unknown table 't2'
deallocate prepare abc;
set @my_password="password";
set @my_data="clear text to encode";
prepare stmt1 from 'select decode(encode(?, ?), ?)';
execute stmt1 using @my_data, @my_password, @my_password;
decode(encode(?, ?), ?)
clear text to encode
set @my_data="more text to encode";
execute stmt1 using @my_data, @my_password, @my_password;
decode(encode(?, ?), ?)
more text to encode
set @my_password="new password";
execute stmt1 using @my_data, @my_password, @my_password;
decode(encode(?, ?), ?)
more text to encode
deallocate prepare stmt1;
set @to_format="123456789.123456789";
set @dec=0;
prepare stmt2 from 'select format(?, ?)';
execute stmt2 using @to_format, @dec;
format(?, ?)
123,456,789
set @dec=4;
execute stmt2 using @to_format, @dec;
format(?, ?)
123,456,789.1235
set @dec=6;
execute stmt2 using @to_format, @dec;
format(?, ?)
123,456,789.123457
set @dec=2;
execute stmt2 using @to_format, @dec;
format(?, ?)
123,456,789.12
set @to_format="100";
execute stmt2 using @to_format, @dec;
format(?, ?)
100.00
set @to_format="1000000";
execute stmt2 using @to_format, @dec;
format(?, ?)
1,000,000.00
set @to_format="10000";
execute stmt2 using @to_format, @dec;
format(?, ?)
10,000.00
deallocate prepare stmt2;
......@@ -944,3 +944,30 @@ c
---> Cleaning up...
DROP TABLE t1;
DROP TABLE t2;
drop table if exists t1;
create table t1(a int, b varchar(50));
drop trigger not_a_trigger;
ERROR HY000: Trigger does not exist
drop trigger if exists not_a_trigger;
Warnings:
Note 1360 Trigger does not exist
create trigger t1_bi before insert on t1
for each row set NEW.b := "In trigger t1_bi";
insert into t1 values (1, "a");
drop trigger if exists t1_bi;
insert into t1 values (2, "b");
drop trigger if exists t1_bi;
Warnings:
Note 1360 Trigger does not exist
insert into t1 values (3, "c");
select * from t1;
a b
1 In trigger t1_bi
2 b
3 c
select * from t1;
a b
1 In trigger t1_bi
2 b
3 c
drop table t1;
......@@ -2178,6 +2178,7 @@ set @stamped_time=in_time;
set x=2;
end if;
end|
set time_zone='+03:00';
call bug3426(1000, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
@i time
......@@ -5627,4 +5628,111 @@ Called B
drop procedure proc_21462_a|
drop procedure proc_21462_b|
End of 5.0 tests
Begin of 5.1 tests
drop function if exists pi;
create function pi() returns varchar(50)
return "pie, my favorite desert.";
Warnings:
Note 1578 This function 'pi' has the same name as a native function.
SET @save_sql_mode=@@sql_mode;
SET SQL_MODE='IGNORE_SPACE';
select pi(), pi ();
pi() pi ()
3.141593 3.141593
select test.pi(), test.pi ();
test.pi() test.pi ()
pie, my favorite desert. pie, my favorite desert.
SET SQL_MODE='';
select pi(), pi ();
pi() pi ()
3.141593 3.141593
select test.pi(), test.pi ();
test.pi() test.pi ()
pie, my favorite desert. pie, my favorite desert.
SET @@sql_mode=@save_sql_mode;
drop function pi;
drop function if exists test.database;
drop function if exists test.current_user;
drop function if exists test.md5;
create database nowhere;
use nowhere;
drop database nowhere;
SET @save_sql_mode=@@sql_mode;
SET SQL_MODE='IGNORE_SPACE';
select database(), database ();
database() database ()
NULL NULL
select current_user(), current_user ();
current_user() current_user ()
root@localhost root@localhost
select md5("aaa"), md5 ("aaa");
md5("aaa") md5 ("aaa")
47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
SET SQL_MODE='';
select database(), database ();
database() database ()
NULL NULL
select current_user(), current_user ();
current_user() current_user ()
root@localhost root@localhost
select md5("aaa"), md5 ("aaa");
md5("aaa") md5 ("aaa")
47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
use test;
create function `database`() returns varchar(50)
return "Stored function database";
Warnings:
Note 1578 This function 'database' has the same name as a native function.
create function `current_user`() returns varchar(50)
return "Stored function current_user";
Warnings:
Note 1578 This function 'current_user' has the same name as a native function.
create function md5(x varchar(50)) returns varchar(50)
return "Stored function md5";
Warnings:
Note 1578 This function 'md5' has the same name as a native function.
SET SQL_MODE='IGNORE_SPACE';
select database(), database ();
database() database ()
test test
select current_user(), current_user ();
current_user() current_user ()
root@localhost root@localhost
select md5("aaa"), md5 ("aaa");
md5("aaa") md5 ("aaa")
47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
select test.database(), test.database ();
test.database() test.database ()
Stored function database Stored function database
select test.current_user(), test.current_user ();
test.current_user() test.current_user ()
Stored function current_user Stored function current_user
select test.md5("aaa"), test.md5 ("aaa");
test.md5("aaa") test.md5 ("aaa")
Stored function md5 Stored function md5
SET SQL_MODE='';
select database(), database ();
database() database ()
test test
select current_user(), current_user ();
current_user() current_user ()
root@localhost root@localhost
select md5("aaa"), md5 ("aaa");
md5("aaa") md5 ("aaa")
47bce5c74f589f4867dbd57e9ca9f808 47bce5c74f589f4867dbd57e9ca9f808
select test.database(), test.database ();
test.database() test.database ()
Stored function database Stored function database
select test.current_user(), test.current_user ();
test.current_user() test.current_user ()
Stored function current_user Stored function current_user
select test.md5("aaa"), test.md5 ("aaa");
test.md5("aaa") test.md5 ("aaa")
Stored function md5 Stored function md5
SET @@sql_mode=@save_sql_mode;
drop function test.database;
drop function test.current_user;
drop function md5;
use test;
End of 5.1 tests
drop table t1,t2;
use test;
drop function if exists a;
drop function if exists x;
drop function if exists y;
create function a() returns int
return 1;
create function x() returns int
return 2;
Warnings:
Note 1578 This function 'x' has the same name as a native function.
create function y() returns int
return 3;
Warnings:
Note 1578 This function 'y' has the same name as a native function.
select a();
a()
1
select x();
ERROR 42000: Incorrect parameter count in the call to native function 'x'
select y();
ERROR 42000: Incorrect parameter count in the call to native function 'y'
select x(PointFromText("POINT(10 20)")), y(PointFromText("POINT(10 20)"));
x(PointFromText("POINT(10 20)")) y(PointFromText("POINT(10 20)"))
10 20
select test.a(), test.x(), test.y();
test.a() test.x() test.y()
1 2 3
drop function a;
drop function x;
drop function y;
......@@ -1241,4 +1241,41 @@ i j
2 2
13 13
drop table t1;
drop table if exists t1;
drop function if exists f1;
create table t1 (i int);
create function f1() returns int return 10;
create trigger t1_bi before insert on t1 for each row set @a:= f1() + 10;
insert into t1 values ();
select @a;
@a
20
insert into t1 values ();
select @a;
@a
20
drop table t1;
drop function f1;
drop table if exists t1;
create table t1(a int, b varchar(50));
drop trigger not_a_trigger;
ERROR HY000: Trigger does not exist
drop trigger if exists not_a_trigger;
Warnings:
Note 1360 Trigger does not exist
create trigger t1_bi before insert on t1
for each row set NEW.b := "In trigger t1_bi";
insert into t1 values (1, "a");
drop trigger if exists t1_bi;
insert into t1 values (2, "b");
drop trigger if exists t1_bi;
Warnings:
Note 1360 Trigger does not exist
insert into t1 values (3, "c");
select * from t1;
a b
1 In trigger t1_bi
2 b
3 c
drop table t1;
End of 5.0 tests
......@@ -185,6 +185,22 @@ DROP VIEW v1;
DROP TABLE t1;
DROP FUNCTION fn;
End of 5.0 tests.
drop function if exists pi;
CREATE FUNCTION pi RETURNS STRING SONAME "should_not_parse.so";
ERROR HY000: This function 'pi' has the same name as a native function.
DROP FUNCTION IF EXISTS metaphon;
CREATE FUNCTION metaphon(a int) RETURNS int
return 0;
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
ERROR HY000: Function 'metaphon' already exists
DROP FUNCTION metaphon;
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION metaphon(a int) RETURNS int
return 0;
ERROR HY000: Function 'metaphon' already exists
CREATE FUNCTION test.metaphon(a int) RETURNS int
return 0;
ERROR HY000: Function 'metaphon' already exists
DROP FUNCTION metaphon;
DROP FUNCTION myfunc_double;
DROP FUNCTION myfunc_nonexist;
......
......@@ -280,7 +280,7 @@ create event e22830_3 on schedule every 1 hour do alter event e22830_3 on schedu
create event e22830_4 on schedule every 1 hour do alter event e22830_4 on schedule every (select f22830() from dual) hour;
select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
set global event_scheduler=on;
--sleep 0.7
--sleep 2.0
set global event_scheduler=off;
select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
drop function f22830;
......
......@@ -109,7 +109,28 @@ select count(*) from t1 where id not in (1);
select count(*) from t1 where id not in (1,2);
drop table t1;
# End of 4.1 tests
#
# BUG#17047: CHAR() and IN() can return NULL without signaling NULL
# result
#
# The problem was in the IN() function that ignored maybe_null flags
# of all arguments except the first (the one _before_ the IN
# keyword, '1' in the test case below).
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 SELECT 1 IN (2, NULL);
--echo SELECT should return NULL.
SELECT * FROM t1;
DROP TABLE t1;
--echo End of 4.1 tests
#
# Bug #11885: WHERE condition with NOT IN (one element)
......@@ -233,6 +254,10 @@ select some_id from t1 where some_id not in(-4,-1,-4);
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
drop table t1;
--echo End of 5.0 tests
#
# Bug#18360: Type aggregation for IN and CASE may lead to a wrong result
#
......@@ -256,3 +281,6 @@ explain select f2 from t2 where f2 in ('a','b');
select f2 from t2 where f2 in (1,'b');
explain select f2 from t2 where f2 in (1,'b');
drop table t1, t2;
--echo End of 5.1 tests
......@@ -468,7 +468,51 @@ drop table t7;
select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty");
explain extended select md5('hello');
explain extended select sha('abc');
explain extended select sha1('abc');
explain extended select soundex('');
explain extended select 'mood' sounds like 'mud';
explain extended select aes_decrypt(aes_encrypt('abc','1'),'1');
explain extended select concat('*',space(5),'*');
explain extended select reverse('abc');
explain extended select rpad('a',4,'1');
explain extended select lpad('a',4,'1');
explain extended select concat_ws(',','',NULL,'a');
explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c');
explain extended select elt(2,1);
explain extended select locate("a","b",2);
explain extended select format(130,10);
explain extended select char(0);
explain extended select conv(130,16,10);
explain extended select hex(130);
explain extended select binary 'HE';
explain extended select export_set(255,_latin2'y', _latin2'n', _latin2' ');
explain extended select FIELD('b' COLLATE latin1_bin,'A','B');
explain extended select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d');
explain extended select collation(conv(130,16,10));
explain extended select coercibility(conv(130,16,10));
explain extended select length('\n\t\r\b\0\_\%\\');
explain extended select bit_length('\n\t\r\b\0\_\%\\');
explain extended select bit_length('\n\t\r\b\0\_\%\\');
explain extended select concat('monty',' was here ','again');
explain extended select length('hello');
explain extended select char(ascii('h'));
explain extended select ord('h');
explain extended select quote(1/0);
explain extended select crc32("123");
explain extended select replace('aaaa','a','b');
explain extended select insert('txs',2,1,'hi');
explain extended select left(_latin2'a',1);
explain extended select right(_latin2'a',1);
explain extended select lcase(_latin2'a');
explain extended select ucase(_latin2'a');
explain extended select SUBSTR('abcdefg',3,2);
explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2);
explain extended select trim(_latin2' a ');
explain extended select ltrim(_latin2' a ');
explain extended select rtrim(_latin2' a ');
explain extended select decode(encode(repeat("a",100000),"monty"),"monty");
#
# lpad returns incorrect result (Bug #2182)
......@@ -788,6 +832,70 @@ SELECT * FROM t1 INNER JOIN t2 ON code=id
DROP TABLE t1,t2;
#
# Bug#22684: The Functions ENCODE, DECODE and FORMAT are not real functions
#
select encode(NULL, NULL);
select encode("data", NULL);
select encode(NULL, "password");
select decode(NULL, NULL);
select decode("data", NULL);
select decode(NULL, "password");
select format(NULL, NULL);
select format(pi(), NULL);
select format(NULL, 2);
select benchmark(NULL, NULL);
select benchmark(0, NULL);
select benchmark(100, NULL);
select benchmark(NULL, 1+1);
#
# Please note:
# 1) The collation of the password is irrelevant, the encryption uses
# the binary representation of the string without charset/collation.
# 2) These tests can not print the encoded text directly, because it's binary,
# and doing this would cause problems with source control.
# Instead, an md5() checksum is used, to verify the result indirectly.
# 3) Each md5() result must be identical.
# 4) The md5() result must never change, and must be stable across releases.
#
set @password="password";
set @my_data="clear text to encode";
select md5(encode(@my_data, "password"));
select md5(encode(@my_data, _utf8 "password"));
select md5(encode(@my_data, binary "password"));
select md5(encode(@my_data, _latin1 "password"));
select md5(encode(@my_data, _koi8r "password"));
select md5(encode(@my_data, (select "password" from dual)));
select md5(encode(@my_data, concat("pass", "word")));
select md5(encode(@my_data, @password));
set @my_data="binary encoded data";
select md5(decode(@my_data, "password"));
select md5(decode(@my_data, _utf8 "password"));
select md5(decode(@my_data, binary "password"));
select md5(decode(@my_data, _latin1 "password"));
select md5(decode(@my_data, _koi8r "password"));
select md5(decode(@my_data, (select "password" from dual)));
select md5(decode(@my_data, concat("pass", "word")));
select md5(decode(@my_data, @password));
set @dec=5;
select format(pi(), (1+1));
select format(pi(), (select 3 from dual));
select format(pi(), @dec);
set @bench_count=10;
select benchmark(10, pi());
select benchmark(5+5, pi());
select benchmark((select 10 from dual), pi());
select benchmark(@bench_count, pi());
#
# Bug #10963
# 4294967296 18446744073709551616
......@@ -977,4 +1085,18 @@ select lpad('hello', 18446744073709551616, '1');
select lpad('hello', -18446744073709551617, '1');
select lpad('hello', 18446744073709551617, '1');
#
# BUG#17047: CHAR() and IN() can return NULL without signaling NULL
# result
#
SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional;
SELECT CHAR(0xff,0x8f USING utf8);
SELECT CHAR(0xff,0x8f USING utf8) IS NULL;
SET SQL_MODE=@orig_sql_mode;
--echo End of 5.0 tests
......@@ -6,59 +6,73 @@
#
###########################################################################
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle im_daemon_life_cycle.imtest started.
###########################################################################
--source include/im_check_env.inc
# Turn on reconnect, not on by default anymore
# Turn on reconnect, not on by default anymore.
--enable_reconnect
###########################################################################
#
# The main daemon-life-cycle test case -- check that IM-angel will restart
# IM-main if it got killed:
# - kill IM-main and check that IM-angel will restart it;
# - wait for IM-main to start accepting connections before continue test
# case;
#
###########################################################################
# Kill the IM main process and check that the IM Angel will restart the main
# process.
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: starting...
###########################################################################
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main...
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 im_daemon_life_cycle
# Wait for IM to start accepting connections.
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections...
--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 im_daemon_life_cycle
--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: done.
###########################################################################
#
# BUG#12751: Instance Manager: client hangs
# - start nonguarded instance (mysqld2);
# - kill IM-main and get it restarted by IM-angel;
# - check that guarded instance (mysqld1) is accepting connections.
# - check that non-guarded instance (mysqld2) were not stopped.
#
###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- Test for BUG#12751
--echo --------------------------------------------------------------------
# Give some time to begin accepting connections after restart.
# FIXME: race condition here.
--sleep 3
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: starting...
# 1. Start mysqld;
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: starting...
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
# 2. Restart IM-main: kill it and IM-angel will restart it; wait for IM to
# start accepting connections again.
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to start...
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_daemon_life_cycle
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: started.
--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30
# 2. Restart IM-main;
# 3. Issue some statement -- connection should be re-established.
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main...
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 im_daemon_life_cycle
# Give some time to begin accepting connections after restart.
# FIXME: race condition here.
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections...
--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 im_daemon_life_cycle
# 3. Issue some statement -- connection should be re-established.
--sleep 3
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Checking that IM-main processing commands...
--replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld1;
......@@ -67,6 +81,13 @@ SHOW INSTANCE STATUS mysqld1;
# So, if it we do not stop it, it will be stopped by mysql-test-run.pl with
# warning.
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopping...
STOP INSTANCE mysqld2;
# FIXME: STOP INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to stop...
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_daemon_life_cycle
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopped.
###########################################################################
--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: done.
......@@ -25,7 +25,7 @@
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
......@@ -58,7 +58,7 @@ SHOW VARIABLES LIKE 'port';
STOP INSTANCE mysqld2;
# FIXME: STOP INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
......@@ -121,7 +121,7 @@ STOP INSTANCE mysqld3;
--echo -- 1.1.6.
--echo --------------------------------------------------------------------
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30 im_life_cycle
# Give some time to IM to detect that mysqld was restarted. It should be
# longer than monitoring interval.
......@@ -143,7 +143,7 @@ SHOW INSTANCES;
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
......@@ -151,7 +151,7 @@ START INSTANCE mysqld2;
# mysqld has started.
# SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10 im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
......
......@@ -32,33 +32,7 @@
#
###########################################################################
--source include/im_check_os.inc
###########################################################################
#
# Check starting conditions.
#
###########################################################################
# - check the configuration file;
--echo --------------------------------------------------------------------
--exec grep '^server_id[^a-zA-Z0-9_-]' $MYSQLTEST_VARDIR/im.cnf ;
--echo --------------------------------------------------------------------
# - check the running instances.
--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
--connection mysql1_con
SHOW VARIABLES LIKE 'server_id';
--connection default
# - check the internal cache.
SHOW INSTANCES;
--source include/im_check_env.inc
###########################################################################
#
......
......@@ -31,10 +31,10 @@ SHOW INSTANCE OPTIONS mysqld2;
#
START INSTANCE mysqld2;
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_utils
STOP INSTANCE mysqld2;
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_utils
#
# Check 'SHOW LOG FILES' command:
......
......@@ -2,74 +2,101 @@
###########################################################################
# NOTE: this script returns 0 (success) even in case of failure. This is
# because this script is executed under mysql-test-run[.pl] and it's better to
# examine particular problem in log file, than just having said that the test
# case has failed.
# NOTE: this script returns 0 (success) even in case of failure (except for
# usage-error). This is because this script is executed under
# mysql-test-run[.pl] and it's better to examine particular problem in log
# file, than just having said that the test case has failed.
###########################################################################
basename=`basename "$0"`
dirname=`dirname "$0"`
###########################################################################
. "$dirname/utils.sh"
###########################################################################
check_restart()
{
if [ ! -r "$pid_path" ]; then
log_debug "No '$pid_path' found."
user_msg='the process was killed'
return 1
fi
new_pid=`cat "$pid_path" 2>/dev/null`
err_code=$?
if [ $? -eq 0 -a "$original_pid" = "$new_pid" ]; then
log_debug "err_code: $err_code; original_pid: $original_pid; new_pid: $new_pid."
if [ $err_code -eq 0 -a "$original_pid" = "$new_pid" ]; then
log_debug "The process was not restarted."
user_msg='the process was not restarted'
return 1
fi
log_debug "The process was restarted."
user_msg='the process was restarted'
return 0
}
###########################################################################
if [ $# -ne 3 ]; then
echo "Usage: kill_n_check.sh <pid file path> killed|restarted <timeout>"
exit 0
if [ $# -ne 4 ]; then
echo "Usage: $basename <pid file path> killed|restarted <timeout> <test id>"
exit 1
fi
pid_path="$1"
expected_result="$2"
total_timeout="$3"
test_id="$4"
log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
log_debug "-- $basename: starting --"
log_debug "pid_path: '$pid_path'"
log_debug "expected_result: '$expected_result'"
log_debug "total_timeout: '$total_timeout'"
log_debug "test_id: '$test_id'"
log_debug "log_file: '$log_file'"
###########################################################################
if [ "$expected_result" != 'killed' -a \
"$expected_result" != 'restarted' ]; then
echo "Error: invalid second argument ('killed' or 'restarted' expected)."
exit 0
log_error "Invalid second argument ($expected_result): 'killed' or 'restarted' expected."
quit 0
fi
if [ -z "$pid_path" ]; then
echo "Error: invalid PID path ($pid_path)."
exit 0
log_error "Invalid PID path ($pid_path)."
quit 0
fi
if [ ! -r "$pid_path" ]; then
echo "Error: PID file ($pid_path) does not exist."
exit 0
log_error "PID file ($pid_path) does not exist."
quit 0
fi
if [ -z "$total_timeout" ]; then
echo "Error: timeout is not specified."
exit 0
log_error "Timeout is not specified."
quit 0
fi
###########################################################################
original_pid=`cat "$pid_path"`
log_debug "original_pid: $original_pid."
echo "Killing the process..."
log_info "Killing the process..."
kill -9 $original_pid
###########################################################################
echo "Sleeping..."
log_info "Waiting..."
if [ "$expected_result" = "restarted" ]; then
......@@ -79,37 +106,42 @@ if [ "$expected_result" = "restarted" ]; then
while true; do
log_debug "cur_attempt: $cur_attempt."
if check_restart; then
echo "Success: $user_msg."
exit 0
log_info "Success: $user_msg."
quit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
log_debug "Sleeping for 1 second..."
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
echo "Error: $user_msg."
exit 0
log_error "$user_msg."
quit 0
else # $expected_result == killed
# Here we have to sleep for some long time to ensure that the process will
# not be restarted.
log_debug "Sleeping for $total_timeout seconds..."
sleep $total_timeout
new_pid=`cat "$pid_path" 2>/dev/null`
log_debug "new_pid: $new_pid."
if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then
echo "Error: the process was restarted."
log_error "The process was restarted."
else
echo "Success: the process was killed."
log_info "Success: the process was killed."
fi
exit 0
quit 0
fi
#!/bin/bash
###########################################################################
basename=`basename "$0"`
dirname=`dirname "$0"`
###########################################################################
. "$dirname/utils.sh"
###########################################################################
if [ $# -lt 2 ]; then
echo "Usage: $basename <test id> log message ..."
exit 1
fi
test_id="$1"
log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
shift
log_debug "$*"
......@@ -399,11 +399,6 @@ select atan();
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select atan2(1, 2, 3);
select benchmark(10, 1+1);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select benchmark(5+5, 2);
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select concat();
select concat("foo");
......@@ -413,12 +408,6 @@ select concat_ws();
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select concat_ws("foo");
set @pwd="my password";
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select encode("secret", @pwd);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select decode("encoded-secret", @pwd);
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select encrypt();
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
......@@ -448,10 +437,6 @@ select field();
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select field("p1");
set @dec=2;
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select format(pi(), @dec);
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select from_unixtime();
-- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
......
......@@ -849,6 +849,9 @@ drop table t1;
# Bug#16365 Prepared Statements: DoS with too many open statements
# Check that the limit @@max_prpeared_stmt_count works.
#
# This is also the test for bug#23159 prepared_stmt_count should be
# status variable.
#
# Save the old value
set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
#
......@@ -858,17 +861,17 @@ set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
#
--disable_ps_protocol
#
# A. Check that the new variables are present in SHOW VARIABLES list.
# A. Check that the new variables are present in SHOW VARIABLES and
# SHOW STATUS lists.
#
show variables like 'max_prepared_stmt_count';
show variables like 'prepared_stmt_count';
show status like 'prepared_stmt_count';
#
# B. Check that the new variables are selectable.
# B. Check that the new system variable is selectable.
#
select @@max_prepared_stmt_count, @@prepared_stmt_count;
select @@max_prepared_stmt_count;
#
# C. Check that max_prepared_stmt_count is settable (global only),
# whereas prepared_stmt_count is readonly.
# C. Check that max_prepared_stmt_count is settable (global only).
#
set global max_prepared_stmt_count=-1;
select @@max_prepared_stmt_count;
......@@ -882,12 +885,6 @@ set @@max_prepared_stmt_count=1;
set max_prepared_stmt_count=1;
--error ER_GLOBAL_VARIABLE
set local max_prepared_stmt_count=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set local prepared_stmt_count=0;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set @@prepared_stmt_count=0;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global prepared_stmt_count=1;
# set to a reasonable limit works
set global max_prepared_stmt_count=1;
select @@max_prepared_stmt_count;
......@@ -895,47 +892,50 @@ select @@max_prepared_stmt_count;
# D. Check that the variables actually work.
#
set global max_prepared_stmt_count=0;
select @@max_prepared_stmt_count, @@prepared_stmt_count;
select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
prepare stmt from "select 1";
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
set global max_prepared_stmt_count=1;
prepare stmt from "select 1";
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
prepare stmt1 from "select 1";
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
deallocate prepare stmt;
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
#
# E. Check that we can prepare a statement with the same name
# successfully, without hitting the limit.
#
prepare stmt from "select 1";
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
prepare stmt from "select 2";
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
#
# F. We can set the max below the current count. In this case no new
# statements should be allowed to prepare.
#
select @@prepared_stmt_count, @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
select @@max_prepared_stmt_count;
set global max_prepared_stmt_count=0;
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
prepare stmt from "select 1";
# Result: the old statement is deallocated, the new is not created.
--error 1243 # ER_UNKNOWN_STMT_HANDLER
--error ER_UNKNOWN_STMT_HANDLER
execute stmt;
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
prepare stmt from "select 1";
select @@prepared_stmt_count;
show status like 'prepared_stmt_count';
#
# G. Show that the variables are up to date even after a connection with all
# statements in it was terminated.
#
set global max_prepared_stmt_count=3;
select @@max_prepared_stmt_count, @@prepared_stmt_count;
select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
prepare stmt from "select 1";
connect (con1,localhost,root,,);
connection con1;
......@@ -944,26 +944,31 @@ prepare stmt1 from "select 3";
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
prepare stmt2 from "select 4";
connection default;
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
prepare stmt2 from "select 4";
select @@max_prepared_stmt_count, @@prepared_stmt_count;
select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
disconnect con1;
connection default;
# Wait for the connection to die: deal with a possible race
deallocate prepare stmt;
let $count= `select @@prepared_stmt_count`;
let $query= select variable_value from information_schema.global_status
where variable_name = 'prepared_stmt_count';
let $count= `$query`;
if ($count)
{
--sleep 2
let $count= `select @@prepared_stmt_count`;
--sleep 1
let $count= `$query`;
}
select @@max_prepared_stmt_count, @@prepared_stmt_count;
select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
#
# Restore the old value.
#
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
--enable_ps_protocol
#
# Bug#19399 "Stored Procedures 'Lost Connection' when dropping/creating
# tables"
......@@ -2400,3 +2405,38 @@ execute abc;
drop table if exists t1, t2;
execute abc;
deallocate prepare abc;
#
# Bug#22684: The Functions ENCODE, DECODE and FORMAT are not real functions
#
set @my_password="password";
set @my_data="clear text to encode";
prepare stmt1 from 'select decode(encode(?, ?), ?)';
execute stmt1 using @my_data, @my_password, @my_password;
set @my_data="more text to encode";
execute stmt1 using @my_data, @my_password, @my_password;
set @my_password="new password";
execute stmt1 using @my_data, @my_password, @my_password;
deallocate prepare stmt1;
set @to_format="123456789.123456789";
set @dec=0;
prepare stmt2 from 'select format(?, ?)';
execute stmt2 using @to_format, @dec;
set @dec=4;
execute stmt2 using @to_format, @dec;
set @dec=6;
execute stmt2 using @to_format, @dec;
set @dec=2;
execute stmt2 using @to_format, @dec;
set @to_format="100";
execute stmt2 using @to_format, @dec;
set @to_format="1000000";
execute stmt2 using @to_format, @dec;
set @to_format="10000";
execute stmt2 using @to_format, @dec;
deallocate prepare stmt2;
......@@ -431,6 +431,43 @@ DROP TABLE t2;
--sync_with_master
--connection master
#
# BUG#23703: DROP TRIGGER needs an IF EXISTS
#
connection master;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(a int, b varchar(50));
-- error ER_TRG_DOES_NOT_EXIST
drop trigger not_a_trigger;
drop trigger if exists not_a_trigger;
create trigger t1_bi before insert on t1
for each row set NEW.b := "In trigger t1_bi";
insert into t1 values (1, "a");
drop trigger if exists t1_bi;
insert into t1 values (2, "b");
drop trigger if exists t1_bi;
insert into t1 values (3, "c");
select * from t1;
save_master_pos;
connection slave;
sync_with_master;
select * from t1;
connection master;
drop table t1;
#
# End of tests
......
......@@ -11,6 +11,7 @@
# Tests that uses 'goto' to into sp-goto.test (currently disabled)
# Tests that destroys system tables (e.g. mysql.proc) for error testing
# go to sp-destruct.
# Tests that require --with-geometry go into sp_gis.test
use test;
......@@ -2584,6 +2585,9 @@ begin
end if;
end|
# so that from_unixtime() has a deterministic result
set time_zone='+03:00';
call bug3426(1000, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
call bug3426(NULL, @i)|
......@@ -6585,6 +6589,122 @@ drop procedure proc_21462_b|
--echo End of 5.0 tests
--echo Begin of 5.1 tests
#
# BUG#18239: Possible to overload internal functions with stored functions
#
delimiter ;|
--disable_warnings
drop function if exists pi;
--enable_warnings
create function pi() returns varchar(50)
return "pie, my favorite desert.";
SET @save_sql_mode=@@sql_mode;
SET SQL_MODE='IGNORE_SPACE';
select pi(), pi ();
# Non deterministic warnings from db_load_routine
--disable_warnings
select test.pi(), test.pi ();
--enable_warnings
SET SQL_MODE='';
select pi(), pi ();
# Non deterministic warnings from db_load_routine
--disable_warnings
select test.pi(), test.pi ();
--enable_warnings
SET @@sql_mode=@save_sql_mode;
drop function pi;
# End of BUG#18239
#
# BUG#22619: Spaces considered harmful
#
--disable_warnings
drop function if exists test.database;
drop function if exists test.current_user;
drop function if exists test.md5;
--enable_warnings
create database nowhere;
use nowhere;
drop database nowhere;
SET @save_sql_mode=@@sql_mode;
SET SQL_MODE='IGNORE_SPACE';
select database(), database ();
select current_user(), current_user ();
select md5("aaa"), md5 ("aaa");
SET SQL_MODE='';
select database(), database ();
select current_user(), current_user ();
select md5("aaa"), md5 ("aaa");
use test;
create function `database`() returns varchar(50)
return "Stored function database";
create function `current_user`() returns varchar(50)
return "Stored function current_user";
create function md5(x varchar(50)) returns varchar(50)
return "Stored function md5";
SET SQL_MODE='IGNORE_SPACE';
select database(), database ();
select current_user(), current_user ();
select md5("aaa"), md5 ("aaa");
# Non deterministic warnings from db_load_routine
--disable_warnings
select test.database(), test.database ();
select test.current_user(), test.current_user ();
select test.md5("aaa"), test.md5 ("aaa");
--enable_warnings
SET SQL_MODE='';
select database(), database ();
select current_user(), current_user ();
select md5("aaa"), md5 ("aaa");
# Non deterministic warnings from db_load_routine
--disable_warnings
select test.database(), test.database ();
select test.current_user(), test.current_user ();
select test.md5("aaa"), test.md5 ("aaa");
--enable_warnings
SET @@sql_mode=@save_sql_mode;
drop function test.database;
drop function test.current_user;
drop function md5;
use test;
delimiter |;
# End of BUG#22619
--echo End of 5.1 tests
#
# BUG#NNNN: New bug synopsis
......
-- source include/have_geometry.inc
use test;
#
# BUG#21025: misleading error message when creating functions named 'x', or 'y'
#
--disable_warnings
drop function if exists a;
drop function if exists x;
drop function if exists y;
--enable_warnings
create function a() returns int
return 1;
create function x() returns int
return 2;
create function y() returns int
return 3;
select a();
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select x();
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select y();
select x(PointFromText("POINT(10 20)")), y(PointFromText("POINT(10 20)"));
# Non deterministic warnings from db_load_routine
--disable_warnings
select test.a(), test.x(), test.y();
--enable_warnings
drop function a;
drop function x;
drop function y;
......@@ -1499,4 +1499,52 @@ select * from t1;
drop table t1;
#
# Bug #23651 "Server crashes when trigger which uses stored function
# invoked from different connections".
#
--disable_warnings
drop table if exists t1;
drop function if exists f1;
--enable_warnings
create table t1 (i int);
create function f1() returns int return 10;
create trigger t1_bi before insert on t1 for each row set @a:= f1() + 10;
insert into t1 values ();
select @a;
connection addconroot1;
insert into t1 values ();
select @a;
connection default;
drop table t1;
drop function f1;
#
# Bug#23703: DROP TRIGGER needs an IF EXISTS
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(a int, b varchar(50));
-- error ER_TRG_DOES_NOT_EXIST
drop trigger not_a_trigger;
drop trigger if exists not_a_trigger;
create trigger t1_bi before insert on t1
for each row set NEW.b := "In trigger t1_bi";
insert into t1 values (1, "a");
drop trigger if exists t1_bi;
insert into t1 values (2, "b");
drop trigger if exists t1_bi;
insert into t1 values (3, "c");
select * from t1;
drop table t1;
--echo End of 5.0 tests
......@@ -173,6 +173,42 @@ DROP FUNCTION fn;
--echo End of 5.0 tests.
#
# BUG#18239: Possible to overload internal functions with stored functions
#
--disable_warnings
drop function if exists pi;
--enable_warnings
--error ER_NATIVE_FCT_NAME_COLLISION
CREATE FUNCTION pi RETURNS STRING SONAME "should_not_parse.so";
# Verify that Stored Functions and UDF are mutually exclusive
DROP FUNCTION IF EXISTS metaphon;
CREATE FUNCTION metaphon(a int) RETURNS int
return 0;
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
--error ER_UDF_EXISTS
eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
DROP FUNCTION metaphon;
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
--error ER_UDF_EXISTS
CREATE FUNCTION metaphon(a int) RETURNS int
return 0;
--error ER_UDF_EXISTS
CREATE FUNCTION test.metaphon(a int) RETURNS int
return 0;
# End of Bug#18239
#
# Drop the example functions from udf_example
#
......
###########################################################################
#
# This file provides utility functions and is included by other scripts.
#
# The following global variables must be set before calling functions from this
# file:
# - basename -- base name of the calling script (main application);
# - log_file -- where to store log records;
#
###########################################################################
log()
{
[ -z "$log_file" ] && return;
log_level="$1"
log_msg="$2"
ts=`date`
echo "[$ts] [$basename] [$log_level] $log_msg" >> "$log_file";
}
###########################################################################
log_debug()
{
log 'DEBUG' "$1"
}
###########################################################################
log_info()
{
log 'INFO' "$1"
echo "$1"
}
###########################################################################
log_error()
{
log 'ERROR' "$1"
echo "Error: $1"
}
###########################################################################
quit()
{
exit_status="$1"
log_debug "-- $basename: finished (exit_status: $exit_status) --"
exit $exit_status
}
......@@ -2,34 +2,40 @@
###########################################################################
pid_path="$1"
total_attempts="$2"
event="$3"
# NOTE: this script returns 0 (success) even in case of failure (except for
# usage-error). This is because this script is executed under
# mysql-test-run[.pl] and it's better to examine particular problem in log
# file, than just having said that the test case has failed.
case "$3" in
started)
check_fn='check_started';
;;
###########################################################################
stopped)
check_fn='check_stopped';
;;
basename=`basename "$0"`
dirname=`dirname "$0"`
*)
echo "Error: invalid third argument ('started' or 'stopped' expected)."
exit 0
esac
###########################################################################
. "$dirname/utils.sh"
###########################################################################
check_started()
{
[ ! -r "$pid_path" ] && return 1
if [ ! -r "$pid_path" ]; then
log_debug "No PID-file ($pid_path) found -- not started."
return 1
fi
new_pid=`cat "$pid_path" 2>/dev/null`
err_code=$?
log_debug "err_code: $err_code; new_pid: $new_pid."
[ $? -eq 0 -a "$original_pid" = "$new_pid" ] && return 1
if [ $? -ne 0 -o -z "$new_pid" ]; then
log_debug "The process was not started."
return 1
fi
log_debug "The process was started."
return 0
}
......@@ -37,30 +43,72 @@ check_started()
check_stopped()
{
[ -r "$pid_path" ] && return 1
if [ -r "$pid_path" ]; then
log_debug "PID-file '$pid_path' exists -- not stopped."
return 1
fi
log_debug "No PID-file ($pid_path) found -- stopped."
return 0
}
###########################################################################
if [ $# -ne 4 ]; then
echo "Usage: $basename <pid file path> <total attempts> started|stopped <test id>"
exit 1
fi
pid_path="$1"
total_attempts="$2"
event="$3"
test_id="$4"
log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
log_debug "-- $basename: starting --"
log_debug "pid_path: '$pid_path'"
log_debug "total_attempts: '$total_attempts'"
log_debug "event: '$event'"
log_debug "test_id: '$test_id'"
log_debug "log_file: '$log_file'"
###########################################################################
case "$event" in
started)
check_fn='check_started';
;;
stopped)
check_fn='check_stopped';
;;
*)
log_error "Invalid third argument ('started' or 'stopped' expected)."
quit 0
esac
###########################################################################
cur_attempt=1
while true; do
log_debug "cur_attempt: $cur_attempt."
if ( eval $check_fn ); then
echo "Success: the process has been $event."
exit 0
log_info "Success: the process has been $event."
quit 0
fi
[ $cur_attempt -ge $total_attempts ] && break
log_debug "Sleeping for 1 second..."
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
echo "Error: the process has not been $event in $total_attempts secs."
exit 0
log_error "The process has not been $event in $total_attempts secs."
quit 0
......@@ -2,9 +2,25 @@
###########################################################################
if [ $# -ne 6 ]; then
echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout>"
exit 0
# NOTE: this script returns 0 (success) even in case of failure (except for
# usage-error). This is because this script is executed under
# mysql-test-run[.pl] and it's better to examine particular problem in log
# file, than just having said that the test case has failed.
###########################################################################
basename=`basename "$0"`
dirname=`dirname "$0"`
###########################################################################
. "$dirname/utils.sh"
###########################################################################
if [ $# -ne 7 ]; then
echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout> <test id>"
exit 1
fi
client_exe="$1"
......@@ -13,22 +29,34 @@ username="$3"
password="$4"
db="$5"
total_timeout="$6"
test_id="$7"
log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
log_debug "-- $basename: starting --"
log_debug "client_exe: '$client_exe'"
log_debug "socket_path: '$socket_path'"
log_debug "username: '$username'"
log_debug "password: '$password'"
log_debug "db: '$db'"
log_debug "total_timeout: '$total_timeout'"
log_debug "test_id: '$test_id'"
log_debug "log_file: '$log_file'"
###########################################################################
if [ -z "$client_exe" ]; then
echo "Error: invalid path to client executable ($client_exe)."
exit 0;
log_error "Invalid path to client executable ($client_exe)."
quit 0;
fi
if [ ! -x "$client_exe" ]; then
echo "Error: client by path '$client_exe' is not available."
exit 0;
log_error "Client by path '$client_exe' is not available."
quit 0;
fi
if [ -z "$socket_path" ]; then
echo "Error: invalid socket patch."
exit 0
log_error "Invalid socket patch ($socket_path)."
quit 0
fi
###########################################################################
......@@ -39,15 +67,19 @@ client_args="--silent --socket=$socket_path --connect_timeout=1 "
[ -n "$password" ] && client_args="$client_args --password=$password "
[ -n "$db" ] && client_args="$client_args $db"
log_debug "client_args: '$client_args'"
###########################################################################
cur_attempt=1
while true; do
log_debug "cur_attempt: $cur_attempt."
if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then
echo "Success: server is ready to accept connection on socket."
exit 0
log_info "Success: server is ready to accept connection on socket."
quit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
......@@ -58,5 +90,5 @@ while true; do
done
echo "Error: server does not accept connections after $total_timeout seconds."
exit 0
log_error "Server does not accept connections after $total_timeout seconds."
quit 0
......@@ -21,22 +21,22 @@ void IMService::Stop()
{
ReportStatus(SERVICE_STOP_PENDING);
// stop the IM work
/* stop the IM work */
raise(SIGTERM);
}
void IMService::Run(DWORD argc, LPTSTR *argv)
{
// report to the SCM that we're about to start
/* report to the SCM that we're about to start */
ReportStatus((DWORD)SERVICE_START_PENDING);
Options::load(argc, argv);
// init goes here
/* init goes here */
ReportStatus((DWORD)SERVICE_RUNNING);
// wait for main loop to terminate
manager();
/* wait for main loop to terminate */
(void) Manager::main();
Options::cleanup();
}
......@@ -54,24 +54,24 @@ int HandleServiceOptions()
if (Options::Service::install_as_service)
{
if (winService.IsInstalled())
log_info("Service is already installed");
log_info("Service is already installed.");
else if (winService.Install())
log_info("Service installed successfully");
log_info("Service installed successfully.");
else
{
log_info("Service failed to install");
log_error("Service failed to install.");
ret_val= 1;
}
}
else if (Options::Service::remove_service)
{
if (! winService.IsInstalled())
log_info("Service is not installed");
log_info("Service is not installed.");
else if (winService.Remove())
log_info("Service removed successfully");
log_info("Service removed successfully.");
else
{
log_info("Service failed to remove");
log_error("Service failed to remove.");
ret_val= 1;
}
}
......@@ -81,7 +81,7 @@ int HandleServiceOptions()
if (!winService.Init())
{
log_info("Service failed to initialize.");
log_error("Service failed to initialize.");
fprintf(stderr,
"The service should be started by Windows Service Manager.\n"
"The MySQL Manager should be started with '--standalone'\n"
......
......@@ -19,7 +19,7 @@
#pragma once
#include "windowsservice.h"
class IMService : public WindowsService
class IMService: public WindowsService
{
public:
IMService(void);
......
......@@ -61,6 +61,8 @@ client_settings.h:
libexec_PROGRAMS= mysqlmanager
mysqlmanager_CXXFLAGS= -Wall -W
mysqlmanager_SOURCES= command.cc command.h mysqlmanager.cc \
manager.h manager.cc log.h log.cc \
thread_registry.h thread_registry.cc \
......
......@@ -27,7 +27,7 @@ const uint Buffer::MAX_BUFFER_SIZE= 16777216;
/*
Puts the given string to the buffer.
SYNOPSYS
SYNOPSIS
append()
position start position in the buffer
string string to be put in the buffer
......@@ -59,7 +59,7 @@ int Buffer::append(uint position, const char *string, uint len_arg)
Checks whether the current buffer size is ok to put a string of the length
"len_arg" starting from "position" and reallocs it if no.
SYNOPSYS
SYNOPSIS
reserve()
position the number starting byte on the buffer to store a buffer
len_arg the length of the string.
......
......@@ -19,10 +19,12 @@
#endif
#include "command.h"
#include "manager.h"
Command::Command(Instance_map *instance_map_arg)
:instance_map(instance_map_arg)
Command::Command()
:guardian(Manager::get_guardian()),
instance_map(Manager::get_instance_map())
{}
Command::~Command()
......
......@@ -24,6 +24,7 @@
/* Class responsible for allocation of IM commands. */
class Guardian;
class Instance_map;
struct st_net;
......@@ -36,13 +37,13 @@ struct st_net;
class Command
{
public:
Command(Instance_map *instance_map_arg= 0);
Command();
virtual ~Command();
/*
This operation incapsulates behaviour of the command.
SYNOPSYS
SYNOPSIS
net The network connection to the client.
connection_id Client connection ID
......@@ -53,6 +54,7 @@ public:
virtual int execute(st_net *net, ulong connection_id) = 0;
protected:
Guardian *guardian;
Instance_map *instance_map;
};
......
This diff is collapsed.
......@@ -32,15 +32,16 @@
/*
Print all instances of this instance manager.
Grammar: SHOW ISTANCES
Grammar: SHOW INSTANCES
*/
class Show_instances : public Command
class Show_instances: public Command
{
public:
Show_instances(Instance_map *instance_map_arg): Command(instance_map_arg)
{}
Show_instances()
{ }
public:
int execute(st_net *net, ulong connection_id);
private:
......@@ -54,12 +55,13 @@ private:
Grammar: FLUSH INSTANCES
*/
class Flush_instances : public Command
class Flush_instances: public Command
{
public:
Flush_instances(Instance_map *instance_map_arg): Command(instance_map_arg)
{}
Flush_instances()
{ }
public:
int execute(st_net *net, ulong connection_id);
};
......@@ -68,11 +70,10 @@ public:
Abstract class for Instance-specific commands.
*/
class Abstract_instance_cmd : public Command
class Abstract_instance_cmd: public Command
{
public:
Abstract_instance_cmd(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Abstract_instance_cmd(const LEX_STRING *instance_name_arg);
public:
virtual int execute(st_net *net, ulong connection_id);
......@@ -102,14 +103,13 @@ private:
/*
Print status of an instance.
Grammar: SHOW ISTANCE STATUS <instance_name>
Grammar: SHOW INSTANCE STATUS <instance_name>
*/
class Show_instance_status : public Abstract_instance_cmd
class Show_instance_status: public Abstract_instance_cmd
{
public:
Show_instance_status(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Show_instance_status(const LEX_STRING *instance_name_arg);
protected:
virtual int execute_impl(st_net *net, Instance *instance);
......@@ -126,11 +126,10 @@ private:
Grammar: SHOW INSTANCE OPTIONS <instance_name>
*/
class Show_instance_options : public Abstract_instance_cmd
class Show_instance_options: public Abstract_instance_cmd
{
public:
Show_instance_options(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Show_instance_options(const LEX_STRING *instance_name_arg);
protected:
virtual int execute_impl(st_net *net, Instance *instance);
......@@ -147,11 +146,10 @@ private:
Grammar: START INSTANCE <instance_name>
*/
class Start_instance : public Abstract_instance_cmd
class Start_instance: public Abstract_instance_cmd
{
public:
Start_instance(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Start_instance(const LEX_STRING *instance_name_arg);
protected:
virtual int execute_impl(st_net *net, Instance *instance);
......@@ -164,11 +162,10 @@ protected:
Grammar: STOP INSTANCE <instance_name>
*/
class Stop_instance : public Abstract_instance_cmd
class Stop_instance: public Abstract_instance_cmd
{
public:
Stop_instance(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Stop_instance(const LEX_STRING *instance_name_arg);
protected:
virtual int execute_impl(st_net *net, Instance *instance);
......@@ -181,11 +178,10 @@ protected:
Grammar: CREATE INSTANCE <instance_name> [<options>]
*/
class Create_instance : public Command
class Create_instance: public Command
{
public:
Create_instance(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Create_instance(const LEX_STRING *instance_name_arg);
public:
bool init(const char **text);
......@@ -217,11 +213,10 @@ private:
is removed from the instance map.
*/
class Drop_instance : public Abstract_instance_cmd
class Drop_instance: public Abstract_instance_cmd
{
public:
Drop_instance(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Drop_instance(const LEX_STRING *instance_name_arg);
protected:
virtual int execute_impl(st_net *net, Instance *instance);
......@@ -235,11 +230,10 @@ protected:
SHOW <instance_name> LOG {ERROR | SLOW | GENERAL} size[, offset_from_end]
*/
class Show_instance_log : public Abstract_instance_cmd
class Show_instance_log: public Abstract_instance_cmd
{
public:
Show_instance_log(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg,
Show_instance_log(const LEX_STRING *instance_name_arg,
Log_type log_type_arg, uint size_arg, uint offset_arg);
protected:
......@@ -263,11 +257,10 @@ private:
Grammar: SHOW <instance_name> LOG FILES
*/
class Show_instance_log_files : public Abstract_instance_cmd
class Show_instance_log_files: public Abstract_instance_cmd
{
public:
Show_instance_log_files(Instance_map *instance_map_arg,
const LEX_STRING *instance_name_arg);
Show_instance_log_files(const LEX_STRING *instance_name_arg);
protected:
virtual int execute_impl(st_net *net, Instance *instance);
......@@ -285,7 +278,7 @@ private:
class Instance_options_list;
class Abstract_option_cmd : public Command
class Abstract_option_cmd: public Command
{
public:
~Abstract_option_cmd();
......@@ -299,7 +292,7 @@ public:
virtual int execute(st_net *net, ulong connection_id);
protected:
Abstract_option_cmd(Instance_map *instance_map_arg);
Abstract_option_cmd();
int correct_file(Instance *instance, Named_value *option, bool skip);
......@@ -324,10 +317,11 @@ private:
Grammar: SET instance_name.option[=option_value][, ...]
*/
class Set_option : public Abstract_option_cmd
class Set_option: public Abstract_option_cmd
{
public:
Set_option(Instance_map *instance_map_arg);
Set_option()
{ }
protected:
virtual bool parse_args(const char **text);
......@@ -343,7 +337,8 @@ protected:
class Unset_option: public Abstract_option_cmd
{
public:
Unset_option(Instance_map *instance_map_arg);
Unset_option()
{ }
protected:
virtual bool parse_args(const char **text);
......@@ -360,12 +355,11 @@ protected:
just returns NULL.
*/
class Syntax_error : public Command
class Syntax_error: public Command
{
public:
/* This is just to avoid compiler warning. */
Syntax_error() :Command(NULL)
{}
Syntax_error()
{ }
public:
int execute(st_net *net, ulong connection_id);
......
This diff is collapsed.
......@@ -16,11 +16,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <my_global.h>
#include <my_sys.h>
#include <my_list.h>
#include "thread_registry.h"
#include <my_sys.h>
#include <my_list.h>
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
#pragma interface
......@@ -31,30 +30,12 @@ class Instance_map;
class Thread_registry;
struct GUARD_NODE;
pthread_handler_t guardian(void *arg);
struct Guardian_thread_args
{
Thread_registry &thread_registry;
Instance_map *instance_map;
int monitoring_interval;
Guardian_thread_args(Thread_registry &thread_registry_arg,
Instance_map *instance_map_arg,
uint monitoring_interval_arg) :
thread_registry(thread_registry_arg),
instance_map(instance_map_arg),
monitoring_interval(monitoring_interval_arg)
{}
};
/*
/**
The guardian thread is responsible for monitoring and restarting of guarded
instances.
*/
class Guardian_thread: public Guardian_thread_args
class Guardian: public Thread
{
public:
/* states of an instance */
......@@ -82,12 +63,10 @@ public:
/* Return client state name. */
static const char *get_instance_state_name(enum_instance_state state);
Guardian_thread(Thread_registry &thread_registry_arg,
Instance_map *instance_map_arg,
uint monitoring_interval_arg);
~Guardian_thread();
/* Main funtion of the thread */
void run();
Guardian(Thread_registry *thread_registry_arg,
Instance_map *instance_map_arg,
uint monitoring_interval_arg);
virtual ~Guardian();
/* Initialize or refresh the list of guarded instances */
int init();
/* Request guardian shutdown. Stop instances if needed */
......@@ -117,6 +96,9 @@ public:
a valid list node.
*/
inline enum_instance_state get_instance_state(LIST *instance_node);
protected:
/* Main funtion of the thread */
virtual void run();
public:
pthread_cond_t COND_guardian;
......@@ -133,6 +115,9 @@ private:
private:
pthread_mutex_t LOCK_guardian;
Thread_info thread_info;
int monitoring_interval;
Thread_registry *thread_registry;
Instance_map *instance_map;
LIST *guarded_instances;
MEM_ROOT alloc;
/* this variable is set to TRUE when we want to stop Guardian thread */
......@@ -140,8 +125,8 @@ private:
};
inline Guardian_thread::enum_instance_state
Guardian_thread::get_instance_state(LIST *instance_node)
inline Guardian::enum_instance_state
Guardian::get_instance_state(LIST *instance_node)
{
return ((GUARD_NODE *) instance_node->data)->state;
}
......
This diff is collapsed.
......@@ -88,21 +88,19 @@ public:
static bool is_mysqld_compatible_name(const LEX_STRING *name);
public:
Instance(Thread_registry &thread_registry_arg);
Instance();
~Instance();
int init(const LEX_STRING *name_arg);
int complete_initialization(Instance_map *instance_map_arg,
const char *mysqld_path);
bool init(const LEX_STRING *name_arg);
bool complete_initialization();
bool is_running();
bool is_mysqld_running();
int start();
int stop();
/* send a signal to the instance */
void kill_instance(int signo);
void kill_mysqld(int signo);
bool is_crashed();
void set_crash_flag_n_wake_all();
Instance_map *get_map();
/*
The operation is intended to check if the instance is mysqld-compatible
......@@ -121,7 +119,6 @@ public:
public:
enum { DEFAULT_SHUTDOWN_DELAY= 35 };
Instance_options options;
Thread_registry &thread_registry;
private:
/* This attributes is a flag, specifies if the instance has been crashed. */
......@@ -155,7 +152,6 @@ private:
stop in Instance::stop()
*/
pthread_cond_t COND_instance_stopped;
Instance_map *instance_map;
void remove_pid();
};
......
......@@ -63,7 +63,7 @@ static void delete_instance(void *u)
/*
The option handler to pass to the process_default_option_files finction.
SYNOPSYS
SYNOPSIS
process_option()
ctx Handler context. Here it is an instance_map structure.
group_name The name of the group the option belongs to.
......@@ -169,7 +169,7 @@ int Instance_map::process_one_option(const LEX_STRING *group,
if (!(instance= (Instance *) hash_search(&hash, (byte *) group->str,
group->length)))
{
if (!(instance= new Instance(thread_registry)))
if (!(instance= new Instance()))
return 1;
if (instance->init(group) || add_instance(instance))
......@@ -213,16 +213,13 @@ int Instance_map::process_one_option(const LEX_STRING *group,
}
Instance_map::Instance_map(const char *default_mysqld_path_arg,
Thread_registry &thread_registry_arg):
mysqld_path(default_mysqld_path_arg),
thread_registry(thread_registry_arg)
Instance_map::Instance_map()
{
pthread_mutex_init(&LOCK_instance_map, 0);
}
int Instance_map::init()
bool Instance_map::init()
{
return hash_init(&hash, default_charset_info, START_HASH_SIZE, 0, 0,
get_instance_key, delete_instance, 0);
......@@ -276,7 +273,7 @@ void Instance_map::unlock()
FLUSH INSTANCES without prior stop of all running instances.
NOTE: The operation should be invoked with the following locks acquired:
- Guardian_thread;
- Guardian;
- Instance_map;
*/
......@@ -310,7 +307,7 @@ bool Instance_map::is_there_active_instance()
while ((instance= iterator.next()))
{
if (guardian->find_instance_node(instance) != NULL ||
instance->is_running())
instance->is_mysqld_running())
{
return TRUE;
}
......@@ -335,18 +332,18 @@ int Instance_map::remove_instance(Instance *instance)
int Instance_map::create_instance(const LEX_STRING *instance_name,
const Named_value_arr *options)
{
Instance *instance= new Instance(thread_registry);
Instance *instance= new Instance();
if (!instance)
{
log_error("Error: can not initialize (name: '%s').",
log_error("Can not allocate instance (name: '%s').",
(const char *) instance_name->str);
return ER_OUT_OF_RESOURCES;
}
if (instance->init(instance_name))
{
log_error("Error: can not initialize (name: '%s').",
log_error("Can not initialize instance (name: '%s').",
(const char *) instance_name->str);
delete instance;
return ER_OUT_OF_RESOURCES;
......@@ -359,7 +356,7 @@ int Instance_map::create_instance(const LEX_STRING *instance_name,
if (instance->is_mysqld_compatible() &&
Instance_options::is_option_im_specific(option.get_name()))
{
log_error("Error: IM-option (%s) can not be used "
log_error("IM-option (%s) can not be used "
"in configuration of mysqld-compatible instance (%s).",
(const char *) option.get_name(),
(const char *) instance_name->str);
......@@ -374,9 +371,9 @@ int Instance_map::create_instance(const LEX_STRING *instance_name,
log_info("Warning: instance name '%s' is mysqld-compatible.",
(const char *) instance_name->str);
if (instance->complete_initialization(this, mysqld_path))
if (instance->complete_initialization())
{
log_error("Error: can not complete initialization of instance (name: '%s').",
log_error("Can not complete initialization of instance (name: '%s').",
(const char *) instance_name->str);
delete instance;
return ER_OUT_OF_RESOURCES;
......@@ -385,7 +382,7 @@ int Instance_map::create_instance(const LEX_STRING *instance_name,
if (add_instance(instance))
{
log_error("Error: can not register instance (name: '%s').",
log_error("Can not register instance (name: '%s').",
(const char *) instance_name->str);
delete instance;
return ER_OUT_OF_RESOURCES;
......@@ -411,7 +408,7 @@ bool Instance_map::complete_initialization()
{
Instance *instance= (Instance *) hash_element(&hash, i);
if (instance->complete_initialization(this, mysqld_path))
if (instance->complete_initialization())
return TRUE;
}
......@@ -429,7 +426,7 @@ bool Instance_map::complete_initialization()
if (create_instance(&Instance::DFLT_INSTANCE_NAME, NULL))
{
log_error("Error: could not create default instance.");
log_error("Can not create default instance.");
return TRUE;
}
......@@ -444,7 +441,7 @@ bool Instance_map::complete_initialization()
break;
default:
log_error("Error: could not add default instance to the config file.");
log_error("Can not add default instance to the config file.");
Instance *instance= find(&Instance::DFLT_INSTANCE_NAME);
......@@ -502,7 +499,7 @@ int Instance_map::load()
if (my_search_option_files(Options::Main::config_file, &argc,
(char ***) &argv, &args_used,
process_option, (void*) this))
log_info("Falling back to compiled-in defaults");
log_info("Falling back to compiled-in defaults.");
return complete_initialization();
}
......@@ -537,20 +534,20 @@ const char *Instance_map::get_instance_state_name(Instance *instance)
{
/* The instance is managed by Guardian: we can report precise state. */
return Guardian_thread::get_instance_state_name(
return Guardian::get_instance_state_name(
guardian->get_instance_state(instance_node));
}
/* The instance is not managed by Guardian: we can report status only. */
return instance->is_running() ? "online" : "offline";
return instance->is_mysqld_running() ? "online" : "offline";
}
/*
Create a new configuration section for mysqld-instance in the config file.
SYNOPSYS
SYNOPSIS
create_instance_in_file()
instance_name mysqld-instance name
options options for the new mysqld-instance
......@@ -569,7 +566,7 @@ int create_instance_in_file(const LEX_STRING *instance_name,
if (my_access(Options::Main::config_file, W_OK))
{
log_error("Error: configuration file (%s) does not exist.",
log_error("Configuration file (%s) does not exist.",
(const char *) Options::Main::config_file);
return ER_CONF_FILE_DOES_NOT_EXIST;
}
......@@ -578,7 +575,7 @@ int create_instance_in_file(const LEX_STRING *instance_name,
if (cnf_file <= 0)
{
log_error("Error: can not open configuration file (%s): %s.",
log_error("Can not open configuration file (%s): %s.",
(const char *) Options::Main::config_file,
(const char *) strerror(errno));
return ER_ACCESS_OPTION_FILE;
......@@ -591,7 +588,7 @@ int create_instance_in_file(const LEX_STRING *instance_name,
my_write(cnf_file, (byte*)"]", 1, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
{
log_error("Error: can not write to configuration file (%s): %s.",
log_error("Can not write to configuration file (%s): %s.",
(const char *) Options::Main::config_file,
(const char *) strerror(errno));
my_close(cnf_file, MYF(0));
......@@ -615,7 +612,7 @@ int create_instance_in_file(const LEX_STRING *instance_name,
if (my_write(cnf_file, (byte*)option_str, option_str_len, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
{
log_error("Error: can not write to configuration file (%s): %s.",
log_error("Can not write to configuration file (%s): %s.",
(const char *) Options::Main::config_file,
(const char *) strerror(errno));
my_close(cnf_file, MYF(0));
......
......@@ -25,7 +25,7 @@
#pragma interface
#endif
class Guardian_thread;
class Guardian;
class Instance;
class Named_value_arr;
class Thread_registry;
......@@ -75,7 +75,7 @@ public:
void lock();
void unlock();
int init();
bool init();
/*
Process a given option and assign it to appropricate instance. This is
......@@ -105,8 +105,7 @@ public:
int create_instance(const LEX_STRING *instance_name,
const Named_value_arr *options);
Instance_map(const char *default_mysqld_path_arg,
Thread_registry &thread_registry_arg);
Instance_map();
~Instance_map();
/*
......@@ -115,13 +114,13 @@ public:
MT-NOTE: the options must be called under acquired locks of the following
objects:
- Instance_map;
- Guardian_thread;
- Guardian;
*/
const char *get_instance_state_name(Instance *instance);
public:
const char *mysqld_path;
Guardian_thread *guardian;
Guardian *guardian;
private:
/* loads options from config files */
......@@ -132,8 +131,6 @@ private:
enum { START_HASH_SIZE = 16 };
pthread_mutex_t LOCK_instance_map;
HASH hash;
Thread_registry &thread_registry;
};
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_MAP_H */
......@@ -45,8 +45,9 @@ public:
public:
Instance_options();
~Instance_options();
/* fills in argv */
int complete_initialization(const char *default_path);
bool complete_initialization();
bool set_option(Named_value *option);
void unset_option(const char *option_name);
......@@ -55,12 +56,15 @@ public:
inline Named_value get_option(int idx) const;
public:
int init(const LEX_STRING *instance_name_arg);
pid_t get_pid();
bool init(const LEX_STRING *instance_name_arg);
pid_t load_pid();
int get_pid_filename(char *result);
int unlink_pidfile();
void print_argv();
uint get_shutdown_delay() const;
int get_mysqld_port() const;
public:
/*
We need this value to be greater or equal then FN_REFLEN found in
......@@ -79,21 +83,17 @@ public:
const char *mysqld_socket;
const char *mysqld_datadir;
const char *mysqld_pid_file;
const char *mysqld_port;
uint mysqld_port_val;
LEX_STRING instance_name;
LEX_STRING mysqld_path;
LEX_STRING mysqld_real_path;
const char *nonguarded;
const char *shutdown_delay;
uint shutdown_delay_val;
/* log enums are defined in parse.h */
char *logs[3];
private:
int fill_log_options();
int fill_instance_version();
int fill_mysqld_real_path();
bool fill_log_options();
bool fill_instance_version();
bool fill_mysqld_real_path();
int add_to_argv(const char *option);
int get_default_option(char *result, size_t result_len,
const char *option_name);
......@@ -102,6 +102,11 @@ private:
int find_option(const char *option_name);
private:
const char *mysqld_port;
uint mysqld_port_val;
const char *shutdown_delay;
uint shutdown_delay_val;
uint filled_default_options;
MEM_ROOT alloc;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -21,7 +21,6 @@
#include <m_string.h>
class Command;
class Instance_map;
enum Log_type
{
......@@ -30,7 +29,7 @@ enum Log_type
IM_LOG_SLOW
};
Command *parse_command(Instance_map *map, const char *text);
Command *parse_command(const char *text);
bool parse_option_value(const char *text, uint *text_len, char **value);
......
......@@ -43,7 +43,7 @@ void trim_space(const char **text, uint *word_len)
/*
Parse output of the given command
SYNOPSYS
SYNOPSIS
parse_output_and_get_value()
command the command to execue with popen.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6010,4 +6010,6 @@ ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 42000
eng "Incorrect parameter count in the call to native function '%-.64s'"
ER_WRONG_PARAMETERS_TO_NATIVE_FCT 42000
eng "Incorrect parameters in the call to native function '%-.64s'"
ER_NATIVE_FCT_NAME_COLLISION
eng "This function '%-.64s' has the same name as a native function."
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment