diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-11-10 16:12:45 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-11-10 16:12:45 +0200 |
commit | a48aa0cd569eda88bef98ed4abe41b0b570fcd51 (patch) | |
tree | 6008b19aabfe0554432c87614d1022594f08fc5f /sql/datadict.cc | |
parent | 8409f721ffe2d91b11d3fc03c6872ff57051bbf8 (diff) | |
parent | 386e5d476e9bf8f216c760c9076ae0ecdc99054d (diff) | |
download | mariadb-git-a48aa0cd569eda88bef98ed4abe41b0b570fcd51.tar.gz |
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'sql/datadict.cc')
-rw-r--r-- | sql/datadict.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sql/datadict.cc b/sql/datadict.cc index 7ea83236cd6..4425f278e12 100644 --- a/sql/datadict.cc +++ b/sql/datadict.cc @@ -46,11 +46,13 @@ static int read_string(File file, uchar**to, size_t length) engine_name is a LEX_CSTRING, where engine_name->str must point to a buffer of at least NAME_CHAR_LEN+1 bytes. + If engine_name is 0, then the function will only test if the file is a + view or not @param[out] is_sequence 1 if table is a SEQUENCE, 0 otherwise @retval TABLE_TYPE_UNKNOWN error - @retval TABLE_TYPE_TABLE table + @retval TABLE_TYPE_NORMAL table @retval TABLE_TYPE_SEQUENCE sequence table @retval TABLE_TYPE_VIEW view */ @@ -80,12 +82,26 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name, 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; - if (!is_binary_frm_header(header) || !engine_name) + /* 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; + dbt= header[3]; if (((header[39] >> 4) & 3) == HA_CHOICE_YES) |