Commit 0ead2031 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents cd04673a 9b7a1c0e
......@@ -1646,6 +1646,17 @@ SELECT JSON_OBJECTAGG('\\', 1);
JSON_OBJECTAGG('\\', 1)
{"\\":1}
#
# MDEV-24784 JSON_ARRAYAGG charset issue
#
set names utf8;
select json_arrayagg('ä'), json_objectagg(1, 'ä');
json_arrayagg('ä') json_objectagg(1, 'ä')
["ä"] {"1":"ä"}
set names latin1;
select json_arrayagg('ä'), json_objectagg(1, 'ä');
json_arrayagg('ä') json_objectagg(1, 'ä')
["ä"] {"1":"ä"}
#
# End of 10.5 tests
#
#
......
......@@ -1111,6 +1111,16 @@ SELECT JSON_OBJECTAGG('"', 1);
SELECT JSON_OBJECTAGG('\"', 1);
SELECT JSON_OBJECTAGG('\\', 1);
--echo #
--echo # MDEV-24784 JSON_ARRAYAGG charset issue
--echo #
--disable_service_connection
set names utf8;
select json_arrayagg('ä'), json_objectagg(1, 'ä');
set names latin1;
select json_arrayagg('ä'), json_objectagg(1, 'ä');
--enable_service_connection
--echo #
--echo # End of 10.5 tests
--echo #
......
......@@ -4689,30 +4689,6 @@ bool Field_longlong::is_max()
single precision float
****************************************************************************/
Field_float::Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg,
bool zero_arg, bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
(dec_arg >= FLOATING_POINT_DECIMALS ? NOT_FIXED_DEC : dec_arg),
zero_arg, unsigned_arg)
{
}
Field_float::Field_float(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
NONE, field_name_arg,
(dec_arg >= FLOATING_POINT_DECIMALS ? NOT_FIXED_DEC : dec_arg),
0, 0)
{
}
int Field_float::store(const char *from,size_t len,CHARSET_INFO *cs)
{
int error;
......@@ -4861,40 +4837,6 @@ Binlog_type_info Field_float::binlog_type_info() const
double precision floating point numbers
****************************************************************************/
Field_double::Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg,
bool zero_arg, bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
(dec_arg >= FLOATING_POINT_DECIMALS ? NOT_FIXED_DEC : dec_arg),
zero_arg, unsigned_arg)
{
}
Field_double::Field_double(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg,
(dec_arg >= FLOATING_POINT_DECIMALS ? NOT_FIXED_DEC : dec_arg),
0, 0)
{
}
Field_double::Field_double(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg, bool not_fixed_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg,
(dec_arg >= FLOATING_POINT_DECIMALS ? NOT_FIXED_DEC : dec_arg),
0, 0)
{
not_fixed= not_fixed_arg;
}
int Field_double::store(const char *from,size_t len,CHARSET_INFO *cs)
{
int error;
......
......@@ -2121,7 +2121,7 @@ class Field_str :public Field {
const LEX_CSTRING *field_name_arg,
const DTCollation &collation);
decimal_digits_t decimals() const override
{ return is_created_from_null_item ? 0 : NOT_FIXED_DEC; }
{ return is_created_from_null_item ? 0 : DECIMAL_NOT_SPECIFIED; }
int save_in_field(Field *to) override { return save_in_field_str(to); }
bool memcpy_field_possible(const Field *from) const override
{
......@@ -2289,7 +2289,7 @@ class Field_real :public Field_num {
Information_schema_numeric_attributes
information_schema_numeric_attributes() const override
{
return dec == NOT_FIXED_DEC ?
return dec == DECIMAL_NOT_SPECIFIED ?
Information_schema_numeric_attributes(field_length) :
Information_schema_numeric_attributes(field_length, dec);
}
......@@ -2861,15 +2861,24 @@ class Field_vers_trx_id :public Field_longlong {
integers. But in all other cases we treat it as TIME_RESULT! */
};
static inline decimal_digits_t fix_dec_arg(decimal_digits_t dec_arg)
{ return dec_arg >= FLOATING_POINT_DECIMALS ? DECIMAL_NOT_SPECIFIED : dec_arg; }
class Field_float final :public Field_real {
public:
Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg,bool zero_arg,bool unsigned_arg);
decimal_digits_t dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
fix_dec_arg(dec_arg), zero_arg, unsigned_arg)
{ }
Field_float(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg, decimal_digits_t dec_arg);
const LEX_CSTRING *field_name_arg, decimal_digits_t dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
NONE, field_name_arg, fix_dec_arg(dec_arg), 0, 0)
{ }
const Type_handler *type_handler() const override
{ return &type_handler_float; }
enum ha_base_keytype key_type() const override { return HA_KEYTYPE_FLOAT; }
......@@ -2902,12 +2911,24 @@ class Field_double :public Field_real {
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg,bool zero_arg,bool unsigned_arg);
decimal_digits_t dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
fix_dec_arg(dec_arg), zero_arg, unsigned_arg)
{ }
Field_double(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg, decimal_digits_t dec_arg);
const LEX_CSTRING *field_name_arg, decimal_digits_t dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, fix_dec_arg(dec_arg), 0, 0)
{ }
Field_double(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
decimal_digits_t dec_arg, bool not_fixed_arg);
decimal_digits_t dec_arg, bool not_fixed_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, fix_dec_arg(dec_arg), 0, 0)
{
not_fixed= not_fixed_arg;
}
void init_for_tmp_table(Field *org_field, TABLE *new_table) override
{
Field::init_for_tmp_table(org_field, new_table);
......
......@@ -3932,6 +3932,13 @@ int Arg_comparator::compare_e_json_str_basic(Item *j, Item *s)
return MY_TEST(sortcmp(res1, res2, compare_collation()) == 0);
}
bool Item_func_json_arrayagg::fix_fields(THD *thd, Item **ref)
{
bool res= Item_func_group_concat::fix_fields(thd, ref);
m_tmp_json.set_charset(collation.collation);
return res;
}
String *Item_func_json_arrayagg::get_str_from_item(Item *i, String *tmp)
{
......
......@@ -669,6 +669,7 @@ class Item_func_json_arrayagg : public Item_func_group_concat
static LEX_CSTRING name= {STRING_WITH_LEN("json_arrayagg(") };
return name;
}
bool fix_fields(THD *thd, Item **ref) override;
enum Sumfunctype sum_func() const override { return JSON_ARRAYAGG_FUNC; }
String* val_str(String *str) override;
......
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