Skip to content

Commit

Permalink
Merge lp:maria/10.0 up to revision 4032 (10.0.9).
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Lindström committed Mar 7, 2014
2 parents 3a4b887 + b95c8ce commit 67cb55c
Show file tree
Hide file tree
Showing 28 changed files with 396 additions and 110 deletions.
10 changes: 9 additions & 1 deletion client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,13 @@ static int dump_tablespaces(char* ts_where)
char *ubs;
char *endsemi;
DBUG_ENTER("dump_tablespaces");


/*
Try to turn off semi-join optimization (if that fails, this is a
pre-optimizer_switch server, and the old query plan is ok for us.
*/
mysql_query(mysql, "set optimizer_switch='semijoin=off'");

init_dynamic_string_checked(&sqlbuf,
"SELECT LOGFILE_GROUP_NAME,"
" FILE_NAME,"
Expand Down Expand Up @@ -4164,6 +4170,8 @@ static int dump_tablespaces(char* ts_where)

mysql_free_result(tableres);
dynstr_free(&sqlbuf);
mysql_query(mysql, "set optimizer_switch=default");

DBUG_RETURN(0);
}

Expand Down
2 changes: 1 addition & 1 deletion client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8945,7 +8945,7 @@ int main(int argc, char **argv)
my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024, MYF(0));

if (my_hash_init2(&var_hash, 64, charset_info,
128, 0, 0, get_var_key, var_free, MYF(0)))
128, 0, 0, get_var_key, 0, var_free, MYF(0)))
die("Variable hash initialization failed");

var_set_string("MYSQL_SERVER_VERSION", MYSQL_SERVER_VERSION);
Expand Down
9 changes: 7 additions & 2 deletions include/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ extern "C" {

typedef uint my_hash_value_type;
typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool);
typedef my_hash_value_type (*my_hash_function)(const CHARSET_INFO *,
const uchar *, size_t);
typedef void (*my_hash_free_key)(void *);
typedef my_bool (*my_hash_walk_action)(void *,void *);

Expand All @@ -54,17 +56,19 @@ typedef struct st_hash {
uint flags;
DYNAMIC_ARRAY array; /* Place for hash_keys */
my_hash_get_key get_key;
my_hash_function hash_function;
void (*free)(void *);
CHARSET_INFO *charset;
} HASH;

/* A search iterator state */
typedef uint HASH_SEARCH_STATE;

#define my_hash_init(A,B,C,D,E,F,G,H) my_hash_init2(A,0,B,C,D,E,F,G,H)
#define my_hash_init(A,B,C,D,E,F,G,H) my_hash_init2(A,0,B,C,D,E,F,0,G,H)
my_bool my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong default_array_elements, size_t key_offset,
size_t key_length, my_hash_get_key get_key,
my_hash_function hash_function,
void (*free_element)(void*),
uint flags);
void my_hash_free(HASH *tree);
Expand All @@ -74,8 +78,9 @@ uchar *my_hash_search(const HASH *info, const uchar *key, size_t length);
uchar *my_hash_search_using_hash_value(const HASH *info,
my_hash_value_type hash_value,
const uchar *key, size_t length);
my_hash_value_type my_calc_hash(const HASH *info,
my_hash_value_type my_hash_sort(const CHARSET_INFO *cs,
const uchar *key, size_t length);
#define my_calc_hash(A, B, C) my_hash_sort((A)->charset, B, C)
uchar *my_hash_first(const HASH *info, const uchar *key, size_t length,
HASH_SEARCH_STATE *state);
uchar *my_hash_first_from_hash_value(const HASH *info,
Expand Down
33 changes: 16 additions & 17 deletions libmysql/libmysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *, MYSQL_FIELD *field);
#define RESET_LONG_DATA 2
#define RESET_STORE_RESULT 4
#define RESET_CLEAR_ERROR 8
#define RESET_ALL_BUFFERS 16

static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags);

