Skip to content

Commit

Permalink
Merge 10.2 into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed May 19, 2020
2 parents 2e9f4cd + a8f044e commit 79ed33c
Show file tree
Hide file tree
Showing 17 changed files with 227 additions and 109 deletions.
2 changes: 1 addition & 1 deletion extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5706,7 +5706,7 @@ static bool xtrabackup_prepare_func(char** argv)

error_cleanup:
xb_filters_free();
return ok;
return ok && !ib::error::was_logged();
}

/**************************************************************************
Expand Down
17 changes: 17 additions & 0 deletions mysql-test/main/ps.result
Original file line number Diff line number Diff line change
Expand Up @@ -5450,5 +5450,22 @@ drop procedure p;
drop view v1;
drop table t1;
#
# MDEV-22591 Debug build crashes on EXECUTE IMMEDIATE '... WHERE ?' USING IGNORE
#
CREATE TABLE t1 (a INT);
EXECUTE IMMEDIATE 'SELECT * FROM t1 WHERE ?' USING IGNORE;
ERROR HY000: Default/ignore value is not supported for such parameter usage
EXECUTE IMMEDIATE 'SELECT * FROM t1 HAVING ?' USING IGNORE;
ERROR HY000: Default/ignore value is not supported for such parameter usage
EXECUTE IMMEDIATE 'SELECT * FROM t1 WHERE ?' USING 0;
a
EXECUTE IMMEDIATE 'SELECT * FROM t1 HAVING ?' USING 0;
a
DROP TABLE t1;
EXECUTE IMMEDIATE 'SHOW DATABASES WHERE ?' USING DEFAULT;
ERROR HY000: Default/ignore value is not supported for such parameter usage
EXECUTE IMMEDIATE 'SHOW DATABASES WHERE ?' USING 0;
Database
#
# End of 10.2 tests
#
17 changes: 17 additions & 0 deletions mysql-test/main/ps.test
Original file line number Diff line number Diff line change
Expand Up @@ -4922,6 +4922,23 @@ drop procedure p;
drop view v1;
drop table t1;


--echo #
--echo # MDEV-22591 Debug build crashes on EXECUTE IMMEDIATE '... WHERE ?' USING IGNORE
--echo #

CREATE TABLE t1 (a INT);
--error ER_INVALID_DEFAULT_PARAM
EXECUTE IMMEDIATE 'SELECT * FROM t1 WHERE ?' USING IGNORE;
--error ER_INVALID_DEFAULT_PARAM
EXECUTE IMMEDIATE 'SELECT * FROM t1 HAVING ?' USING IGNORE;
EXECUTE IMMEDIATE 'SELECT * FROM t1 WHERE ?' USING 0;
EXECUTE IMMEDIATE 'SELECT * FROM t1 HAVING ?' USING 0;
DROP TABLE t1;
--error ER_INVALID_DEFAULT_PARAM
EXECUTE IMMEDIATE 'SHOW DATABASES WHERE ?' USING DEFAULT;
EXECUTE IMMEDIATE 'SHOW DATABASES WHERE ?' USING 0;

--echo #
--echo # End of 10.2 tests
--echo #
20 changes: 20 additions & 0 deletions mysql-test/main/sp2.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE DATABASE test1;
CREATE PROCEDURE test1.sp3() BEGIN END;
SHOW PROCEDURE STATUS;
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
mtr add_suppression PROCEDURE root@localhost # # DEFINER utf8 utf8_general_ci latin1_swedish_ci
mtr check_testcase PROCEDURE root@localhost # # DEFINER utf8 utf8_general_ci latin1_swedish_ci
mtr check_warnings PROCEDURE root@localhost # # DEFINER utf8 utf8_general_ci latin1_swedish_ci
mysql AddGeometryColumn PROCEDURE root@localhost # # INVOKER latin1 latin1_swedish_ci latin1_swedish_ci
mysql DropGeometryColumn PROCEDURE root@localhost # # INVOKER latin1 latin1_swedish_ci latin1_swedish_ci
test sp2 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
test1 sp1 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
test1 sp3 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE sp2;
DROP DATABASE test1;
select count(*) from mysql.event;
count(*)
416
flush tables;
show events;
truncate table mysql.event;
37 changes: 37 additions & 0 deletions mysql-test/main/sp2.test

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_frag.result
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SET @binlog_fragment_0='012345';
BINLOG @binlog_fragment_0, @binlog_fragment_not_exist;
ERROR 42000: Incorrect argument type to variable 'binlog_fragment_not_exist'
SET @a= '42';
BINLOG @a, @a;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
# Cleanup
DROP TABLE t;
5 changes: 5 additions & 0 deletions mysql-test/suite/binlog/t/binlog_mysqlbinlog_row_frag.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ SET @binlog_fragment_0='012345';
--error ER_WRONG_TYPE_FOR_VAR
BINLOG @binlog_fragment_0, @binlog_fragment_not_exist;

# MDEV-22520
SET @a= '42';
--error ER_SYNTAX_ERROR
BINLOG @a, @a;

--echo # Cleanup
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.sql
DROP TABLE t;
1 change: 0 additions & 1 deletion sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -3571,7 +3571,6 @@ class Item_param :public Item_basic_value,

enum Type type() const
{
DBUG_ASSERT(fixed || state == NO_VALUE);
return item_type;
}

Expand Down
3 changes: 2 additions & 1 deletion sql/sql_binlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ int binlog_defragment(THD *thd)
memcpy(const_cast<char*>(thd->lex->comment.str) + gathered_length, entry[k]->value,
entry[k]->length);
gathered_length += entry[k]->length;
update_hash(entry[k], true, NULL, 0, STRING_RESULT, &my_charset_bin, 0);
}
for (uint k=0; k < 2; k++)
update_hash(entry[k], true, NULL, 0, STRING_RESULT, &my_charset_bin, 0);

DBUG_ASSERT(gathered_length == thd->lex->comment.length);

Expand Down
4 changes: 3 additions & 1 deletion storage/innobase/dict/dict0dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ void dict_index_remove_from_v_col_list(dict_index_t* index)

for (ulint i = 0; i < dict_index_get_n_fields(index); i++) {
col = dict_index_get_nth_col(index, i);
if (col->is_virtual()) {
if (col && col->is_virtual()) {
vcol = reinterpret_cast<const dict_v_col_t*>(
col);
/* This could be NULL, when we do add
Expand Down Expand Up @@ -2319,7 +2319,9 @@ dict_index_remove_from_cache_low(
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(table->id);
#ifdef BTR_CUR_HASH_ADAPT
ut_ad(!index->freed());
#endif /* BTR_CUR_HASH_ADAPT */

