diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-04-24 10:37:21 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-04-24 10:37:21 +0300 |
commit | c425d93b92acbf00f03a339c117616d2308669b6 (patch) | |
tree | b58de458933e1473a8d0701a709082be81a00079 | |
parent | e3a25793be936d9682a711a00d6b4bf708b6fb8d (diff) | |
parent | 14a18d7d7f6293ad0e106288eab4fdcb3a72ebd9 (diff) | |
download | mariadb-git-c425d93b92acbf00f03a339c117616d2308669b6.tar.gz |
Merge 10.2 into 10.3
except commit 1288dfffe77a99d6c5906d12010a1677ee149308
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | EXCEPTIONS-CLIENT | 136 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/foreign_key.result | 11 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/mvcc_secondary.result | 24 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/foreign_key.test | 39 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/mvcc_secondary.test | 26 | ||||
-rw-r--r-- | mysql-test/suite/vcol/r/vcol_syntax.result | 38 | ||||
-rw-r--r-- | mysql-test/suite/vcol/t/vcol_syntax.test | 44 | ||||
-rw-r--r-- | sql/gen_win_tzname_data.ps1 | 1 | ||||
-rw-r--r-- | sql/item.h | 36 | ||||
-rw-r--r-- | sql/sql_lex.h | 19 | ||||
-rw-r--r-- | sql/sql_table.cc | 54 | ||||
-rw-r--r-- | sql/win_tzname_data.h | 1 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 32 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 3 | ||||
-rw-r--r-- | storage/innobase/row/row0sel.cc | 94 |
16 files changed, 362 insertions, 199 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b7aa6ca5386..532b540c5b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -518,8 +518,7 @@ ADD_CUSTOM_TARGET(INFO_BIN ALL WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) -INSTALL_DOCUMENTATION(README.md CREDITS COPYING THIRDPARTY - EXCEPTIONS-CLIENT COMPONENT Readme) +INSTALL_DOCUMENTATION(README.md CREDITS COPYING THIRDPARTY COMPONENT Readme) # MDEV-6526 these files are not installed anymore #INSTALL_DOCUMENTATION(${CMAKE_BINARY_DIR}/Docs/INFO_SRC diff --git a/EXCEPTIONS-CLIENT b/EXCEPTIONS-CLIENT deleted file mode 100644 index 11ba42c422f..00000000000 --- a/EXCEPTIONS-CLIENT +++ /dev/null @@ -1,136 +0,0 @@ - FOSS License Exception - - http://www.mysql.com/about/legal/licensing/foss-exception/ - Updated February 23, 2012 - -What is the FOSS License Exception? - - Oracle's Free and Open Source Software ("FOSS") License Exception - (formerly known as the FLOSS License Exception) allows developers of FOSS - applications to include Oracle's MySQL Client Libraries (also referred to - as "MySQL Drivers" or "MySQL Connectors") with their FOSS applications. - MySQL Client Libraries are typically licensed pursuant to version 2 of the - General Public License ("GPL"), but this exception permits distribution of - certain MySQL Client Libraries with a developer's FOSS applications - licensed under the terms of another FOSS license listed below, even though - such other FOSS license may be incompatible with the GPL. - - The following terms and conditions describe the circumstances under which - Oracle's FOSS License Exception applies. - -Oracle's FOSS License Exception Terms and Conditions - - 1. Definitions. "Derivative Work" means a derivative work, as defined - under applicable copyright law, formed entirely from the Program and - one or more FOSS Applications. - - "FOSS Application" means a free and open source software application - distributed subject to a license listed in the section below titled - "FOSS License List." - - "FOSS Notice" means a notice placed by Oracle or MySQL in a copy of - the MySQL Client Libraries stating that such copy of the MySQL Client - Libraries may be distributed under Oracle's or MySQL's FOSS (or FLOSS) - License Exception. - - "Independent Work" means portions of the Derivative Work that are not - derived from the Program and can reasonably be considered independent - and separate works. - - "Program" means a copy of Oracle's MySQL Client Libraries that - contains a FOSS Notice. - - 2. A FOSS application developer ("you" or "your") may distribute a - Derivative Work provided that you and the Derivative Work meet all of - the following conditions: - - a. You obey the GPL in all respects for the Program and all portions - (including modifications) of the Program included in the - Derivative Work (provided that this condition does not apply to - Independent Works); - b. The Derivative Work does not include any work licensed under the - GPL other than the Program; - c. You distribute Independent Works subject to a license listed in - the section below titled "FOSS License List"; - d. You distribute Independent Works in object code or executable - form with the complete corresponding machine-readable source code - on the same medium and under the same FOSS license applying to - the object code or executable forms; - e. All works that are aggregated with the Program or the Derivative - Work on a medium or volume of storage are not derivative works of - the Program, Derivative Work or FOSS Application, and must - reasonably be considered independent and separate works. - - 3. Oracle reserves all rights not expressly granted in these terms and - conditions. If all of the above conditions are not met, then this FOSS - License Exception does not apply to you or your Derivative Work. - -FOSS License List - -+------------------------------------------------------------------------+ -|License Name |Version(s)/Copyright Date| -|----------------------------------------------+-------------------------| -|Academic Free License |2.0 | -|----------------------------------------------+-------------------------| -|Apache Software License |1.0/1.1/2.0 | -|----------------------------------------------+-------------------------| -|Apple Public Source License |2.0 | -|----------------------------------------------+-------------------------| -|Artistic license |From Perl 5.8.0 | -|----------------------------------------------+-------------------------| -|BSD license |"July 22 1999" | -|----------------------------------------------+-------------------------| -|Common Development and Distribution License |1.0 | -|(CDDL) | | -|----------------------------------------------+-------------------------| -|Common Public License |1.0 | -|----------------------------------------------+-------------------------| -|Eclipse Public License |1.0 | -|----------------------------------------------+-------------------------| -|European Union Public License (EUPL)¹ |1.1 | -|----------------------------------------------+-------------------------| -|GNU Affero General Public License (AGPL) |3.0 | -|----------------------------------------------+-------------------------| -|GNU Library or "Lesser" General Public License|2.0/2.1/3.0 | -|(LGPL) | | -|----------------------------------------------+-------------------------| -|GNU General Public License (GPL) |3.0 | -|----------------------------------------------+-------------------------| -|IBM Public License |1.0 | -|----------------------------------------------+-------------------------| -|Jabber Open Source License |1.0 | -|----------------------------------------------+-------------------------| -|MIT License (As listed in file |- | -|MIT-License.txt) | | -|----------------------------------------------+-------------------------| -|Mozilla Public License (MPL) |1.0/1.1 | -|----------------------------------------------+-------------------------| -|Open Software License |2.0 | -|----------------------------------------------+-------------------------| -|OpenSSL license (with original SSLeay license)|"2003" ("1998") | -|----------------------------------------------+-------------------------| -|PHP License |3.0/3.01 | -|----------------------------------------------+-------------------------| -|Python license (CNRI Python License) |- | -|----------------------------------------------+-------------------------| -|Python Software Foundation License |2.1.1 | -|----------------------------------------------+-------------------------| -|Sleepycat License |"1999" | -|----------------------------------------------+-------------------------| -|University of Illinois/NCSA Open Source |- | -|License | | -|----------------------------------------------+-------------------------| -|W3C License |"2001" | -|----------------------------------------------+-------------------------| -|X11 License |"2001" | -|----------------------------------------------+-------------------------| -|Zlib/libpng License |- | -|----------------------------------------------+-------------------------| -|Zope Public License |2.0 | -+------------------------------------------------------------------------+ - -¹) When an Independent Work is licensed under a "Compatible License" -pursuant to the EUPL, the Compatible License rather than the EUPL is the -applicable license for purposes of these FOSS License Exception Terms and -Conditions. - diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result index a01c70b2353..5d98fc3f73d 100644 --- a/mysql-test/suite/innodb/r/foreign_key.result +++ b/mysql-test/suite/innodb/r/foreign_key.result @@ -800,4 +800,15 @@ ERROR 23000: Duplicate entry '10' for key 'ind9' SET FOREIGN_KEY_CHECKS= 0; ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (pk); DROP TABLE t1; +SET FOREIGN_KEY_CHECKS= 1; +# +# MDEV-23455 Hangs + Sig11 in unknown location(s) due to single complex FK query +# +Parsing foreign keys 1... +ERROR HY000: Can't create table `test`.`t0` (errno: 150 "Foreign key constraint is incorrectly formed") +Parsing foreign keys 2... +ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed") +Parsing foreign keys 3... +ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed") +Parsing foreign keys 4... # End of 10.2 tests diff --git a/mysql-test/suite/innodb/r/mvcc_secondary.result b/mysql-test/suite/innodb/r/mvcc_secondary.result new file mode 100644 index 00000000000..2289742e830 --- /dev/null +++ b/mysql-test/suite/innodb/r/mvcc_secondary.result @@ -0,0 +1,24 @@ +# +# MDEV-25459 MVCC read from index on CHAR or VARCHAR wrongly omits rows +# +CREATE TABLE t1 ( +pk int PRIMARY KEY, c varchar(255) UNIQUE, +d char(255), e varchar(255), f char(255), g char(255) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC DEFAULT CHARACTER SET ucs2; +INSERT INTO t1 VALUES +(1,REPEAT('c',248),REPEAT('a',106),REPEAT('b',220),REPEAT('x',14),''); +BEGIN; +UPDATE t1 SET c=REPEAT('d',170); +connect con1,localhost,root,,; +SELECT pk FROM t1 FORCE INDEX (c); +pk +1 +connection default; +COMMIT; +connection con1; +SELECT pk FROM t1 FORCE INDEX (c); +pk +1 +disconnect con1; +connection default; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test index 7756d48046f..08f2c529659 100644 --- a/mysql-test/suite/innodb/t/foreign_key.test +++ b/mysql-test/suite/innodb/t/foreign_key.test @@ -782,6 +782,45 @@ ALTER TABLE t1 ADD UNIQUE INDEX ind9 (b), LOCK=SHARED; SET FOREIGN_KEY_CHECKS= 0; ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (pk); DROP TABLE t1; +SET FOREIGN_KEY_CHECKS= 1; + +--echo # +--echo # MDEV-23455 Hangs + Sig11 in unknown location(s) due to single complex FK query +--echo # +let $constr_prefix= aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +let $fk_ref= xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; +let $fk_field= yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy; +let $constr_count= 200; # each 100 constrs is 1 sec of test execution +let $i= 0; + +while ($i < $constr_count) +{ + let $p= $constr_prefix$i; + let $constr= CONSTRAINT $p FOREIGN KEY ($fk_field) REFERENCES t1($fk_ref) ON UPDATE SET NULL; + if ($i) + { + let $constrs= $constrs, $constr; + } + if (!$i) + { + let $constrs= $constr; + } + inc $i; +} +--disable_query_log +--echo Parsing foreign keys 1... +--error ER_CANT_CREATE_TABLE +eval create table t0($fk_field int, $constrs) engine innodb; +--echo Parsing foreign keys 2... +--error ER_CANT_CREATE_TABLE +eval create table t1($fk_field int, $constrs) engine innodb; +--echo Parsing foreign keys 3... +--error ER_CANT_CREATE_TABLE +eval create table t1($fk_ref int, $fk_field int, $constrs) engine innodb; +--echo Parsing foreign keys 4... +eval create table t1($fk_ref int primary key, $fk_field int, $constrs) engine innodb; +drop table t1; +--enable_query_log --echo # End of 10.2 tests diff --git a/mysql-test/suite/innodb/t/mvcc_secondary.test b/mysql-test/suite/innodb/t/mvcc_secondary.test new file mode 100644 index 00000000000..93c91c40076 --- /dev/null +++ b/mysql-test/suite/innodb/t/mvcc_secondary.test @@ -0,0 +1,26 @@ +--source include/innodb_page_size_small.inc + +--echo # +--echo # MDEV-25459 MVCC read from index on CHAR or VARCHAR wrongly omits rows +--echo # + +CREATE TABLE t1 ( + pk int PRIMARY KEY, c varchar(255) UNIQUE, + d char(255), e varchar(255), f char(255), g char(255) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC DEFAULT CHARACTER SET ucs2; + +INSERT INTO t1 VALUES +(1,REPEAT('c',248),REPEAT('a',106),REPEAT('b',220),REPEAT('x',14),''); + +BEGIN; +UPDATE t1 SET c=REPEAT('d',170); + +connect (con1,localhost,root,,); +SELECT pk FROM t1 FORCE INDEX (c); +connection default; +COMMIT; +connection con1; +SELECT pk FROM t1 FORCE INDEX (c); +disconnect con1; +connection default; +DROP TABLE t1; diff --git a/mysql-test/suite/vcol/r/vcol_syntax.result b/mysql-test/suite/vcol/r/vcol_syntax.result index 16e30e57230..c8983f34c93 100644 --- a/mysql-test/suite/vcol/r/vcol_syntax.result +++ b/mysql-test/suite/vcol/r/vcol_syntax.result @@ -50,3 +50,41 @@ t1 CREATE TABLE "t1" ( ) drop table t1; set session sql_mode=@OLD_SQL_MODE; +# +# MDEV-25091 CREATE TABLE: field references qualified by a wrong table name succeed +# +create table t2 (x int); +create table t1 (x int, y int generated always as (t2.x)); +ERROR 42S22: Unknown column '`t2`.`x`' in 'GENERATED ALWAYS' +create table t1 (x int, y int check (y > t2.x)); +ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK' +create table t1 (x int, y int default t2.x); +ERROR 42S22: Unknown column '`t2`.`x`' in 'DEFAULT' +create table t1 (x int, check (t2.x > 0)); +ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK' +create table t1 (x int); +alter table t1 add column y int generated always as (t2.x); +ERROR 42S22: Unknown column '`t2`.`x`' in 'GENERATED ALWAYS' +alter table t1 add column y int check (z > t2.x); +ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK' +alter table t1 add column y int default t2.x; +ERROR 42S22: Unknown column '`t2`.`x`' in 'DEFAULT' +alter table t1 add constraint check (t2.x > 0); +ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK' +create or replace table t1 (x int, y int generated always as (t1.x)); +create or replace table t1 (x int, y int check (y > t1.x)); +create or replace table t1 (x int, y int default t1.x); +create or replace table t1 (x int, check (t1.x > 0)); +create or replace table t1 (x int, y int generated always as (test.t1.x)); +create or replace table t1 (x int, y int check (y > test.t1.x)); +create or replace table t1 (x int, y int default test.t1.x); +create or replace table t1 (x int, check (test.t1.x > 0)); +drop tables t1, t2; +create table t1 (x int, y int generated always as (test2.t1.x)); +ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'GENERATED ALWAYS' +create table t1 (x int, y int check (y > test2.t1.x)); +ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK' +create table t1 (x int, y int default test2.t1.x); +ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'DEFAULT' +create table t1 (x int, check (test2.t1.x > 0)); +ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK' diff --git a/mysql-test/suite/vcol/t/vcol_syntax.test b/mysql-test/suite/vcol/t/vcol_syntax.test index 6dc3cf43317..f425b52ab79 100644 --- a/mysql-test/suite/vcol/t/vcol_syntax.test +++ b/mysql-test/suite/vcol/t/vcol_syntax.test @@ -28,3 +28,47 @@ show create table t1; drop table t1; set session sql_mode=@OLD_SQL_MODE; +--echo # +--echo # MDEV-25091 CREATE TABLE: field references qualified by a wrong table name succeed +--echo # +create table t2 (x int); + +--error ER_BAD_FIELD_ERROR +create table t1 (x int, y int generated always as (t2.x)); +--error ER_BAD_FIELD_ERROR +create table t1 (x int, y int check (y > t2.x)); +--error ER_BAD_FIELD_ERROR +create table t1 (x int, y int default t2.x); +--error ER_BAD_FIELD_ERROR +create table t1 (x int, check (t2.x > 0)); + +create table t1 (x int); +--error ER_BAD_FIELD_ERROR +alter table t1 add column y int generated always as (t2.x); +--error ER_BAD_FIELD_ERROR +alter table t1 add column y int check (z > t2.x); +--error ER_BAD_FIELD_ERROR +alter table t1 add column y int default t2.x; +--error ER_BAD_FIELD_ERROR +alter table t1 add constraint check (t2.x > 0); + +create or replace table t1 (x int, y int generated always as (t1.x)); +create or replace table t1 (x int, y int check (y > t1.x)); +create or replace table t1 (x int, y int default t1.x); +create or replace table t1 (x int, check (t1.x > 0)); + +create or replace table t1 (x int, y int generated always as (test.t1.x)); +create or replace table t1 (x int, y int check (y > test.t1.x)); +create or replace table t1 (x int, y int default test.t1.x); +create or replace table t1 (x int, check (test.t1.x > 0)); + +drop tables t1, t2; + +--error ER_BAD_FIELD_ERROR +create table t1 (x int, y int generated always as (test2.t1.x)); +--error ER_BAD_FIELD_ERROR +create table t1 (x int, y int check (y > test2.t1.x)); +--error ER_BAD_FIELD_ERROR +create table t1 (x int, y int default test2.t1.x); +--error ER_BAD_FIELD_ERROR +create table t1 (x int, check (test2.t1.x > 0)); diff --git a/sql/gen_win_tzname_data.ps1 b/sql/gen_win_tzname_data.ps1 index c0a37d21895..474ab889d25 100644 --- a/sql/gen_win_tzname_data.ps1 +++ b/sql/gen_win_tzname_data.ps1 @@ -4,6 +4,7 @@ write-output "/* This file was generated using gen_win_tzname_data.ps1 */" $xdoc = new-object System.Xml.XmlDocument +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $xdoc.load("https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml") $nodes = $xdoc.SelectNodes("//mapZone[@territory='001']") # use default territory (001) foreach ($node in $nodes) { diff --git a/sql/item.h b/sql/item.h index af4043a218a..a9598ca29c6 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1772,6 +1772,15 @@ public: return 0; } + /** + Check db/table_name if they defined in item and match arg values + + @param arg Pointer to Check_table_name_prm structure + + @retval true Match failed + @retval false Match succeeded + */ + virtual bool check_table_name_processor(void *arg) { return false; } /* TRUE if the expression depends only on the table indicated by tab_map or can be converted to such an exression using equalities. @@ -1904,6 +1913,15 @@ public: bool collect; }; + struct Check_table_name_prm + { + LEX_CSTRING db; + LEX_CSTRING table_name; + String field; + Check_table_name_prm(LEX_CSTRING _db, LEX_CSTRING _table_name) : + db(_db), table_name(_table_name) {} + }; + /* For SP local variable returns pointer to Item representing its current value and pointer to current Item otherwise. @@ -3177,6 +3195,24 @@ public: } return 0; } + bool check_table_name_processor(void *arg) + { + Check_table_name_prm &p= *(Check_table_name_prm *) arg; + if (p.table_name.length && table_name) + { + DBUG_ASSERT(p.db.length); + if ((db_name && + my_strcasecmp(table_alias_charset, p.db.str, db_name)) || + my_strcasecmp(table_alias_charset, p.table_name.str, table_name)) + { + print(&p.field, (enum_query_type) (QT_ITEM_ORIGINAL_FUNC_NULLIF | + QT_NO_DATA_EXPANSION | + QT_TO_SYSTEM_CHARSET)); + return true; + } + } + return false; + } void cleanup(); Item_equal *get_item_equal() { return item_equal; } void set_item_equal(Item_equal *item_eq) { item_equal= item_eq; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index b5b39feca91..710c17a51d8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB Corporation + Copyright (c) 2010, 2021, MariaDB Corporation 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 @@ -4011,6 +4011,23 @@ public: return false; } + bool create_like() const + { + DBUG_ASSERT(!create_info.like() || !select_lex.item_list.elements); + return create_info.like(); + } + + bool create_select() const + { + DBUG_ASSERT(!create_info.like() || !select_lex.item_list.elements); + return select_lex.item_list.elements; + } + + bool create_simple() const + { + return !create_like() && !create_select(); + } + SELECT_LEX *exclude_last_select(); bool add_unit_in_brackets(SELECT_LEX *nselect); void check_automatic_up(enum sub_select_type type); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a6347c58c21..64f67358194 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -81,7 +81,9 @@ static int copy_data_between_tables(THD *thd, TABLE *from,TABLE *to, Alter_table_ctx *alter_ctx); static int mysql_prepare_create_table(THD *, HA_CREATE_INFO *, Alter_info *, - uint *, handler *, KEY **, uint *, int); + uint *, handler *, KEY **, uint *, int, + const LEX_CSTRING db, + const LEX_CSTRING table_name); static uint blob_length_by_type(enum_field_types type); static bool fix_constraints_names(THD *thd, List<Virtual_column_info> *check_constraint_list); @@ -1831,7 +1833,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) if (mysql_prepare_create_table(lpt->thd, lpt->create_info, lpt->alter_info, &lpt->db_options, lpt->table->file, &lpt->key_info_buffer, &lpt->key_count, - C_ALTER_TABLE)) + C_ALTER_TABLE, lpt->db, lpt->table_name)) { DBUG_RETURN(TRUE); } @@ -3395,7 +3397,8 @@ static int mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, Alter_info *alter_info, uint *db_options, handler *file, KEY **key_info_buffer, - uint *key_count, int create_table_mode) + uint *key_count, int create_table_mode, + const LEX_CSTRING db, const LEX_CSTRING table_name) { const char *key_name; Create_field *sql_field,*dup_field; @@ -3410,6 +3413,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, uint total_uneven_bit_length= 0; int select_field_count= C_CREATE_SELECT(create_table_mode); bool tmp_table= create_table_mode == C_ALTER_TABLE; + const bool create_simple= thd->lex->create_simple(); DBUG_ENTER("mysql_prepare_create_table"); DBUG_EXECUTE_IF("test_pseudo_invisible",{ @@ -4204,6 +4208,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, create_info->null_bits= null_fields; /* Check fields. */ + Item::Check_table_name_prm walk_prm(db, table_name); it.rewind(); while ((sql_field=it++)) { @@ -4258,6 +4263,37 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->field_name.str); DBUG_RETURN(TRUE); } + + if (create_simple) + { + /* + NOTE: we cannot do this in check_vcol_func_processor() as there is already + no table name qualifier in expression. + */ + if (sql_field->vcol_info && + sql_field->vcol_info->expr->walk(&Item::check_table_name_processor, + false, (void *) &walk_prm)) + { + my_error(ER_BAD_FIELD_ERROR, MYF(0), walk_prm.field.c_ptr(), "GENERATED ALWAYS"); + DBUG_RETURN(TRUE); + } + + if (sql_field->default_value && + sql_field->default_value->expr->walk(&Item::check_table_name_processor, + false, (void *) &walk_prm)) + { + my_error(ER_BAD_FIELD_ERROR, MYF(0), walk_prm.field.c_ptr(), "DEFAULT"); + DBUG_RETURN(TRUE); + } + + if (sql_field->check_constraint && + sql_field->check_constraint->expr->walk(&Item::check_table_name_processor, + false, (void *) &walk_prm)) + { + my_error(ER_BAD_FIELD_ERROR, MYF(0), walk_prm.field.c_ptr(), "CHECK"); + DBUG_RETURN(TRUE); + } + } } /* Check table level constraints */ @@ -4267,6 +4303,12 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, Virtual_column_info *check; while ((check= c_it++)) { + if (create_simple && check->expr->walk(&Item::check_table_name_processor, false, + (void *) &walk_prm)) + { + my_error(ER_BAD_FIELD_ERROR, MYF(0), walk_prm.field.c_ptr(), "CHECK"); + DBUG_RETURN(TRUE); + } if (!check->name.length || check->automatic_name) continue; @@ -4795,7 +4837,7 @@ handler *mysql_create_frm_image(THD *thd, if (mysql_prepare_create_table(thd, create_info, alter_info, &db_options, file, key_info, key_count, - create_table_mode)) + create_table_mode, *db, *table_name)) goto err; create_info->table_options=db_options; @@ -7243,13 +7285,15 @@ bool mysql_compare_tables(TABLE *table, Alter_info tmp_alter_info(*alter_info, thd->mem_root); uint db_options= 0; /* not used */ KEY *key_info_buffer= NULL; + LEX_CSTRING db= { table->s->db.str, table->s->db.length }; + LEX_CSTRING table_name= { table->s->db.str, table->s->table_name.length }; /* Create the prepared information. */ int create_table_mode= table->s->tmp_table == NO_TMP_TABLE ? C_ORDINARY_CREATE : C_ALTER_TABLE; if (mysql_prepare_create_table(thd, create_info, &tmp_alter_info, &db_options, table->file, &key_info_buffer, - &key_count, create_table_mode)) + &key_count, create_table_mode, db, table_name)) DBUG_RETURN(1); /* Some very basic checks. */ diff --git a/sql/win_tzname_data.h b/sql/win_tzname_data.h index 03197227f8e..792cdbc7a13 100644 --- a/sql/win_tzname_data.h +++ b/sql/win_tzname_data.h @@ -12,6 +12,7 @@ {L"US Mountain Standard Time","America/Phoenix"}, {L"Mountain Standard Time (Mexico)","America/Chihuahua"}, {L"Mountain Standard Time","America/Denver"}, +{L"Yukon Standard Time","America/Whitehorse"}, {L"Central America Standard Time","America/Guatemala"}, {L"Central Standard Time","America/Chicago"}, {L"Easter Island Standard Time","Pacific/Easter"}, diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ce00673ed5e..c5b65160827 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -6193,16 +6193,6 @@ no_such_table: innobase_copy_frm_flags_from_table_share(ib_table, table->s); - const bool bk_thread = THDVAR(thd, background_thread); - /* No point to init any statistics if tablespace is still encrypted - or if table is being opened by background thread */ - if (bk_thread) { - } else if (ib_table->is_readable()) { - dict_stats_init(ib_table); - } else { - ib_table->stat_initialized = 1; - } - MONITOR_INC(MONITOR_TABLE_OPEN); if ((ib_table->flags2 & DICT_TF2_DISCARDED)) { @@ -6398,7 +6388,7 @@ no_such_table: ut_ad(!m_prebuilt->table || table->versioned() == m_prebuilt->table->versioned()); - if (!bk_thread) { + if (!THDVAR(thd, background_thread)) { info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_OPEN); } @@ -14229,6 +14219,10 @@ ha_innobase::info_low( ib_table = m_prebuilt->table; DBUG_ASSERT(ib_table->get_ref_count() > 0); + if (!ib_table->is_readable()) { + ib_table->stat_initialized = true; + } + if (flag & HA_STATUS_TIME) { if (is_analyze || innobase_stats_on_metadata) { @@ -14281,6 +14275,8 @@ ha_innobase::info_low( DBUG_EXECUTE_IF("dict_sys_mutex_avoid", goto func_exit;); + dict_stats_init(ib_table); + if (flag & HA_STATUS_VARIABLE) { ulint stat_clustered_index_size; @@ -21775,11 +21771,12 @@ ib_push_warning( va_start(args, format); buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME)); - vsprintf(buf,format, args); - - push_warning_printf( - thd, Sql_condition::WARN_LEVEL_WARN, - uint(convert_error_code_to_mysql(error, 0, thd)), buf); + buf[MAX_BUF_SIZE - 1] = 0; + vsnprintf(buf, MAX_BUF_SIZE - 1, format, args); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + uint(convert_error_code_to_mysql(error, 0, + thd)), + buf); my_free(buf); va_end(args); } @@ -21807,7 +21804,8 @@ ib_push_warning( if (thd) { va_start(args, format); buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME)); - vsprintf(buf,format, args); + buf[MAX_BUF_SIZE - 1] = 0; + vsnprintf(buf, MAX_BUF_SIZE - 1, format, args); push_warning_printf( thd, Sql_condition::WARN_LEVEL_WARN, diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 59087c76e37..d8b7bd2ce85 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -960,7 +960,8 @@ fail: DBUG_EXECUTE_IF("log_checksum_mismatch", { cksum = crc + 1; }); if (crc != cksum) { - ib::error() << "Invalid log block checksum." + ib::error_or_warn(srv_operation != SRV_OPERATION_BACKUP) + << "Invalid log block checksum." << " block: " << block_number << " checkpoint no: " << log_block_get_checkpoint_no(buf) diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 248a6592913..788cf644191 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -78,9 +78,9 @@ is alphabetically the same as the corresponding BLOB column in the clustered index record. NOTE: the comparison is NOT done as a binary comparison, but character fields are compared with collation! -@return TRUE if the columns are equal */ +@return whether the columns are equal */ static -ibool +bool row_sel_sec_rec_is_for_blob( /*========================*/ ulint mtype, /*!< in: main type */ @@ -99,19 +99,18 @@ row_sel_sec_rec_is_for_blob( const byte* sec_field, /*!< in: column in secondary index */ ulint sec_len, /*!< in: length of sec_field */ ulint prefix_len, /*!< in: index column prefix length - in bytes */ + in bytes, or 0 for full column */ dict_table_t* table) /*!< in: table */ { ulint len; - byte buf[REC_VERSION_56_MAX_INDEX_COL_LEN]; + byte buf[REC_VERSION_56_MAX_INDEX_COL_LEN + 1]; /* This function should never be invoked on tables in ROW_FORMAT=REDUNDANT or ROW_FORMAT=COMPACT, because they should always contain enough prefix in the clustered index record. */ ut_ad(dict_table_has_atomic_blobs(table)); ut_a(clust_len >= BTR_EXTERN_FIELD_REF_SIZE); - ut_ad(prefix_len >= sec_len); - ut_ad(prefix_len > 0); + ut_ad(!prefix_len || prefix_len >= sec_len); ut_a(prefix_len <= sizeof buf); if (!memcmp(clust_field + clust_len - BTR_EXTERN_FIELD_REF_SIZE, @@ -120,11 +119,12 @@ row_sel_sec_rec_is_for_blob( This record should only be seen by recv_recovery_rollback_active() or any TRX_ISO_READ_UNCOMMITTED transactions. */ - return(FALSE); + return false; } len = btr_copy_externally_stored_field_prefix( - buf, prefix_len, page_size_t(table->space->flags), + buf, prefix_len ? prefix_len : sizeof buf, + page_size_t(table->space->flags), clust_field, clust_len); if (len == 0) { @@ -133,11 +133,18 @@ row_sel_sec_rec_is_for_blob( referring to this clustered index record, because btr_free_externally_stored_field() is called after all secondary index entries of the row have been purged. */ - return(FALSE); + return false; } - len = dtype_get_at_most_n_mbchars(prtype, mbminlen, mbmaxlen, - prefix_len, len, (const char*) buf); + if (prefix_len) { + len = dtype_get_at_most_n_mbchars(prtype, mbminlen, mbmaxlen, + prefix_len, len, + reinterpret_cast<const char*> + (buf)); + } else if (len >= sizeof buf) { + ut_ad("too long column" == 0); + return false; + } return(!cmp_data_data(mtype, prtype, buf, len, sec_field, sec_len)); } @@ -214,12 +221,13 @@ row_sel_sec_rec_is_for_clust_rec( ulint clust_pos = 0; ulint clust_len = 0; ulint len; - bool is_virtual; ifield = dict_index_get_nth_field(sec_index, i); col = dict_field_get_col(ifield); - is_virtual = col->is_virtual(); + sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len); + + const bool is_virtual = col->is_virtual(); /* For virtual column, its value will need to be reconstructed from base column in cluster index */ @@ -251,43 +259,55 @@ row_sel_sec_rec_is_for_clust_rec( innobase_report_computed_value_failed(row); return DB_COMPUTE_VALUE_FAILED; } - clust_len = vfield->len; + len = clust_len = vfield->len; clust_field = static_cast<byte*>(vfield->data); } else { clust_pos = dict_col_get_clust_pos(col, clust_index); + clust_field = rec_get_nth_cfield( clust_rec, clust_index, clust_offs, clust_pos, &clust_len); - } - - sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len); - - len = clust_len; - - if (ifield->prefix_len > 0 && len != UNIV_SQL_NULL - && sec_len != UNIV_SQL_NULL && !is_virtual) { + if (clust_len == UNIV_SQL_NULL) { + if (sec_len == UNIV_SQL_NULL) { + continue; + } + return DB_SUCCESS; + } + if (sec_len == UNIV_SQL_NULL) { + return DB_SUCCESS; + } + len = clust_len; if (rec_offs_nth_extern(clust_offs, clust_pos)) { len -= BTR_EXTERN_FIELD_REF_SIZE; } - len = dtype_get_at_most_n_mbchars( - col->prtype, col->mbminlen, col->mbmaxlen, - ifield->prefix_len, len, (char*) clust_field); - - if (rec_offs_nth_extern(clust_offs, clust_pos) - && len < sec_len) { - if (!row_sel_sec_rec_is_for_blob( - col->mtype, col->prtype, - col->mbminlen, col->mbmaxlen, - clust_field, clust_len, - sec_field, sec_len, - ifield->prefix_len, - clust_index->table)) { - return DB_SUCCESS; + if (ulint prefix_len = ifield->prefix_len) { + len = dtype_get_at_most_n_mbchars( + col->prtype, col->mbminlen, + col->mbmaxlen, prefix_len, len, + reinterpret_cast<const char*>( + clust_field)); + if (len < sec_len) { + goto check_for_blob; } + } else { +check_for_blob: + if (rec_offs_nth_extern(clust_offs, + clust_pos)) { + if (!row_sel_sec_rec_is_for_blob( + col->mtype, col->prtype, + col->mbminlen, + col->mbmaxlen, + clust_field, clust_len, + sec_field, sec_len, + prefix_len, + clust_index->table)) { + return DB_SUCCESS; + } - continue; + continue; + } } } |