Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stonedb): show stonedb tag version. (#1251) #1252

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}$');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we upgrade our core to 5.7.4x, what will happen to this line code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sql result wil be 0, need to modify the testcase if upgrade to 5.7.4x

(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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments here will be better?
Old code logic --> new code.
mysqld include storage engines like tianmu, innodb, myisam..., after we change the code, select version() acctually only shows tianmu version.

Copy link
Author

@lujiashun lujiashun Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks, I will add some comment here later. select version() shows stonedb version, include the sql layer and storage layer include tianmu, innodb

#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