-
Notifications
You must be signed in to change notification settings - Fork 0
Test_ODBC
The instructions provided below specify the steps to build MariaDB Connector/ODBC version 3.0.3 on Linux on IBM Z for following distributions:
- RHEL (7.3, 7.4)
- SLES (12 SP2, 12 SP3)
- Ubuntu (16.04, 17.10)
General Notes:
-
When following the steps below, please use a standard permission user unless otherwise specified.
-
A directory
/<source_root>/
will be referred to in these instructions, this is a temporary writeable directory anywhere you'd like to place it.
-
RHEL (7.3, 7.4)
sudo yum install -y git wget cmake gcc gcc-c++ make ncurses-devel bison hostname tar boost-devel check-devel openssl-devel perl-CPAN 'perl(Test::More)'
-
SLES (12 SP2, 12 SP3)
sudo zypper install -y git wget tar cmake gcc gcc-c++ make ncurses-devel boost-devel check-devel openssl-devel bison scons glibc-locale unixODBC unixODBC-devel
-
Ubuntu (16.04)
sudo apt-get update sudo apt-get install -y build-essential hostname libncurses-dev git wget cmake gcc make tar libpcre3-dev bison scons libboost-dev libboost-program-options-dev openssl dh-autoreconf libssl-dev
-
Ubuntu (17.10)
sudo apt-get update sudo apt-get install -y build-essential hostname libncurses-dev git wget cmake gcc make tar libpcre3-dev bison scons libboost-dev libboost-program-options-dev openssl dh-autoreconf libssl-dev unixodbc unixodbc-dev
- Get MariaDB source
cd /<source_root>/
wget https://github.com/MariaDB/server/archive/mariadb-10.2.12.tar.gz
tar xzf mariadb-10.2.12.tar.gz
- Copy MariaDB Connector/C source into
libmariadb
folder
cd /<source_root>/
git clone https://github.com/MariaDB/mariadb-connector-c.git
cd mariadb-connector-c
git checkout v3.0.3
cp -r /<source_root>/mariadb-connector-c/* /<source_root>/server-mariadb-10.2.12/libmariadb/
- Build and install MariaDB
cd /<source_root>/server-mariadb-10.2.12
BUILD/autorun.sh
./configure
make
sudo make install
- Create a user and group with name mysql
sudo useradd mysql
sudo groupadd mysql
- Give owner permission to the mysql directory
cd /usr/local/mysql
sudo chmod -R o+rwx .
- Create database and populate test data into database
sudo scripts/mysql_install_db --user=mysql
- Start MySQL server
sudo cp support-files/mysql.server /etc/init.d/mysql
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
sudo bin/mysqladmin version --user=mysql
export PATH=$PATH:/usr/local/mysql/bin
- Drop anonymous user before running test cases
mysql -u root -e "DROP USER ''@'localhost';"
- Run tests
cd /<source_root>/server-mariadb-10.2.12/
make test
Note: Atleast unixODBC 2.3.4 is needed which is not present in repo of Ubuntu 16.04 and RHEL
cd /<source_root>/
wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.4.tar.gz
tar xvf unixODBC-2.3.4.tar.gz
cd unixODBC-2.3.4
./configure
make
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/bin:$PATH
- Download MariaDB Connector ODBC source code
cd /<source_root>/
wget https://github.com/MariaDB/mariadb-connector-odbc/archive/3.0.3.tar.gz
tar -xvf 3.0.3.tar.gz
- Make changes to
/<source_root>/mariadb-connector-odbc-3.0.3/CMakeLists.txt
to resolve linking error.@@ -207,6 +207,14 @@ ENDIF() +find_package(ZLIB) +if (ZLIB_FOUND) + MESSAGE(STATUS "Configuring to build with ZLIB") + include_directories(${ZLIB_INCLUDE_DIRS}) + ADD_DEFINITIONS(-DHAVE_ZLIB) + SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${ZLIB_LIBRARIES}) +endif() + IF(WIN32 OR WITH_OPENSSL) IF(WITH_OPENSSL) FIND_PACKAGE(OpenSSL)
- Make changes to
/<source_root>/mariadb-connector-odbc-3.0.3/ma_connection.c
.@@ -556,7 +556,7 @@ MADB_Dsn *Dsn) { char StmtStr[128]; - unsigned ReportDataTruncation= 1; + my_bool ReportDataTruncation= 1; unsigned int i; unsigned long client_flags= 0L; my_bool my_reconnect= 1; ```
- Make changes to
/<source_root>/mariadb-connector-odbc-3.0.3/ma_odbc.h
.@@ -301,7 +301,7 @@ MYSQL_RES *metadata; MADB_List ListItem; MADB_QUERY *Tokens; - SQLSMALLINT ParamCount; + SQLINTEGER ParamCount; enum MADB_DaeType DataExecutionType; MYSQL_RES *DefaultsResult; int ArrayOffset;
- Make changes to
/<source_root>/mariadb-connector-odbc-3.0.3/test/basic.c
.@@ -71,7 +71,7 @@ { SQLRETURN rc= SQL_SUCCESS; - SQLINTEGER value=3; + SQLSMALLINT value=3; SQLWCHAR Buffer[20]; char buffer[128];
- Make changes to
/<source_root>/mariadb-connector-odbc-3.0.3/test/param.c
.@@ -1485,6 +1485,7 @@ ODBC_TEST(odbc45) { SQLSMALLINT i; + SQLCHAR value; SQLLEN len= 0; SQLCHAR val[][4]= {"0", "1"};//, "4", "-1", "0.5", "z"}, SQLWCHAR valw[][4]= { { '0', '\0' }, { '1', '\0' }, { '4', '\0' }, { '-', '1', '\0' }, { '0', '.', '5', '\0' }, { 'z', '\0' } }; @@ -1523,7 +1524,8 @@ for (i= 0; i<sizeof(XpctdValue); ++i) { CHECK_STMT_RC(Stmt, SQLFetch(Stmt)); - is_num(my_fetch_int(Stmt, 1), XpctdValue[i]); + SQLGetData(Stmt, 1, SQL_C_BIT, &value, sizeof(value), 0); + is_num(value, XpctdValue[i]); } CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));
- Create a soft link (Only for RHEL)
sudo ln -s /usr/local/mysql/lib/libmysqlclient.a /usr/local/mysql/lib/libmariadbclient.a
- Run cmake
- For RHEL & SLES
cd /<source_root>/mariadb-connector-odbc-3.0.3/
cmake ../mariadb-connector-odbc-3.0.3/ -DWITH_OPENSSL=1
make
sudo make install
- For Ubuntu
cd /<source_root>/mariadb-connector-odbc-3.0.3/
cmake -DWITH_OPENSSL=1 -DODBC_LIB_DIR=/usr/lib/s390x-linux-gnu/
make
sudo make install
- Setup test environment for Connector ODBC
- Set Password for root user on localhost
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'rootpass';CREATE USER 'root' IDENTIFIED BY 'rootpass';"
- Set the environment variables
export TEST_DRIVER=maodbc_test
export TEST_SCHEMA=test
export TEST_DSN=maodbc_test
export TEST_UID=root
export TEST_PASSWORD=rootpass
- Edit odbc.ini file with following configuration
Note: Edit /etc/unixODBC/odbc.ini
on SLES, /etc/odbc.ini
on Ubuntu 17.10 and /usr/local/etc/odbc.ini
on Ubuntu 16.04 & RHEL
[maodbc_test]
Driver = maodbc_test
DESCRIPTION = MariaDB ODBC Connector Test
SERVER = localhost
PORT = 3306
DATABASE = test
UID = root
PASSWORD = rootpass
- Edit odbcinst.ini file with following configuration
Note: Edit /etc/unixODBC/odbcinst.ini
on SLES, /etc/odbcinst.ini
on Ubuntu 17.10 and /usr/local/etc/odbcinst.ini
on Ubuntu 16.04 & RHEL.
[ODBC]
# Change to "yes" to turn on tracing
Trace = no
TraceFile = /tmp/maodbc_trace.log
[maodbc_test]
Driver = /<source_root>/mariadb-connector-odbc-3.0.3/libmaodbc.so
DESCRIPTION = MariaDB ODBC Connector
Threading = 0
IconvEncoding=UTF16
5.2.3 Run tests
cd /<source_root>/mariadb-connector-odbc-3.0.3/test
ctest