diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-08-26 15:28:32 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-09-03 05:34:53 +0400 |
commit | dc719597ee0b11da722e9813639e8b48018a8c10 (patch) | |
tree | 548b53ee953557ddf6f88191b9e6cf70f74c96a2 /sql/sql_mode.cc | |
parent | 0d6635822094a424f19e753aa24a8424d449dd6a (diff) | |
download | mariadb-git-dc719597ee0b11da722e9813639e8b48018a8c10.tar.gz |
MDEV-18156 Assertion `0' failed or `btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with PAD_CHAR_TO_FULL_LENGTH
This change takes into account a column's GENERATED ALWAYS AS
expression dependcy on sql_mode's PAD_CHAR_TO_FULL_LENGTH and
NO_UNSIGNED_SUBTRACTION flags.
Indexed virtual columns as well as persistent generated columns are
now not allowed to have such dependencies to avoid inconsistent data
or index files on sql_mode changes.
So an error is now returned in cases like this:
CREATE OR REPLACE TABLE t1
(
a CHAR(5),
v VARCHAR(5) AS (a) PERSISTENT -- CHAR->VARCHAR or CHAR->TEXT = ERROR
);
Functions RPAD() and RTRIM() can now remove dependency on
PAD_CHAR_TO_FULL_LENGTH. So this can be used instead:
CREATE OR REPLACE TABLE t1
(
a CHAR(5),
v VARCHAR(5) AS (RTRIM(a)) PERSISTENT
);
Note, unlike CHAR->VARCHAR and CHAR->TEXT this still works,
not RPAD(a) is needed:
CREATE OR REPLACE TABLE t1
(
a CHAR(5),
v CHAR(5) AS (a) PERSISTENT -- CHAR->CHAR is OK
);
More sql_mode flags may affect values of generated columns.
They will be addressed separately.
See comments in sql_mode.h for implementation details.
Diffstat (limited to 'sql/sql_mode.cc')
-rw-r--r-- | sql/sql_mode.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/sql_mode.cc b/sql/sql_mode.cc new file mode 100644 index 00000000000..9eea6ccdb52 --- /dev/null +++ b/sql/sql_mode.cc @@ -0,0 +1,34 @@ +/* + Copyright (c) 2019, MariaDB. + + 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 Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include "mysqld.h" +#include "set_var.h" + +void Sql_mode_dependency::push_dependency_warnings(THD *thd) +{ + sql_mode_t all= m_hard | m_soft; + for (uint i= 0; all ; i++, all >>= 1) + { + if (all & 1) + { + // TODO-10.5: add a new error code + push_warning_printf(thd, + Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, + "Expression depends on the @@%s value %s", + "sql_mode", sql_mode_string_representation(i)); + } + } +} |