Commit 4c2db1be authored by unknown's avatar unknown

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

into  mysql.com:/opt/local/work/mysql-5.0-runtime


mysql-test/r/func_sapdb.result:
  Auto merged
mysql-test/r/func_time.result:
  Auto merged
mysql-test/t/func_sapdb.test:
  Auto merged
mysql-test/t/func_time.test:
  Auto merged
sql/item.h:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
parents 047e2be2 697e8d71
...@@ -361,12 +361,6 @@ extract(SECOND FROM "1999-01-02 10:11:12") ...@@ -361,12 +361,6 @@ extract(SECOND FROM "1999-01-02 10:11:12")
select extract(MONTH FROM "2001-02-00"); select extract(MONTH FROM "2001-02-00");
extract(MONTH FROM "2001-02-00") extract(MONTH FROM "2001-02-00")
2 2
SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
9999-12-31 00:00:00
SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
9999-12-31 00:00:00
SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter; SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
quarter quarter
1 1
...@@ -403,6 +397,12 @@ quarter ...@@ -403,6 +397,12 @@ quarter
SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter; SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
quarter quarter
4 4
SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
9999-12-31 00:00:00
SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
9999-12-31 00:00:00
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND; SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
"1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
1968-01-20 03:14:08 1968-01-20 03:14:08
......
...@@ -294,26 +294,26 @@ show create function sub1; ...@@ -294,26 +294,26 @@ show create function sub1;
ERROR 42000: FUNCTION sub1 does not exist ERROR 42000: FUNCTION sub1 does not exist
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION ROUTINE_NAME ROUTINE_DEFINITION
sel2 sel2 NULL
sub1 sub1 NULL
grant all privileges on test.* to mysqltest_1@localhost; grant all privileges on test.* to mysqltest_1@localhost;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION ROUTINE_NAME ROUTINE_DEFINITION
sel2 sel2 NULL
sub1 sub1 NULL
create function sub2(i int) returns int create function sub2(i int) returns int
return i+1; return i+1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION ROUTINE_NAME ROUTINE_DEFINITION
sel2 sel2 NULL
sub1 sub1 NULL
sub2 return i+1 sub2 return i+1
show create procedure sel2; show create procedure sel2;
Procedure sql_mode Create Procedure Procedure sql_mode Create Procedure
sel2 sel2 NULL
show create function sub1; show create function sub1;
Function sql_mode Create Function Function sql_mode Create Function
sub1 sub1 NULL
show create function sub2; show create function sub2;
Function sql_mode Create Function Function sql_mode Create Function
sub2 CREATE DEFINER=`mysqltest_1`@`localhost` FUNCTION `sub2`(i int) RETURNS int(11) sub2 CREATE DEFINER=`mysqltest_1`@`localhost` FUNCTION `sub2`(i int) RETURNS int(11)
...@@ -1134,3 +1134,39 @@ concat(@a, table_name) @a table_name ...@@ -1134,3 +1134,39 @@ concat(@a, table_name) @a table_name
.t1 . t1 .t1 . t1
.t2 . t2 .t2 . t2
drop table t1,t2; drop table t1,t2;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
CREATE PROCEDURE p1() SET @a= 1;
CREATE FUNCTION f1() RETURNS INT RETURN @a + 1;
CREATE USER mysql_bug20230@localhost;
GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost;
GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost;
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
f1 RETURN @a + 1
p1 SET @a= 1
SHOW CREATE PROCEDURE p1;
Procedure sql_mode Create Procedure
p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
SET @a= 1
SHOW CREATE FUNCTION f1;
Function sql_mode Create Function
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
RETURN @a + 1
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
f1 NULL
p1 NULL
SHOW CREATE PROCEDURE p1;
Procedure sql_mode Create Procedure
p1 NULL
SHOW CREATE FUNCTION f1;
Function sql_mode Create Function
f1 NULL
CALL p1();
SELECT f1();
f1()
2
DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
...@@ -1075,3 +1075,18 @@ SELECT f1(); ...@@ -1075,3 +1075,18 @@ SELECT f1();
f1() f1()
abc abc
DROP FUNCTION f1; DROP FUNCTION f1;
DROP PROCEDURE IF EXISTS p1;
CREATE PROCEDURE p1()
BEGIN
DECLARE v_char VARCHAR(255);
DECLARE v_text TEXT DEFAULT '';
SET v_char = 'abc';
SET v_text = v_char;
SET v_char = 'def';
SET v_text = concat(v_text, '|', v_char);
SELECT v_text;
END|
CALL p1();
v_text
abc|def
DROP PROCEDURE p1;
...@@ -143,10 +143,6 @@ select extract(SECOND FROM "1999-01-02 10:11:12"); ...@@ -143,10 +143,6 @@ select extract(SECOND FROM "1999-01-02 10:11:12");
select extract(MONTH FROM "2001-02-00"); select extract(MONTH FROM "2001-02-00");
# #
# MySQL Bugs: #12356: DATE_SUB or DATE_ADD incorrectly returns null
#
SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
# test EXTRACT QUARTER (Bug #18100) # test EXTRACT QUARTER (Bug #18100)
# #
...@@ -162,7 +158,11 @@ SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter; ...@@ -162,7 +158,11 @@ SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter; SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter; SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter; SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
#
# MySQL Bugs: #12356: DATE_SUB or DATE_ADD incorrectly returns null
#
SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
# #
# Test big intervals (Bug #3498) # Test big intervals (Bug #3498)
......
...@@ -852,3 +852,39 @@ create table t2(f1 char(5)); ...@@ -852,3 +852,39 @@ create table t2(f1 char(5));
select concat(@a, table_name), @a, table_name select concat(@a, table_name), @a, table_name
from information_schema.tables where table_schema = 'test'; from information_schema.tables where table_schema = 'test';
drop table t1,t2; drop table t1,t2;
#
# Bug#20230: routine_definition is not null
#
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
--enable_warnings
CREATE PROCEDURE p1() SET @a= 1;
CREATE FUNCTION f1() RETURNS INT RETURN @a + 1;
CREATE USER mysql_bug20230@localhost;
GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost;
GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost;
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
SHOW CREATE PROCEDURE p1;
SHOW CREATE FUNCTION f1;
connect (conn1, localhost, mysql_bug20230,,);
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES;
SHOW CREATE PROCEDURE p1;
SHOW CREATE FUNCTION f1;
CALL p1();
SELECT f1();
disconnect conn1;
connection default;
DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
# End of 5.0 tests.
...@@ -1271,3 +1271,39 @@ SELECT f1(); ...@@ -1271,3 +1271,39 @@ SELECT f1();
# #
DROP FUNCTION f1; DROP FUNCTION f1;
#
# Bug#17226: Variable set in cursor on first iteration is assigned
# second iterations value
#
# The problem was in incorrect handling of local variables of type
# TEXT (BLOB).
#
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
--enable_warnings
delimiter |;
CREATE PROCEDURE p1()
BEGIN
DECLARE v_char VARCHAR(255);
DECLARE v_text TEXT DEFAULT '';
SET v_char = 'abc';
SET v_text = v_char;
SET v_char = 'def';
SET v_text = concat(v_text, '|', v_char);
SELECT v_text;
END|
delimiter ;|
CALL p1();
DROP PROCEDURE p1;
# End of 5.0 tests.
...@@ -675,9 +675,14 @@ void field_conv(Field *to,Field *from) ...@@ -675,9 +675,14 @@ void field_conv(Field *to,Field *from)
{ // Be sure the value is stored { // Be sure the value is stored
Field_blob *blob=(Field_blob*) to; Field_blob *blob=(Field_blob*) to;
from->val_str(&blob->value); from->val_str(&blob->value);
if (!blob->value.is_alloced() && /*
Copy value if copy_blobs is set, or source is not a string and
we have a pointer to its internal string conversion buffer.
*/
if (to->table->copy_blobs ||
(!blob->value.is_alloced() &&
from->real_type() != MYSQL_TYPE_STRING && from->real_type() != MYSQL_TYPE_STRING &&
from->real_type() != MYSQL_TYPE_VARCHAR) from->real_type() != MYSQL_TYPE_VARCHAR))
blob->value.copy(); blob->value.copy();
blob->store(blob->value.ptr(),blob->value.length(),from->charset()); blob->store(blob->value.ptr(),blob->value.length(),from->charset());
return; return;
......
...@@ -827,13 +827,6 @@ protected: ...@@ -827,13 +827,6 @@ protected:
public: public:
LEX_STRING m_name; LEX_STRING m_name;
/*
Buffer, pointing to the string value of the item. We need it to
protect internal buffer from changes. See comment to analogous
member in Item_param for more details.
*/
String str_value_ptr;
public: public:
#ifndef DBUG_OFF #ifndef DBUG_OFF
/* /*
......
...@@ -1869,8 +1869,11 @@ sp_head::show_create_procedure(THD *thd) ...@@ -1869,8 +1869,11 @@ sp_head::show_create_procedure(THD *thd)
field_list.push_back(new Item_empty_string("Procedure", NAME_LEN)); field_list.push_back(new Item_empty_string("Procedure", NAME_LEN));
field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len)); field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
// 1024 is for not to confuse old clients // 1024 is for not to confuse old clients
field_list.push_back(new Item_empty_string("Create Procedure", Item_empty_string *definition=
max(buffer.length(), 1024))); new Item_empty_string("Create Procedure", max(buffer.length(),1024));
definition->maybe_null= TRUE;
field_list.push_back(definition);
if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF)) Protocol::SEND_EOF))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -1879,6 +1882,8 @@ sp_head::show_create_procedure(THD *thd) ...@@ -1879,6 +1882,8 @@ sp_head::show_create_procedure(THD *thd)
protocol->store((char*) sql_mode_str, sql_mode_len, system_charset_info); protocol->store((char*) sql_mode_str, sql_mode_len, system_charset_info);
if (full_access) if (full_access)
protocol->store(m_defstr.str, m_defstr.length, system_charset_info); protocol->store(m_defstr.str, m_defstr.length, system_charset_info);
else
protocol->store_null();
res= protocol->write(); res= protocol->write();
send_eof(thd); send_eof(thd);
...@@ -1934,8 +1939,11 @@ sp_head::show_create_function(THD *thd) ...@@ -1934,8 +1939,11 @@ sp_head::show_create_function(THD *thd)
&sql_mode_len); &sql_mode_len);
field_list.push_back(new Item_empty_string("Function",NAME_LEN)); field_list.push_back(new Item_empty_string("Function",NAME_LEN));
field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len)); field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
field_list.push_back(new Item_empty_string("Create Function", Item_empty_string *definition=
max(buffer.length(),1024))); new Item_empty_string("Create Function", max(buffer.length(),1024));
definition->maybe_null= TRUE;
field_list.push_back(definition);
if (protocol->send_fields(&field_list, if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -1944,6 +1952,8 @@ sp_head::show_create_function(THD *thd) ...@@ -1944,6 +1952,8 @@ sp_head::show_create_function(THD *thd)
protocol->store((char*) sql_mode_str, sql_mode_len, system_charset_info); protocol->store((char*) sql_mode_str, sql_mode_len, system_charset_info);
if (full_access) if (full_access)
protocol->store(m_defstr.str, m_defstr.length, system_charset_info); protocol->store(m_defstr.str, m_defstr.length, system_charset_info);
else
protocol->store_null();
res= protocol->write(); res= protocol->write();
send_eof(thd); send_eof(thd);
......
...@@ -41,8 +41,6 @@ sys_var_long_ptr trg_new_row_fake_var(0, 0); ...@@ -41,8 +41,6 @@ sys_var_long_ptr trg_new_row_fake_var(0, 0);
#define yySkip() lex->ptr++ #define yySkip() lex->ptr++
#define yyLength() ((uint) (lex->ptr - lex->tok_start)-1) #define yyLength() ((uint) (lex->ptr - lex->tok_start)-1)
pthread_key(LEX*,THR_LEX);
/* Longest standard keyword name */ /* Longest standard keyword name */
#define TOCK_NAME_LENGTH 24 #define TOCK_NAME_LENGTH 24
...@@ -91,8 +89,6 @@ void lex_init(void) ...@@ -91,8 +89,6 @@ void lex_init(void)
for (i=0 ; i < array_elements(sql_functions) ; i++) for (i=0 ; i < array_elements(sql_functions) ; i++)
sql_functions[i].length=(uchar) strlen(sql_functions[i].name); sql_functions[i].length=(uchar) strlen(sql_functions[i].name);
VOID(pthread_key_create(&THR_LEX,NULL));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -1116,6 +1116,3 @@ extern void lex_start(THD *thd, uchar *buf,uint length); ...@@ -1116,6 +1116,3 @@ extern void lex_start(THD *thd, uchar *buf,uint length);
extern void lex_end(LEX *lex); extern void lex_end(LEX *lex);
extern int MYSQLlex(void *arg, void *yythd); extern int MYSQLlex(void *arg, void *yythd);
extern pthread_key(LEX*,THR_LEX);
#define current_lex (current_thd->lex)
...@@ -2365,7 +2365,7 @@ static void reset_one_shot_variables(THD *thd) ...@@ -2365,7 +2365,7 @@ static void reset_one_shot_variables(THD *thd)
/* /*
Execute command saved in thd and current_lex->sql_command Execute command saved in thd and lex->sql_command
SYNOPSIS SYNOPSIS
mysql_execute_command() mysql_execute_command()
...@@ -5547,7 +5547,7 @@ bool check_stack_overrun(THD *thd, long margin, ...@@ -5547,7 +5547,7 @@ bool check_stack_overrun(THD *thd, long margin,
bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, ulong *yystacksize) bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, ulong *yystacksize)
{ {
LEX *lex=current_lex; LEX *lex= current_thd->lex;
ulong old_info=0; ulong old_info=0;
if ((uint) *yystacksize >= MY_YACC_MAX) if ((uint) *yystacksize >= MY_YACC_MAX)
return 1; return 1;
...@@ -5984,7 +5984,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, ...@@ -5984,7 +5984,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
void store_position_for_column(const char *name) void store_position_for_column(const char *name)
{ {
current_lex->last_field->after=my_const_cast(char*) (name); current_thd->lex->last_field->after=my_const_cast(char*) (name);
} }
bool bool
......
...@@ -2916,6 +2916,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, ...@@ -2916,6 +2916,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
{ {
get_field(thd->mem_root, proc_table->field[10], &tmp_string); get_field(thd->mem_root, proc_table->field[10], &tmp_string);
table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[7]->set_notnull();
} }
table->field[6]->store(STRING_WITH_LEN("SQL"), cs); table->field[6]->store(STRING_WITH_LEN("SQL"), cs);
table->field[10]->store(STRING_WITH_LEN("SQL"), cs); table->field[10]->store(STRING_WITH_LEN("SQL"), cs);
...@@ -4069,7 +4070,7 @@ ST_FIELD_INFO proc_fields_info[]= ...@@ -4069,7 +4070,7 @@ ST_FIELD_INFO proc_fields_info[]=
{"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"}, {"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"DTD_IDENTIFIER", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"DTD_IDENTIFIER", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"ROUTINE_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0}, {"ROUTINE_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0},
{"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, {"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
{"EXTERNAL_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"EXTERNAL_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"EXTERNAL_LANGUAGE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0}, {"EXTERNAL_LANGUAGE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"PARAMETER_STYLE", 8, MYSQL_TYPE_STRING, 0, 0, 0}, {"PARAMETER_STYLE", 8, MYSQL_TYPE_STRING, 0, 0, 0},
......
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