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

Update upstream source from tag 'upstream/5.5.64'

Update to upstream version '5.5.64'
with Debian dir b7957bbeb847da5eea7ad7ce27dbb476ae08d867
parents cbc39f88 b9a9fe5c
......@@ -1208,6 +1208,9 @@ int mysql_multi_update_prepare(THD *thd)
List<Item> *fields= &lex->select_lex.item_list;
table_map tables_for_update;
bool update_view= 0;
DML_prelocking_strategy prelocking_strategy;
bool has_prelocking_list= thd->lex->requires_prelocking();
/*
if this multi-update was converted from usual update, here is table
counter else junk will be assigned here, but then replaced with real
......@@ -1228,10 +1231,10 @@ int mysql_multi_update_prepare(THD *thd)
keep prepare of multi-UPDATE compatible with concurrent LOCK TABLES WRITE
and global read lock.
*/
if ((original_multiupdate &&
open_tables(thd, &table_list, &table_count,
(thd->stmt_arena->is_stmt_prepare() ?
MYSQL_OPEN_FORCE_SHARED_MDL : 0))) ||
if ((original_multiupdate && open_tables(thd, &table_list, &table_count,
thd->stmt_arena->is_stmt_prepare()
? MYSQL_OPEN_FORCE_SHARED_MDL : 0,
&prelocking_strategy)) ||
mysql_handle_derived(lex, DT_INIT))
DBUG_RETURN(TRUE);
/*
......@@ -1278,6 +1281,9 @@ int mysql_multi_update_prepare(THD *thd)
if (unsafe_key_update(lex->select_lex.leaf_tables, tables_for_update))
DBUG_RETURN(true);
TABLE_LIST **new_tables= lex->query_tables_last;
DBUG_ASSERT(*new_tables== NULL);
/*
Setup timestamp handling and locking mode
*/
......@@ -1305,6 +1311,11 @@ int mysql_multi_update_prepare(THD *thd)
If table will be updated we should not downgrade lock for it and
leave it as is.
*/
tl->updating= 1;
if (tl->belong_to_view)
tl->belong_to_view->updating= 1;
if (extend_table_list(thd, tl, &prelocking_strategy, has_prelocking_list))
DBUG_RETURN(TRUE);
}
else
{
......@@ -1323,9 +1334,21 @@ int mysql_multi_update_prepare(THD *thd)
tl->lock_type= read_lock_type_for_table(thd, lex, tl);
else
tl->set_lock_type(thd, read_lock_type_for_table(thd, lex, tl));
tl->updating= 0;
}
}
uint addon_table_count= 0;
if (*new_tables)
{
Sroutine_hash_entry **new_routines= thd->lex->sroutines_list.next;
DBUG_ASSERT(*new_routines == NULL);
if (open_tables(thd, new_tables, &addon_table_count, new_routines,
thd->stmt_arena->is_stmt_prepare()
? MYSQL_OPEN_FORCE_SHARED_MDL : 0,
&prelocking_strategy))
DBUG_RETURN(TRUE);
}
for (tl= table_list; tl; tl= tl->next_local)
{
/* Check access privileges for table */
......@@ -1358,7 +1381,7 @@ int mysql_multi_update_prepare(THD *thd)
/* now lock and fill tables */
if (!thd->stmt_arena->is_stmt_prepare() &&
lock_tables(thd, table_list, table_count, 0))
lock_tables(thd, table_list, table_count + addon_table_count, 0))
{
DBUG_RETURN(TRUE);
}
......
......@@ -1511,6 +1511,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
tbl->lock_type= table->lock_type;
tbl->mdl_request.set_type((tbl->lock_type >= TL_WRITE_ALLOW_WRITE) ?
MDL_SHARED_WRITE : MDL_SHARED_READ);
tbl->updating= table->updating;
}
/*
If the view is mergeable, we might want to
......
This diff is collapsed.
......@@ -7676,14 +7676,14 @@ select_lock_type:
| FOR_SYM UPDATE_SYM
{
LEX *lex=Lex;
lex->current_select->set_lock_for_tables(TL_WRITE);
lex->current_select->set_lock_for_tables(TL_WRITE, false);
lex->safe_to_cache_query=0;
}
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
{
LEX *lex=Lex;
lex->current_select->
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS, false);
lex->safe_to_cache_query=0;
}
;
......@@ -10966,7 +10966,7 @@ insert:
insert_lock_option
opt_ignore insert2
{
Select->set_lock_for_tables($3);
Select->set_lock_for_tables($3, true);
Lex->current_select= &Lex->select_lex;
}
insert_field_spec opt_insert_update
......@@ -10983,7 +10983,7 @@ replace:
}
replace_lock_option insert2
{
Select->set_lock_for_tables($3);
Select->set_lock_for_tables($3, true);
Lex->current_select= &Lex->select_lex;
}
insert_field_spec
......@@ -11159,14 +11159,14 @@ update:
opt_low_priority opt_ignore join_table_list
SET update_list
{
LEX *lex= Lex;
if (lex->select_lex.table_list.elements > 1)
lex->sql_command= SQLCOM_UPDATE_MULTI;
else if (lex->select_lex.get_table_list()->derived)
SELECT_LEX *slex= &Lex->select_lex;
if (slex->table_list.elements > 1)
Lex->sql_command= SQLCOM_UPDATE_MULTI;
else if (slex->get_table_list()->derived)
{
/* it is single table update and it is update of derived table */
my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
lex->select_lex.get_table_list()->alias, "UPDATE");
slex->get_table_list()->alias, "UPDATE");
MYSQL_YYABORT;
}
/*
......@@ -11174,7 +11174,7 @@ update:
be too pessimistic. We will decrease lock level if possible in
mysql_multi_update().
*/
Select->set_lock_for_tables($3);
slex->set_lock_for_tables($3, slex->table_list.elements == 1);
}
where_clause opt_order_clause delete_limit_clause {}
;
......@@ -13834,13 +13834,16 @@ table_lock:
table_ident opt_table_alias lock_option
{
thr_lock_type lock_type= (thr_lock_type) $3;
bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE);
if (!Select->add_table_to_list(thd, $1, $2, 0, lock_type,
(lock_for_write ?
lock_type == TL_WRITE_CONCURRENT_INSERT ?
MDL_SHARED_WRITE :
MDL_SHARED_NO_READ_WRITE :
MDL_SHARED_READ)))
bool lock_for_write= lock_type >= TL_WRITE_ALLOW_WRITE;
ulong table_options= lock_for_write ? TL_OPTION_UPDATING : 0;
enum_mdl_type mdl_type= !lock_for_write
? MDL_SHARED_READ
: lock_type == TL_WRITE_CONCURRENT_INSERT
? MDL_SHARED_WRITE
: MDL_SHARED_NO_READ_WRITE;
if (!Select->add_table_to_list(thd, $1, $2, table_options,
lock_type, mdl_type))
MYSQL_YYABORT;
}
;
......
......@@ -5373,7 +5373,8 @@ const char *Field_iterator_table_ref::get_table_name()
return natural_join_it.column_ref()->table_name();
DBUG_ASSERT(!strcmp(table_ref->table_name,
table_ref->table->s->table_name.str));
table_ref->table->s->table_name.str) ||
table_ref->schema_table);
return table_ref->table_name;
}
......
/*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, 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 the Free Software
......@@ -3787,6 +3788,9 @@ dict_create_foreign_constraints_low(
}
goto loop;
} else {
strncpy(create_name, name, sizeof create_name);
create_name[(sizeof create_name) - 1] = '\0';
}
if (table == NULL) {
......@@ -3811,12 +3815,21 @@ dict_create_foreign_constraints_low(
goto loop;
}
orig = ptr;
for (;;) {
ptr = dict_accept(cs, ptr, "TABLE", &success);
if (success) {
break;
}
ptr = dict_accept(cs, ptr, "ONLINE", &success);
if (success) {
continue;
}
ptr = dict_accept(cs, ptr, "IGNORE", &success);
if (!success) {
goto loop;
}
}
/* We are doing an ALTER TABLE: scan the table name we are altering */
......
/*****************************************************************************
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, 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 the Free Software
......@@ -353,11 +354,14 @@ trx_is_active(
}
trx = trx_get_on_id(trx_id);
if (trx && (trx->conc_state == TRX_ACTIVE
|| trx->conc_state == TRX_PREPARED)) {
if (trx) {
switch (trx->conc_state) {
case TRX_ACTIVE:
case TRX_PREPARED:
case TRX_PREPARED_RECOVERED:
return(TRUE);
}
}
return(FALSE);
}
......
/*****************************************************************************
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
Copyright (c) 2019, 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 the Free Software
......@@ -741,6 +742,8 @@ struct trx_struct{
#define TRX_ACTIVE 1
#define TRX_COMMITTED_IN_MEMORY 2
#define TRX_PREPARED 3 /* Support for 2PC/XA */
#define TRX_PREPARED_RECOVERED 4 /* XA PREPARE transaction that
was returned to ha_recover() */
/* Transaction execution states when trx->conc_state == TRX_ACTIVE */
#define TRX_QUE_RUNNING 0 /* transaction is running */
......
/*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, 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 the Free Software
......@@ -4782,6 +4783,22 @@ lock_print_info_all_transactions(
}
#ifdef UNIV_DEBUG
/** Validate the state of a transaction that holds locks */
static void lock_trx_state_validate(const trx_t* trx)
{
switch (trx->conc_state) {
case TRX_NOT_STARTED:
break;
case TRX_ACTIVE:
case TRX_PREPARED:
case TRX_PREPARED_RECOVERED:
case TRX_COMMITTED_IN_MEMORY:
return;
}
ut_ad(!"wrong state");
}
/*********************************************************************//**
Validates the lock queue on a table.
@return TRUE if ok */
......@@ -4798,9 +4815,7 @@ lock_table_queue_validate(
lock = UT_LIST_GET_FIRST(table->locks);
while (lock) {
ut_a(((lock->trx)->conc_state == TRX_ACTIVE)
|| ((lock->trx)->conc_state == TRX_PREPARED)
|| ((lock->trx)->conc_state == TRX_COMMITTED_IN_MEMORY));
ut_d(lock_trx_state_validate(lock->trx));
if (!lock_get_wait(lock)) {
......@@ -4848,15 +4863,7 @@ lock_rec_queue_validate(
lock = lock_rec_get_first(block, heap_no);
while (lock) {
switch(lock->trx->conc_state) {
case TRX_ACTIVE:
case TRX_PREPARED:
case TRX_COMMITTED_IN_MEMORY:
break;
default:
ut_error;
}
ut_d(lock_trx_state_validate(lock->trx));
ut_a(trx_in_trx_list(lock->trx));
if (lock_get_wait(lock)) {
......@@ -4935,9 +4942,7 @@ lock_rec_queue_validate(
lock = lock_rec_get_first(block, heap_no);
while (lock) {
ut_a(lock->trx->conc_state == TRX_ACTIVE
|| lock->trx->conc_state == TRX_PREPARED
|| lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY);
ut_d(lock_trx_state_validate(lock->trx));
ut_a(trx_in_trx_list(lock->trx));
if (index) {
......@@ -5014,10 +5019,8 @@ lock_rec_validate_page(
}
}
ut_d(lock_trx_state_validate(lock->trx));
ut_a(trx_in_trx_list(lock->trx));
ut_a(lock->trx->conc_state == TRX_ACTIVE
|| lock->trx->conc_state == TRX_PREPARED
|| lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY);
# ifdef UNIV_SYNC_DEBUG
/* Only validate the record queues when this thread is not
......
......@@ -10,8 +10,8 @@
-INSERT INTO t1 (a) VALUES (1),(2);
-INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
-Warnings:
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-SELECT a,b FROM t1;
-a b
-1 2
......@@ -27,8 +27,8 @@
-INSERT INTO t1 (a) VALUES (1),(2);
-INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
-Warnings:
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-SELECT a,b FROM t1;
-a b
-1 2
......@@ -44,8 +44,8 @@
-INSERT INTO t1 (a) VALUES (1),(2);
-INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
-Warnings:
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-SELECT a,b FROM t1;
-a b
-1 2
......@@ -61,8 +61,8 @@
-INSERT INTO t1 (a) VALUES (1),(2);
-INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
-Warnings:
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-Warning 1906 The value specified for computed column 'b' in table 't1' has been ignored
-SELECT a,b FROM t1;
-a b
-1 2
......
/*****************************************************************************
Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
Copyright (c) 2019, 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 the Free Software
......@@ -272,15 +273,19 @@ read_view_open_now(
view->low_limit_id = view->low_limit_no;
n = 0;
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
/* No active transaction should be visible, except cr_trx */
while (trx) {
if (trx->id != cr_trx_id
&& (trx->conc_state == TRX_ACTIVE
|| trx->conc_state == TRX_PREPARED)) {
for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list); trx;
trx = UT_LIST_GET_NEXT(trx_list, trx)) {
if (trx->id == cr_trx_id) {
continue;
}
switch (trx->conc_state) {
case TRX_ACTIVE:
case TRX_PREPARED:
case TRX_PREPARED_RECOVERED:
read_view_set_nth_trx_id(view, n, trx->id);
n++;
......@@ -296,8 +301,6 @@ read_view_open_now(
view->low_limit_no = trx->no;
}
}
trx = UT_LIST_GET_NEXT(trx_list, trx);
}
view->n_trx_ids = n;
......@@ -437,18 +440,15 @@ read_cursor_view_create_for_mysql(
view->low_limit_id = view->low_limit_no;
n = 0;
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
/* No active transaction should be visible */
while (trx) {
if (trx->conc_state == TRX_ACTIVE
|| trx->conc_state == TRX_PREPARED) {
read_view_set_nth_trx_id(view, n, trx->id);
n++;
for (trx = UT_LIST_GET_FIRST(trx_sys->trx_list); trx;
trx = UT_LIST_GET_NEXT(trx_list, trx)) {
switch (trx->conc_state) {
case TRX_ACTIVE:
case TRX_PREPARED:
case TRX_PREPARED_RECOVERED:
read_view_set_nth_trx_id(view, n++, trx->id);
/* NOTE that a transaction whose trx number is <
trx_sys->max_trx_id can still be active, if it is
......@@ -461,8 +461,6 @@ read_cursor_view_create_for_mysql(
view->low_limit_no = trx->no;
}
}
trx = UT_LIST_GET_NEXT(trx_list, trx);
}
view->n_trx_ids = n;
......
This diff is collapsed.
......@@ -2,6 +2,7 @@
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, 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 the Free Software
......@@ -564,6 +565,7 @@ trx_rollback_or_clean_recovered(
switch (trx->conc_state) {
case TRX_NOT_STARTED:
case TRX_PREPARED:
case TRX_PREPARED_RECOVERED:
continue;
case TRX_COMMITTED_IN_MEMORY:
......
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, 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 the Free Software
......@@ -1031,7 +1032,7 @@ trx_sys_init_at_db_start(void)
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
for (;;) {
ut_ad(trx->conc_state != TRX_PREPARED_RECOVERED);
if (trx->conc_state != TRX_PREPARED) {
rows_to_undo += trx->undo_no;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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