/* No need to acquire the dict_index_t::lock here because
there can't be any active operations on this index (or table). */
Expand Down
16 changes: 6 additions & 10 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,12 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
@return whether the table will be rebuilt */
bool need_rebuild () const { return(old_table != new_table); }

/** Clear uncommmitted added indexes after a failed operation. */
void clear_added_indexes()
{
for (ulint i = 0; i < num_to_add_index; i++) {
if (!add_index[i]->is_committed()) {
add_index[i]->detach_columns();
add_index[i]->n_fields = 0;
}
}
}
/** Clear uncommmitted added indexes after a failed operation. */
void clear_added_indexes()
{
for (ulint i= 0; i < num_to_add_index; i++)
add_index[i]->detach_columns(true);
}

/** Convert table-rebuilding ALTER to instant ALTER. */
void prepare_instant()
Expand Down
190 changes: 99 additions & 91 deletions storage/innobase/include/dict0mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,71 +574,72 @@ struct dict_col_t{
3072 (REC_VERSION_56_MAX_INDEX_COL_LEN)
bytes. */

/** Detach the column from an index.
@param[in] index index to be detached from */
inline void detach(const dict_index_t& index);

/** Data for instantly added columns */
struct def_t {
/** original default value of instantly added column */
const void* data;
/** len of data, or UNIV_SQL_DEFAULT if unavailable */
ulint len;
} def_val;

/** Retrieve the column name.
@param[in] table the table of this column */
const char* name(const dict_table_t& table) const;

/** @return whether this is a virtual column */
bool is_virtual() const { return prtype & DATA_VIRTUAL; }
/** @return whether NULL is an allowed value for this column */
bool is_nullable() const { return !(prtype & DATA_NOT_NULL); }

/** @return whether table of this system field is TRX_ID-based */
bool vers_native() const
{
ut_ad(vers_sys_start() || vers_sys_end());
ut_ad(mtype == DATA_INT || mtype == DATA_FIXBINARY);
return mtype == DATA_INT;
}
/** @return whether this is system versioned */
bool is_versioned() const { return !(~prtype & DATA_VERSIONED); }
/** @return whether this is the system version start */
bool vers_sys_start() const
{
return (prtype & DATA_VERSIONED) == DATA_VERS_START;
}
/** @return whether this is the system version end */
bool vers_sys_end() const
{
return (prtype & DATA_VERSIONED) == DATA_VERS_END;
}

/** @return whether this is an instantly-added column */
bool is_instant() const
{
DBUG_ASSERT(def_val.len != UNIV_SQL_DEFAULT || !def_val.data);
return def_val.len != UNIV_SQL_DEFAULT;
}
/** Get the default value of an instantly-added column.
@param[out] len value length (in bytes), or UNIV_SQL_NULL
@return default value
@retval NULL if the default value is SQL NULL (len=UNIV_SQL_NULL) */
const byte* instant_value(ulint* len) const
{
DBUG_ASSERT(is_instant());
*len = def_val.len;
return static_cast<const byte*>(def_val.data);
}

/** Remove the 'instant ADD' status of the column */
void remove_instant()
{
DBUG_ASSERT(is_instant());
def_val.len = UNIV_SQL_DEFAULT;
def_val.data = NULL;
}
/** Detach a virtual column from an index.
@param index being-freed index */
inline void detach(const dict_index_t &index);

/** Data for instantly added columns */
struct def_t
{
/** original default value of instantly added column */
const void *data;
/** len of data, or UNIV_SQL_DEFAULT if unavailable */
ulint len;
} def_val;

/** Retrieve the column name.
@param[in] table the table of this column */
const char *name(const dict_table_t &table) const;

/** @return whether this is a virtual column */
bool is_virtual() const { return prtype & DATA_VIRTUAL; }
/** @return whether NULL is an allowed value for this column */
bool is_nullable() const { return !(prtype & DATA_NOT_NULL); }

/** @return whether table of this system field is TRX_ID-based */
bool vers_native() const
{
ut_ad(vers_sys_start() || vers_sys_end());
ut_ad(mtype == DATA_INT || mtype == DATA_FIXBINARY);
return mtype == DATA_INT;
}
/** @return whether this is system versioned */
bool is_versioned() const { return !(~prtype & DATA_VERSIONED); }
/** @return whether this is the system version start */
bool vers_sys_start() const
{
return (prtype & DATA_VERSIONED) == DATA_VERS_START;
}
/** @return whether this is the system version end */
bool vers_sys_end() const
{
return (prtype & DATA_VERSIONED) == DATA_VERS_END;
}

/** @return whether this is an instantly-added column */
bool is_instant() const
{
DBUG_ASSERT(def_val.len != UNIV_SQL_DEFAULT || !def_val.data);
return def_val.len != UNIV_SQL_DEFAULT;
}
/** Get the default value of an instantly-added column.
@param[out] len value length (in bytes), or UNIV_SQL_NULL
@return default value
@retval NULL if the default value is SQL NULL (len=UNIV_SQL_NULL) */
const byte *instant_value(ulint *len) const
{
DBUG_ASSERT(is_instant());
*len= def_val.len;
return static_cast<const byte*>(def_val.data);
}

/** Remove the 'instant ADD' status of the column */
void remove_instant()
{
DBUG_ASSERT(is_instant());
def_val.len= UNIV_SQL_DEFAULT;
def_val.data= NULL;
}
};

