Skip to content

Commit

Permalink
Simplify fn_rext
Browse files Browse the repository at this point in the history
- Change interface according to real usage
- Fix comment
- Rename to fn_frm_ext
  • Loading branch information
montywi committed Nov 17, 2017
1 parent 326bfb0 commit 5b3da95
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ int ha_partition::create(const char *name, TABLE *table_arg,
handler **file, **abort_file;
DBUG_ENTER("ha_partition::create");

DBUG_ASSERT(*fn_rext((char*)name) == '\0');
DBUG_ASSERT(!fn_frm_ext(name));

/* Not allowed to create temporary partitioned tables */
if (create_info && create_info->tmp_table())
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1725,8 +1725,7 @@ bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db)
DBUG_PRINT("info",("Examining: %s", file->name));

/* skiping non-FRM files */
if (my_strcasecmp(files_charset_info,
(extension= fn_rext(file->name)), reg_ext))
if (!(extension= (char*) fn_frm_ext(file->name)))
continue;

/* A frm file found, add the table info rename list */
Expand Down
17 changes: 6 additions & 11 deletions sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,31 +217,26 @@ static uchar *get_field_name(Field **buff, size_t *length,
Returns pointer to '.frm' extension of the file name.
SYNOPSIS
fn_rext()
fn_frm_ext()
name file name
DESCRIPTION
Checks file name part starting with the rightmost '.' character,
and returns it if it is equal to '.frm'.
TODO
It is a good idea to get rid of this function modifying the code
to garantee that the functions presently calling fn_rext() always
get arguments in the same format: either with '.frm' or without '.frm'.
RETURN VALUES
Pointer to the '.frm' extension. If there is no extension,
or extension is not '.frm', pointer at the end of file name.
Pointer to the '.frm' extension or NULL if not a .frm file
*/

char *fn_rext(char *name)
const char *fn_frm_ext(const char *name)
{
char *res= strrchr(name, '.');
const char *res= strrchr(name, '.');
if (res && !strcmp(res, reg_ext))
return res;
return name + strlen(name);
return 0;
}


TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
const LEX_CSTRING *name)
{
Expand Down
2 changes: 1 addition & 1 deletion sql/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -2702,7 +2702,7 @@ ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
void append_unescaped(String *res, const char *pos, uint length);
void prepare_frm_header(THD *thd, uint reclength, uchar *fileinfo,
HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
char *fn_rext(char *name);
const char *fn_frm_ext(const char *name);

/* Check that the integer is in the internal */
static inline int set_zone(int nr,int min_zone,int max_zone)
Expand Down

0 comments on commit 5b3da95

Please sign in to comment.