Commit cf297f60 authored by unknown's avatar unknown

Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/Users/kent/mysql/bk/mysql-5.0

parents ad0516d9 4727620b
...@@ -1639,6 +1639,7 @@ sub mysqld_arguments ($$$$$) { ...@@ -1639,6 +1639,7 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir); mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir); mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir);
mtr_add_arg($args, "%s--core", $prefix); mtr_add_arg($args, "%s--core", $prefix);
mtr_add_arg($args, "%s--log-bin-trust-routine-creators", $prefix);
mtr_add_arg($args, "%s--default-character-set=latin1", $prefix); mtr_add_arg($args, "%s--default-character-set=latin1", $prefix);
mtr_add_arg($args, "%s--language=%s", $prefix, $path_language); mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix); mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
......
...@@ -486,6 +486,7 @@ void start_master() ...@@ -486,6 +486,7 @@ void start_master()
#endif #endif
add_arg(&al, "--local-infile"); add_arg(&al, "--local-infile");
add_arg(&al, "--core"); add_arg(&al, "--core");
add_arg(&al, "--log-bin-trust-routine-creators");
add_arg(&al, "--datadir=%s", master_dir); add_arg(&al, "--datadir=%s", master_dir);
#ifndef __WIN__ #ifndef __WIN__
add_arg(&al, "--pid-file=%s", master_pid); add_arg(&al, "--pid-file=%s", master_pid);
......
...@@ -586,3 +586,8 @@ use test; ...@@ -586,3 +586,8 @@ use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost; REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost; DROP USER dummy@localhost;
DROP DATABASE mysqltest; DROP DATABASE mysqltest;
use mysql;
insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_grantor',CURRENT_TIMESTAMP,'Select','Select');
flush privileges;
delete from tables_priv where host = '' and user = 'mysqltest_1';
flush privileges;
...@@ -738,7 +738,7 @@ x_real NULL NULL ...@@ -738,7 +738,7 @@ x_real NULL NULL
x_float NULL NULL x_float NULL NULL
x_double_precision NULL NULL x_double_precision NULL NULL
drop table t1; drop table t1;
create user mysqltest_4@localhost; grant select on test.* to mysqltest_4@localhost;
SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME='TABLE_NAME'; where COLUMN_NAME='TABLE_NAME';
TABLE_NAME COLUMN_NAME PRIVILEGES TABLE_NAME COLUMN_NAME PRIVILEGES
...@@ -751,6 +751,7 @@ COLUMN_PRIVILEGES TABLE_NAME select ...@@ -751,6 +751,7 @@ COLUMN_PRIVILEGES TABLE_NAME select
TABLE_CONSTRAINTS TABLE_NAME select TABLE_CONSTRAINTS TABLE_NAME select
KEY_COLUMN_USAGE TABLE_NAME select KEY_COLUMN_USAGE TABLE_NAME select
delete from mysql.user where user='mysqltest_4'; delete from mysql.user where user='mysqltest_4';
delete from mysql.db where user='mysqltest_4';
flush privileges; flush privileges;
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
table_schema count(*) table_schema count(*)
......
...@@ -1665,7 +1665,7 @@ v2 VIEW ...@@ -1665,7 +1665,7 @@ v2 VIEW
v3 VIEW v3 VIEW
show create view v1; show create view v1;
View Create View View Create View
v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`v3`.`a` AS `a`,`test`.`v3`.`b` AS `b`,`test`.`v3`.`c` AS `c` from `test`.`v3` where (`test`.`v3`.`b` in (1,2,3,4,5,6,7)) v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `v3`.`a` AS `a`,`v3`.`b` AS `b`,`v3`.`c` AS `c` from `test`.`v3` where (`v3`.`b` in (1,2,3,4,5,6,7))
select * from v1; select * from v1;
a b c a b c
1 2 one 1 2 one
......
...@@ -665,3 +665,43 @@ TEMP_SUM ...@@ -665,3 +665,43 @@ TEMP_SUM
0 0
drop procedure SP001; drop procedure SP001;
drop table t1, t2; drop table t1, t2;
drop function if exists bug11394|
drop function if exists bug11394_1|
drop function if exists bug11394_2|
drop procedure if exists bug11394|
create function bug11394(i int) returns int
begin
if i <= 0 then
return 0;
else
return (i in (100, 200, bug11394(i-1), 400));
end if;
end|
select bug11394(2)|
ERROR HY000: Recursive stored routines are not allowed.
drop function bug11394|
create function bug11394_1(i int) returns int
begin
if i <= 0 then
return 0;
else
return (select bug11394_1(i-1));
end if;
end|
select bug11394_1(2)|
ERROR HY000: Recursive stored routines are not allowed.
drop function bug11394_1|
create function bug11394_2(i int) returns int return i|
select bug11394_2(bug11394_2(10))|
bug11394_2(bug11394_2(10))
10
drop function bug11394_2|
create procedure bug11394(i int, j int)
begin
if i > 0 then
call bug11394(i - 1,(select 1));
end if;
end|
call bug11394(2, 1)|
ERROR HY000: Recursive stored routines are not allowed.
drop procedure bug11394|
...@@ -1257,60 +1257,6 @@ drop procedure opp| ...@@ -1257,60 +1257,6 @@ drop procedure opp|
drop procedure ip| drop procedure ip|
show procedure status like '%p%'| show procedure status like '%p%'|
Db Name Type Definer Modified Created Security_type Comment Db Name Type Definer Modified Created Security_type Comment
drop table if exists fib|
create table fib ( 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;
open c;
fetch c into y;
fetch c into x;
close c;
insert into fib values (x+y);
call fib(n-1);
end;
end if;
end|
insert into fib values (0), (1)|
call fib(3)|
select * from fib 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|
f
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
drop table fib|
drop procedure fib|
drop procedure if exists bar| drop procedure if exists bar|
create procedure bar(x char(16), y int) create procedure bar(x char(16), y int)
comment "111111111111" sql security invoker comment "111111111111" sql security invoker
...@@ -2367,20 +2313,6 @@ s1 ...@@ -2367,20 +2313,6 @@ s1
1 1
drop procedure bug4905| drop procedure bug4905|
drop table t3| drop table t3|
drop function if exists bug6022|
drop function if exists bug6022|
create function bug6022(x int) returns int
begin
if x < 0 then
return 0;
else
return bug6022(x-1);
end if;
end|
select bug6022(5)|
bug6022(5)
0
drop function bug6022|
drop procedure if exists bug6029| drop procedure if exists bug6029|
drop procedure if exists bug6029| drop procedure if exists bug6029|
create procedure bug6029() create procedure bug6029()
......
...@@ -420,4 +420,41 @@ t1 CREATE TABLE `t1` ( ...@@ -420,4 +420,41 @@ t1 CREATE TABLE `t1` (
`a` int(11) default NULL `a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
SET @@SQL_MODE='';
create function `foo` () returns int return 5;
show create function `foo`;
Function sql_mode Create Function
foo CREATE FUNCTION `test`.`foo`() RETURNS int(11)
return 5
SET @@SQL_MODE='ANSI_QUOTES';
show create function `foo`;
Function sql_mode Create Function
foo CREATE FUNCTION `test`.`foo`() RETURNS int(11)
return 5
drop function `foo`;
create function `foo` () returns int return 5;
show create function `foo`;
Function sql_mode Create Function
foo ANSI_QUOTES CREATE FUNCTION "test"."foo"() RETURNS int(11)
return 5
SET @@SQL_MODE='';
show create function `foo`;
Function sql_mode Create Function
foo ANSI_QUOTES CREATE FUNCTION "test"."foo"() RETURNS int(11)
return 5
drop function `foo`;
SET @@SQL_MODE='';
create table t1 (a int);
create table t2 (a int);
create view v1 as select a from t1;
show create view v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1`
SET @@SQL_MODE='ANSI_QUOTES';
show create view v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED VIEW "test"."v1" AS select "test"."t1"."a" AS "a" from "test"."t1"
create view v2 as select a from t2 where a in (select a from v1);
drop view v2, v1;
drop table t1, t2;
SET @@SQL_MODE=@OLD_SQL_MODE; SET @@SQL_MODE=@OLD_SQL_MODE;
...@@ -550,7 +550,7 @@ create table t1 ("a*b" int); ...@@ -550,7 +550,7 @@ create table t1 ("a*b" int);
create view v1 as select "a*b" from t1; create view v1 as select "a*b" from t1;
show create view v1; show create view v1;
View Create View View Create View
v1 CREATE VIEW "test"."v1" AS select `test`.`t1`.`a*b` AS `a*b` from `test`.`t1` v1 CREATE VIEW "test"."v1" AS select "test"."t1"."a*b" AS "a*b" from "test"."t1"
drop view v1; drop view v1;
drop table t1; drop table t1;
set sql_mode=default; set sql_mode=default;
...@@ -760,7 +760,7 @@ a b ...@@ -760,7 +760,7 @@ a b
1 1 1 1
show create view v3; show create view v3;
View Create View View Create View
v3 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v3` AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from `test`.`v1` join `test`.`v2` where (`v1`.`col1` = `v2`.`col1`) v3 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v3` AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from (`test`.`v1` join `test`.`v2`) where (`v1`.`col1` = `v2`.`col1`)
drop view v3, v2, v1; drop view v3, v2, v1;
drop table t2, t1; drop table t2, t1;
create function `f``1` () returns int return 5; create function `f``1` () returns int return 5;
......
...@@ -470,3 +470,12 @@ use test; ...@@ -470,3 +470,12 @@ use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost; REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost; DROP USER dummy@localhost;
DROP DATABASE mysqltest; DROP DATABASE mysqltest;
#
# Bug #11330: Entry in tables_priv with host = '' causes crash
#
connection default;
use mysql;
insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_grantor',CURRENT_TIMESTAMP,'Select','Select');
flush privileges;
delete from tables_priv where host = '' and user = 'mysqltest_1';
flush privileges;
...@@ -489,13 +489,14 @@ drop table t1; ...@@ -489,13 +489,14 @@ drop table t1;
# Bug#10261 INFORMATION_SCHEMA.COLUMNS, incomplete result for non root user # Bug#10261 INFORMATION_SCHEMA.COLUMNS, incomplete result for non root user
# #
create user mysqltest_4@localhost; grant select on test.* to mysqltest_4@localhost;
connect (user4,localhost,mysqltest_4,,); connect (user4,localhost,mysqltest_4,,);
connection user4; connection user4;
SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME='TABLE_NAME'; where COLUMN_NAME='TABLE_NAME';
connection default; connection default;
delete from mysql.user where user='mysqltest_4'; delete from mysql.user where user='mysqltest_4';
delete from mysql.db where user='mysqltest_4';
flush privileges; flush privileges;
# #
...@@ -516,9 +517,9 @@ grant select on mysqltest.t2 to user2@localhost; ...@@ -516,9 +517,9 @@ grant select on mysqltest.t2 to user2@localhost;
grant select on mysqltest.* to user3@localhost; grant select on mysqltest.* to user3@localhost;
grant select on *.* to user4@localhost; grant select on *.* to user4@localhost;
connect (con1,localhost,user1,,); connect (con1,localhost,user1,,mysqltest);
connect (con2,localhost,user2,,); connect (con2,localhost,user2,,mysqltest);
connect (con3,localhost,user3,,); connect (con3,localhost,user3,,mysqltest);
connect (con4,localhost,user4,,); connect (con4,localhost,user4,,);
connection con1; connection con1;
select * from information_schema.column_privileges; select * from information_schema.column_privileges;
......
...@@ -971,3 +971,58 @@ delimiter ;| ...@@ -971,3 +971,58 @@ delimiter ;|
call SP001(); call SP001();
drop procedure SP001; drop procedure SP001;
drop table t1, t2; drop table t1, t2;
# Bug #11394 "Recursion in SP crash server" and bug #11600 "Stored
# procedures: crash with function calling itself".
# We have to disable recursion since in many cases LEX and many
# Item's can't be used in reentrant way nowdays.
delimiter |;
--disable_warnings
drop function if exists bug11394|
drop function if exists bug11394_1|
drop function if exists bug11394_2|
drop procedure if exists bug11394|
--enable_warnings
create function bug11394(i int) returns int
begin
if i <= 0 then
return 0;
else
return (i in (100, 200, bug11394(i-1), 400));
end if;
end|
# If we allow recursive functions without additional modifications
# this will crash server since Item for "IN" is not reenterable.
--error 1424
select bug11394(2)|
drop function bug11394|
create function bug11394_1(i int) returns int
begin
if i <= 0 then
return 0;
else
return (select bug11394_1(i-1));
end if;
end|
# The following statement will crash because some LEX members responsible
# for selects cannot be used in reentrant fashion.
--error 1424
select bug11394_1(2)|
drop function bug11394_1|
# Note that the following should be allowed since it does not contains
# recursion
create function bug11394_2(i int) returns int return i|
select bug11394_2(bug11394_2(10))|
drop function bug11394_2|
create procedure bug11394(i int, j int)
begin
if i > 0 then
call bug11394(i - 1,(select 1));
end if;
end|
# Again if we allow recursion for stored procedures (without
# additional efforts) the following statement will crash the server.
--error 1424
call bug11394(2, 1)|
drop procedure bug11394|
delimiter |;
...@@ -1498,54 +1498,56 @@ show procedure status like '%p%'| ...@@ -1498,54 +1498,56 @@ show procedure status like '%p%'|
# Fibonacci, for recursion test. (Yet Another Numerical series :) # Fibonacci, for recursion test. (Yet Another Numerical series :)
#
--disable_warnings # This part of test is disabled until we implement support for
drop table if exists fib| # recursive stored procedures.
--enable_warnings #--disable_warnings
create table fib ( f bigint unsigned not null )| #drop table if exists fib|
#--enable_warnings
# We deliberately do it the awkward way, fetching the last two #create table fib ( f bigint unsigned not null )|
# values from the table, in order to exercise various statements #
# and table accesses at each turn. ## We deliberately do it the awkward way, fetching the last two
--disable_warnings ## values from the table, in order to exercise various statements
drop procedure if exists fib| ## and table accesses at each turn.
--enable_warnings #--disable_warnings
create procedure fib(n int unsigned) #drop procedure if exists fib|
begin #--enable_warnings
if n > 1 then #create procedure fib(n int unsigned)
begin #begin
declare x, y bigint unsigned; # if n > 1 then
declare c cursor for select f from fib order by f desc limit 2; # begin
# declare x, y bigint unsigned;
open c; # declare c cursor for select f from fib order by f desc limit 2;
fetch c into y; #
fetch c into x; # open c;
close c; # fetch c into y;
insert into fib values (x+y); # fetch c into x;
call fib(n-1); # close c;
end; # insert into fib values (x+y);
end if; # call fib(n-1);
end| # end;
# end if;
# Minimum test: recursion of 3 levels #end|
#
insert into fib values (0), (1)| ## Minimum test: recursion of 3 levels
#
call fib(3)| #insert into fib values (0), (1)|
#
select * from fib order by f asc| #call fib(3)|
#
delete from fib| #select * from fib order by f asc|
#
# Original test: 20 levels (may run into memory limits!) #delete from fib|
#
insert into fib values (0), (1)| ## Original test: 20 levels (may run into memory limits!)
#
call fib(20)| #insert into fib values (0), (1)|
#
select * from fib order by f asc| #call fib(20)|
drop table fib| #
drop procedure fib| #select * from fib order by f asc|
#drop table fib|
#drop procedure fib|
# #
...@@ -2879,24 +2881,26 @@ drop table t3| ...@@ -2879,24 +2881,26 @@ drop table t3|
# #
# BUG#6022: Stored procedure shutdown problem with self-calling function. # BUG#6022: Stored procedure shutdown problem with self-calling function.
# #
--disable_warnings # This part of test is disabled until we implement support for
drop function if exists bug6022| # recursive stored functions.
--enable_warnings #--disable_warnings
#drop function if exists bug6022|
--disable_warnings #--enable_warnings
drop function if exists bug6022| #
--enable_warnings #--disable_warnings
create function bug6022(x int) returns int #drop function if exists bug6022|
begin #--enable_warnings
if x < 0 then #create function bug6022(x int) returns int
return 0; #begin
else # if x < 0 then
return bug6022(x-1); # return 0;
end if; # else
end| # return bug6022(x-1);
# end if;
select bug6022(5)| #end|
drop function bug6022| #
#select bug6022(5)|
#drop function bug6022|
# #
# BUG#6029: Stored procedure specific handlers should have priority # BUG#6029: Stored procedure specific handlers should have priority
......
...@@ -189,7 +189,6 @@ SET @@SQL_MODE=''; ...@@ -189,7 +189,6 @@ SET @@SQL_MODE='';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b'; SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b"; SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
# #
# Bug#6877: MySQL should give an error if the requested table type # Bug#6877: MySQL should give an error if the requested table type
# is not available # is not available
...@@ -208,5 +207,37 @@ create table t1 (a int) engine=isam; ...@@ -208,5 +207,37 @@ create table t1 (a int) engine=isam;
show create table t1; show create table t1;
drop table t1; drop table t1;
#
# Bug #6903: ANSI_QUOTES does not come into play with SHOW CREATE FUNCTION
# or PROCEDURE because it displays the SQL_MODE used to create the routine.
#
SET @@SQL_MODE='';
create function `foo` () returns int return 5;
show create function `foo`;
SET @@SQL_MODE='ANSI_QUOTES';
show create function `foo`;
drop function `foo`;
create function `foo` () returns int return 5;
show create function `foo`;
SET @@SQL_MODE='';
show create function `foo`;
drop function `foo`;
#
# Bug #6903: ANSI_QUOTES should have effect for SHOW CREATE VIEW (Bug #6903)
#
SET @@SQL_MODE='';
create table t1 (a int);
create table t2 (a int);
create view v1 as select a from t1;
show create view v1;
SET @@SQL_MODE='ANSI_QUOTES';
show create view v1;
# Test a view with a subselect, which will get shown incorrectly without
# thd->lex->view_prepare_mode set properly.
create view v2 as select a from t2 where a in (select a from v1);
drop view v2, v1;
drop table t1, t2;
SET @@SQL_MODE=@OLD_SQL_MODE; SET @@SQL_MODE=@OLD_SQL_MODE;
...@@ -60,10 +60,18 @@ fix_path () ...@@ -60,10 +60,18 @@ fix_path ()
get_full_path () get_full_path ()
{ {
case $1 in file=$1
/*) echo "$1";;
./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/\./;/;' ;; # if the file is a symlink, try to resolve it
*) which $1 ;; if [ -h $file ];
then
file=`ls -l $file | awk '{ print $NF }'`
fi
case $file in
/*) echo "$file";;
*/*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
*) which $file ;;
esac esac
} }
......
...@@ -5360,3 +5360,5 @@ ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG ...@@ -5360,3 +5360,5 @@ ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
eng "Explicit or implicit commit is not allowed in stored function or trigger." eng "Explicit or implicit commit is not allowed in stored function or trigger."
ER_NO_DEFAULT_FOR_VIEW_FIELD ER_NO_DEFAULT_FOR_VIEW_FIELD
eng "Field of view '%-.64s.%-.64s' underlying table doesn't have a default value" eng "Field of view '%-.64s.%-.64s' underlying table doesn't have a default value"
ER_SP_NO_RECURSION
eng "Recursive stored routines are not allowed."
...@@ -312,7 +312,8 @@ sp_head::operator delete(void *ptr, size_t size) ...@@ -312,7 +312,8 @@ sp_head::operator delete(void *ptr, size_t size)
sp_head::sp_head() sp_head::sp_head()
:Query_arena(&main_mem_root, INITIALIZED_FOR_SP), :Query_arena(&main_mem_root, INITIALIZED_FOR_SP),
m_returns_cs(NULL), m_has_return(FALSE), m_returns_cs(NULL), m_has_return(FALSE),
m_simple_case(FALSE), m_multi_results(FALSE), m_in_handler(FALSE) m_simple_case(FALSE), m_multi_results(FALSE), m_in_handler(FALSE),
m_is_invoked(FALSE)
{ {
extern byte * extern byte *
sp_table_key(const byte *ptr, uint *plen, my_bool first); sp_table_key(const byte *ptr, uint *plen, my_bool first);
...@@ -587,6 +588,28 @@ sp_head::execute(THD *thd) ...@@ -587,6 +588,28 @@ sp_head::execute(THD *thd)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (m_is_invoked)
{
/*
We have to disable recursion for stored routines since in
many cases LEX structure and many Item's can't be used in
reentrant way now.
TODO: We can circumvent this problem by using separate
sp_head instances for each recursive invocation.
NOTE: Theoretically arguments of procedure can be evaluated
before its invocation so there should be no problem with
recursion. But since we perform cleanup for CALL statement
as for any other statement only after its execution, its LEX
structure is not reusable for recursive calls. Thus we have
to prohibit recursion for stored procedures too.
*/
my_error(ER_SP_NO_RECURSION, MYF(0));
DBUG_RETURN(-1);
}
m_is_invoked= TRUE;
dbchanged= FALSE; dbchanged= FALSE;
if (m_db.length && if (m_db.length &&
(ret= sp_use_new_db(thd, m_db.str, olddb, sizeof(olddb), 0, &dbchanged))) (ret= sp_use_new_db(thd, m_db.str, olddb, sizeof(olddb), 0, &dbchanged)))
...@@ -710,6 +733,7 @@ sp_head::execute(THD *thd) ...@@ -710,6 +733,7 @@ sp_head::execute(THD *thd)
if (! thd->killed) if (! thd->killed)
ret= sp_change_db(thd, olddb, 0); ret= sp_change_db(thd, olddb, 0);
} }
m_is_invoked= FALSE;
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
......
...@@ -259,6 +259,9 @@ private: ...@@ -259,6 +259,9 @@ private:
*/ */
HASH m_sptabs; HASH m_sptabs;
/* Used for tracking of routine invocations and preventing recursion. */
bool m_is_invoked;
int int
execute(THD *thd); execute(THD *thd);
......
...@@ -2035,7 +2035,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) ...@@ -2035,7 +2035,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
{ {
uint key_prefix_len; uint key_prefix_len;
KEY_PART_INFO *key_part= col_privs->key_info->key_part; KEY_PART_INFO *key_part= col_privs->key_info->key_part;
col_privs->field[0]->store(host.hostname,(uint) strlen(host.hostname), col_privs->field[0]->store(host.hostname,
host.hostname ? (uint) strlen(host.hostname) : 0,
system_charset_info); system_charset_info);
col_privs->field[1]->store(db,(uint) strlen(db), system_charset_info); col_privs->field[1]->store(db,(uint) strlen(db), system_charset_info);
col_privs->field[2]->store(user,(uint) strlen(user), system_charset_info); col_privs->field[2]->store(user,(uint) strlen(user), system_charset_info);
......
...@@ -347,6 +347,9 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) ...@@ -347,6 +347,9 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
DBUG_PRINT("enter",("db: %s table: %s",table_list->db, DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->table_name)); table_list->table_name));
/* We want to preserve the tree for views. */
thd->lex->view_prepare_mode= TRUE;
/* Only one table for now, but VIEW can involve several tables */ /* Only one table for now, but VIEW can involve several tables */
if (open_normal_and_derived_tables(thd, table_list)) if (open_normal_and_derived_tables(thd, table_list))
{ {
...@@ -1068,7 +1071,13 @@ view_store_create_info(THD *thd, TABLE_LIST *table, String *buff) ...@@ -1068,7 +1071,13 @@ view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
buff->append('.'); buff->append('.');
append_identifier(thd, buff, table->view_name.str, table->view_name.length); append_identifier(thd, buff, table->view_name.str, table->view_name.length);
buff->append(" AS ", 4); buff->append(" AS ", 4);
buff->append(table->query.str, table->query.length);
/*
We can't just use table->query, because our SQL_MODE may trigger
a different syntax, like when ANSI_QUOTES is defined.
*/
table->view->unit.print(buff);
if (table->with_check != VIEW_CHECK_NONE) if (table->with_check != VIEW_CHECK_NONE)
{ {
if (table->with_check == VIEW_CHECK_LOCAL) if (table->with_check == VIEW_CHECK_LOCAL)
......
...@@ -1550,14 +1550,12 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -1550,14 +1550,12 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
/* Check if table exists */ /* Check if table exists */
if (create_info->options & HA_LEX_CREATE_TMP_TABLE) if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{ {
char tmp_table_name[tmp_file_prefix_length+22+22+22+3]; my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s",
my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x", mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id,
tmp_file_prefix, current_pid, thd->thread_id, thd->tmp_table++, reg_ext);
thd->tmp_table++);
if (lower_case_table_names) if (lower_case_table_names)
my_casedn_str(files_charset_info, tmp_table_name); my_casedn_str(files_charset_info, path);
create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE;
build_table_path(path, sizeof(path), db, tmp_table_name, reg_ext);
} }
else else
build_table_path(path, sizeof(path), db, alias, reg_ext); build_table_path(path, sizeof(path), db, alias, reg_ext);
......
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