summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2022-10-12 15:59:46 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2022-10-24 14:09:46 +0200
commit4fd6dd2d3b9bb08a3897d59160515a09fe357114 (patch)
treed9538f746e4cc44f8a4328fbb80de554f4c88084 /sql/sql_view.cc
parente00ea301efd9e02f89341dfec3a5e0e751213ed8 (diff)
downloadmariadb-git-4fd6dd2d3b9bb08a3897d59160515a09fe357114.tar.gz
MDEV-29748 ASAN errors or server crash in File_parser::parse upon concurrent view operations
Read the version of the view share when we read definition to prevent simultaniouse access to a view table SHARE (and so its MEM_ROOT) from different threads.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc24
1 files changed, 10 insertions, 14 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 68a8410f559..1b8762f90dd 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1175,19 +1175,26 @@ err:
bool mariadb_view_version_get(TABLE_SHARE *share)
{
DBUG_ASSERT(share->is_view);
+ DBUG_ASSERT(share->tabledef_version.length == 0);
if (!(share->tabledef_version.str=
(uchar*) alloc_root(&share->mem_root,
MICROSECOND_TIMESTAMP_BUFFER_SIZE)))
return TRUE;
- share->tabledef_version.length= 0; // safety if the drfinition file is brocken
DBUG_ASSERT(share->view_def != NULL);
if (share->view_def->parse((uchar *) &share->tabledef_version, NULL,
view_timestamp_parameters, 1,
&file_parser_dummy_hook))
+ {
+ // safety if the definition file is brocken
+ share->tabledef_version.length= 0;
+ my_error(ER_TABLE_CORRUPT, MYF(0),
+ share->db.str, share->table_name.str);
return TRUE;
+ }
DBUG_ASSERT(share->tabledef_version.length == MICROSECOND_TIMESTAMP_BUFFER_SIZE-1);
+
return FALSE;
}
@@ -1251,10 +1258,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
mysql_derived_reinit(thd, NULL, table);
DEBUG_SYNC(thd, "after_cached_view_opened");
- if (!share->tabledef_version.length)
- {
- mariadb_view_version_get(share);
- }
+ DBUG_ASSERT(share->tabledef_version.length);
DBUG_RETURN(0);
}
@@ -1308,15 +1312,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
required_view_parameters,
&file_parser_dummy_hook)))
goto end;
- if (!share->tabledef_version.length)
- {
- share->tabledef_version.str= (const uchar *)
- memdup_root(&share->mem_root,
- (const void *)
- table->hr_timestamp.str,
- (share->tabledef_version.length=
- table->hr_timestamp.length));
- }
+ DBUG_ASSERT(share->tabledef_version.length);
if (!table->tabledef_version.length)
{
table->set_view_def_version(&table->hr_timestamp);