Expand Down Expand Up @@ -4615,6 +4616,14 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
*mysql->unbuffered_fetch_owner= TRUE;
mysql->status= MYSQL_STATUS_READY;
}
if (flags & RESET_ALL_BUFFERS)
{
/* mysql_stmt_next_result will flush all pending
result sets
*/
while (mysql_more_results(mysql) &&
mysql_stmt_next_result(stmt) == 0);
}
}
if (flags & RESET_SERVER_SIDE)
{
Expand Down Expand Up @@ -4679,27 +4688,18 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
{
mysql->stmts= list_delete(mysql->stmts, &stmt->list);
/*
Clear NET error state: if the following commands come through
successfully, connection will still be usable for other commands.
Clear NET error state: if the following commands come through
successfully, connection will still be usable for other commands.
*/
net_clear_error(&mysql->net);

if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE)
{
uchar buff[MYSQL_STMT_HEADER]; /* 4 bytes - stmt id */

if (mysql->unbuffered_fetch_owner == &stmt->unbuffered_fetch_cancelled)
mysql->unbuffered_fetch_owner= 0;
if (mysql->status != MYSQL_STATUS_READY)
{
/*
Flush result set of the connection. If it does not belong
to this statement, set a warning.
*/
(*mysql->methods->flush_use_result)(mysql, TRUE);
if (mysql->unbuffered_fetch_owner)
*mysql->unbuffered_fetch_owner= TRUE;
mysql->status= MYSQL_STATUS_READY;
}
if ((rc= reset_stmt_handle(stmt, RESET_ALL_BUFFERS | RESET_CLEAR_ERROR)))
return rc;

int4store(buff, stmt->stmt_id);
if ((rc= stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt)))
{
Expand Down Expand Up @@ -4731,7 +4731,7 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt)
/* Reset the client and server sides of the prepared statement */
DBUG_RETURN(reset_stmt_handle(stmt,
RESET_SERVER_SIDE | RESET_LONG_DATA |
RESET_CLEAR_ERROR));
RESET_ALL_BUFFERS | RESET_CLEAR_ERROR));
}

/*
Expand Down Expand Up @@ -4843,7 +4843,6 @@ int STDCALL mysql_next_result(MYSQL *mysql)
DBUG_RETURN(-1); /* No more results */
}


