summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.local>2007-03-19 23:59:53 +0300
committerunknown <kostja@bodhi.local>2007-03-19 23:59:53 +0300
commit14ab9bef52258465f13e8838d8f55ea62c0905e7 (patch)
tree4ce7f23faf1f92e854083442f093270a2cd2f098
parent6d93f15039d551f291232c1b60527b00cd9c6bc9 (diff)
parentcfcd27b3db1459c11e89ca21510438ac9ee55747 (diff)
downloadmariadb-git-14ab9bef52258465f13e8838d8f55ea62c0905e7.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into bodhi.local:/opt/local/work/mysql-5.0-runtime sql/field.cc: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_func.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged mysql-test/r/sp.result: SCCS merged mysql-test/t/sp.test: SCCS merged
-rw-r--r--include/my_global.h9
-rw-r--r--mysql-test/r/sp-error.result52
-rw-r--r--mysql-test/r/sp.result191
-rw-r--r--mysql-test/t/sp-error.test68
-rw-r--r--mysql-test/t/sp.test176
-rw-r--r--sql/field.cc6
-rw-r--r--sql/ha_innodb.cc16
-rw-r--r--sql/handler.cc6
-rw-r--r--sql/item.cc6
-rw-r--r--sql/item.h9
-rw-r--r--sql/item_func.cc5
-rw-r--r--sql/item_subselect.cc3
-rw-r--r--sql/lex.h4
-rw-r--r--sql/lex_symbol.h2
-rw-r--r--sql/log_event.cc5
-rw-r--r--sql/sp_head.cc22
-rw-r--r--sql/sp_head.h29
-rw-r--r--sql/sp_pcontext.cc90
-rw-r--r--sql/sp_pcontext.h61
-rw-r--r--sql/sql_base.cc3
-rw-r--r--sql/sql_select.cc17
-rw-r--r--sql/sql_show.cc43
-rw-r--r--sql/sql_table.cc3
-rw-r--r--sql/sql_yacc.yy43
24 files changed, 725 insertions, 144 deletions
diff --git a/include/my_global.h b/include/my_global.h
index 21fe1ebc3cb..61c2afc541b 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1357,4 +1357,13 @@ do { doubleget_union _tmp; \
#define NO_EMBEDDED_ACCESS_CHECKS
#endif
+
+/* Length of decimal number represented by INT32. */
+
+#define MY_INT32_NUM_DECIMAL_DIGITS 11
+
+/* Length of decimal number represented by INT64. */
+
+#define MY_INT64_NUM_DECIMAL_DIGITS 21
+
#endif /* my_global_h */
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 332d4fa4519..bdcb51c4db8 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1400,3 +1400,55 @@ drop table table_25345_b;
drop procedure proc_25345;
drop function func_25345;
drop function func_25345_b;
+create procedure proc_26503_error_1()
+begin
+retry:
+repeat
+begin
+declare continue handler for sqlexception
+begin
+iterate retry;
+end
+select "do something";
+end
+until true end repeat retry;
+end//
+ERROR 42000: ITERATE with no matching label: retry
+create procedure proc_26503_error_2()
+begin
+retry:
+repeat
+begin
+declare continue handler for sqlexception
+iterate retry;
+select "do something";
+end
+until true end repeat retry;
+end//
+ERROR 42000: ITERATE with no matching label: retry
+create procedure proc_26503_error_3()
+begin
+retry:
+repeat
+begin
+declare continue handler for sqlexception
+begin
+leave retry;
+end
+select "do something";
+end
+until true end repeat retry;
+end//
+ERROR 42000: LEAVE with no matching label: retry
+create procedure proc_26503_error_4()
+begin
+retry:
+repeat
+begin
+declare continue handler for sqlexception
+leave retry;
+select "do something";
+end
+until true end repeat retry;
+end//
+ERROR 42000: LEAVE with no matching label: retry
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 34f2aa94000..cf3cf07630a 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -5633,6 +5633,32 @@ call proc_bug19733()|
call proc_bug19733()|
drop procedure proc_bug19733|
drop table t3|
+DROP PROCEDURE IF EXISTS p1|
+DROP VIEW IF EXISTS v1, v2|
+DROP TABLE IF EXISTS t3, t4|
+CREATE TABLE t3 (t3_id INT)|
+INSERT INTO t3 VALUES (0)|
+INSERT INTO t3 VALUES (1)|
+CREATE TABLE t4 (t4_id INT)|
+INSERT INTO t4 VALUES (2)|
+CREATE VIEW v1 AS
+SELECT t3.t3_id, t4.t4_id
+FROM t3 JOIN t4 ON t3.t3_id = 0|
+CREATE VIEW v2 AS
+SELECT t3.t3_id AS t3_id_1, v1.t3_id AS t3_id_2, v1.t4_id
+FROM t3 LEFT JOIN v1 ON t3.t3_id = 0|
+CREATE PROCEDURE p1() SELECT * FROM v2|
+CALL p1()|
+t3_id_1 t3_id_2 t4_id
+0 0 2
+1 NULL NULL
+CALL p1()|
+t3_id_1 t3_id_2 t4_id
+0 0 2
+1 NULL NULL
+DROP PROCEDURE p1|
+DROP VIEW v1, v2|
+DROP TABLE t3, t4|
End of 5.0 tests
DROP TABLE IF EXISTS bug23760|
DROP TABLE IF EXISTS bug23760_log|
@@ -5765,6 +5791,171 @@ func_8407_b()
1500
drop function func_8407_a|
drop function func_8407_b|
+drop table if exists table_26503|
+drop procedure if exists proc_26503_ok_1|
+drop procedure if exists proc_26503_ok_2|
+drop procedure if exists proc_26503_ok_3|
+drop procedure if exists proc_26503_ok_4|
+create table table_26503(a int unique)|
+create procedure proc_26503_ok_1(v int)
+begin
+declare i int default 5;
+declare continue handler for sqlexception
+begin
+select 'caught something';
+retry:
+while i > 0 do
+begin
+set i = i - 1;
+select 'looping', i;
+iterate retry;
+select 'dead code';
+end;
+end while retry;
+select 'leaving handler';
+end;
+select 'do something';
+insert into table_26503 values (v);
+select 'do something again';
+insert into table_26503 values (v);
+end|
+create procedure proc_26503_ok_2(v int)
+begin
+declare i int default 5;
+declare continue handler for sqlexception
+begin
+select 'caught something';
+retry:
+while i > 0 do
+begin
+set i = i - 1;
+select 'looping', i;
+leave retry;
+select 'dead code';
+end;
+end while;
+select 'leaving handler';
+end;
+select 'do something';
+insert into table_26503 values (v);
+select 'do something again';
+insert into table_26503 values (v);
+end|
+create procedure proc_26503_ok_3(v int)
+begin
+declare i int default 5;
+retry:
+begin
+declare continue handler for sqlexception
+begin
+select 'caught something';
+retry:
+while i > 0 do
+begin
+set i = i - 1;
+select 'looping', i;
+iterate retry;
+select 'dead code';
+end;
+end while retry;
+select 'leaving handler';
+end;
+select 'do something';
+insert into table_26503 values (v);
+select 'do something again';
+insert into table_26503 values (v);
+end;
+end|
+create procedure proc_26503_ok_4(v int)
+begin
+declare i int default 5;
+retry:
+begin
+declare continue handler for sqlexception
+begin
+select 'caught something';
+retry:
+while i > 0 do
+begin
+set i = i - 1;
+select 'looping', i;
+leave retry;
+select 'dead code';
+end;
+end while;
+select 'leaving handler';
+end;
+select 'do something';
+insert into table_26503 values (v);
+select 'do something again';
+insert into table_26503 values (v);
+end;
+end|
+call proc_26503_ok_1(1)|
+do something
+do something
+do something again
+do something again
+caught something
+caught something
+looping i
+looping 4
+looping i
+looping 3
+looping i
+looping 2
+looping i
+looping 1
+looping i
+looping 0
+leaving handler
+leaving handler
+call proc_26503_ok_2(2)|
+do something
+do something
+do something again
+do something again
+caught something
+caught something
+looping i
+looping 4
+leaving handler
+leaving handler
+call proc_26503_ok_3(3)|
+do something
+do something
+do something again
+do something again
+caught something
+caught something
+looping i
+looping 4
+looping i
+looping 3
+looping i
+looping 2
+looping i
+looping 1
+looping i
+looping 0
+leaving handler
+leaving handler
+call proc_26503_ok_4(4)|
+do something
+do something
+do something again
+do something again
+caught something
+caught something
+looping i
+looping 4
+leaving handler
+leaving handler
+drop table table_26503|
+drop procedure proc_26503_ok_1|
+drop procedure proc_26503_ok_2|
+drop procedure proc_26503_ok_3|
+drop procedure proc_26503_ok_4|
DROP FUNCTION IF EXISTS bug25373|
CREATE FUNCTION bug25373(p1 INTEGER) RETURNS INTEGER
LANGUAGE SQL DETERMINISTIC
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 396c1552e37..9e5c795d586 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -2022,6 +2022,74 @@ drop function func_25345;
drop function func_25345_b;
#
+# Bug#26503 (Illegal SQL exception handler code causes the server to crash)
+#
+
+delimiter //;
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_1()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ begin
+ iterate retry;
+ end
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_2()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ iterate retry;
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_3()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ begin
+ leave retry;
+ end
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+--error ER_SP_LILABEL_MISMATCH
+create procedure proc_26503_error_4()
+begin
+retry:
+ repeat
+ begin
+ declare continue handler for sqlexception
+ leave retry;
+
+ select "do something";
+ end
+ until true end repeat retry;
+end//
+
+delimiter ;//
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 9af24ee0337..5c67319cefc 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -6592,6 +6592,47 @@ call proc_bug19733()|
drop procedure proc_bug19733|
drop table t3|
+
+#
+# BUG#20492: Subsequent calls to stored procedure yeild incorrect
+# result if join is used
+#
+# Optimized ON expression in join wasn't properly saved for reuse.
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1|
+DROP VIEW IF EXISTS v1, v2|
+DROP TABLE IF EXISTS t3, t4|
+--enable_warnings
+
+CREATE TABLE t3 (t3_id INT)|
+
+INSERT INTO t3 VALUES (0)|
+INSERT INTO t3 VALUES (1)|
+
+CREATE TABLE t4 (t4_id INT)|
+
+INSERT INTO t4 VALUES (2)|
+
+CREATE VIEW v1 AS
+SELECT t3.t3_id, t4.t4_id
+FROM t3 JOIN t4 ON t3.t3_id = 0|
+
+CREATE VIEW v2 AS
+SELECT t3.t3_id AS t3_id_1, v1.t3_id AS t3_id_2, v1.t4_id
+FROM t3 LEFT JOIN v1 ON t3.t3_id = 0|
+
+CREATE PROCEDURE p1() SELECT * FROM v2|
+
+# Results should not differ.
+CALL p1()|
+CALL p1()|
+
+DROP PROCEDURE p1|
+DROP VIEW v1, v2|
+DROP TABLE t3, t4|
+
+
--echo End of 5.0 tests
@@ -6739,6 +6780,141 @@ drop function func_8407_a|
drop function func_8407_b|
#
+# Bug#26503 (Illegal SQL exception handler code causes the server to crash)
+#
+
+--disable_warnings
+drop table if exists table_26503|
+drop procedure if exists proc_26503_ok_1|
+drop procedure if exists proc_26503_ok_2|
+drop procedure if exists proc_26503_ok_3|
+drop procedure if exists proc_26503_ok_4|
+--enable_warnings
+
+create table table_26503(a int unique)|
+
+create procedure proc_26503_ok_1(v int)
+begin
+ declare i int default 5;
+
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ iterate retry;
+ select 'dead code';
+ end;
+ end while retry;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+end|
+
+create procedure proc_26503_ok_2(v int)
+begin
+ declare i int default 5;
+
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ leave retry;
+ select 'dead code';
+ end;
+ end while;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+end|
+
+## The outer retry label should not prevent using the inner label.
+
+create procedure proc_26503_ok_3(v int)
+begin
+ declare i int default 5;
+
+retry:
+ begin
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ iterate retry;
+ select 'dead code';
+ end;
+ end while retry;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+ end;
+end|
+
+## The outer retry label should not prevent using the inner label.
+
+create procedure proc_26503_ok_4(v int)
+begin
+ declare i int default 5;
+
+retry:
+ begin
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ leave retry;
+ select 'dead code';
+ end;
+ end while;
+ select 'leaving handler';
+ end;
+
+ select 'do something';
+ insert into table_26503 values (v);
+ select 'do something again';
+ insert into table_26503 values (v);
+ end;
+end|
+
+call proc_26503_ok_1(1)|
+call proc_26503_ok_2(2)|
+call proc_26503_ok_3(3)|
+call proc_26503_ok_4(4)|
+
+drop table table_26503|
+drop procedure proc_26503_ok_1|
+drop procedure proc_26503_ok_2|
+drop procedure proc_26503_ok_3|
+drop procedure proc_26503_ok_4|
+
+#
# Bug#25373: Stored functions wasn't compared correctly which leads to a wrong
# result.
#
diff --git a/sql/field.cc b/sql/field.cc
index fbb5fb520bc..152c1bdc364 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1204,12 +1204,12 @@ static bool test_if_real(const char *str,int length, CHARSET_INFO *cs)
String *Field::val_int_as_str(String *val_buffer, my_bool unsigned_val)
{
CHARSET_INFO *cs= &my_charset_bin;
- uint length= 21;
+ uint length;
longlong value= val_int();
- if (val_buffer->alloc(length))
+ if (val_buffer->alloc(MY_INT64_NUM_DECIMAL_DIGITS))
return 0;
length= (uint) (*cs->cset->longlong10_to_str)(cs, (char*) val_buffer->ptr(),
- length,
+ MY_INT64_NUM_DECIMAL_DIGITS,
unsigned_val ? 10 : -10,
value);
val_buffer->length(length);
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 8a35ff000a8..cbefa9d3949 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -6391,16 +6391,16 @@ innodb_mutex_show_status(
#ifdef UNIV_DEBUG
field_list.push_back(new Item_empty_string("Mutex", FN_REFLEN));
field_list.push_back(new Item_empty_string("Module", FN_REFLEN));
- field_list.push_back(new Item_uint("Count", 21));
- field_list.push_back(new Item_uint("Spin_waits", 21));
- field_list.push_back(new Item_uint("Spin_rounds", 21));
- field_list.push_back(new Item_uint("OS_waits", 21));
- field_list.push_back(new Item_uint("OS_yields", 21));
- field_list.push_back(new Item_uint("OS_waits_time", 21));
+ field_list.push_back(new Item_uint("Count", MY_INT64_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_uint("Spin_waits", MY_INT64_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_uint("Spin_rounds", MY_INT64_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_uint("OS_waits", MY_INT64_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_uint("OS_yields", MY_INT64_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_uint("OS_waits_time", MY_INT64_NUM_DECIMAL_DIGITS));
#else /* UNIV_DEBUG */
field_list.push_back(new Item_empty_string("File", FN_REFLEN));
- field_list.push_back(new Item_uint("Line", 21));
- field_list.push_back(new Item_uint("OS_waits", 21));
+ field_list.push_back(new Item_uint("Line", MY_INT64_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_uint("OS_waits", MY_INT64_NUM_DECIMAL_DIGITS));
#endif /* UNIV_DEBUG */
if (protocol->send_fields(&field_list,
diff --git a/sql/handler.cc b/sql/handler.cc
index 5a27e470d70..524f47209dc 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1082,9 +1082,9 @@ bool mysql_xa_recover(THD *thd)
XID_STATE *xs;
DBUG_ENTER("mysql_xa_recover");
- field_list.push_back(new Item_int("formatID",0,11));
- field_list.push_back(new Item_int("gtrid_length",0,11));
- field_list.push_back(new Item_int("bqual_length",0,11));
+ field_list.push_back(new Item_int("formatID", 0, MY_INT32_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_int("gtrid_length", 0, MY_INT32_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new Item_int("bqual_length", 0, MY_INT32_NUM_DECIMAL_DIGITS));
field_list.push_back(new Item_empty_string("data",XIDDATASIZE));
if (protocol->send_fields(&field_list,
diff --git a/sql/item.cc b/sql/item.cc
index 11a5039ca19..3174274b79f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -148,7 +148,7 @@ void
Hybrid_type_traits_integer::fix_length_and_dec(Item *item, Item *arg) const
{
item->decimals= 0;
- item->max_length= 21;
+ item->max_length= MY_INT64_NUM_DECIMAL_DIGITS;
item->unsigned_flag= 0;
}
@@ -2492,7 +2492,7 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
item_result_type= REAL_RESULT;
break;
case INT_RESULT:
- set_int(*(longlong*)entry->value, 21);
+ set_int(*(longlong*)entry->value, MY_INT64_NUM_DECIMAL_DIGITS);
item_type= Item::INT_ITEM;
item_result_type= INT_RESULT;
break;
@@ -6587,7 +6587,7 @@ uint32 Item_type_holder::display_length(Item *item)
case MYSQL_TYPE_SHORT:
return 6;
case MYSQL_TYPE_LONG:
- return 11;
+ return MY_INT32_NUM_DECIMAL_DIGITS;
case MYSQL_TYPE_FLOAT:
return 25;
case MYSQL_TYPE_DOUBLE:
diff --git a/sql/item.h b/sql/item.h
index c2084fb727c..786d65ff6f4 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1495,11 +1495,14 @@ class Item_int :public Item_num
{
public:
longlong value;
- Item_int(int32 i,uint length=11) :value((longlong) i)
+ Item_int(int32 i,uint length= MY_INT32_NUM_DECIMAL_DIGITS)
+ :value((longlong) i)
{ max_length=length; fixed= 1; }
- Item_int(longlong i,uint length=21) :value(i)
+ Item_int(longlong i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
+ :value(i)
{ max_length=length; fixed= 1; }
- Item_int(ulonglong i, uint length= 21) :value((longlong)i)
+ Item_int(ulonglong i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
+ :value((longlong)i)
{ max_length=length; fixed= 1; unsigned_flag= 1; }
Item_int(const char *str_arg,longlong i,uint length) :value(i)
{ max_length=length; name=(char*) str_arg; fixed= 1; }
diff --git a/sql/item_func.cc b/sql/item_func.cc
index e8ecd6b8f1c..3d92be5e9d2 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -431,7 +431,7 @@ Field *Item_func::tmp_table_field(TABLE *t_arg)
switch (result_type()) {
case INT_RESULT:
- if (max_length > 11)
+ if (max_length > MY_INT32_NUM_DECIMAL_DIGITS)
res= new Field_longlong(max_length, maybe_null, name, t_arg,
unsigned_flag);
else
@@ -2321,7 +2321,8 @@ longlong Item_func_coercibility::val_int()
void Item_func_locate::fix_length_and_dec()
{
- maybe_null=0; max_length=11;
+ maybe_null= 0;
+ max_length= MY_INT32_NUM_DECIMAL_DIGITS;
agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1);
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 12ae0c026eb..b3744d6eb96 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1037,7 +1037,8 @@ Item_in_subselect::single_value_transformer(JOIN *join,
Item *having= item, *orig_item= item;
select_lex->item_list.empty();
select_lex->item_list.push_back(new Item_int("Not_used",
- (longlong) 1, 21));
+ (longlong) 1,
+ MY_INT64_NUM_DECIMAL_DIGITS));
select_lex->ref_pointer_array[0]= select_lex->item_list.head();
item= func->create(expr, item);
diff --git a/sql/lex.h b/sql/lex.h
index 5299be89d35..352d80da5c6 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -32,10 +32,10 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"};
#define SYM(A) SYM_OR_NULL(A),0,0,&sym_group_common
#define F_SYM(A) SYM_OR_NULL(A)
-#define CREATE_FUNC(A) (void *)(SYM_OR_NULL(A)), &sym_group_common
+#define CREATE_FUNC(A) (void (*)())(SYM_OR_NULL(A)), &sym_group_common
#ifdef HAVE_SPATIAL
-#define CREATE_FUNC_GEOM(A) (void *)(SYM_OR_NULL(A)), &sym_group_geom
+#define CREATE_FUNC_GEOM(A) (void (*)())(SYM_OR_NULL(A)), &sym_group_geom
#else
#define CREATE_FUNC_GEOM(A) 0, &sym_group_geom
#endif
diff --git a/sql/lex_symbol.h b/sql/lex_symbol.h
index 5d929508030..c87cdb4ec43 100644
--- a/sql/lex_symbol.h
+++ b/sql/lex_symbol.h
@@ -25,7 +25,7 @@ typedef struct st_symbol {
const char *name;
uint tok;
uint length;
- void *create_func;
+ void (*create_func)();
struct st_sym_group *group;
} SYMBOL;
diff --git a/sql/log_event.cc b/sql/log_event.cc
index dbf69acf70a..e272140c080 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -541,12 +541,13 @@ int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
void Log_event::init_show_field_list(List<Item>* field_list)
{
field_list->push_back(new Item_empty_string("Log_name", 20));
- field_list->push_back(new Item_return_int("Pos", 11,
+ field_list->push_back(new Item_return_int("Pos", MY_INT32_NUM_DECIMAL_DIGITS,
MYSQL_TYPE_LONGLONG));
field_list->push_back(new Item_empty_string("Event_type", 20));
field_list->push_back(new Item_return_int("Server_id", 10,
MYSQL_TYPE_LONG));
- field_list->push_back(new Item_return_int("End_log_pos", 11,
+ field_list->push_back(new Item_return_int("End_log_pos",
+ MY_INT32_NUM_DECIMAL_DIGITS,
MYSQL_TYPE_LONGLONG));
field_list->push_back(new Item_empty_string("Info", 20));
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 4cb56e003ee..1f44fa6639c 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -470,7 +470,7 @@ sp_head::init(LEX *lex)
{
DBUG_ENTER("sp_head::init");
- lex->spcont= m_pcont= new sp_pcontext(NULL);
+ lex->spcont= m_pcont= new sp_pcontext();
/*
Altough trg_table_fields list is used only in triggers we init for all
@@ -1078,7 +1078,7 @@ sp_head::execute(THD *thd)
case SP_HANDLER_CONTINUE:
thd->restore_active_arena(&execute_arena, &backup_arena);
thd->set_n_backup_active_arena(&execute_arena, &backup_arena);
- ctx->push_hstack(ip);
+ ctx->push_hstack(i->get_cont_dest());
// Fall through
default:
ip= hip;
@@ -2395,7 +2395,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
reinit_stmt_before_use(thd, m_lex);
if (open_tables)
- res= instr->exec_open_and_lock_tables(thd, m_lex->query_tables, nextp);
+ res= instr->exec_open_and_lock_tables(thd, m_lex->query_tables);
if (!res)
res= instr->exec_core(thd, nextp);
@@ -2444,8 +2444,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
sp_instr class functions
*/
-int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables,
- uint *nextp)
+int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables)
{
int result;
@@ -2455,19 +2454,16 @@ int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables,
*/
if (check_table_access(thd, SELECT_ACL, tables, 0)
|| open_and_lock_tables(thd, tables))
- {
- get_cont_dest(nextp);
result= -1;
- }
else
result= 0;
return result;
}
-void sp_instr::get_cont_dest(uint *nextp)
+uint sp_instr::get_cont_dest()
{
- *nextp= m_ip+1;
+ return (m_ip+1);
}
@@ -2655,9 +2651,9 @@ sp_instr_set_trigger_field::print(String *str)
sp_instr_opt_meta
*/
-void sp_instr_opt_meta::get_cont_dest(uint *nextp)
+uint sp_instr_opt_meta::get_cont_dest()
{
- *nextp= m_cont_dest;
+ return m_cont_dest;
}
@@ -2749,7 +2745,6 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp)
if (! it)
{
res= -1;
- *nextp = m_cont_dest;
}
else
{
@@ -3318,7 +3313,6 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
spcont->clear_handler();
thd->spcont= spcont;
}
- *nextp= m_cont_dest; /* For continue handler */
}
else
*nextp= m_ip+1;
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 10eada43721..901b7a19c39 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -107,8 +107,6 @@ public:
/* Possible values of m_flags */
enum {
HAS_RETURN= 1, // For FUNCTIONs only: is set if has RETURN
- IN_SIMPLE_CASE= 2, // Is set if parsing a simple CASE
- IN_HANDLER= 4, // Is set if the parser is in a handler body
MULTI_RESULTS= 8, // Is set if a procedure with SELECT(s)
CONTAINS_DYNAMIC_SQL= 16, // Is set if a procedure with PREPARE/EXECUTE
IS_INVOKED= 32, // Is set if this sp_head is being used
@@ -449,13 +447,15 @@ public:
thd Thread handle
nextp OUT index of the next instruction to execute. (For most
instructions this will be the instruction following this
- one).
-
- RETURN
- 0 on success,
- other if some error occured
+ one). Note that this parameter is undefined in case of
+ errors, use get_cont_dest() to find the continuation
+ instruction for CONTINUE error handlers.
+
+ RETURN
+ 0 on success,
+ other if some error occurred
*/
-
+
virtual int execute(THD *thd, uint *nextp) = 0;
/**
@@ -463,22 +463,17 @@ public:
Open and lock the tables used by this statement, as a pre-requisite
to execute the core logic of this instruction with
<code>exec_core()</code>.
- If this statement fails, the next instruction to execute is also returned.
- This is useful when a user defined SQL continue handler needs to be
- executed.
@param thd the current thread
@param tables the list of tables to open and lock
- @param nextp the continuation instruction, returned to the caller if this
- method fails.
@return zero on success, non zero on failure.
*/
- int exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables, uint *nextp);
+ int exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables);
/**
Get the continuation destination of this instruction.
- @param nextp the continuation destination (output)
+ @return the continuation destination
*/
- virtual void get_cont_dest(uint *nextp);
+ virtual uint get_cont_dest();
/*
Execute core function of instruction after all preparations (e.g.
@@ -744,7 +739,7 @@ public:
virtual void set_destination(uint old_dest, uint new_dest)
= 0;
- virtual void get_cont_dest(uint *nextp);
+ virtual uint get_cont_dest();
protected:
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 6229cf14604..780243cc79f 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -25,6 +25,11 @@
#include "sp_pcontext.h"
#include "sp_head.h"
+/* Initial size for the dynamic arrays in sp_pcontext */
+#define PCONTEXT_ARRAY_INIT_ALLOC 16
+/* Increment size for the dynamic arrays in sp_pcontext */
+#define PCONTEXT_ARRAY_INCREMENT_ALLOC 8
+
/*
Sanity check for SQLSTATEs. Will not check if it's really an existing
state (there are just too many), but will check length and bad characters.
@@ -49,28 +54,61 @@ sp_cond_check(LEX_STRING *sqlstate)
return TRUE;
}
-sp_pcontext::sp_pcontext(sp_pcontext *prev)
- :Sql_alloc(), m_max_var_index(0), m_max_cursor_index(0), m_max_handler_index(0),
- m_context_handlers(0), m_parent(prev), m_pboundary(0)
+sp_pcontext::sp_pcontext()
+ : Sql_alloc(),
+ m_max_var_index(0), m_max_cursor_index(0), m_max_handler_index(0),
+ m_context_handlers(0), m_parent(NULL), m_pboundary(0),
+ m_label_scope(LABEL_DEFAULT_SCOPE)
{
- VOID(my_init_dynamic_array(&m_vars, sizeof(sp_variable_t *), 16, 8));
- VOID(my_init_dynamic_array(&m_case_expr_id_lst, sizeof(int), 16, 8));
- VOID(my_init_dynamic_array(&m_conds, sizeof(sp_cond_type_t *), 16, 8));
- VOID(my_init_dynamic_array(&m_cursors, sizeof(LEX_STRING), 16, 8));
- VOID(my_init_dynamic_array(&m_handlers, sizeof(sp_cond_type_t *), 16, 8));
+ VOID(my_init_dynamic_array(&m_vars, sizeof(sp_variable_t *),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_case_expr_id_lst, sizeof(int),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_conds, sizeof(sp_cond_type_t *),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_cursors, sizeof(LEX_STRING),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_handlers, sizeof(sp_cond_type_t *),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
m_label.empty();
m_children.empty();
- if (!prev)
- {
- m_var_offset= m_cursor_offset= 0;
- m_num_case_exprs= 0;
- }
- else
- {
- m_var_offset= prev->m_var_offset + prev->m_max_var_index;
- m_cursor_offset= prev->current_cursor_count();
- m_num_case_exprs= prev->get_num_case_exprs();
- }
+
+ m_var_offset= m_cursor_offset= 0;
+ m_num_case_exprs= 0;
+}
+
+sp_pcontext::sp_pcontext(sp_pcontext *prev, label_scope_type label_scope)
+ : Sql_alloc(),
+ m_max_var_index(0), m_max_cursor_index(0), m_max_handler_index(0),
+ m_context_handlers(0), m_parent(prev), m_pboundary(0),
+ m_label_scope(label_scope)
+{
+ VOID(my_init_dynamic_array(&m_vars, sizeof(sp_variable_t *),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_case_expr_id_lst, sizeof(int),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_conds, sizeof(sp_cond_type_t *),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_cursors, sizeof(LEX_STRING),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ VOID(my_init_dynamic_array(&m_handlers, sizeof(sp_cond_type_t *),
+ PCONTEXT_ARRAY_INIT_ALLOC,
+ PCONTEXT_ARRAY_INCREMENT_ALLOC));
+ m_label.empty();
+ m_children.empty();
+
+ m_var_offset= prev->m_var_offset + prev->m_max_var_index;
+ m_cursor_offset= prev->current_cursor_count();
+ m_num_case_exprs= prev->get_num_case_exprs();
}
void
@@ -92,9 +130,9 @@ sp_pcontext::destroy()
}
sp_pcontext *
-sp_pcontext::push_context()
+sp_pcontext::push_context(label_scope_type label_scope)
{
- sp_pcontext *child= new sp_pcontext(this);
+ sp_pcontext *child= new sp_pcontext(this, label_scope);
if (child)
m_children.push_back(child);
@@ -257,7 +295,15 @@ sp_pcontext::find_label(char *name)
if (my_strcasecmp(system_charset_info, name, lab->name) == 0)
return lab;
- if (m_parent)
+ /*
+ Note about exception handlers.
+ See SQL:2003 SQL/PSM (ISO/IEC 9075-4:2003),
+ section 13.1 <compound statement>,
+ syntax rule 4.
+ In short, a DECLARE HANDLER block can not refer
+ to labels from the parent context, as they are out of scope.
+ */
+ if (m_parent && (m_label_scope == LABEL_DEFAULT_SCOPE))
return m_parent->find_label(name);
return NULL;
}
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h
index b2cdd5e689c..5bffda79f98 100644
--- a/sql/sp_pcontext.h
+++ b/sql/sp_pcontext.h
@@ -88,16 +88,33 @@ typedef struct sp_cond
sp_cond_type_t *val;
} sp_cond_t;
+/**
+ The scope of a label in Stored Procedures,
+ for name resolution of labels in a parsing context.
+*/
+enum label_scope_type
+{
+ /**
+ The labels declared in a parent context are in scope.
+ */
+ LABEL_DEFAULT_SCOPE,
+ /**
+ The labels declared in a parent context are not in scope.
+ */
+ LABEL_HANDLER_SCOPE
+};
-/*
- The parse-time context, used to keep track on declared variables/parameters,
+/**
+ The parse-time context, used to keep track of declared variables/parameters,
conditions, handlers, cursors and labels, during parsing.
sp_contexts are organized as a tree, with one object for each begin-end
- block, plus a root-context for the parameters.
+ block, one object for each exception handler,
+ plus a root-context for the parameters.
This is used during parsing for looking up defined names (e.g. declared
variables and visible labels), for error checking, and to calculate offsets
to be used at runtime. (During execution variable values, active handlers
and cursors, etc, are referred to by an index in a stack.)
+ Parsing contexts for exception handlers limit the visibility of labels.
The pcontext tree is also kept during execution and is used for error
checking (e.g. correct number of parameters), and in the future, used by
the debugger.
@@ -105,21 +122,30 @@ typedef struct sp_cond
class sp_pcontext : public Sql_alloc
{
- sp_pcontext(const sp_pcontext &); /* Prevent use of these */
- void operator=(sp_pcontext &);
+public:
- public:
-
- sp_pcontext(sp_pcontext *prev);
+ /**
+ Constructor.
+ Builds a parsing context root node.
+ */
+ sp_pcontext();
// Free memory
void
destroy();
+ /**
+ Create and push a new context in the tree.
+ @param label_scope label scope for the new parsing context
+ @return the node created
+ */
sp_pcontext *
- push_context();
+ push_context(label_scope_type label_scope);
- // Returns the previous context, not the one we pop
+ /**
+ Pop a node from the parsing context tree.
+ @return the parent node
+ */
sp_pcontext *
pop_context();
@@ -363,6 +389,13 @@ class sp_pcontext : public Sql_alloc
protected:
+ /**
+ Constructor for a tree node.
+ @param prev the parent parsing context
+ @param label_scope label_scope for this parsing context
+ */
+ sp_pcontext(sp_pcontext *prev, label_scope_type label_scope);
+
/*
m_max_var_index -- number of variables (including all types of arguments)
in this context including all children contexts.
@@ -416,6 +449,14 @@ private:
List<sp_pcontext> m_children; // Children contexts, used for destruction
+ /**
+ Scope of labels for this parsing context.
+ */
+ label_scope_type m_label_scope;
+
+private:
+ sp_pcontext(const sp_pcontext &); /* Prevent use of these */
+ void operator=(sp_pcontext &);
}; // class sp_pcontext : public Sql_alloc
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 77bb1d9642b..97cb2d00689 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4582,7 +4582,8 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
Item_int do not need fix_fields() because it is basic constant.
*/
- it.replace(new Item_int("Not_used", (longlong) 1, 21));
+ it.replace(new Item_int("Not_used", (longlong) 1,
+ MY_INT64_NUM_DECIMAL_DIGITS));
}
else if (insert_fields(thd, ((Item_field*) item)->context,
((Item_field*) item)->db_name,
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9fe92d63da3..35e6a7da0aa 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8003,9 +8003,14 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top)
*/
expr= simplify_joins(join, &nested_join->join_list,
expr, FALSE);
- table->on_expr= expr;
- if (!table->prep_on_expr)
+
+ if (!table->prep_on_expr || expr != table->on_expr)
+ {
+ DBUG_ASSERT(expr);
+
+ table->on_expr= expr;
table->prep_on_expr= expr->copy_andor_structure(join->thd);
+ }
}
nested_join->used_tables= (table_map) 0;
nested_join->not_null_tables=(table_map) 0;
@@ -8015,7 +8020,7 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top)
}
else
{
- if (!(table->prep_on_expr))
+ if (!table->prep_on_expr)
table->prep_on_expr= table->on_expr;
used_tables= table->table->map;
if (conds)
@@ -8506,7 +8511,7 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
if ((new_cond= new Item_func_eq(args[0],
new Item_int("last_insert_id()",
thd->current_insert_id,
- 21))))
+ MY_INT64_NUM_DECIMAL_DIGITS))))
{
/*
Set THD::last_insert_id_used_bin_log manually, as this
@@ -8772,7 +8777,7 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
break;
case INT_RESULT:
/* Select an integer type with the minimal fit precision */
- if (item->max_length > 11)
+ if (item->max_length > MY_INT32_NUM_DECIMAL_DIGITS)
new_field=new Field_longlong(item->max_length, maybe_null,
item->name, table, item->unsigned_flag);
else
@@ -14974,7 +14979,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
/* Add "rows" field to item_list. */
item_list.push_back(new Item_int((longlong) (ulonglong)
join->best_positions[i]. records_read,
- 21));
+ MY_INT64_NUM_DECIMAL_DIGITS));
/* Build "Extra" field and add it to item_list. */
my_bool key_read=table->key_read;
if ((tab->type == JT_NEXT || tab->type == JT_CONST) &&
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 24aef80626f..286799a44f6 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -205,7 +205,8 @@ bool mysqld_show_column_types(THD *thd)
DBUG_ENTER("mysqld_show_column_types");
field_list.push_back(new Item_empty_string("Type",30));
- field_list.push_back(new Item_int("Size",(longlong) 1,21));
+ field_list.push_back(new Item_int("Size",(longlong) 1,
+ MY_INT64_NUM_DECIMAL_DIGITS));
field_list.push_back(new Item_empty_string("Min_Value",20));
field_list.push_back(new Item_empty_string("Max_Value",20));
field_list.push_back(new Item_return_int("Prec", 4, MYSQL_TYPE_SHORT));
@@ -1284,7 +1285,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
Protocol *protocol= thd->protocol;
DBUG_ENTER("mysqld_list_processes");
- field_list.push_back(new Item_int("Id",0,11));
+ field_list.push_back(new Item_int("Id", 0, MY_INT32_NUM_DECIMAL_DIGITS));
field_list.push_back(new Item_empty_string("User",16));
field_list.push_back(new Item_empty_string("Host",LIST_PROCESS_HOST_LEN));
field_list.push_back(field=new Item_empty_string("db",NAME_LEN));
@@ -4038,20 +4039,25 @@ ST_FIELD_INFO tables_fields_info[]=
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
{"TABLE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"ENGINE", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Engine"},
- {"VERSION", 21 , MYSQL_TYPE_LONG, 0, 1, "Version"},
+ {"VERSION", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1, "Version"},
{"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format"},
- {"TABLE_ROWS", 21 , MYSQL_TYPE_LONG, 0, 1, "Rows"},
- {"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Avg_row_length"},
- {"DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Data_length"},
- {"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Max_data_length"},
- {"INDEX_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, "Index_length"},
- {"DATA_FREE", 21 , MYSQL_TYPE_LONG, 0, 1, "Data_free"},
- {"AUTO_INCREMENT", 21 , MYSQL_TYPE_LONG, 0, 1, "Auto_increment"},
+ {"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1, "Rows"},
+ {"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1,
+ "Avg_row_length"},
+ {"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1,
+ "Data_length"},
+ {"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1,
+ "Max_data_length"},
+ {"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1,
+ "Index_length"},
+ {"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1, "Data_free"},
+ {"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1,
+ "Auto_increment"},
{"CREATE_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Create_time"},
{"UPDATE_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Update_time"},
{"CHECK_TIME", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Check_time"},
{"TABLE_COLLATION", 64, MYSQL_TYPE_STRING, 0, 1, "Collation"},
- {"CHECKSUM", 21 , MYSQL_TYPE_LONG, 0, 1, "Checksum"},
+ {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1, "Checksum"},
{"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options"},
{"TABLE_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
@@ -4064,14 +4070,15 @@ ST_FIELD_INFO columns_fields_info[]=
{"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Field"},
- {"ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
+ {"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 0, 0},
{"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, MYSQL_TYPE_STRING, 0, 1, "Default"},
{"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"},
{"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
- {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
- {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
- {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
- {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+ {"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1,
+ 0},
+ {"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1, 0},
+ {"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1, 0},
+ {"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONG, 0, 1, 0},
{"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0},
{"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation"},
{"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type"},
@@ -4097,7 +4104,7 @@ ST_FIELD_INFO collation_fields_info[]=
{
{"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Collation"},
{"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset"},
- {"ID", 11, MYSQL_TYPE_LONG, 0, 0, "Id"},
+ {"ID", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Id"},
{"IS_DEFAULT", 3, MYSQL_TYPE_STRING, 0, 0, "Default"},
{"IS_COMPILED", 3, MYSQL_TYPE_STRING, 0, 0, "Compiled"},
{"SORTLEN", 3 ,MYSQL_TYPE_LONG, 0, 0, "Sortlen"},
@@ -4150,7 +4157,7 @@ ST_FIELD_INFO stat_fields_info[]=
{"SEQ_IN_INDEX", 2, MYSQL_TYPE_LONG, 0, 0, "Seq_in_index"},
{"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Column_name"},
{"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1, "Collation"},
- {"CARDINALITY", 21, MYSQL_TYPE_LONG, 0, 1, "Cardinality"},
+ {"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 1, "Cardinality"},
{"SUB_PART", 3, MYSQL_TYPE_LONG, 0, 1, "Sub_part"},
{"PACKED", 10, MYSQL_TYPE_STRING, 0, 1, "Packed"},
{"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"},
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 14b9e0aa25d..c75aff7fab6 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4147,7 +4147,8 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2));
item->maybe_null= 1;
- field_list.push_back(item=new Item_int("Checksum",(longlong) 1,21));
+ field_list.push_back(item= new Item_int("Checksum", (longlong) 1,
+ MY_INT64_NUM_DECIMAL_DIGITS));
item->maybe_null= 1;
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 258283d113e..3e9c7ba7344 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2006,6 +2006,9 @@ sp_decl:
{
LEX *lex= Lex;
sp_head *sp= lex->sphead;
+
+ lex->spcont= lex->spcont->push_context(LABEL_HANDLER_SCOPE);
+
sp_pcontext *ctx= lex->spcont;
sp_instr_hpush_jump *i=
new sp_instr_hpush_jump(sp->instructions(), ctx, $2,
@@ -2013,7 +2016,6 @@ sp_decl:
sp->add_instr(i);
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
- sp->m_flags|= sp_head::IN_HANDLER;
}
sp_hcond_list sp_proc_stmt
{
@@ -2037,10 +2039,12 @@ sp_decl:
sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
}
lex->sphead->backpatch(hlab);
- sp->m_flags&= ~sp_head::IN_HANDLER;
+
+ lex->spcont= ctx->pop_context();
+
$$.vars= $$.conds= $$.curs= 0;
$$.hndlrs= $6;
- ctx->add_handlers($6);
+ lex->spcont->add_handlers($6);
}
| DECLARE_SYM ident CURSOR_SYM FOR_SYM sp_cursor_stmt
{
@@ -2103,11 +2107,18 @@ sp_handler_type:
;
sp_hcond_list:
+ sp_hcond_element
+ { $$= 1; }
+ | sp_hcond_list ',' sp_hcond_element
+ { $$+= 1; }
+ ;
+
+sp_hcond_element:
sp_hcond
{
LEX *lex= Lex;
sp_head *sp= lex->sphead;
- sp_pcontext *ctx= lex->spcont;
+ sp_pcontext *ctx= lex->spcont->parent_context();
if (ctx->find_handler($1))
{
@@ -2121,28 +2132,6 @@ sp_hcond_list:
i->add_condition($1);
ctx->push_handler($1);
- $$= 1;
- }
- }
- | sp_hcond_list ',' sp_hcond
- {
- LEX *lex= Lex;
- sp_head *sp= lex->sphead;
- sp_pcontext *ctx= lex->spcont;
-
- if (ctx->find_handler($3))
- {
- my_message(ER_SP_DUP_HANDLER, ER(ER_SP_DUP_HANDLER), MYF(0));
- MYSQL_YYABORT;
- }
- else
- {
- sp_instr_hpush_jump *i=
- (sp_instr_hpush_jump *)sp->last_instruction();
-
- i->add_condition($3);
- ctx->push_handler($3);
- $$= $1 + 1;
}
}
;
@@ -2687,7 +2676,7 @@ sp_unlabeled_control:
sp_label_t *lab= lex->spcont->last_label();
lab->type= SP_LAB_BEGIN;
- lex->spcont= lex->spcont->push_context();
+ lex->spcont= lex->spcont->push_context(LABEL_DEFAULT_SCOPE);
}
sp_decls
sp_proc_stmts