/** Index information put in a list of virtual column structure. Index
Expand Down Expand Up @@ -1046,15 +1047,22 @@ struct dict_index_t{
/** @return whether the index is corrupted */
inline bool is_corrupted() const;

/** Detach the columns from the index that is to be freed. */
void detach_columns()
{
if (has_virtual()) {
for (unsigned i = 0; i < n_fields; i++) {
fields[i].col->detach(*this);
}
}
}
/** Detach the virtual columns from the index that is to be removed.
@param whether to reset fields[].col */
void detach_columns(bool clear= false)
{
if (!has_virtual())
return;
for (unsigned i= 0; i < n_fields; i++)
{
dict_col_t* col= fields[i].col;
if (!col || !col->is_virtual())
continue;
col->detach(*this);
if (clear)
fields[i].col= NULL;
}
}

/** Determine how many fields of a given prefix can be set NULL.
@param[in] n_prefix number of fields in the prefix
Expand Down Expand Up @@ -1194,24 +1202,24 @@ struct dict_index_t{
inline record_size_info_t record_size_info() const;
};

/** Detach a column from an index.
@param[in] index index to be detached from */
inline void dict_col_t::detach(const dict_index_t& index)
/** Detach a virtual column from an index.
@param index being-freed index */
inline void dict_col_t::detach(const dict_index_t &index)
{
if (!is_virtual()) {
return;
}

if (dict_v_idx_list* v_indexes = reinterpret_cast<const dict_v_col_t*>
(this)->v_indexes) {
for (dict_v_idx_list::iterator i = v_indexes->begin();
i != v_indexes->end(); i++) {
if (i->index == &index) {
v_indexes->erase(i);
return;
}
}
}
ut_ad(is_virtual());

if (dict_v_idx_list *v_indexes= reinterpret_cast<const dict_v_col_t*>(this)
->v_indexes)
{
for (dict_v_idx_list::iterator i= v_indexes->begin();
i != v_indexes->end(); i++)
{
if (i->index == &index) {
v_indexes->erase(i);
return;
}
}
}
}

/** The status of online index creation */
Expand Down
8 changes: 8 additions & 0 deletions storage/innobase/include/ut0ut.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ class error : public logger {
public:
ATTRIBUTE_COLD
~error();
/** Indicates that error::~error() was invoked. Can be used to
determine if error messages were logged during innodb code execution.
@return true if there were error messages, false otherwise. */
static bool was_logged() { return logged; }

private:
/** true if error::~error() was invoked, false otherwise */
static bool logged;
};

/** The class fatal is used to emit an error message and stop the server
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/lock/lock0lock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6314,7 +6314,7 @@ static my_bool lock_table_locks_lookup(rw_trx_hash_element_t *element,
ut_ad(lock->trx == element->trx);
if (lock_get_type_low(lock) == LOCK_REC)
{
ut_ad(!dict_index_is_online_ddl(lock->index) ||
ut_ad(lock->index->online_status != ONLINE_INDEX_CREATION ||
lock->index->is_primary());
ut_ad(lock->index->table != table);
}
Expand Down
Loading

0 comments on commit 79ed33c

Please sign in to comment.