int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
{
MYSQL *mysql= stmt->mysql;
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/r/create_or_replace.result
Original file line number Diff line number Diff line change
Expand Up @@ -333,29 +333,29 @@ lock table t1 write, t2 read;
select * from information_schema.metadata_lock_info;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2
create or replace table t1 (i int);
select * from information_schema.metadata_lock_info;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2
create or replace table t1 like t2;
select * from information_schema.metadata_lock_info;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2
create or replace table t1 select 1 as f1;
select * from information_schema.metadata_lock_info;
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Global read lock
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_NO_READ_WRITE MDL_EXPLICIT Table metadata lock test t1
# MDL_INTENTION_EXCLUSIVE MDL_EXPLICIT Schema metadata lock test
# MDL_SHARED_READ MDL_EXPLICIT Table metadata lock test t2
drop table t1;
unlock tables;
Expand Down
42 changes: 42 additions & 0 deletions mysql-test/r/information_schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -1985,3 +1985,45 @@ drop database mysqltest;
#
# End of 5.5 tests
#
#
# MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases
#
drop database if exists db1;
create database db1;
use db1;
create table t1 (a int);
create table t2 (a int);
create table t3 (a int);
create database mysqltest;
use mysqltest;
create table t1 (a int);
create table t2 (a int);
create table t3 (a int);
flush tables;
flush status;
SELECT
LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA
FROM
INFORMATION_SCHEMA.FILES
WHERE
FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND
LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME
FROM INFORMATION_SCHEMA.FILES
WHERE
FILE_TYPE = 'DATAFILE' AND
TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME
FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_SCHEMA IN ('db1')
)
)
GROUP BY
LOGFILE_GROUP_NAME, FILE_NAME, ENGINE
ORDER BY
LOGFILE_GROUP_NAME;
LOGFILE_GROUP_NAME FILE_NAME TOTAL_EXTENTS INITIAL_SIZE ENGINE EXTRA
# This must have Opened_tables=3, not 6.
show status like 'Opened_tables';
Variable_name Value
Opened_tables 3
drop database mysqltest;
drop database db1;
2 changes: 1 addition & 1 deletion mysql-test/r/innodb_ext_key.result
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ from lineitem use index (i_l_shipdate, i_l_receiptdate)
where l_shipdate='1992-07-01' and l_orderkey=130
or l_receiptdate='1992-07-01' and l_orderkey=5603;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE lineitem index_merge i_l_shipdate,i_l_receiptdate i_l_shipdate,i_l_receiptdate 8,8 NULL 2 Using sort_union(i_l_shipdate,i_l_receiptdate); Using where
1 SIMPLE lineitem index_merge i_l_shipdate,i_l_receiptdate i_l_shipdate,i_l_receiptdate 8,8 NULL 2 Using union(i_l_shipdate,i_l_receiptdate); Using where
flush status;
select l_orderkey, l_linenumber
from lineitem use index (i_l_shipdate, i_l_receiptdate)
Expand Down
11 changes: 11 additions & 0 deletions mysql-test/r/join.result
Original file line number Diff line number Diff line change
Expand Up @@ -1538,3 +1538,14 @@ a
3
4
DROP TABLE t1,t2;
#
# MDEV-5635: join of a const table with non-const tables
#
CREATE TABLE t1 (a varchar(3) NOT NULL) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo');
CREATE TABLE t2 (b varchar(3), c varchar(3), INDEX(b)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('bar', 'bar'),( 'qux', 'qux');
SELECT STRAIGHT_JOIN * FROM t1, t2 AS t2_1, t2 AS t2_2
WHERE t2_2.c = t2_1.c AND t2_2.b = t2_1.b AND ( a IS NULL OR t2_1.c = a );
a b c b c
DROP TABLE t1,t2;
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ DROP EVENT e1;




--sync_slave_with_master
# Check received heartbeat events while logs flushed on slave
--connection slave
--echo *** Flush logs on slave ***
Expand Down
56 changes: 56 additions & 0 deletions mysql-test/t/information_schema.test
Original file line number Diff line number Diff line change
Expand Up @@ -1816,5 +1816,61 @@ drop database mysqltest;
--echo # End of 5.5 tests
--echo #

--echo #
--echo # MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases
--echo #

--disable_warnings
drop database if exists db1;
--enable_warnings

connect (con1,localhost,root,,);
connection con1;

create database db1;
use db1;
create table t1 (a int);
create table t2 (a int);
create table t3 (a int);

create database mysqltest;
use mysqltest;
create table t1 (a int);
create table t2 (a int);
create table t3 (a int);

flush tables;
flush status;

SELECT
LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA
FROM
INFORMATION_SCHEMA.FILES
WHERE
FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND
LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME
FROM INFORMATION_SCHEMA.FILES
WHERE
FILE_TYPE = 'DATAFILE' AND
TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME
FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_SCHEMA IN ('db1')
)
)
GROUP BY
LOGFILE_GROUP_NAME, FILE_NAME, ENGINE
ORDER BY
LOGFILE_GROUP_NAME;

--echo # This must have Opened_tables=3, not 6.
show status like 'Opened_tables';

drop database mysqltest;
drop database db1;

connection default;
disconnect con1;

# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc

15 changes: 15 additions & 0 deletions mysql-test/t/join.test
Original file line number Diff line number Diff line change
Expand Up @@ -1185,3 +1185,18 @@ SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a;
SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a;

DROP TABLE t1,t2;

--echo #
--echo # MDEV-5635: join of a const table with non-const tables
--echo #

CREATE TABLE t1 (a varchar(3) NOT NULL) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo');

CREATE TABLE t2 (b varchar(3), c varchar(3), INDEX(b)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('bar', 'bar'),( 'qux', 'qux');

SELECT STRAIGHT_JOIN * FROM t1, t2 AS t2_1, t2 AS t2_2
WHERE t2_2.c = t2_1.c AND t2_2.b = t2_1.b AND ( a IS NULL OR t2_1.c = a );

DROP TABLE t1,t2;
Loading

0 comments on commit 67cb55c

Please sign in to comment.