Commit eeca95d0 authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

New upstream version 5.5.59

parent fa5f29ea
......@@ -1756,6 +1756,44 @@ UNION
ORDER BY NULL, @a0 := 3, @a1 := 3, @a2 := 3, @a3 := 3, @a4 := 3,
@a5 := 3, @a6 := 3, @a7 := 3, @a8 := 3, @a9 := 3, @a10 := 3 );
--echo #
--echo # mdev-6706: semi-join with duplicate weedout + ORDER BY
--echo #
CREATE TABLE t1 (f1 VARCHAR(3)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo');
CREATE TABLE t2 (f2 VARCHAR(3)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('bar'),('baz');
CREATE TABLE t3
(i3_key INT, f3_key VARCHAR(3), f3 VARCHAR(3), KEY(f3_key,i3_key))
ENGINE=MyISAM;
INSERT INTO t3 VALUES (0,'qux','qux'),(8,'bar','bar');
let $q1=
SELECT CONCAT( f1, f2 ) AS field FROM t1, t2
WHERE f1 = ANY ( SELECT f1
FROM t1
LEFT JOIN ( t3 AS t3a, t3 AS t3b )
ON ( t3b.f3_key = t3a.f3 )
WHERE t3a.f3 < f1 OR t3b.f3 != f1 );
let $q2=
SELECT CONCAT( f1, f2 ) AS field FROM t1, t2
WHERE f1 = ANY ( SELECT f1
FROM t1
LEFT JOIN ( t3 AS t3a, t3 AS t3b )
ON ( t3b.f3_key = t3a.f3 )
WHERE t3a.f3 < f1 OR t3b.f3 != f1 )
ORDER BY field;
eval $q1;
eval $q2;
eval EXPLAIN EXTENDED $q2;
DROP TABLE t1,t2,t3;
--echo End of 5.5 tests
......@@ -3843,4 +3843,19 @@ deallocate prepare stmt;
drop view v1,v2,v3;
drop table t1,t2,t3;
--echo #
--echo # MDEV-10657: incorrect result returned with binary protocol
--echo # (prepared statements)
--echo #
create table t1 (code varchar(10) primary key);
INSERT INTO t1(code) VALUES ('LINE1'), ('LINE2'), ('LINE3');
SELECT X.*
FROM
(SELECT CODE, RN
FROM
(SELECT A.CODE, @cnt := @cnt + 1 AS RN
FROM t1 A, (SELECT @cnt := 0) C) T
) X;
drop table t1;
--echo # End of 5.5 tests
......@@ -319,3 +319,55 @@ RESET QUERY CACHE;
DROP TABLE t1;
SET GLOBAL query_cache_size= DEFAULT;
SET GLOBAL query_cache_type= DEFAULT;
--echo #
--echo # MDEV-14526: MariaDB keeps crashing under load when
--echo # query_cache_type is changed
--echo #
CREATE TABLE t1 (
`id` int(10) NOT NULL AUTO_INCREMENT,
`k` int(10) default '0',
PRIMARY KEY (`id`))
ENGINE=MyISAM;
INSERT IGNORE INTO t1 VALUES
(NULL,1),(NULL,8),(NULL,NULL),(NULL,NULL),(NULL,4),(NULL,9),(NULL,7),
(NULL,3),(NULL,NULL),(NULL,2),(NULL,3),(NULL,NULL),(NULL,2),(NULL,7),
(NULL,1),(NULL,2),(NULL,4),(NULL,NULL),(NULL,1),(NULL,1),(NULL,4);
SET GLOBAL query_cache_size= 1024*1024;
SET GLOBAL query_cache_type= 1;
--connect (con2,localhost,root,,test)
--connect (con1,localhost,root,,test)
set debug_sync="wait_in_query_cache_store_query SIGNAL parked WAIT_FOR go";
--send
SELECT DISTINCT id FROM t1 WHERE id BETWEEN 5603 AND 16218 ORDER BY k;
--connection default
set debug_sync="now WAIT_FOR parked";
--connection con2
--send
SET GLOBAL query_cache_type= 0;
--connection default
set debug_sync="now SIGNAL go";
--connection con1
--reap
--connection con2
--reap
# Cleanup
--disconnect con1
--disconnect con2
--connection default
set debug_sync= 'RESET';
DROP TABLE t1;
SEt GLOBAL query_cache_size= DEFAULT;
SEt GLOBAL query_cache_type= DEFAULT;
--echo # End of 5.5 tests
......@@ -6033,3 +6033,31 @@ CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
INSERT t2 VALUES (6),(9);
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
drop table t1, t2;
--echo #
--echo # MDEV-13933: Wrong results in COUNT() query with EXISTS and exists_to_in
--echo # (5.5 test)
--echo #
SET @optimiser_switch_save= @@optimizer_switch;
CREATE TABLE t1 (a INT NOT NULL);
INSERT INTO t1 VALUES (1),(1),(1),(5),(5);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (5),(1);
CREATE TABLE t3 (c INT, KEY(c));
INSERT INTO t3 VALUES (5),(5);
SET optimizer_switch='semijoin=on';
select t1.a from t1 where t1.a in (select `test`.`t2`.`b` from `test`.`t2`)
and t1.a in (select `test`.`t3`.`c` from `test`.`t3`);
SET optimizer_switch='semijoin=off';
select t1.a from t1 where t1.a in (select `test`.`t2`.`b` from `test`.`t2`)
and t1.a in (select `test`.`t3`.`c` from `test`.`t3`);
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
--echo End of 5.5 tests
......@@ -5578,6 +5578,18 @@ PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
drop view v1,v2;
drop table t3;
--echo #
--echo # MDEV-14619: VIEW and GROUP_CONCAT
--echo #
CREATE TABLE t1 (str text);
INSERT INTO t1 VALUES ("My"),("SQL");
CREATE VIEW v1 AS SELECT GROUP_CONCAT(str SEPARATOR '\\') FROM t1;
SELECT * FROM v1;
SHOW CREATE VIEW v1;
drop view v1;
drop table t1;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.5 tests.
--echo # -----------------------------------------------------------------
......
......@@ -327,6 +327,20 @@ SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # MDEV-14609 XA Transction unable to ROLLBACK TO SAVEPOINT
--echo #
CREATE TABLE t1 (c1 INT) ENGINE=INNODB;
XA START 'xa1';
SAVEPOINT savepoint1;
INSERT INTO t1 (c1) VALUES (1),(2),(3),(4);
ROLLBACK TO SAVEPOINT savepoint1;
XA END 'xa1';
XA ROLLBACK 'xa1';
DROP TABLE t1;
--echo #
--echo # Bug#12352846 - TRANS_XA_START(THD*):
--echo # ASSERTION THD->TRANSACTION.XID_STATE.XID.IS_NULL()
......
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2011, 2018, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -234,7 +235,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
(char **) &my_defaults_group_suffix);
if (! my_defaults_group_suffix)
my_defaults_group_suffix= getenv(STRINGIFY_ARG(DEFAULT_GROUP_SUFFIX_ENV));
my_defaults_group_suffix= getenv("MYSQL_GROUP_SUFFIX");
if (forced_extra_defaults && !defaults_already_read)
{
......
......@@ -103,10 +103,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
DBUG_ENTER("my_dir");
DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));
#if !defined(HAVE_READDIR_R)
mysql_mutex_lock(&THR_LOCK_open);
#endif
dirp = opendir(directory_file_name(tmp_path,(char *) path));
#if defined(__amiga__)
if ((dirp->dd_fd) < 0) /* Directory doesn't exists */
......@@ -162,9 +158,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
}
(void) closedir(dirp);
#if !defined(HAVE_READDIR_R)
mysql_mutex_unlock(&THR_LOCK_open);
#endif
result->dir_entry= (FILEINFO *)dir_entries_storage->buffer;
result->number_off_files= dir_entries_storage->elements;
......@@ -174,9 +167,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
DBUG_RETURN(result);
error:
#if !defined(HAVE_READDIR_R)
mysql_mutex_unlock(&THR_LOCK_open);
#endif
my_errno=errno;
if (dirp)
(void) closedir(dirp);
......
......@@ -15,7 +15,7 @@
#define PLUGIN_VERSION 0x104
#define PLUGIN_STR_VERSION "1.4.2"
#define PLUGIN_STR_VERSION "1.4.3"
#define _my_thread_var loc_thread_var
......@@ -1122,6 +1122,21 @@ do { \
} while(0)
#define ESC_MAP_SIZE 0x60
static const char esc_map[ESC_MAP_SIZE]=
{
0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, '\'', 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\\', 0, 0, 0
};
static char escaped_char(char c)
{
return ((unsigned char ) c) >= ESC_MAP_SIZE ? 0 : esc_map[(unsigned char) c];
}
static void setup_connection_initdb(struct connection_info *cn,
......@@ -1328,21 +1343,16 @@ static size_t escape_string(const char *str, unsigned int len,
const char *res_end= result + result_len - 2;
while (len)
{
char esc_c;
if (result >= res_end)
break;
if (*str == '\'')
{
if (result+1 >= res_end)
break;
*(result++)= '\\';
*(result++)= '\'';
}
else if (*str == '\\')
if ((esc_c= escaped_char(*str)))
{
if (result+1 >= res_end)
break;
*(result++)= '\\';
*(result++)= '\\';
*(result++)= esc_c;
}
else if (is_space(*str))
*(result++)= ' ';
......@@ -1431,19 +1441,12 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len,
no_password:
if (result >= res_end)
break;
if (*str == '\'')
if ((b_char= escaped_char(*str)))
{
if (result+1 >= res_end)
break;
*(result++)= '\\';
*(result++)= '\'';
}
else if (*str == '\\')
{
if (result+1 >= res_end)
break;
*(result++)= '\\';
*(result++)= '\\';
*(result++)= b_char;
}
else if (is_space(*str))
*(result++)= ' ';
......
......@@ -27,6 +27,7 @@ srcdir=""
args=""
defaults=""
defaults_group_suffix=""
mysqld_opt=""
user=""
......@@ -49,6 +50,9 @@ Usage: $0 [OPTIONS]
--defaults-extra-file=name
Read this file after the global files are read.
--defaults-file=name Only read default options from the given file name.
--defaults-group-suffix=name
In addition to the given groups, read also groups with
this suffix
--force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that
normally use hostnames will use IP addresses.
......@@ -129,6 +133,8 @@ parse_arguments()
--help) usage ;;
--no-defaults|--defaults-file=*|--defaults-extra-file=*)
defaults="$arg" ;;
--defaults-group-suffix=*)
defaults_group_suffix="$arg" ;;
--cross-bootstrap|--windows)
# Used when building the MariaDB system tables on a different host than
......@@ -257,7 +263,7 @@ fi
# Now we can get arguments from the groups [mysqld] and [mysql_install_db]
# in the my.cfg file, then re-run to merge with command line arguments.
parse_arguments `"$print_defaults" $defaults --mysqld mysql_install_db`
parse_arguments `"$print_defaults" $defaults $defaults_group_suffix --mysqld mysql_install_db`
parse_arguments PICK-ARGS-FROM-ARGV "$@"
# Configure paths to support files
......@@ -417,9 +423,9 @@ fi
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
mysqld_install_cmd_line()
{
"$mysqld_bootstrap" $defaults "$mysqld_opt" --bootstrap \
"--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --loose-skip-innodb \
--loose-skip-ndbcluster $args --max_allowed_packet=8M \
"$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" \
--bootstrap "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 \
--loose-skip-innodb --loose-skip-ndbcluster $args --max_allowed_packet=8M \
--default-storage-engine=myisam \
--net_buffer_length=16K
}
......
......@@ -868,8 +868,8 @@ if expr "${-}" : '.*x' > /dev/null
then
:
else
exec 1>&-
exec 2>&-
exec 1>/dev/null
exec 2>/dev/null
fi
while true
......
# Copyright (c) 2006, 2014, Oracle and/or its affiliates.
# Copyright (c) 2010, 2015, MariaDB
# Copyright (c) 2010, 2018, MariaDB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
......@@ -1758,7 +1758,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
{
uint store_length;
copy->str= ptr;
copy->length= pack_length();
copy->length= pack_length_in_rec();
copy->field= this;
if (flags & BLOB_FLAG)
{
......@@ -8422,7 +8422,7 @@ int Field_bit::cmp_max(const uchar *a, const uchar *b, uint max_len)
if ((flag= (int) (bits_a - bits_b)))
return flag;
}
return memcmp(a, b, field_length);
return memcmp(a, b, bytes_in_rec);
}
......@@ -8437,7 +8437,7 @@ int Field_bit::key_cmp(const uchar *str, uint length)
str++;
length--;
}
return memcmp(ptr, str, length);
return memcmp(ptr, str, bytes_in_rec);
}
......
......@@ -589,7 +589,7 @@ void Copy_field::set(uchar *to,Field *from)
{
from_ptr=from->ptr;
to_ptr=to;
from_length=from->pack_length();
from_length=from->pack_length_in_rec();
if (from->maybe_null())
{
from_null_ptr=from->null_ptr;
......@@ -640,9 +640,9 @@ void Copy_field::set(Field *to,Field *from,bool save)
from_field=from;
to_field=to;
from_ptr=from->ptr;
from_length=from->pack_length();
from_length=from->pack_length_in_rec();
to_ptr= to->ptr;
to_length=to_field->pack_length();
to_length=to_field->pack_length_in_rec();
// set up null handling
from_null_ptr=to_null_ptr=0;
......
......@@ -210,7 +210,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
{
ulonglong keys= memory_available / (param.rec_length + sizeof(char*));
table_sort.keys= (uint) min(num_rows, keys);
sort_buff_sz= table_sort.keys*(param.rec_length+sizeof(char*));
/* Cast to size_t to avoid overflow when result is greater than uint. */
sort_buff_sz= ((size_t)table_sort.keys) *
(param.rec_length + sizeof(char*));
set_if_bigger(sort_buff_sz, param.rec_length * MERGEBUFF2);
DBUG_EXECUTE_IF("make_sort_keys_alloc_fail",
......@@ -914,7 +916,8 @@ static void make_sortkey(register SORTPARAM *param,
if (maybe_null)
*to++=1;
char *tmp_buffer= param->tmp_buffer ? param->tmp_buffer : (char*)to;
String tmp(tmp_buffer, param->sort_length, cs);
String tmp(tmp_buffer, param->tmp_buffer ? param->sort_length :
sort_field->length, cs);
String *res= item->str_result(&tmp);
if (!res)
{
......
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2010, 2017, MariaDB Corporation
Copyright (c) 2010, 2018, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -4771,7 +4771,8 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
select->having_fix_field &&
select_ref != not_found_item && !group_by_ref)
select_ref != not_found_item && !group_by_ref &&
!ref->alias_name_used)
{
/*
Report the error if fields was found only in the SELECT item list and
......@@ -8491,7 +8492,7 @@ Item *Item_default_value::transform(Item_transformer transformer, uchar *args)
bool Item_insert_value::eq(const Item *item, bool binary_cmp) const
{
return item->type() == INSERT_VALUE_ITEM &&
((Item_default_value *)item)->arg->eq(arg, binary_cmp);
((Item_insert_value *)item)->arg->eq(arg, binary_cmp);
}
......
......@@ -2,7 +2,7 @@
#define SQL_ITEM_INCLUDED
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2009, 2017, MariaDB
Copyright (c) 2009, 2018, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
......@@ -2001,6 +2001,19 @@ bool Item_func_opt_neg::eq(const Item *item, bool binary_cmp) const
}
bool Item_func_interval::fix_fields(THD *thd, Item **ref)
{
if (Item_int_func::fix_fields(thd, ref))
return true;
for (uint i= 0 ; i < row->cols(); i++)
{
if (row->element_index(i)->check_cols(1))
return true;
}
return false;
}
void Item_func_interval::fix_length_and_dec()
{
uint rows= row->cols();
......
......@@ -728,6 +728,7 @@ class Item_func_interval :public Item_int_func
{
allowed_arg_cols= 0; // Fetch this value from first argument
}
bool fix_fields(THD *, Item **);
longlong val_int();
void fix_length_and_dec();
const char *func_name() const { return "interval"; }
......
/*
Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2009, 2017, MariaDB
Copyright (c) 2009, 2018, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -265,9 +265,9 @@ String *Item_func_sha2::val_str_ascii(String *str)
size_t input_len;
uint digest_length= 0;
input_string= args[0]->val_str(str);
str->set_charset(&my_charset_bin);
input_string= args[0]->val_str(str);
if (input_string == NULL)
{
null_value= TRUE;
......
Supports Markdown
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