@@ -72,33 +72,36 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
72
72
if ((file= mysql_file_open (key_file_frm, path, O_RDONLY | O_SHARE, MYF (0 )))
73
73
< 0 )
74
74
DBUG_RETURN (TABLE_TYPE_UNKNOWN);
75
- error= mysql_file_read (file, (uchar*) header, sizeof (header), MYF (MY_NABP));
76
75
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))))
78
93
goto err;
94
+
79
95
if (!strncmp ((char *) header, " TYPE=VIEW\n " , 10 ))
80
96
{
81
97
type= TABLE_TYPE_VIEW;
82
98
goto err;
83
99
}
84
100
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
-
91
101
/* engine_name is 0 if we only want to know if table is view or not */
92
102
if (!engine_name)
93
103
goto err;
94
104
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
-
102
105
if (!is_binary_frm_header (header))
103
106
goto err;
104
107
0 commit comments