Skip to content

Commit

Permalink
feat(stonedb): show stonedb tag version. (stoneatom#1251)
Browse files Browse the repository at this point in the history
  • Loading branch information
lujiashun authored and mergify[bot] committed Jan 31, 2023
1 parent a486f2a commit e65c757
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,17 @@ IF (UNIX)
OUTPUT_VARIABLE ER_BUILD_TIME)
string(STRIP "${ER_BUILD_TIME}" ER_BUILD_TIME)

EXECUTE_PROCESS(COMMAND bash "-c" "git describe --tags `git rev-list --tags --max-count=1` |head -n 1 |awk -F'-' '{print $2}'"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ER_TAG_NAME)
string(STRIP "${ER_TAG_NAME}" ER_TAG_NAME)

SET(STONEDB_REPO_ADDR "${ER_REPO_NAME}:${ER_BRANCH_NAME}")
SET(STONEDB_BRANCH_NAME "${ER_BRANCH_NAME}")
SET(STONEDB_COMMIT_ID "${ER_COMMIT_ID}")
SET(STONEDB_COMMIT_TIME "${ER_COMMIT_TIME}")
SET(STONEDB_BUILD_TIME "Date: ${ER_BUILD_TIME}")
SET(STONEDB_TAG_NAME "${ER_TAG_NAME}")
ENDIF()

CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/my_config.h)
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/suite/tianmu/r/issue1251.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select (select version() regexp '^5.7.36-StoneDB-v[0-9]*\\.[0-9]*\\.[0-9]*$') or (select version() regexp '^5.7.36-StoneDB-v[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9a-z]{9}$');
(select version() regexp '^5.7.36-StoneDB-v[0-9]*\\.[0-9]*\\.[0-9]*$') or (select version() regexp '^5.7.36-StoneDB-v[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9a-z]{9}$')
1
2 changes: 2 additions & 0 deletions mysql-test/suite/tianmu/t/issue1251.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- source include/have_tianmu.inc
select (select version() regexp '^5.7.36-StoneDB-v[0-9]*\\.[0-9]*\\.[0-9]*$') or (select version() regexp '^5.7.36-StoneDB-v[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9a-z]{9}$');
1 change: 1 addition & 0 deletions sql/build_info.h.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
#cmakedefine STONEDB_COMMIT_ID "@STONEDB_COMMIT_ID@"
#cmakedefine STONEDB_COMMIT_TIME "@STONEDB_COMMIT_TIME@"
#cmakedefine STONEDB_BUILD_TIME "@STONEDB_BUILD_TIME@"
#cmakedefine STONEDB_TAG_NAME "@STONEDB_TAG_NAME@"

#endif //BUILD_INFO_T_H
2 changes: 2 additions & 0 deletions sql/build_info_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
#define STONEDB_BRANCH_NAME "AS_BRANCH_NAME"
#define STONEDB_COMMIT_ID "AS_COMMIT_ID"
#define STONEDB_COMMIT_TIME "AS_COMMIT_TIME"
#define STONEDB_TAG_NAME "AS_TAG_NAME"

#endif
21 changes: 21 additions & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8103,6 +8103,9 @@ static void set_server_version(void)
{
char *end= strxmov(server_version, MYSQL_SERVER_VERSION,
MYSQL_SERVER_SUFFIX_STR, NullS);
//for release version: 5.7.36-StoneDB-v0.0.2
//for debug version: 5.7.36-StoneDB-v0.0.2.abcdef123, abcdef123 means commit id;
#if 0
#ifdef EMBEDDED_LIBRARY
end= my_stpcpy(end, "-embedded");
#endif
Expand All @@ -8122,6 +8125,24 @@ static void set_server_version(void)
static_cast<int>(sizeof("-asan")))
end= my_stpcpy(end, "-asan");
#endif
#endif

if (SERVER_VERSION_LENGTH - (end - server_version) >
static_cast<int>(sizeof("-")))
end = my_stpcpy(end, "-");
if (SERVER_VERSION_LENGTH - (end - server_version) >
static_cast<int>(sizeof(STONEDB_TAG_NAME)))
end = my_stpcpy(end, STONEDB_TAG_NAME);

#ifndef NDEBUG
if (SERVER_VERSION_LENGTH - (end - server_version) >
static_cast<int>(sizeof(".")))
end = my_stpcpy(end, ".");
if (SERVER_VERSION_LENGTH - (end - server_version) >
static_cast<int>(sizeof(STONEDB_COMMIT_ID)))
end = my_stpcpy(end, STONEDB_COMMIT_ID);
#endif

}


Expand Down

0 comments on commit e65c757

Please sign in to comment.