From 3df297271a02ef13babae6ff6a7e47a6bdb7d538 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 15 May 2020 20:16:58 +0400 Subject: [PATCH 1/9] MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column The code erroneously allowed both: INSERT INTO t1 (vcol) VALUES (DEFAULT); INSERT INTO t1 (vcol) VALUES (DEFAULT(non_virtual_column)); The former is OK, but the latter is not. Adding a new virtual method in Item: virtual bool vcol_assignment_allowed_value() const { return false; } Item_null, Item_param and Item_default_value override it. Item_default_value overrides it in the way to: - allow DEFAULT - disallow DEFAULT(col) --- mysql-test/suite/vcol/r/vcol_misc.result | 20 ++++++++++++++++ mysql-test/suite/vcol/t/vcol_misc.test | 30 ++++++++++++++++++++++++ sql/item.h | 11 +++++++++ sql/sql_base.cc | 6 ++--- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index 5e84a314b38..abbd73cead6 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -409,5 +409,25 @@ aaa Warnings: Warning 1918 Encountered illegal value '\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7' when converting to DOUBLE # +# MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column +# +SET sql_mode=STRICT_ALL_TABLES; +CREATE OR REPLACE TABLE t1 ( +a INT NOT NULL DEFAULT 10, +b INT AS (a+1) VIRTUAL +) ENGINE=MyISAM; +INSERT INTO t1 (b) VALUES (10); +ERROR HY000: The value specified for computed column 'b' in table 't1' has been ignored +INSERT INTO t1 (b) VALUES (DEFAULT(a)); +ERROR HY000: The value specified for computed column 'b' in table 't1' has been ignored +INSERT INTO t1 (b) VALUES (DEFAULT); +INSERT INTO t1 VALUES (10,10); +ERROR HY000: The value specified for computed column 'b' in table 't1' has been ignored +INSERT INTO t1 VALUES (10,DEFAULT(a)); +ERROR HY000: The value specified for computed column 'b' in table 't1' has been ignored +INSERT INTO t1 VALUES (10, DEFAULT); +DROP TABLE t1; +SET sql_mode=DEFAULT; +# # End of 10.1 tests # diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test index d753f4c09cf..9440cc533f8 100644 --- a/mysql-test/suite/vcol/t/vcol_misc.test +++ b/mysql-test/suite/vcol/t/vcol_misc.test @@ -365,6 +365,36 @@ SELECT COLUMN_GET(@aaa, 'price' AS DECIMAL) aaa; SELECT COLUMN_GET(@aaa, 'price' AS INT) aaa; SELECT COLUMN_GET(@aaa, 'price' AS DOUBLE) aaa; + +--echo # +--echo # MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column +--echo # + +SET sql_mode=STRICT_ALL_TABLES; +CREATE OR REPLACE TABLE t1 ( + a INT NOT NULL DEFAULT 10, + b INT AS (a+1) VIRTUAL +) ENGINE=MyISAM; + +# Testing with a column list + +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN +INSERT INTO t1 (b) VALUES (10); +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN +INSERT INTO t1 (b) VALUES (DEFAULT(a)); +INSERT INTO t1 (b) VALUES (DEFAULT); + +# Testing without a column list +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN +INSERT INTO t1 VALUES (10,10); +--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN +INSERT INTO t1 VALUES (10,DEFAULT(a)); +INSERT INTO t1 VALUES (10, DEFAULT); + +DROP TABLE t1; +SET sql_mode=DEFAULT; + + --echo # --echo # End of 10.1 tests --echo # diff --git a/sql/item.h b/sql/item.h index 8a90d99db9d..bf1087e7e6e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1128,6 +1128,13 @@ public: a constant expression. Used in the optimizer to propagate basic constants. */ virtual bool basic_const_item() const { return 0; } + /* + Determines if the expression is allowed as + a virtual column assignment source: + INSERT INTO t1 (vcol) VALUES (10) -> error + INSERT INTO t1 (vcol) VALUES (NULL) -> ok + */ + virtual bool vcol_assignment_allowed_value() const { return false; } /* cloning of constant items (0 if it is not const) */ virtual Item *clone_item(THD *thd) { return 0; } virtual cond_result eq_cmp_result() const { return COND_OK; } @@ -2626,6 +2633,7 @@ public: collation.set(cs, DERIVATION_IGNORABLE, MY_REPERTOIRE_ASCII); } enum Type type() const { return NULL_ITEM; } + bool vcol_assignment_allowed_value() const { return true; } bool eq(const Item *item, bool binary_cmp) const { return null_eq(item); } double val_real(); longlong val_int(); @@ -2699,6 +2707,8 @@ public: DECIMAL_VALUE } state; + bool vcol_assignment_allowed_value() const { return state == NULL_VALUE; } + /* A buffer for string and long data values. Historically all allocated values returned from val_str() were treated as eligible to @@ -4837,6 +4847,7 @@ public: (const char *)NULL), arg(a) {} enum Type type() const { return DEFAULT_VALUE_ITEM; } + bool vcol_assignment_allowed_value() const { return arg == NULL; } bool eq(const Item *item, bool binary_cmp) const; bool fix_fields(THD *, Item **); virtual void print(String *str, enum_query_type query_type); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c092faa986b..3533c241fbc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8889,8 +8889,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, rfield->field_index == table->next_number_field->field_index) table->auto_increment_field_not_null= TRUE; if (rfield->vcol_info && - value->type() != Item::DEFAULT_VALUE_ITEM && - value->type() != Item::NULL_ITEM && + !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, @@ -9098,8 +9097,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List &values, if (field->field_index == autoinc_index) table->auto_increment_field_not_null= TRUE; if (field->vcol_info && - value->type() != Item::DEFAULT_VALUE_ITEM && - value->type() != Item::NULL_ITEM && + !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, From 4f26aea51b22eaf65a44d5f4d8587d2060953d35 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Sun, 17 May 2020 11:42:50 +0530 Subject: [PATCH 2/9] MDEV-21269 Parallel merging of fts index rebuild fails Problem: ======= - During alter rebuild, document read from old table is tokenzied parallelly by innodb_ft_sort_pll_degree threads and stores it in respective merge files. While doing the parallel merge, InnoDB wrongly skips the root level selection of merging buffer records. So it leads to insertion of merge records in non-ascending order. Solution: ========== Build selection tree for the root level also. So that root of selection tree can always contain sorted buffer. --- storage/innobase/row/row0ftsort.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index ec65f295e7f..874854c2da9 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1528,10 +1528,11 @@ row_fts_build_sel_tree( sel_tree[i + start] = int(i); } - for (i = treelevel; --i; ) { + i = treelevel; + do { row_fts_build_sel_tree_level( - sel_tree, i, mrec, offsets, index); - } + sel_tree, --i, mrec, offsets, index); + } while (i > 0); return(treelevel); } From 9ddeccc299112864d98ced1b0415c086b7d98a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 5 Apr 2020 18:55:15 +0300 Subject: [PATCH 3/9] Travis-CI: Add missing build dependency dh-exec Backported from 30b44aaec7120f41ee1383536730947cfa427308. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8f21dc4d337..c2edb30e9c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,7 @@ matrix: - cmake - debhelper - dh-apparmor + - dh-exec - dpatch - gdb - libaio-dev From 8d056affd86dcfa0546b4eb2ce133812871b2bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 5 Apr 2020 23:55:23 +0300 Subject: [PATCH 4/9] Travis-CI: Shorten deb build log to keep it under 4 MB There is a 4 MB hard limit on Travis-CI and build output needs to be less than that. Silencing the 'make install' step gets rid of a lot of "Installing.." and "Missing.." and removing all mysql-test files will make the dh_missing warnings much shorter. Cherry-picked from 41952c85f1644690249ce624de7609cbebb93638. --- debian/rules | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index 647c73e43e0..809911d4179 100755 --- a/debian/rules +++ b/debian/rules @@ -121,8 +121,13 @@ endif cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.2.mariadb.service cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server-10.2.mariadb@.service - # make install - cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(TMP) + # Run 'make install' without output since it is uninteresting and + # silencing it helps to make overall build log shorter and more readable + @echo "Running $(MAKE) install DESTDIR=$(TMP) ..." + cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(TMP) > /dev/null + + # If mariadb-test package is removed, also remove most of it's files + grep --quiet "Package: mariadb-test" debian/control || rm -rf $(TMP)/usr/share/mysql/mysql-test # Delete runnable files we don't want to have in the test data package. # This avoids triggering multiple Lintian errors. From c995090a537b79b4ab92e7cae0f74560325965d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 17 May 2020 15:52:35 +0300 Subject: [PATCH 5/9] Travis-CI: Remove builds that always fail to make CI useful again Also clean away dead code that is not used and will never have any use on the 10.2 branch. --- .travis.yml | 70 +++-------------------------------------------------- 1 file changed, 4 insertions(+), 66 deletions(-) diff --git a/.travis.yml b/.travis.yml index c2edb30e9c1..d38ba46b971 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,8 @@ git: depth: 2 language: cpp -os: - - linux - - osx -osx_image: xcode9.1 +os: linux + compiler: - gcc - clang @@ -19,15 +17,9 @@ compiler: cache: apt: true ccache: true - directories: - - /usr/local/Cellar env: matrix: -# - GCC_VERSION=4.8 TYPE=Debug MYSQL_TEST_SUITES=rpl -# - GCC_VERSION=5 TYPE=Debug MYSQL_TEST_SUITES=main,archive,optimizer_unfixed_bugs,parts,sys_vars,unit,vcol,innodb,innodb_gis,innodb_zip,innodb_fts -# - GCC_VERSION=6 TYPE=Debug MYSQL_TEST_SUITES=binlog,binlog_encryption,encryption,rocksdb -# - GCC_VERSION=6 TYPE=Debug MYSQL_TEST_SUITES=csv,federated,funcs_1,funcs_2,gcol,handler,heap,json,maria,percona,perfschema,plugins,multi_source,roles - GCC_VERSION=4.8 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=rpl - GCC_VERSION=5 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main,archive,optimizer_unfixed_bugs,parts,sys_vars,unit,vcol,innodb,innodb_gis,innodb_zip,innodb_fts - GCC_VERSION=6 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=binlog,binlog_encryption,encryption,rocksdb @@ -35,8 +27,8 @@ env: matrix: exclude: - - os: osx - compiler: gcc + - compiler: clang + env: GCC_VERSION=5 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main,archive,optimizer_unfixed_bugs,parts,sys_vars,unit,vcol,innodb,innodb_gis,innodb_zip,innodb_fts include: - os: linux compiler: gcc @@ -87,51 +79,6 @@ matrix: - export MTR_MEM=/tmp - env DEB_BUILD_OPTIONS="parallel=6" debian/autobake-deb.sh; - ccache --show-stats - # Until OSX becomes a bit more stable: MDEV-12435 - allow_failures: - - os: osx - compiler: clang - env: GCC_VERSION=4.8 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=rpl - - os: osx - compiler: clang - env: GCC_VERSION=5 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main,archive,optimizer_unfixed_bugs,parts,sys_vars,unit,vcol,innodb,innodb_gis,innodb_zip,innodb_fts - - os: osx - compiler: clang - env: GCC_VERSION=6 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=binlog,binlog_encryption,encryption,rocksdb - - os: osx - compiler: clang - env: GCC_VERSION=6 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=csv,federated,funcs_1,funcs_2,gcol,handler,heap,json,maria,percona,perfschema,plugins,multi_source,roles - -# Matrix include for coverity -# - env: -# - GCC_VERSION=6 -# addon: -# coverity_scan: -# # ref: https://scan.coverity.com/travis_ci -# # GitHub project metadata -# project: -# - name: MariaDB/server -# - description: MariaDB Server -# -# # Where email notification of build analysis results will be sent -# notification_email: security@mariadb.org -# -# # Commands to prepare for build_command -# build_command_prepend: -# - source .travis.compiler.sh -# - ${MYSQL_BUILD_CC} --version ; ${MYSQL_BUILD_CXX} --version -# - cmake . -# -DCMAKE_BUILD_TYPE=Debug -# -DWITH_SSL=system -DWITH_ZLIB=system -# -DWITHOUT_TOKUDB_STORAGE_ENGINE=ON -DWITHOUT_MROONGA_STORAGE_ENGINE=ON -# -# # The command that will be added as an argument to "cov-build" to compile your project for analysis, -# build_command: make -j 4 -# -# # Pattern to match selecting branches that will run analysis. -# # Take care in resource usage, and consider the build frequency allowances per -# # https://scan.coverity.com/faq#frequency - 7 per week is the current limit. -# branch_pattern: .*coverity.* addons: apt: @@ -178,15 +125,6 @@ addons: - libzmq-dev - uuid-dev -# libsystemd-daemon-dev # https://github.com/travis-ci/apt-package-whitelist/issues/3882 - -before_install: - - if [[ "${TRAVIS_OS_NAME}" == 'osx' ]]; then - brew update; - brew install gnutls lz4 lzo xz snappy ccache jemalloc curl ossp-uuid pcre; - brew link ccache; - fi - script: - ccache --version # Clang: From 7baa40dffae4c8175913ab58d320684f1d5f1bad Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 18 May 2020 16:37:51 +1000 Subject: [PATCH 6/9] MDEV-21976: mtr main.udf - broaden localhost (#1543) Localhost, depending on the platform can return any 127.0.0.1/8 address. --- mysql-test/r/udf.result | 6 +++--- mysql-test/t/udf.test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index bcfc9941db9..c74b89a1b96 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -30,9 +30,9 @@ lookup("127.0.0.1") 127.0.0.1 select lookup(127,0,0,1); ERROR HY000: Can't initialize function 'lookup'; Wrong arguments to lookup; Use the source -select lookup("localhost"); -lookup("localhost") -127.0.0.1 +select lookup("localhost") rlike '^127\.\\d+\.\\d+.\\d+$'; +lookup("localhost") rlike '^127\.\\d+\.\\d+.\\d+$' +1 select reverse_lookup(); ERROR HY000: Can't initialize function 'reverse_lookup'; Wrong number of arguments to reverse_lookup; Use the source select reverse_lookup("127.0.0.1"); diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 4ee412f80d8..e9ba8e941e3 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -47,7 +47,7 @@ select lookup(); select lookup("127.0.0.1"); --error ER_CANT_INITIALIZE_UDF select lookup(127,0,0,1); -select lookup("localhost"); +select lookup("localhost") rlike '^127\.\\d+\.\\d+.\\d+$'; --error ER_CANT_INITIALIZE_UDF select reverse_lookup(); From f9d8571f383c820accbca662cc4f850f5d29c98c Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 15 May 2020 18:35:19 +0200 Subject: [PATCH 7/9] MDEV-22554: galera_sst_mariabackup fails with "Failed to start mysqld.2" The problem is caused by the operation of netcat streamer and does not appear on systems where socat is installed. We need to add the "-N" option for netcat to call shutdown() on the socket when receiving EOF from STDIN. --- scripts/wsrep_sst_mariabackup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 4eb9917d341..1d6aedfb8eb 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -202,7 +202,11 @@ get_transfer() tcmd="nc ${REMOTEIP} ${TSST_PORT}" elif nc -h 2>&1 | grep -q -- '-d\>';then # Debian netcat - tcmd="nc ${REMOTEIP} ${TSST_PORT}" + if nc -h 2>&1 | grep -q -- '-N\>';then + tcmd="nc -N ${REMOTEIP} ${TSST_PORT}" + else + tcmd="nc ${REMOTEIP} ${TSST_PORT}" + fi else # traditional netcat tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}" From e0ddb077d95baac131e9ac8a701b8f9ff625b1a8 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 15 May 2020 18:35:19 +0200 Subject: [PATCH 8/9] MDEV-22554: galera_sst_mariabackup fails with "Failed to start mysqld.2" The problem is caused by the operation of netcat streamer and does not appear on systems where socat is installed. We need to add the "-N" option for netcat to call shutdown() on the socket when receiving EOF from STDIN. --- scripts/wsrep_sst_mariabackup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 799276258f2..9aadcc0bc9b 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -201,7 +201,11 @@ get_transfer() tcmd="nc ${REMOTEIP} ${TSST_PORT}" elif nc -h 2>&1 | grep -q -- '-d\>';then # Debian netcat - tcmd="nc ${REMOTEIP} ${TSST_PORT}" + if nc -h 2>&1 | grep -q -- '-N\>';then + tcmd="nc -N ${REMOTEIP} ${TSST_PORT}" + else + tcmd="nc ${REMOTEIP} ${TSST_PORT}" + fi else # traditional netcat tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}" From 5b6bcb59ac7791cf99caf683fb131b7be4b02341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 18 May 2020 14:04:31 +0300 Subject: [PATCH 9/9] MDEV-22611 Assertion btr_search_enabled failed during buffer pool resizing In commit ad6171b91cac33e70bb28fa6865488b2c65e858c (MDEV-22456) we removed the acquisition of the adaptive hash index latch from the caller of btr_search_update_hash_ref(). The tests innodb.innodb_buffer_pool_resize_with_chunks and innodb.innodb_buffer_pool_resize would occasionally fail starting with 10.3, due to MDEV-12288 causing more purge activity during the test. btr_search_update_hash_ref(): After acquiring the adaptive hash index latch, check that the adaptive hash index is still enabled on the page. --- storage/innobase/btr/btr0sea.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index f1075358ad2..76aabf287c0 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -648,7 +648,7 @@ btr_search_update_hash_ref( dict_index_t* index = block->index; - if (!index) { + if (!index || !info->n_hash_potential) { return; } @@ -657,8 +657,9 @@ btr_search_update_hash_ref( ut_ad(!dict_index_is_ibuf(index)); rw_lock_t* const latch = btr_get_search_latch(index); rw_lock_x_lock(latch); + ut_ad(!block->index || block->index == index); - if ((info->n_hash_potential > 0) + if (block->index && (block->curr_n_fields == info->n_fields) && (block->curr_n_bytes == info->n_bytes) && (block->curr_left_side == info->left_side)) {