Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mysql-test/main/global_temporary_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ set max_session_mem_used= 8192;
insert t values (0);
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
lock table t write;
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
alter table t add z int;
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
set max_session_mem_used= default;
Expand Down Expand Up @@ -1322,6 +1323,8 @@ set autocommit=1;
create global temporary table t (c int) engine=innodb on commit preserve rows;
set session transaction isolation level serializable;
flush tables t with read lock;
Warnings:
Warning 1809 Table `test`.`t` in system tablespace
insert t values (1);
update t set c=c+1;
# Cleanup
Expand Down Expand Up @@ -1351,3 +1354,12 @@ ERROR HY000: 'mysql.help_topic' is not of type 'BASE TABLE'
drop table mysql.help_topic;
rename table mysql.help_topic1 to mysql.help_topic;
disconnect con1;
# MDEV-40167 - GTT created with the InnoDB incorrectly accept FULLTEXT/VECTOR indexes
CREATE GLOBAL TEMPORARY TABLE gtt (id INT PRIMARY KEY, body TEXT, FULLTEXT (body))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;
ERROR HY000: Cannot create FULLTEXT index on temporary InnoDB table
CREATE GLOBAL TEMPORARY TABLE gtt_v (id INT PRIMARY KEY, v VECTOR (4) NOT NULL, VECTOR INDEX (v))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;
ERROR HY000: Cannot create VECTOR index on temporary InnoDB table
CREATE GLOBAL TEMPORARY TABLE gtt (id INT ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ON COMMIT PRESERVE ROWS;
ERROR HY000: InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.
15 changes: 15 additions & 0 deletions mysql-test/main/global_temporary_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,11 @@ create global temporary table t (t text);
set max_session_mem_used= 8192;
--error ER_OPTION_PREVENTS_STATEMENT
insert t values (0);
--error ER_OPTION_PREVENTS_STATEMENT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was about to check ALTER TABLE under locked table. Now the table won't be locked. Maybe raise the memory?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was about to check ALTER TABLE under locked table. Now the table won't be locked. Maybe raise the memory limit?

lock table t write;
--error ER_OPTION_PREVENTS_STATEMENT
alter table t add z int;
--error 0, ER_OPTION_PREVENTS_STATEMENT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's sometimes 0, and sometimes ER_OPTION_PREVENTS_STATEMENT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's sometimes 0, and sometimes ER_OPTION_PREVENTS_STATEMENT?

set max_session_mem_used= default;
drop table t;
unlock tables;
Expand Down Expand Up @@ -1234,3 +1236,16 @@ drop table mysql.help_topic;
rename table mysql.help_topic1 to mysql.help_topic;

--disconnect con1

--echo # MDEV-40167 - GTT created with the InnoDB incorrectly accept FULLTEXT/VECTOR indexes

--error ER_NO_INDEX_ON_TEMPORARY
CREATE GLOBAL TEMPORARY TABLE gtt (id INT PRIMARY KEY, body TEXT, FULLTEXT (body))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;

--error ER_NO_INDEX_ON_TEMPORARY
CREATE GLOBAL TEMPORARY TABLE gtt_v (id INT PRIMARY KEY, v VECTOR (4) NOT NULL, VECTOR INDEX (v))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;

--error ER_UNSUPPORTED_COMPRESSED_TABLE
CREATE GLOBAL TEMPORARY TABLE gtt (id INT ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ON COMMIT PRESERVE ROWS;
12 changes: 12 additions & 0 deletions mysql-test/suite/binlog/r/global_temporary_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ set max_session_mem_used= 8192;
insert t values (0);
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
lock table t write;
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
alter table t add z int;
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
set max_session_mem_used= default;
Expand Down Expand Up @@ -1325,6 +1326,8 @@ set autocommit=1;
create global temporary table t (c int) engine=innodb on commit preserve rows;
set session transaction isolation level serializable;
flush tables t with read lock;
Warnings:
Warning 1809 Table `test`.`t` in system tablespace
insert t values (1);
update t set c=c+1;
# Cleanup
Expand Down Expand Up @@ -1354,6 +1357,15 @@ ERROR HY000: 'mysql.help_topic' is not of type 'BASE TABLE'
drop table mysql.help_topic;
rename table mysql.help_topic1 to mysql.help_topic;
disconnect con1;
# MDEV-40167 - GTT created with the InnoDB incorrectly accept FULLTEXT/VECTOR indexes
CREATE GLOBAL TEMPORARY TABLE gtt (id INT PRIMARY KEY, body TEXT, FULLTEXT (body))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;
ERROR HY000: Cannot create FULLTEXT index on temporary InnoDB table
CREATE GLOBAL TEMPORARY TABLE gtt_v (id INT PRIMARY KEY, v VECTOR (4) NOT NULL, VECTOR INDEX (v))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;
ERROR HY000: Cannot create VECTOR index on temporary InnoDB table
CREATE GLOBAL TEMPORARY TABLE gtt (id INT ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ON COMMIT PRESERVE ROWS;
ERROR HY000: InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
Expand Down
12 changes: 12 additions & 0 deletions mysql-test/suite/rpl/r/global_temporary_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ set max_session_mem_used= 8192;
insert t values (0);
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
lock table t write;
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
alter table t add z int;
ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement
set max_session_mem_used= default;
Expand Down Expand Up @@ -1325,6 +1326,8 @@ set autocommit=1;
create global temporary table t (c int) engine=innodb on commit preserve rows;
set session transaction isolation level serializable;
flush tables t with read lock;
Warnings:
Warning 1809 Table `test`.`t` in system tablespace
insert t values (1);
update t set c=c+1;
# Cleanup
Expand Down Expand Up @@ -1354,6 +1357,15 @@ ERROR HY000: 'mysql.help_topic' is not of type 'BASE TABLE'
drop table mysql.help_topic;
rename table mysql.help_topic1 to mysql.help_topic;
disconnect con1;
# MDEV-40167 - GTT created with the InnoDB incorrectly accept FULLTEXT/VECTOR indexes
CREATE GLOBAL TEMPORARY TABLE gtt (id INT PRIMARY KEY, body TEXT, FULLTEXT (body))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;
ERROR HY000: Cannot create FULLTEXT index on temporary InnoDB table
CREATE GLOBAL TEMPORARY TABLE gtt_v (id INT PRIMARY KEY, v VECTOR (4) NOT NULL, VECTOR INDEX (v))
ENGINE=InnoDB ON COMMIT PRESERVE ROWS;
ERROR HY000: Cannot create VECTOR index on temporary InnoDB table
CREATE GLOBAL TEMPORARY TABLE gtt (id INT ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED ON COMMIT PRESERVE ROWS;
ERROR HY000: InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.
connection slave;
connection master;
set @old_timeout= @@global.lock_wait_timeout;
Expand Down
2 changes: 1 addition & 1 deletion sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6748,7 +6748,7 @@ int ha_create_table(THD *thd, const char *path, const char *db,
// open an frm file
share.db_plugin= ha_lock_engine(thd, create_info->db_type);

if (open_table_def(thd, &share))
if (open_table_def(thd, &share) || thd->killed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain, how thd->killed could be set here, while open_table_def returns 0? I guess it's set by memory overflow, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain, how thd->killed could be set here, while open_table_def returns 0? I guess it's set by memory overflow, right?

goto err;
}

Expand Down
2 changes: 1 addition & 1 deletion sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2672,7 +2672,7 @@ Locked_tables_list::init_locked_tables(THD *thd)
&db.str, (size_t) db.length + 1,
&table_name.str, (size_t) table_name.length + 1,
&alias.str, (size_t) alias.length + 1,
NullS))
NullS) || thd->killed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same. This definitely needs explanation. Does it mean that every alloc_root needs thd->killed check

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same. This definitely needs explanation. Does it mean that every alloc_root needs thd->killed check?

{
reset();
return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3778,7 +3778,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
my_error(ER_INDEX_CANNOT_HAVE_NULL, MYF(0), "VECTOR");
DBUG_RETURN(TRUE);
}
if (create_info->tmp_table())
if (create_info->tmp_table() || create_info->global_tmp_table())
{
my_error(ER_NO_INDEX_ON_TEMPORARY, MYF(0), "VECTOR",
file->table_type());
Expand Down
43 changes: 24 additions & 19 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11055,15 +11055,17 @@ create_table_info_t::create_option_data_directory_is_valid()
is_valid = false;
}

/* Do not use DATA DIRECTORY with TEMPORARY TABLE. */
if (m_create_info->tmp_table()) {
push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: DATA DIRECTORY cannot be used"
" for TEMPORARY tables.");
is_valid = false;
}
/* Do not use DATA DIRECTORY with TEMPORARY TABLE or
GLOBAL TEMPORARY TABLE. */
Comment thread
FooBarrior marked this conversation as resolved.
if (m_create_info->tmp_table() || m_create_info->global_tmp_table()) {
push_warning_printf(
m_thd, Sql_condition::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: DATA DIRECTORY cannot be used for %s tables.",
m_create_info->global_tmp_table()
? "GLOBAL TEMPORARY" : "TEMPORARY");
is_valid = false;
}

/* We check for a DATA DIRECTORY mixed with TABLESPACE in
create_option_tablespace_is_valid(), no need to here. */
Expand All @@ -11086,6 +11088,7 @@ create_table_info_t::create_options_are_invalid()
const char* ret = NULL;
enum row_type row_format = m_create_info->row_type;
const bool is_temp = m_create_info->tmp_table();
const bool is_global_temp = m_create_info->global_tmp_table();

ut_ad(m_thd != NULL);

Expand All @@ -11096,7 +11099,7 @@ create_table_info_t::create_options_are_invalid()

/* Check if a non-zero KEY_BLOCK_SIZE was specified. */
if (has_key_block_size) {
if (is_temp || innodb_read_only_compressed) {
if (is_temp || is_global_temp || innodb_read_only_compressed) {
my_error(ER_UNSUPPORTED_COMPRESSED_TABLE, MYF(0));
return("KEY_BLOCK_SIZE");
}
Expand Down Expand Up @@ -11152,7 +11155,7 @@ create_table_info_t::create_options_are_invalid()
other incompatibilities. */
switch (row_format) {
case ROW_TYPE_COMPRESSED:
if (is_temp || innodb_read_only_compressed) {
if (is_temp || is_global_temp || innodb_read_only_compressed) {
my_error(ER_UNSUPPORTED_COMPRESSED_TABLE, MYF(0));
return("ROW_FORMAT");
}
Expand Down Expand Up @@ -11510,7 +11513,8 @@ bool create_table_info_t::innobase_table_flags()
rec_format_t innodb_row_format =
get_row_format(m_default_row_format);
const bool is_temp = m_create_info->tmp_table();
bool zip_allowed = !is_temp;
const bool is_global_temp = m_create_info->global_tmp_table();
bool zip_allowed = !is_temp && !is_global_temp;

const ulint zip_ssize_max =
ut_min(static_cast<ulint>(UNIV_PAGE_SSIZE_MAX),
Expand All @@ -11531,7 +11535,7 @@ bool create_table_info_t::innobase_table_flags()

/* We don't support FTS indexes in temporary
tables. */
if (is_temp) {
if (is_temp || is_global_temp) {
Comment thread
pranavktiwari marked this conversation as resolved.
my_error(ER_NO_INDEX_ON_TEMPORARY, MYF(0),
"FULLTEXT", "InnoDB");
DBUG_RETURN(false);
Expand Down Expand Up @@ -11581,7 +11585,7 @@ bool create_table_info_t::innobase_table_flags()
}

/* Make sure compressed row format is allowed. */
if (is_temp) {
if (is_temp || is_global_temp) {
push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
Expand Down Expand Up @@ -11653,7 +11657,7 @@ bool create_table_info_t::innobase_table_flags()
innodb_row_format = REC_FORMAT_COMPACT;
break;
case ROW_TYPE_COMPRESSED:
if (is_temp) {
if (is_temp || is_global_temp) {
push_warning_printf(
m_thd, Sql_condition::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
Expand Down Expand Up @@ -11698,8 +11702,8 @@ bool create_table_info_t::innobase_table_flags()
zip_allowed = false;
}

ut_ad(!is_temp || !zip_allowed);
ut_ad(!is_temp || innodb_row_format != REC_FORMAT_COMPRESSED);
ut_ad(!(is_temp || is_global_temp) || !zip_allowed);
ut_ad(!(is_temp || is_global_temp) || innodb_row_format != REC_FORMAT_COMPRESSED);

/* Set the table flags */
if (!zip_allowed) {
Expand Down Expand Up @@ -11929,10 +11933,11 @@ create_table_info_t::set_tablespace_type(
/* Ignore the current innodb-file-per-table setting if we are
creating a temporary table. */
m_use_file_per_table = m_allow_file_per_table
&& !m_create_info->tmp_table();
&& !m_create_info->tmp_table()
&& !m_create_info->global_tmp_table();

/* DATA DIRECTORY must have m_use_file_per_table but cannot be
used with TEMPORARY tables. */
used with TEMPORARY tables and global temporary tables. */
m_use_data_dir =
m_use_file_per_table
&& m_create_info->data_file_name
Expand Down
Loading