Skip to content
Permalink
Browse files
Fix failing test mysql_client_test
Backported patch from 10.3 that allows one to remove short .frm files
  • Loading branch information
montywi committed Dec 7, 2017
1 parent bce4065 commit 6d4b095
Showing 1 changed file with 18 additions and 15 deletions.
@@ -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;

0 comments on commit 6d4b095

Please sign in to comment.