Skip to content

Commit f404911

Browse files
committed
Merge 10.3 into 10.4
2 parents 2aab7f2 + 1f56153 commit f404911

File tree

16 files changed

+204
-26
lines changed

16 files changed

+204
-26
lines changed

libmysqld/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,23 @@ ${SSL_INTERNAL_INCLUDE_DIRS}
2929
)
3030

3131
SET(GEN_SOURCES
32-
${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
32+
${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
3333
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
3434
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh
3535
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc
36-
${CMAKE_BINARY_DIR}/sql/lex_hash.h
36+
${CMAKE_BINARY_DIR}/sql/lex_hash.h
3737
)
3838

3939
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)
4040

41+
IF(CMAKE_C_COMPILER_ID MATCHES "Clang" AND
42+
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.0.0")
43+
ADD_COMPILE_FLAGS(
44+
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
45+
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc
46+
COMPILE_FLAGS "-Wno-unused-but-set-variable")
47+
ENDIF()
48+
4149
SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
4250
libmysql.c ../sql-common/errmsg.c
4351
../sql-common/client.c

mysql-test/suite/gcol/r/innodb_virtual_index.result

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
SET default_storage_engine= innodb;
12
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
23
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
34
#
@@ -248,12 +249,15 @@ ENGINE=InnoDB;
248249
INSERT IGNORE INTO t1 (a,b) VALUES(1,20190132);
249250
Warnings:
250251
Warning 1265 Data truncated for column 'vb' at row 1
252+
SELECT * FROM t1;
253+
a b vb
254+
1 20190132 0000-00-00
251255
BEGIN;
252256
DELETE FROM t1;
253257
INSERT INTO t1 (a,b) VALUES(1,20190123);
254-
ERROR 22007: Incorrect date value: '20190132' for column `test`.`t1`.`vb` at row 1
255258
SELECT * FROM t1;
256259
a b vb
260+
1 20190123 2019-01-23
257261
ROLLBACK;
258262
SELECT * FROM t1;
259263
a b vb
@@ -310,3 +314,62 @@ ALTER TABLE t1 ADD KEY (b), ALGORITHM=INPLACE;
310314
# Cleanup
311315
DROP TABLE t1;
312316
# End of 10.2 tests
317+
#
318+
# MDEV-29299 SELECT from table with vcol index reports warning
319+
#
320+
CREATE TABLE t(fld1 INT NOT NULL,
321+
fld2 INT AS (100/fld1) VIRTUAL,
322+
KEY(fld1), KEY(fld2));
323+
CREATE TABLE t_odd(id int);
324+
INSERT INTO t(fld1) VALUES(1), (2);
325+
connect stop_purge,localhost,root;
326+
START TRANSACTION WITH CONSISTENT SNAPSHOT;
327+
INSERT INTO t_odd VALUES(10000);
328+
connection default;
329+
UPDATE IGNORE t SET fld1= 3 WHERE fld1= 2;
330+
UPDATE IGNORE t SET fld1= 4 WHERE fld1= 3;
331+
UPDATE IGNORE t SET fld1= 0 WHERE fld1= 4;
332+
Warnings:
333+
Warning 1365 Division by 0
334+
SELECT fld2 FROM t FORCE INDEX(fld2);
335+
fld2
336+
NULL
337+
100
338+
SELECT fld2 FROM t FORCE INDEX(fld1);
339+
fld2
340+
100
341+
NULL
342+
Warnings:
343+
Warning 1365 Division by 0
344+
disconnect stop_purge;
345+
DROP TABLE t, t_odd;
346+
#
347+
# MDEV-29753 An error is wrongly reported during INSERT with vcol index
348+
# See also Bug #22990029
349+
#
350+
CREATE TABLE t(pk INT PRIMARY KEY,
351+
fld1 INT NOT NULL,
352+
fld2 INT AS (100/fld1) VIRTUAL,
353+
KEY(fld1), KEY(fld2));
354+
INSERT IGNORE t(pk, fld1) VALUES(1, 0);
355+
Warnings:
356+
Warning 1365 Division by 0
357+
SELECT * FROM t;
358+
pk fld1 fld2
359+
1 0 NULL
360+
Warnings:
361+
Warning 1365 Division by 0
362+
BEGIN;
363+
DELETE FROM t;
364+
Warnings:
365+
Warning 1365 Division by 0
366+
Warning 1365 Division by 0
367+
Warning 1365 Division by 0
368+
INSERT INTO t (pk, fld1) VALUES(1,1);
369+
SELECT * FROM t;
370+
pk fld1 fld2
371+
1 1 100
372+
# Cleanup
373+
ROLLBACK;
374+
DROP TABLE t;
375+
# End of 10.3 tests

mysql-test/suite/gcol/t/innodb_virtual_index.test

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
--source include/have_innodb.inc
22
--source include/have_sequence.inc
33

4+
SET default_storage_engine= innodb;
5+
46
# Ensure that the history list length will actually be decremented by purge.
57
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
68
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
@@ -273,9 +275,9 @@ DROP TABLE t1;
273275
CREATE TABLE t1(a INT PRIMARY KEY, b INT, vb DATE AS(b) VIRTUAL, KEY(vb))
274276
ENGINE=InnoDB;
275277
INSERT IGNORE INTO t1 (a,b) VALUES(1,20190132);
278+
SELECT * FROM t1;
276279
BEGIN;
277280
DELETE FROM t1;
278-
--error ER_TRUNCATED_WRONG_VALUE
279281
INSERT INTO t1 (a,b) VALUES(1,20190123);
280282
SELECT * FROM t1;
281283
ROLLBACK;
@@ -334,3 +336,49 @@ DROP TABLE t1;
334336

335337
--echo # End of 10.2 tests
336338

339+
--echo #
340+
--echo # MDEV-29299 SELECT from table with vcol index reports warning
341+
--echo #
342+
343+
CREATE TABLE t(fld1 INT NOT NULL,
344+
fld2 INT AS (100/fld1) VIRTUAL,
345+
KEY(fld1), KEY(fld2));
346+
CREATE TABLE t_odd(id int);
347+
INSERT INTO t(fld1) VALUES(1), (2);
348+
349+
--connect stop_purge,localhost,root
350+
# This prevents purge for records in t
351+
START TRANSACTION WITH CONSISTENT SNAPSHOT;
352+
INSERT INTO t_odd VALUES(10000);
353+
354+
--connection default
355+
UPDATE IGNORE t SET fld1= 3 WHERE fld1= 2;
356+
UPDATE IGNORE t SET fld1= 4 WHERE fld1= 3;
357+
UPDATE IGNORE t SET fld1= 0 WHERE fld1= 4;
358+
SELECT fld2 FROM t FORCE INDEX(fld2);
359+
SELECT fld2 FROM t FORCE INDEX(fld1);
360+
361+
--disconnect stop_purge
362+
DROP TABLE t, t_odd;
363+
364+
--echo #
365+
--echo # MDEV-29753 An error is wrongly reported during INSERT with vcol index
366+
--echo # See also Bug #22990029
367+
--echo #
368+
369+
CREATE TABLE t(pk INT PRIMARY KEY,
370+
fld1 INT NOT NULL,
371+
fld2 INT AS (100/fld1) VIRTUAL,
372+
KEY(fld1), KEY(fld2));
373+
INSERT IGNORE t(pk, fld1) VALUES(1, 0);
374+
SELECT * FROM t;
375+
BEGIN;
376+
DELETE FROM t;
377+
INSERT INTO t (pk, fld1) VALUES(1,1);
378+
SELECT * FROM t;
379+
380+
--echo # Cleanup
381+
ROLLBACK;
382+
DROP TABLE t;
383+
384+
--echo # End of 10.3 tests

sql/mysqld.cc

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,14 +3975,24 @@ static int init_common_variables()
39753975
if (ignore_db_dirs_init())
39763976
exit(1);
39773977

3978-
#ifdef _WIN32
3979-
get_win_tzname(system_time_zone, sizeof(system_time_zone));
3980-
#elif defined(HAVE_TZNAME)
39813978
struct tm tm_tmp;
3982-
localtime_r(&server_start_time,&tm_tmp);
3983-
const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
3984-
strmake_buf(system_time_zone, tz_name);
3985-
#endif /* HAVE_TZNAME */
3979+
localtime_r(&server_start_time, &tm_tmp);
3980+
3981+
#ifdef HAVE_TZNAME
3982+
#ifdef _WIN32
3983+
/*
3984+
If env.variable TZ is set, derive timezone name from it.
3985+
Otherwise, use IANA tz name from get_win_tzname.
3986+
*/
3987+
if (!getenv("TZ"))
3988+
get_win_tzname(system_time_zone, sizeof(system_time_zone));
3989+
else
3990+
#endif
3991+
{
3992+
const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
3993+
strmake_buf(system_time_zone, tz_name);
3994+
}
3995+
#endif
39863996

39873997
/*
39883998
We set SYSTEM time zone as reasonable default and

sql/sql_class.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,21 @@ class MDL_deadlock_and_lock_abort_error_handler: public Internal_error_handler
18781878
};
18791879

18801880

1881+
struct Suppress_warnings_error_handler : public Internal_error_handler
1882+
{
1883+
bool handle_condition(THD *thd,
1884+
uint sql_errno,
1885+
const char *sqlstate,
1886+
Sql_condition::enum_warning_level *level,
1887+
const char *msg,
1888+
Sql_condition **cond_hdl)
1889+
{
1890+
return *level == Sql_condition::WARN_LEVEL_WARN;
1891+
}
1892+
};
1893+
1894+
1895+
18811896
/**
18821897
Tables that were locked with LOCK TABLES statement.
18831898

sql/table.cc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8614,12 +8614,28 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
86148614
DBUG_RETURN(in_use->is_error());
86158615
}
86168616

8617-
int TABLE::update_virtual_field(Field *vf)
8617+
/*
8618+
Calculate the virtual field value for a specified field.
8619+
@param vf A field to calculate
8620+
@param ignore_warnings Ignore the warnings and also make the
8621+
calculations permissive. This usually means
8622+
that a calculation is internal and is not
8623+
expected to fail.
8624+
*/
8625+
int TABLE::update_virtual_field(Field *vf, bool ignore_warnings)
86188626
{
86198627
DBUG_ENTER("TABLE::update_virtual_field");
86208628
Query_arena backup_arena;
86218629
Counting_error_handler count_errors;
8630+
Suppress_warnings_error_handler warning_handler;
86228631
in_use->push_internal_handler(&count_errors);
8632+
bool abort_on_warning;
8633+
if (ignore_warnings)
8634+
{
8635+
abort_on_warning= in_use->abort_on_warning;
8636+
in_use->abort_on_warning= false;
8637+
in_use->push_internal_handler(&warning_handler);
8638+
}
86238639
/*
86248640
TODO: this may impose memory leak until table flush.
86258641
See comment in
@@ -8633,6 +8649,13 @@ int TABLE::update_virtual_field(Field *vf)
86338649
DBUG_RESTORE_WRITE_SET(vf);
86348650
in_use->restore_active_arena(expr_arena, &backup_arena);
86358651
in_use->pop_internal_handler();
8652+
if (ignore_warnings)
8653+
{
8654+
in_use->abort_on_warning= abort_on_warning;
8655+
in_use->pop_internal_handler();
8656+
// This is an internal calculation, we expect it to always succeed
8657+
DBUG_ASSERT(count_errors.errors == 0);
8658+
}
86368659
DBUG_RETURN(count_errors.errors);
86378660
}
86388661

sql/table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ struct TABLE
16451645

16461646
uint actual_n_key_parts(KEY *keyinfo);
16471647
ulong actual_key_flags(KEY *keyinfo);
1648-
int update_virtual_field(Field *vf);
1648+
int update_virtual_field(Field *vf, bool ignore_warnings);
16491649
int update_virtual_fields(handler *h, enum_vcol_update_mode update_mode);
16501650
int update_default_fields(bool ignore_errors);
16511651
void evaluate_update_default_function();

storage/innobase/handler/ha_innodb.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20790,7 +20790,8 @@ innobase_get_computed_value(
2079020790
TABLE* mysql_table,
2079120791
byte* mysql_rec,
2079220792
const dict_table_t* old_table,
20793-
const upd_t* update)
20793+
const upd_t* update,
20794+
bool ignore_warnings)
2079420795
{
2079520796
byte rec_buf2[REC_VERSION_56_MAX_INDEX_COL_LEN];
2079620797
byte* buf;
@@ -20888,7 +20889,9 @@ innobase_get_computed_value(
2088820889

2088920890
MY_BITMAP *old_write_set = dbug_tmp_use_all_columns(mysql_table, &mysql_table->write_set);
2089020891
MY_BITMAP *old_read_set = dbug_tmp_use_all_columns(mysql_table, &mysql_table->read_set);
20891-
ret = mysql_table->update_virtual_field(mysql_table->field[col->m_col.ind]);
20892+
ret = mysql_table->update_virtual_field(
20893+
mysql_table->field[col->m_col.ind],
20894+
ignore_warnings);
2089220895
dbug_tmp_restore_column_map(&mysql_table->read_set, old_read_set);
2089320896
dbug_tmp_restore_column_map(&mysql_table->write_set, old_write_set);
2089420897

storage/innobase/include/row0mysql.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,9 @@ void innobase_report_computed_value_failed(dtuple_t *row);
921921
@param[in] old_table during ALTER TABLE, this is the old table
922922
or NULL.
923923
@param[in] update update vector for the parent row
924-
@param[in] foreign foreign key information
924+
@param[in] ignore_warnings ignore warnings during calculation. Usually
925+
means that a calculation is internal and
926+
should have no side effects.
925927
@return the field filled with computed value */
926928
dfield_t*
927929
innobase_get_computed_value(
@@ -934,8 +936,9 @@ innobase_get_computed_value(
934936
THD* thd,
935937
TABLE* mysql_table,
936938
byte* mysql_rec,
937-
const dict_table_t* old_table,
938-
const upd_t* update);
939+
const dict_table_t* old_table=NULL,
940+
const upd_t* update=NULL,
941+
bool ignore_warnings=false);
939942

940943
/** Get the computed value by supplying the base column values.
941944
@param[in,out] table the table whose virtual column

storage/innobase/include/row0upd.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ the equal ordering fields. NOTE: we compare the fields as binary strings!
190190
@param[in] offsets rec_get_offsets(rec,index), or NULL
191191
@param[in] no_sys skip the system columns
192192
DB_TRX_ID and DB_ROLL_PTR
193+
@param[in] ignore_warnings ignore warnings during vcol calculation, which
194+
means that this calculation is internal only
193195
@param[in] trx transaction (for diagnostics),
194196
or NULL
195197
@param[in] heap memory heap from which allocated
@@ -205,11 +207,12 @@ row_upd_build_difference_binary(
205207
const rec_t* rec,
206208
const rec_offs* offsets,
207209
bool no_sys,
210+
bool ignore_warnings,
208211
trx_t* trx,
209212
mem_heap_t* heap,
210213
TABLE* mysql_table,
211214
dberr_t* error)
212-
MY_ATTRIBUTE((nonnull(1,2,3,7,9), warn_unused_result));
215+
MY_ATTRIBUTE((nonnull(1,2,3,8,10), warn_unused_result));
213216
/** Apply an update vector to an index entry.
214217
@param[in,out] entry index entry to be updated; the clustered index record
215218
must be covered by a lock or a page latch to prevent

0 commit comments

Comments
 (0)