summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-12-07 11:41:52 +0200
committerMonty <monty@mariadb.org>2017-12-07 11:41:52 +0200
commit6d4b0958dc5a6a2d44dcccf083ec9e136bb4a38e (patch)
tree7b2adc430bf4ef3f78f2050f69b4b9608f228512
parentbce40651296987974924cfdf9e6bb7fff4599fed (diff)
downloadmariadb-git-6d4b0958dc5a6a2d44dcccf083ec9e136bb4a38e.tar.gz
Fix failing test mysql_client_test
Backported patch from 10.3 that allows one to remove short .frm files
-rw-r--r--sql/datadict.cc33
1 files changed, 18 insertions, 15 deletions
diff --git a/sql/datadict.cc b/sql/datadict.cc
index 5b70639174c..5a4d8bbb8bf 100644
--- a/sql/datadict.cc
+++ b/sql/datadict.cc
@@ -72,33 +72,36 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
if ((file= mysql_file_open(key_file_frm, path, O_RDONLY | O_SHARE, MYF(0)))
< 0)
DBUG_RETURN(TABLE_TYPE_UNKNOWN);
- error= mysql_file_read(file, (uchar*) header, sizeof(header), MYF(MY_NABP));
- if (error)
+ /*
+ We return TABLE_TYPE_NORMAL if we can open the .frm file. This allows us
+ to drop a bad .frm file with DROP TABLE
+ */
+ type= TABLE_TYPE_NORMAL;
+
+ /*
+ Initialize engine name in case we are not able to find it out
+ The cast is safe, as engine_name->str points to a usable buffer.
+ */
+ if (engine_name)
+ {
+ engine_name->length= 0;
+ ((char*) (engine_name->str))[0]= 0;
+ }
+
+ if ((error= mysql_file_read(file, (uchar*) header, sizeof(header), MYF(MY_NABP))))
goto err;
+
if (!strncmp((char*) header, "TYPE=VIEW\n", 10))
{
type= TABLE_TYPE_VIEW;
goto err;
}
- /*
- We return TABLE_TYPE_NORMAL if we can read the .frm file. This allows us
- to drop a bad .frm file with DROP TABLE
- */
- type= TABLE_TYPE_NORMAL;
-
/* engine_name is 0 if we only want to know if table is view or not */
if (!engine_name)
goto err;
- /*
- Initialize engine name in case we are not able to find it out
- The cast is safe, as engine_name->str points to a usable buffer.
- */
- engine_name->length= 0;
- ((char*) (engine_name->str))[0]= 0;
-
if (!is_binary_frm_header(header))
goto err;