1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

CONC-282:

Connector/C now provides additional information for package version
mariadb_config --cc_version lists the package version
Beside MARIADB_PACKAGE_VERSION numeric representation MARIADB_PACKAGE_VERSION_ID can be used now within preprocessor directives
This commit is contained in:
Georg Richter
2017-10-02 09:08:03 +02:00
parent b241f8995f
commit 7209efa5aa
4 changed files with 23 additions and 12 deletions

View File

@@ -39,6 +39,9 @@ SET(CPACK_PACKAGE_VERSION_MAJOR 3)
SET(CPACK_PACKAGE_VERSION_MINOR 0) SET(CPACK_PACKAGE_VERSION_MINOR 0)
SET(CPACK_PACKAGE_VERSION_PATCH 2) SET(CPACK_PACKAGE_VERSION_PATCH 2)
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 +
${CPACK_PACKAGE_VERSION_MINOR} * 100 +
${CPACK_PACKAGE_VERSION_PATCH}")
MACRO(ADD_OPTION _name _text _default) MACRO(ADD_OPTION _name _text _default)
IF(NOT DEFINED ${_name}) IF(NOT DEFINED ${_name})
@@ -165,6 +168,7 @@ IF(GIT_EXECUTABLE)
ENDIF() ENDIF()
ENDIF() ENDIF()
SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd ! SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
# if C/C is build as subproject inside MariaDB server tree we will # if C/C is build as subproject inside MariaDB server tree we will
# use the version defined by server # use the version defined by server
IF(MAJOR_VERSION) IF(MAJOR_VERSION)

View File

@@ -19,6 +19,7 @@
#define MYSQL_CONFIG_NAME "my" #define MYSQL_CONFIG_NAME "my"
#define MARIADB_PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@" #define MARIADB_PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@"
#define MARIADB_PACKAGE_VERSION_ID @MARIADB_PACKAGE_VERSION_ID@
#define MARIADB_SYSTEM_TYPE "@CMAKE_SYSTEM_NAME@" #define MARIADB_SYSTEM_TYPE "@CMAKE_SYSTEM_NAME@"
#define MARIADB_MACHINE_TYPE "@CMAKE_SYSTEM_PROCESSOR@" #define MARIADB_MACHINE_TYPE "@CMAKE_SYSTEM_PROCESSOR@"
#define MARIADB_PLUGINDIR "@PLUGINDIR@" #define MARIADB_PLUGINDIR "@PLUGINDIR@"

View File

@@ -11,6 +11,7 @@ static char *mariadb_progname;
#define LIBS_SYS "@extra_dynamic_LDFLAGS@" #define LIBS_SYS "@extra_dynamic_LDFLAGS@"
#define CFLAGS INCLUDE #define CFLAGS INCLUDE
#define VERSION "@MARIADB_CLIENT_VERSION@" #define VERSION "@MARIADB_CLIENT_VERSION@"
#define CC_VERSION "@CPACK_PACKAGE_VERSION@"
#define PLUGIN_DIR "@CMAKE_INSTALL_PREFIX@/@INSTALL_PLUGINDIR@" #define PLUGIN_DIR "@CMAKE_INSTALL_PREFIX@/@INSTALL_PLUGINDIR@"
#define SOCKET "@MARIADB_UNIX_ADDR@" #define SOCKET "@MARIADB_UNIX_ADDR@"
#define PORT "@MARIADB_PORT@" #define PORT "@MARIADB_PORT@"
@@ -23,12 +24,13 @@ static struct option long_options[]=
{"include", no_argument, 0, 'c'}, {"include", no_argument, 0, 'c'},
{"libs", no_argument, 0, 'd'}, {"libs", no_argument, 0, 'd'},
{"libs_r", no_argument, 0, 'e'}, {"libs_r", no_argument, 0, 'e'},
{"libs_sys", no_argument, 0, 'y'}, {"libs_sys", no_argument, 0, 'l'},
{"version", no_argument, 0, 'f'}, {"version", no_argument, 0, 'f'},
{"socket", no_argument, 0, 'g'}, {"cc_version", no_argument, 0, 'g'},
{"port", no_argument, 0, 'h'}, {"socket", no_argument, 0, 'h'},
{"plugindir", no_argument, 0, 'p'}, {"port", no_argument, 0, 'i'},
{"tlsinfo", no_argument, 0, 't'}, {"plugindir", no_argument, 0, 'j'},
{"tlsinfo", no_argument, 0, 'k'},
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
@@ -41,6 +43,7 @@ static const char *values[]=
LIBS, LIBS,
LIBS_SYS, LIBS_SYS,
VERSION, VERSION,
CC_VERSION,
SOCKET, SOCKET,
PORT, PORT,
PLUGIN_DIR, PLUGIN_DIR,
@@ -76,7 +79,7 @@ int main(int argc, char **argv)
while(1) while(1)
{ {
int option_index= 0; int option_index= 0;
c= getopt_long(argc, argv, "abcdef", long_options, &option_index); c= getopt_long(argc, argv, "abcdefghij", long_options, &option_index);
switch(c) { switch(c) {
case 'a': case 'a':
@@ -96,18 +99,21 @@ int main(int argc, char **argv)
puts(VERSION); puts(VERSION);
break; break;
case 'g': case 'g':
puts(SOCKET); puts(CC_VERSION);
break; break;
case 'h': case 'h':
puts(SOCKET);
break;
case 'i':
puts(PORT); puts(PORT);
break; break;
case 'p': case 'j':
puts(PLUGIN_DIR); puts(PLUGIN_DIR);
break; break;
case 't': case 'k':
puts(TLS_LIBRARY_VERSION); puts(TLS_LIBRARY_VERSION);
break; break;
case 'y': case 'l':
puts(LIBS_SYS); puts(LIBS_SYS);
break; break;
default: default:

View File

@@ -924,7 +924,7 @@ static int test_fetch_double(MYSQL *mysql)
return rc; return rc;
} }
static int test_conc282(MYSQL *mysql) static int test_conc281(MYSQL *mysql)
{ {
int rc; int rc;
MYSQL_STMT *stmt= mysql_stmt_init(mysql); MYSQL_STMT *stmt= mysql_stmt_init(mysql);
@@ -973,7 +973,7 @@ static int test_conc282(MYSQL *mysql)
} }
struct my_tests_st my_tests[] = { struct my_tests_st my_tests[] = {
{"test_conc282", test_conc282, 1, 0, NULL, NULL}, {"test_conc281", test_conc281, 1, 0, NULL, NULL},
{"test_fetch_seek", test_fetch_seek, 1, 0, NULL , NULL}, {"test_fetch_seek", test_fetch_seek, 1, 0, NULL , NULL},
{"test_fetch_offset", test_fetch_offset, 1, 0, NULL , NULL}, {"test_fetch_offset", test_fetch_offset, 1, 0, NULL , NULL},
{"test_fetch_column", test_fetch_column, 1, 0, NULL , NULL}, {"test_fetch_column", test_fetch_column, 1, 0, NULL , NULL},