Skip to content

Commit

Permalink
Merge branch '10.8' into 10.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Oct 17, 2022
2 parents 069552a + f3fddc1 commit d86ad1f
Show file tree
Hide file tree
Showing 24 changed files with 233 additions and 28 deletions.
2 changes: 1 addition & 1 deletion extra/wolfssl/wolfssl
Submodule wolfssl updated 905 files
12 changes: 10 additions & 2 deletions libmysqld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ ${SSL_INTERNAL_INCLUDE_DIRS}
)

SET(GEN_SOURCES
${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
${CMAKE_BINARY_DIR}/sql/yy_mariadb.cc
${CMAKE_BINARY_DIR}/sql/yy_oracle.hh
${CMAKE_BINARY_DIR}/sql/yy_oracle.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h
${CMAKE_BINARY_DIR}/sql/lex_hash.h
)

SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)

IF(CMAKE_C_COMPILER_ID MATCHES "Clang" AND
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.0.0")
ADD_COMPILE_FLAGS(
${CMAKE_BINARY_DIR}/sql/yy_mariadb.cc
${CMAKE_BINARY_DIR}/sql/yy_oracle.cc
COMPILE_FLAGS "-Wno-unused-but-set-variable")
ENDIF()

SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
libmysql.c ../sql-common/errmsg.c
../sql-common/client.c
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/main/create_or_replace.result
Original file line number Diff line number Diff line change
Expand Up @@ -576,5 +576,8 @@ CREATE TABLE tm (a INT) ENGINE=MERGE UNION(t);
CREATE OR REPLACE TABLE t LIKE tm;
ERROR HY000: Table 'tm' is specified twice, both as a target for 'CREATE' and as a separate source for data
DROP TABLE IF EXISTS tm, t;
#
# End of 10.3 tests
#
# End of 10.4 tests
SET GLOBAL innodb_stats_persistent=@save_persistent;
4 changes: 4 additions & 0 deletions mysql-test/main/create_or_replace.test
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ CREATE OR REPLACE TABLE t LIKE tm;
# Cleanup
DROP TABLE IF EXISTS tm, t;

--echo #
--echo # End of 10.3 tests
--echo #

--echo # End of 10.4 tests

SET GLOBAL innodb_stats_persistent=@save_persistent;
1 change: 1 addition & 0 deletions mysql-test/main/kill.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# application. 'mysqltest' does not handle the kill request.
#

-- source include/count_sessions.inc
-- source include/not_embedded.inc

--disable_service_connection
Expand Down
65 changes: 64 additions & 1 deletion mysql-test/suite/gcol/r/innodb_virtual_index.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SET default_storage_engine= innodb;
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
#
Expand Down Expand Up @@ -248,12 +249,15 @@ ENGINE=InnoDB;
INSERT IGNORE INTO t1 (a,b) VALUES(1,20190132);
Warnings:
Warning 1265 Data truncated for column 'vb' at row 1
SELECT * FROM t1;
a b vb
1 20190132 0000-00-00
BEGIN;
DELETE FROM t1;
INSERT INTO t1 (a,b) VALUES(1,20190123);
ERROR 22007: Incorrect date value: '20190132' for column `test`.`t1`.`vb` at row 1
SELECT * FROM t1;
a b vb
1 20190123 2019-01-23
ROLLBACK;
SELECT * FROM t1;
a b vb
Expand Down Expand Up @@ -310,3 +314,62 @@ ALTER TABLE t1 ADD KEY (b), ALGORITHM=INPLACE;
# Cleanup
DROP TABLE t1;
# End of 10.2 tests
#
# MDEV-29299 SELECT from table with vcol index reports warning
#
CREATE TABLE t(fld1 INT NOT NULL,
fld2 INT AS (100/fld1) VIRTUAL,
KEY(fld1), KEY(fld2));
CREATE TABLE t_odd(id int);
INSERT INTO t(fld1) VALUES(1), (2);
connect stop_purge,localhost,root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
INSERT INTO t_odd VALUES(10000);
connection default;
UPDATE IGNORE t SET fld1= 3 WHERE fld1= 2;
UPDATE IGNORE t SET fld1= 4 WHERE fld1= 3;
UPDATE IGNORE t SET fld1= 0 WHERE fld1= 4;
Warnings:
Warning 1365 Division by 0
SELECT fld2 FROM t FORCE INDEX(fld2);
fld2
NULL
100
SELECT fld2 FROM t FORCE INDEX(fld1);
fld2
100
NULL
Warnings:
Warning 1365 Division by 0
disconnect stop_purge;
DROP TABLE t, t_odd;
#
# MDEV-29753 An error is wrongly reported during INSERT with vcol index
# See also Bug #22990029
#
CREATE TABLE t(pk INT PRIMARY KEY,
fld1 INT NOT NULL,
fld2 INT AS (100/fld1) VIRTUAL,
KEY(fld1), KEY(fld2));
INSERT IGNORE t(pk, fld1) VALUES(1, 0);
Warnings:
Warning 1365 Division by 0
SELECT * FROM t;
pk fld1 fld2
1 0 NULL
Warnings:
Warning 1365 Division by 0
BEGIN;
DELETE FROM t;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
INSERT INTO t (pk, fld1) VALUES(1,1);
SELECT * FROM t;
pk fld1 fld2
1 1 100
# Cleanup
ROLLBACK;
DROP TABLE t;
# End of 10.3 tests
50 changes: 49 additions & 1 deletion mysql-test/suite/gcol/t/innodb_virtual_index.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
--source include/have_innodb.inc
--source include/have_sequence.inc

SET default_storage_engine= innodb;

# Ensure that the history list length will actually be decremented by purge.
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
Expand Down Expand Up @@ -280,9 +282,9 @@ DROP TABLE t1;
CREATE TABLE t1(a INT PRIMARY KEY, b INT, vb DATE AS(b) VIRTUAL, KEY(vb))
ENGINE=InnoDB;
INSERT IGNORE INTO t1 (a,b) VALUES(1,20190132);
SELECT * FROM t1;
BEGIN;
DELETE FROM t1;
--error ER_TRUNCATED_WRONG_VALUE
INSERT INTO t1 (a,b) VALUES(1,20190123);
SELECT * FROM t1;
ROLLBACK;
Expand Down Expand Up @@ -341,3 +343,49 @@ DROP TABLE t1;

--echo # End of 10.2 tests

--echo #
--echo # MDEV-29299 SELECT from table with vcol index reports warning
--echo #

CREATE TABLE t(fld1 INT NOT NULL,
fld2 INT AS (100/fld1) VIRTUAL,
KEY(fld1), KEY(fld2));
CREATE TABLE t_odd(id int);
INSERT INTO t(fld1) VALUES(1), (2);

--connect stop_purge,localhost,root
# This prevents purge for records in t
START TRANSACTION WITH CONSISTENT SNAPSHOT;
INSERT INTO t_odd VALUES(10000);

--connection default
UPDATE IGNORE t SET fld1= 3 WHERE fld1= 2;
UPDATE IGNORE t SET fld1= 4 WHERE fld1= 3;
UPDATE IGNORE t SET fld1= 0 WHERE fld1= 4;
SELECT fld2 FROM t FORCE INDEX(fld2);
SELECT fld2 FROM t FORCE INDEX(fld1);

--disconnect stop_purge
DROP TABLE t, t_odd;

--echo #
--echo # MDEV-29753 An error is wrongly reported during INSERT with vcol index
--echo # See also Bug #22990029
--echo #

CREATE TABLE t(pk INT PRIMARY KEY,
fld1 INT NOT NULL,
fld2 INT AS (100/fld1) VIRTUAL,
KEY(fld1), KEY(fld2));
INSERT IGNORE t(pk, fld1) VALUES(1, 0);
SELECT * FROM t;
BEGIN;
DELETE FROM t;
INSERT INTO t (pk, fld1) VALUES(1,1);
SELECT * FROM t;

--echo # Cleanup
ROLLBACK;
DROP TABLE t;

--echo # End of 10.3 tests
6 changes: 6 additions & 0 deletions mysql-test/suite/json/r/json_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,12 @@ name VARCHAR(10) CHARACTER SET latin1 COLLATE DEFAULT PATH '$.name'
name
Jeans
#
# MDEV-28480: Assertion `0' failed in Item_row::illegal_method_call
# on SELECT FROM JSON_TABLE
#
SELECT 1 FROM JSON_TABLE (row(1,2), '$' COLUMNS (o FOR ORDINALITY)) AS j;
ERROR 21000: Operand should contain 1 column(s)
#
# End of 10.6 tests
#
#
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/json/t/json_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,14 @@ SELECT * FROM json_table('[{"name":"Jeans"}]', '$[*]'
) AS jt;


--echo #
--echo # MDEV-28480: Assertion `0' failed in Item_row::illegal_method_call
--echo # on SELECT FROM JSON_TABLE
--echo #

--error ER_OPERAND_COLUMNS
SELECT 1 FROM JSON_TABLE (row(1,2), '$' COLUMNS (o FOR ORDINALITY)) AS j;

--echo #
--echo # End of 10.6 tests
--echo #
Expand Down
5 changes: 5 additions & 0 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,11 @@ class Item :public Value_source,
{
return fixed() ? false : fix_fields(thd, ref);
}

/*
fix_fields_if_needed_for_scalar() is used where we need to filter items
that can't be scalars and want to return error for it.
*/
bool fix_fields_if_needed_for_scalar(THD *thd, Item **ref)
{
return fix_fields_if_needed(thd, ref) || check_cols(1);
Expand Down
2 changes: 1 addition & 1 deletion sql/json_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ bool Table_function_json_table::setup(THD *thd, TABLE_LIST *sql_table,
// fields in non_agg_field_used:
const bool saved_non_agg_field_used= s_lex->non_agg_field_used();

bool res= m_json->fix_fields_if_needed(thd, &m_json);
bool res= m_json->fix_fields_if_needed_for_scalar(thd, &m_json);

s_lex->is_item_list_lookup= save_is_item_list_lookup;
s_lex->set_non_agg_field_used(saved_non_agg_field_used);
Expand Down
24 changes: 17 additions & 7 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3905,14 +3905,24 @@ static int init_common_variables()
if (ignore_db_dirs_init())
exit(1);

#ifdef _WIN32
get_win_tzname(system_time_zone, sizeof(system_time_zone));
#elif defined(HAVE_TZNAME)
struct tm tm_tmp;
localtime_r(&server_start_time,&tm_tmp);
const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
strmake_buf(system_time_zone, tz_name);
#endif /* HAVE_TZNAME */
localtime_r(&server_start_time, &tm_tmp);

#ifdef HAVE_TZNAME
#ifdef _WIN32
/*
If env.variable TZ is set, derive timezone name from it.
Otherwise, use IANA tz name from get_win_tzname.
*/
if (!getenv("TZ"))
get_win_tzname(system_time_zone, sizeof(system_time_zone));
else
#endif
{
const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
strmake_buf(system_time_zone, tz_name);
}
#endif

/*
We set SYSTEM time zone as reasonable default and
Expand Down
15 changes: 15 additions & 0 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -2069,6 +2069,21 @@ class Turn_errors_to_warnings_handler : public Internal_error_handler
};


struct Suppress_warnings_error_handler : public Internal_error_handler
{
bool handle_condition(THD *thd,
uint sql_errno,
const char *sqlstate,
Sql_condition::enum_warning_level *level,
const char *msg,
Sql_condition **cond_hdl)
{
return *level == Sql_condition::WARN_LEVEL_WARN;
}
};



/**
Tables that were locked with LOCK TABLES statement.

Expand Down
25 changes: 24 additions & 1 deletion sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8893,12 +8893,28 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
DBUG_RETURN(in_use->is_error());
}

int TABLE::update_virtual_field(Field *vf)
/*
Calculate the virtual field value for a specified field.
@param vf A field to calculate
@param ignore_warnings Ignore the warnings and also make the
calculations permissive. This usually means
that a calculation is internal and is not
expected to fail.
*/
int TABLE::update_virtual_field(Field *vf, bool ignore_warnings)
{
DBUG_ENTER("TABLE::update_virtual_field");
Query_arena backup_arena;
Counting_error_handler count_errors;
Suppress_warnings_error_handler warning_handler;
in_use->push_internal_handler(&count_errors);
bool abort_on_warning;
if (ignore_warnings)
{
abort_on_warning= in_use->abort_on_warning;
in_use->abort_on_warning= false;
in_use->push_internal_handler(&warning_handler);
}
/*
TODO: this may impose memory leak until table flush.
See comment in
Expand All @@ -8912,6 +8928,13 @@ int TABLE::update_virtual_field(Field *vf)
DBUG_RESTORE_WRITE_SET(vf);
in_use->restore_active_arena(expr_arena, &backup_arena);
in_use->pop_internal_handler();
if (ignore_warnings)
{
in_use->abort_on_warning= abort_on_warning;
in_use->pop_internal_handler();
// This is an internal calculation, we expect it to always succeed
DBUG_ASSERT(count_errors.errors == 0);
}
DBUG_RETURN(count_errors.errors);
}

Expand Down
2 changes: 1 addition & 1 deletion sql/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ struct TABLE

uint actual_n_key_parts(KEY *keyinfo);
ulong actual_key_flags(KEY *keyinfo);
int update_virtual_field(Field *vf);
int update_virtual_field(Field *vf, bool ignore_warnings);
int update_virtual_fields(handler *h, enum_vcol_update_mode update_mode);
int update_default_fields(bool ignore_errors);
void evaluate_update_default_function();
Expand Down
7 changes: 5 additions & 2 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20225,7 +20225,8 @@ innobase_get_computed_value(
TABLE* mysql_table,
byte* mysql_rec,
const dict_table_t* old_table,
const upd_t* update)
const upd_t* update,
bool ignore_warnings)
{
byte rec_buf2[REC_VERSION_56_MAX_INDEX_COL_LEN];
byte* buf;
Expand Down Expand Up @@ -20332,7 +20333,9 @@ innobase_get_computed_value(

MY_BITMAP *old_write_set = dbug_tmp_use_all_columns(mysql_table, &mysql_table->write_set);
MY_BITMAP *old_read_set = dbug_tmp_use_all_columns(mysql_table, &mysql_table->read_set);
ret = mysql_table->update_virtual_field(mysql_table->field[col->m_col.ind]);
ret = mysql_table->update_virtual_field(
mysql_table->field[col->m_col.ind],
ignore_warnings);
dbug_tmp_restore_column_map(&mysql_table->read_set, old_read_set);
dbug_tmp_restore_column_map(&mysql_table->write_set, old_write_set);

Expand Down
Loading

0 comments on commit d86ad1f

Please sign in to comment.