Commit 1743883d authored by Alexander Barkov's avatar Alexander Barkov

Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3

parents 6db1b018 22c9663d
...@@ -2246,3 +2246,13 @@ b ...@@ -2246,3 +2246,13 @@ b
10 10
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-13527 Crash when EXPLAIN SELECT .. INTO row_sp_variable.field
#
BEGIN NOT ATOMIC
DECLARE a ROW(a INT);
EXPLAIN SELECT 1 INTO a.a;
END;
$$
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -3070,3 +3070,14 @@ b ...@@ -3070,3 +3070,14 @@ b
10 10
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-13527 Crash when EXPLAIN SELECT .. INTO row_sp_variable.field
#
DECLARE
a ROW(a INT);
BEGIN
EXPLAIN SELECT 1 INTO a.a;
END;
$$
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -2375,3 +2375,16 @@ DELIMITER ;$$ ...@@ -2375,3 +2375,16 @@ DELIMITER ;$$
CALL p1; CALL p1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-13527 Crash when EXPLAIN SELECT .. INTO row_sp_variable.field
--echo #
DELIMITER $$;
DECLARE
a ROW(a INT);
BEGIN
EXPLAIN SELECT 1 INTO a.a;
END;
$$
DELIMITER ;$$
...@@ -1471,3 +1471,16 @@ DELIMITER ;$$ ...@@ -1471,3 +1471,16 @@ DELIMITER ;$$
CALL p1; CALL p1;
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-13527 Crash when EXPLAIN SELECT .. INTO row_sp_variable.field
--echo #
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE a ROW(a INT);
EXPLAIN SELECT 1 INTO a.a;
END;
$$
DELIMITER ;$$
...@@ -109,36 +109,6 @@ void Item::push_note_converted_to_positive_complement(THD *thd) ...@@ -109,36 +109,6 @@ void Item::push_note_converted_to_positive_complement(THD *thd)
} }
/**
@todo
Make this functions class dependent
*/
bool Item::val_bool()
{
switch(result_type()) {
case INT_RESULT:
return val_int() != 0;
case DECIMAL_RESULT:
{
my_decimal decimal_value;
my_decimal *val= val_decimal(&decimal_value);
if (val)
return !my_decimal_is_zero(val);
return 0;
}
case REAL_RESULT:
case STRING_RESULT:
return val_real() != 0.0;
case ROW_RESULT:
case TIME_RESULT:
DBUG_ASSERT(0);
return 0; // Wrong (but safe)
}
return 0; // Wrong (but safe)
}
/** /**
Get date/time/datetime. Get date/time/datetime.
Optionally extend TIME result to DATETIME. Optionally extend TIME result to DATETIME.
......
...@@ -1047,7 +1047,10 @@ class Item: public Value_source, ...@@ -1047,7 +1047,10 @@ class Item: public Value_source,
FALSE value is false or NULL FALSE value is false or NULL
TRUE value is true (not equal to 0) TRUE value is true (not equal to 0)
*/ */
virtual bool val_bool(); virtual bool val_bool()
{
return type_handler()->Item_val_bool(this);
}
virtual String *val_nodeset(String*) { return 0; } virtual String *val_nodeset(String*) { return 0; }
/* /*
......
...@@ -3077,6 +3077,38 @@ bool Type_handler_geometry:: ...@@ -3077,6 +3077,38 @@ bool Type_handler_geometry::
#endif #endif
/*************************************************************************/
bool Type_handler_real_result::Item_val_bool(Item *item) const
{
return item->val_real() != 0.0;
}
bool Type_handler_int_result::Item_val_bool(Item *item) const
{
return item->val_int() != 0;
}
bool Type_handler_decimal_result::Item_val_bool(Item *item) const
{
my_decimal decimal_value;
my_decimal *val= item->val_decimal(&decimal_value);
if (val)
return !my_decimal_is_zero(val);
return false;
}
bool Type_handler_temporal_result::Item_val_bool(Item *item) const
{
return item->val_real() != 0.0;
}
bool Type_handler_string_result::Item_val_bool(Item *item) const
{
return item->val_real() != 0.0;
}
/*************************************************************************/ /*************************************************************************/
longlong Type_handler_real_result:: longlong Type_handler_real_result::
......
...@@ -891,6 +891,7 @@ class Type_handler ...@@ -891,6 +891,7 @@ class Type_handler
virtual virtual
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const= 0; bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const= 0;
virtual bool Item_val_bool(Item *item) const= 0;
virtual longlong Item_val_int_signed_typecast(Item *item) const= 0; virtual longlong Item_val_int_signed_typecast(Item *item) const= 0;
virtual longlong Item_val_int_unsigned_typecast(Item *item) const= 0; virtual longlong Item_val_int_unsigned_typecast(Item *item) const= 0;
...@@ -1147,6 +1148,11 @@ class Type_handler_row: public Type_handler ...@@ -1147,6 +1148,11 @@ class Type_handler_row: public Type_handler
DBUG_ASSERT(0); DBUG_ASSERT(0);
return true; return true;
} }
bool Item_val_bool(Item *item) const
{
DBUG_ASSERT(0);
return false;
}
longlong Item_val_int_signed_typecast(Item *item) const longlong Item_val_int_signed_typecast(Item *item) const
{ {
DBUG_ASSERT(0); DBUG_ASSERT(0);
...@@ -1352,6 +1358,7 @@ class Type_handler_real_result: public Type_handler_numeric ...@@ -1352,6 +1358,7 @@ class Type_handler_real_result: public Type_handler_numeric
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const; bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const;
bool Item_func_signed_fix_length_and_dec(Item_func_signed *item) const; bool Item_func_signed_fix_length_and_dec(Item_func_signed *item) const;
bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const; bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const;
bool Item_val_bool(Item *item) const;
longlong Item_val_int_signed_typecast(Item *item) const; longlong Item_val_int_signed_typecast(Item *item) const;
longlong Item_val_int_unsigned_typecast(Item *item) const; longlong Item_val_int_unsigned_typecast(Item *item) const;
String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const; String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const;
...@@ -1427,6 +1434,7 @@ class Type_handler_decimal_result: public Type_handler_numeric ...@@ -1427,6 +1434,7 @@ class Type_handler_decimal_result: public Type_handler_numeric
bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const; bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const;
bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const; bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const;
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const; bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const;
bool Item_val_bool(Item *item) const;
longlong Item_val_int_signed_typecast(Item *item) const; longlong Item_val_int_signed_typecast(Item *item) const;
longlong Item_val_int_unsigned_typecast(Item *item) const; longlong Item_val_int_unsigned_typecast(Item *item) const;
String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const; String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const;
...@@ -1494,6 +1502,7 @@ class Type_handler_int_result: public Type_handler_numeric ...@@ -1494,6 +1502,7 @@ class Type_handler_int_result: public Type_handler_numeric
bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const; bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const;
bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const; bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const;
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const; bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const;
bool Item_val_bool(Item *item) const;
longlong Item_val_int_signed_typecast(Item *item) const; longlong Item_val_int_signed_typecast(Item *item) const;
longlong Item_val_int_unsigned_typecast(Item *item) const; longlong Item_val_int_unsigned_typecast(Item *item) const;
String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const; String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const;
...@@ -1564,6 +1573,7 @@ class Type_handler_temporal_result: public Type_handler ...@@ -1564,6 +1573,7 @@ class Type_handler_temporal_result: public Type_handler
bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const; bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const;
bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const; bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const;
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const; bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const;
bool Item_val_bool(Item *item) const;
longlong Item_val_int_signed_typecast(Item *item) const; longlong Item_val_int_signed_typecast(Item *item) const;
longlong Item_val_int_unsigned_typecast(Item *item) const; longlong Item_val_int_unsigned_typecast(Item *item) const;
String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const; String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const;
...@@ -1673,6 +1683,7 @@ class Type_handler_string_result: public Type_handler ...@@ -1673,6 +1683,7 @@ class Type_handler_string_result: public Type_handler
bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const; bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const;
bool Item_func_signed_fix_length_and_dec(Item_func_signed *item) const; bool Item_func_signed_fix_length_and_dec(Item_func_signed *item) const;
bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const; bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const;
bool Item_val_bool(Item *item) const;
longlong Item_val_int_signed_typecast(Item *item) const; longlong Item_val_int_signed_typecast(Item *item) const;
longlong Item_val_int_unsigned_typecast(Item *item) const; longlong Item_val_int_unsigned_typecast(Item *item) const;
String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const; String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const;
......
...@@ -12156,7 +12156,7 @@ select_outvar: ...@@ -12156,7 +12156,7 @@ select_outvar:
} }
| ident '.' ident | ident '.' ident
{ {
if (!($$= Lex->create_outvar(thd, &$1, &$3))) if (!($$= Lex->create_outvar(thd, &$1, &$3)) && Lex->result)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
; ;
......
...@@ -12219,7 +12219,7 @@ select_outvar: ...@@ -12219,7 +12219,7 @@ select_outvar:
} }
| ident '.' ident | ident '.' ident
{ {
if (!($$= Lex->create_outvar(thd, &$1, &$3))) if (!($$= Lex->create_outvar(thd, &$1, &$3)) && Lex->result)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
; ;
......
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