Navigation Menu

Skip to content

Commit

Permalink
Move version check to hpp from cpp
Browse files Browse the repository at this point in the history
We should check MySQL version and define logical flags in hpp and use
them in cpp. It improves maintenability.

Some flags are used in two or more locations. If they are used in two
or more locations, we need to write the same version check conditions
there. It reduces maintenability:

Not good:

    #if MYSQL_VERSION_ID >= 50607
      // code1
    #endif
      // ...
    #if MYSQL_VERSION_ID >= 50607
      // code2
    #endif

Better:

    #if MYSQL_VERSION_ID >= 50607
    #  define LOGICAL_FLAG
    #endif

    #ifdef LOGICAL_FLAG
      // code1
    #endif
      // ...
    #ifdef LOGICAL_FLAG
      // code2
    #endif
  • Loading branch information
kou committed Nov 17, 2013
1 parent 2241a88 commit c4b16ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ha_mroonga.cpp
Expand Up @@ -3809,7 +3809,7 @@ int ha_mroonga::wrapper_open(const char *name, int mode, uint test_if_locked)
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
wrap_handler->init();
#if MYSQL_VERSION_ID >= 50600
#ifdef MRN_HANDLER_HAVE_SET_HA_SHARE_REF
wrap_handler->set_ha_share_ref(&table->s->ha_share);
#endif
error = wrap_handler->ha_open(table, name, mode, test_if_locked);
Expand Down
4 changes: 4 additions & 0 deletions ha_mroonga.hpp
Expand Up @@ -91,6 +91,10 @@ extern "C" {
# define MRN_HANDLER_HAVE_GET_TABLESPACE_NAME
#endif

#if MYSQL_VERSION_ID >= 50607
# define MRN_HANDLER_HAVE_SET_HA_SHARE_REF
#endif

#if MYSQL_VERSION_ID >= 50500
# define MRN_TABLE_LIST_INIT_REQUIRE_ALIAS
#endif
Expand Down

0 comments on commit c4b16ed

Please sign in to comment.