Skip to content

Commit 6d4b095

Browse files
committed
Fix failing test mysql_client_test
Backported patch from 10.3 that allows one to remove short .frm files
1 parent bce4065 commit 6d4b095

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

sql/datadict.cc

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,36 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
7272
if ((file= mysql_file_open(key_file_frm, path, O_RDONLY | O_SHARE, MYF(0)))
7373
< 0)
7474
DBUG_RETURN(TABLE_TYPE_UNKNOWN);
75-
error= mysql_file_read(file, (uchar*) header, sizeof(header), MYF(MY_NABP));
7675

77-
if (error)
76+
/*
77+
We return TABLE_TYPE_NORMAL if we can open the .frm file. This allows us
78+
to drop a bad .frm file with DROP TABLE
79+
*/
80+
type= TABLE_TYPE_NORMAL;
81+
82+
/*
83+
Initialize engine name in case we are not able to find it out
84+
The cast is safe, as engine_name->str points to a usable buffer.
85+
*/
86+
if (engine_name)
87+
{
88+
engine_name->length= 0;
89+
((char*) (engine_name->str))[0]= 0;
90+
}
91+
92+
if ((error= mysql_file_read(file, (uchar*) header, sizeof(header), MYF(MY_NABP))))
7893
goto err;
94+
7995
if (!strncmp((char*) header, "TYPE=VIEW\n", 10))
8096
{
8197
type= TABLE_TYPE_VIEW;
8298
goto err;
8399
}
84100

85-
/*
86-
We return TABLE_TYPE_NORMAL if we can read the .frm file. This allows us
87-
to drop a bad .frm file with DROP TABLE
88-
*/
89-
type= TABLE_TYPE_NORMAL;
90-
91101
/* engine_name is 0 if we only want to know if table is view or not */
92102
if (!engine_name)
93103
goto err;
94104

95-
/*
96-
Initialize engine name in case we are not able to find it out
97-
The cast is safe, as engine_name->str points to a usable buffer.
98-
*/
99-
engine_name->length= 0;
100-
((char*) (engine_name->str))[0]= 0;
101-
102105
if (!is_binary_frm_header(header))
103106
goto err;
104107

0 commit comments

Comments
 (0)