Skip to content

Commit 49525b7

Browse files
committed
Merge branch 'odbc-3.1'
2 parents 06acf4b + 8b25483 commit 49525b7

22 files changed

+502
-157
lines changed

.github/workflows/ci.yml

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
name: Run CI Tests
3+
4+
on:
5+
push:
6+
branches:
7+
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
# Run weekly on Sundays at 2 AM UTC
11+
- cron: '0 2 * * 0'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
env:
18+
MYSQL_TEST_HOST: mariadb.example.com
19+
MYSQL_TEST_PORT: 3306
20+
MYSQL_TEST_USER: root
21+
MYSQL_TEST_PASSWD: "heyPassw+-_20oRd"
22+
MYSQL_TEST_DB: testo
23+
TEST_DSN: maodbc_test
24+
TEST_UID: root
25+
TEST_SERVER: mariadb.example.com
26+
TEST_PASSWORD: "heyPassw+-_20oRd"
27+
TEST_PORT: 3306
28+
TEST_SCHEMA: testo
29+
ODBCINI: "${{ github.workspace }}/test/odbc.ini"
30+
ODBCSYSINI: ${{ github.workspace }}/test
31+
ODBCINTSTINI: ${{ github.workspace }}/test/odbcinst.ini
32+
33+
jobs:
34+
setup:
35+
runs-on: ubuntu-latest
36+
# Only run scheduled jobs if we're on the right branch
37+
if: github.event_name != 'schedule' || contains(fromJSON('["odbc-3.1", "master"]'), github.ref_name)
38+
outputs:
39+
matrix: ${{ steps.set-matrix.outputs.final-matrix }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
- id: set-matrix
43+
name: build matrix
44+
uses: rusher/mariadb-test-build-matrix@main
45+
with:
46+
additional-matrix: '[]'
47+
48+
ci:
49+
name: ${{ matrix.name }}
50+
needs: setup
51+
timeout-minutes: 50
52+
strategy:
53+
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
54+
55+
runs-on: ${{ matrix.os }}
56+
continue-on-error: ${{ matrix.continue-on-error || matrix.os == 'macos-latest' }}
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Setup Test Environment
61+
id: setup-env
62+
uses: rusher/mariadb-test-setup@master
63+
with:
64+
node-version: ${{ matrix.node }}
65+
db-type: ${{ matrix.db-type }}
66+
db-tag: ${{ matrix.db-tag }}
67+
test-db-password: ${{ env.MYSQL_TEST_PASSWD }}
68+
test-db-database: ${{ env.MYSQL_TEST_DB }}
69+
test-db-port: ${{ env.MYSQL_TEST_PORT }}
70+
additional-conf: ${{ matrix.additional-conf || '' }}
71+
registry-user: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_USER || (secrets.DOCKER_PWD != '' && 'mariadbtest' || '') }}
72+
registry-password: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_TOKEN || secrets.DOCKER_PWD }}
73+
os: ${{ matrix.os }}
74+
75+
- name: make ubuntu
76+
if: ${{ startsWith(matrix.os, 'ubuntu') }}
77+
run: |
78+
sudo apt install unixodbc-dev
79+
cmake -DCONC_WITH_MSI=OFF -DCONC_WITH_UNIT_TESTS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=OPENSSL .
80+
cmake --build . --config RelWithDebInfo
81+
82+
- name: make macos
83+
if: ${{ startsWith(matrix.os, 'mac') }}
84+
run: |
85+
brew install libiodbc openssl
86+
ls -lrt /opt/homebrew/opt/libiodbc/lib
87+
88+
TEST_DRIVER=${{ github.workspace }}/RelWithDebInfo/libmaodbc.dylib
89+
echo "TEST_DRIVER=${{ github.workspace }}/RelWithDebInfo/libmaodbc.dylib" >> $GITHUB_ENV
90+
cmake -G Xcode -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY="" -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=NO -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO -DWITH_SIGNCODE=OFF -DODBC_LIB_DIR=/opt/homebrew/opt/libiodbc/lib -DODBC_INCLUDE_DIR=/opt/homebrew/opt/libiodbc/include -DCONC_WITH_MSI=OFF -DCONC_WITH_UNIT_TESTS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=OPENSSL -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -DWITH_EXTERNAL_ZLIB=On .
91+
cmake --build . --config RelWithDebInfo
92+
93+
- name: Install WiX
94+
if: ${{ startsWith(matrix.os, 'windows') }}
95+
shell: powershell
96+
run: |
97+
choco install wixtoolset -y
98+
99+
- name: make windows
100+
if: ${{ startsWith(matrix.os, 'windows') }}
101+
shell: powershell
102+
run: |
103+
cmake -DCONC_WITH_MSI=OFF -DCONC_WITH_UNIT_TESTS=OFF -DWITH_MSI=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=SCHANNEL . #-DDIRECT_LINK_TESTS=1 .
104+
cmake --build . --config RelWithDebInfo
105+
106+
- name: Install generated MSI (Windows only)
107+
if: startsWith(matrix.os, 'windows')
108+
shell: powershell
109+
run: |
110+
pwd
111+
ls ${{ github.workspace }}\packaging\windows
112+
Get-ChildItem -Path ${{ github.workspace }}\packaging\windows\mariadb-connector-odbc-*.msi
113+
$log = "install.log"
114+
foreach ($msi in Get-ChildItem -Path ${{ github.workspace }}\packaging\windows\mariadb-connector-odbc-*.msi) {
115+
$procInstall= Start-Process msiexec.exe -ArgumentList "/i $($msi.FullName) /qn /norestart" -NoNewWindow -PassThru
116+
#$procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru
117+
#$procMain.WaitForExit()
118+
#$procLog.Kill()
119+
}
120+
Get-OdbcDriver -Platform "64-bit"
121+
Add-OdbcDsn -Name $env:TEST_DSN -DriverName "MariaDB ODBC 3.1 Driver" -DsnType "User" -SetPropertyValue @( "SERVER=$env:TEST_SERVER", "DATABASE=$env:TEST_SCHEMA", "USER=$env:TEST_UID", "PASSWORD=$env:TEST_PASSWORD", "PORT=$env:TEST_PORT" )
122+
123+
- name: Run test suite
124+
shell: bash
125+
run: |
126+
echo "$PWD"
127+
128+
chmod 777 test
129+
ls -lrta
130+
cd ./test
131+
echo "$PWD"
132+
if [ "$DB_TYPE" = "mysql" ] ; then
133+
cp ../libmariadb/caching_sha2_password.* ../
134+
fi
135+
136+
if [[ "${RUNNER_OS}" == "Windows" ]]; then
137+
TEST_DRIVER="MariaDB ODBC 3.1 Driver"
138+
# INSTALLFOLDER=''
139+
ls ./RelWithDebInfo
140+
set +x
141+
#odbcconf CONFIGDSN "$TEST_DRIVER" "DSN=$TEST_DSN;SERVER=$TEST_SERVER;DATABASE=$TEST_SCHEMA;USER=$TEST_UID;PASSWORD=$TEST_PASSWORD;PORT=$TEST_PORT;$TEST_ADD_PARAM"
142+
set -ex
143+
else
144+
145+
cat $ODBCINSTINI
146+
cat $ODBCINI | grep -v PASSWORD
147+
148+
chmod 666 $ODBCINI $ODBCSYSINI/odbcinst.ini
149+
ls -lrt
150+
fi
151+
ctest --verbose
152+
153+
export TEST_ADD_PARAM="STREAMRS=1;FORWARDONLY=1"
154+
ctest --output-on-failure
155+
156+
env:
157+
DB_TYPE: ${{ matrix.db-type }}
158+
LOCAL_DB: ${{ steps.setup-env.outputs.database-type }}
159+
os: ${{ matrix.os }}
160+
TEST_DRIVER: ${{ env.TEST_DRIVER || 'maodbc_test' }}
161+
TEST_SOCKET:
162+
SSLCERT: ${{ matrix.db-type == 'container' && format('{0}/.github/workflows/certs/server.crt', github.workspace) || '' }}
163+
MARIADB_PLUGIN_DIR: ${{ github.workspace }}

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,3 @@ MESSAGE(STATUS "License File: ${CPACK_RESOURCE_FILE_LICENSE}")
406406
MESSAGE(STATUS "ReadMe File: ${CPACK_PACKAGE_DESCRIPTION_FILE}")
407407
MESSAGE(STATUS "Source Package Filename: ${CPACK_SOURCE_PACKAGE_FILE_NAME}.${CPACK_SOURCE_GENERATOR}")
408408

409-

driver/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ ENDIF()
256256
IF(EXISTS "${CMAKE_SOURCE_DIR}/test/CMakeLists.txt")
257257
IF(WITH_UNIT_TESTS)
258258
IF(NOT WIN32)
259+
IF(DIRECT_LINK_TESTS)
260+
ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD
261+
COMMAND ${CMAKE_COMMAND} ARGS -E copy $<TARGET_FILE:${LIBRARY_NAME}> test)
262+
ENDIF()
259263
# Configuring ini files for testing with UnixODBC
260264
SET_VALUE(TEST_DRIVER "maodbc_test")
261265
SET_VALUE(TEST_DSN "maodbc_test")

driver/ma_catalog.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ SQLRETURN MADB_StmtColumns(MADB_Stmt *Stmt,
660660
if (MADB_DYNAPPENDCONST(&StmtStr, "=DATABASE()"))
661661
goto dynerror;
662662

663-
if (TableName && NameLength3)
663+
if (TableName/* && NameLength3*/)
664664
{
665665
if (MADB_DynstrAppend(&StmtStr, "AND TABLE_NAME") ||
666666
AddPvOrIdCondition(Stmt, (void*)&StmtStr, (size_t)-1, TableName, NameLength3))
@@ -935,6 +935,14 @@ SQLRETURN MADB_StmtSpecialColumns(MADB_Stmt *Stmt, SQLUSMALLINT IdentifierType,
935935
}
936936
p+= _snprintf(p, sizeof(StmtStr) - (p - StmtStr), "ORDER BY TABLE_SCHEMA, TABLE_NAME, COLUMN_KEY");
937937
}
938+
#ifdef _ACTIONS_TRACE_
939+
#ifdef __APPLE__
940+
if (getenv("GITHUB_ACTIONS") != NULL && strncmp(getenv("GITHUB_ACTIONS"), "true", 4) == 0 && IdentifierType == SQL_ROWVER)
941+
{
942+
printf("# \"%s\"(%hu)\n", StmtStr, Nullable);
943+
}
944+
#endif // __APPLE__
945+
#endif
938946
return Stmt->Methods->ExecDirect(Stmt, StmtStr, SQL_NTS);
939947
}
940948
/* }}} */

driver/ma_connection.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ SQLRETURN MADB_Dbc::SetAttr(SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGE
246246
MADB_FREE(CatalogName);
247247
if (isWChar)
248248
{
249+
/* This can happen with direct linking only */
250+
if (StringLength == SQL_NTS)
251+
{
252+
StringLength= (SQLINTEGER)(SqlwcsLen((SQLWCHAR*)ValuePtr, -1) * sizeof(SQLWCHAR));
253+
}
249254
/* IsAnsi will be set before this, even if it is set before connection
250255
StringLength from DM here is octets length */
251256
CatalogName= MADB_ConvertFromWChar((SQLWCHAR *)ValuePtr, StringLength/ sizeof(SQLWCHAR), nullptr, ConnOrSrcCharset, nullptr, true);
@@ -407,6 +412,12 @@ SQLRETURN MADB_Dbc::GetAttr(SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGE
407412
case SQL_ATTR_CURRENT_CATALOG:
408413
{
409414
SQLSMALLINT StrLen;
415+
/* This is normally cared by DM and this is only for direct linking case - if connection has not been established yet,
416+
returnring error */
417+
if (mariadb == nullptr && CatalogName == nullptr)
418+
{
419+
return MADB_SetError(&Error, MADB_ERR_08003, nullptr, 0);
420+
}
410421

411422
auto ret= GetCurrentDB(ValuePtr, BufferLength, &StrLen, isWChar);
412423

@@ -434,10 +445,7 @@ SQLRETURN MADB_Dbc::GetAttr(SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGE
434445
/* SQL_ATTR_METADATA_ID is SQLUINTEGER attribute on connection level, but SQLULEN on statement level :/ */
435446
*(SQLUINTEGER *)ValuePtr= MetadataId;
436447
case SQL_ATTR_ODBC_CURSORS:
437-
#pragma warning(disable: 4995)
438-
#pragma warning(push)
439-
*(SQLULEN*)ValuePtr= SQL_CUR_USE_ODBC;
440-
#pragma warning(pop)
448+
*(SQLULEN*)ValuePtr= SQL_CUR_USE_DRIVER;
441449
break;
442450
case SQL_ATTR_ENLIST_IN_DTC:
443451
/* MS Distributed Transaction Coordinator not supported */

driver/ma_dsn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ my_bool MADB_SaveDSN(MADB_Dsn *Dsn)
456456
}
457457
if (!SQLWriteDSNToIni(Dsn->DSNName, Dsn->Driver))
458458
{
459-
SQLInstallerError(1,&ErrNum, Dsn->ErrorMsg, SQL_MAX_MESSAGE_LENGTH, NULL);
459+
SQLInstallerError((WORD)1,&ErrNum, Dsn->ErrorMsg, (WORD)SQL_MAX_MESSAGE_LENGTH, NULL);
460460
return FALSE;
461461
}
462462

driver/ma_environment.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*************************************************************************************/
1919
#include "ma_odbc.h"
2020

21-
Client_Charset utf8= { CP_UTF8, NULL };
22-
MARIADB_CHARSET_INFO* DmUnicodeCs= NULL;;
21+
Client_Charset utf8= { CP_UTF8, nullptr };
22+
MARIADB_CHARSET_INFO* DmUnicodeCs= nullptr;;
2323
Client_Charset SourceAnsiCs= {0, 0}; /* Basically it should be initialized with 0 anyway */
24-
const char* DefaultPluginLocation= NULL;
24+
const char* DefaultPluginLocation= nullptr;
2525
#ifndef _MAX_PATH
2626
# define _MAX_PATH 260
2727
#endif
@@ -84,7 +84,7 @@ static void DetectAppType(MADB_Env* Env)
8484
{
8585
Env->AppType= ATypeGeneral;
8686
#ifdef _WIN32
87-
if (GetModuleHandle("msaccess.exe") != NULL)
87+
if (GetModuleHandle("msaccess.exe") != nullptr)
8888
{
8989
Env->AppType= ATypeMSAccess;
9090
}
@@ -121,19 +121,19 @@ MADB_Env *MADB_EnvInit()
121121
goto cleanup;
122122
}
123123
#endif
124-
mysql_library_init(0, NULL, NULL);
124+
mysql_library_init(0, nullptr, nullptr);
125125
if (!(Env= new MADB_Env()))
126126
{
127127
/* todo: optional debug output */
128128
goto cleanup;
129129
}
130130

131-
MADB_PutErrorPrefix(NULL, &Env->Error);
131+
MADB_PutErrorPrefix(nullptr, &Env->Error);
132132

133133
Env->OdbcVersion= MADB_SUPPORTED_OV;
134134

135135
/* This is probably is better todo with thread_once */
136-
if (DmUnicodeCs == NULL)
136+
if (DmUnicodeCs == nullptr)
137137
{
138138
if (sizeof(SQLWCHAR) == 2)
139139
{
@@ -148,7 +148,7 @@ MADB_Env *MADB_EnvInit()
148148
GetDefaultLogDir();
149149
GetSourceAnsiCs(&SourceAnsiCs);
150150
/* If we have something in the buffer - then we've already tried to get default location w/out much success */
151-
if (DefaultPluginLocation == NULL && strlen(PluginLocationBuf) == 0)
151+
if (DefaultPluginLocation == nullptr && strlen(PluginLocationBuf) == 0)
152152
{
153153
DefaultPluginLocation= MADB_GetDefaultPluginsDir(PluginLocationBuf, sizeof(PluginLocationBuf));
154154
}
@@ -175,21 +175,20 @@ SQLRETURN MADB_EnvSetAttr(MADB_Env* Env, SQLINTEGER Attribute, SQLPOINTER ValueP
175175
case SQL_ATTR_ODBC_VERSION:
176176
if (!Env->Dbcs.empty())
177177
{
178-
return MADB_SetError(&Env->Error, MADB_ERR_HYC00, NULL, 0);
178+
return MADB_SetError(&Env->Error, MADB_ERR_HY010, nullptr, 0);
179179
}
180-
181180
if (valueAsInt != SQL_OV_ODBC2 && valueAsInt != SQL_OV_ODBC3 && valueAsInt != MADB_SUPPORTED_OV)
182181
{
183-
return MADB_SetError(&Env->Error, MADB_ERR_HY024, NULL, 0);
182+
return MADB_SetError(&Env->Error, MADB_ERR_HY024, nullptr, 0);
184183
}
185184
Env->OdbcVersion= valueAsInt;
186185
break;
187186
case SQL_ATTR_OUTPUT_NTS:
188187
if (valueAsInt != SQL_TRUE)
189-
MADB_SetError(&Env->Error, MADB_ERR_S1C00, NULL, 0);
188+
MADB_SetError(&Env->Error, MADB_ERR_S1C00, nullptr, 0);
190189
break;
191190
default:
192-
MADB_SetError(&Env->Error, MADB_ERR_HYC00, NULL, 0);
191+
MADB_SetError(&Env->Error, MADB_ERR_HYC00, nullptr, 0);
193192
break;
194193
}
195194
return Env->Error.ReturnValue;
@@ -212,7 +211,7 @@ SQLRETURN MADB_EnvGetAttr(MADB_Env *Env, SQLINTEGER Attribute, SQLPOINTER ValueP
212211
*(SQLINTEGER *)ValuePtr= SQL_TRUE;
213212
break;
214213
default:
215-
MADB_SetError(&Env->Error, MADB_ERR_HYC00, NULL, 0);
214+
MADB_SetError(&Env->Error, MADB_ERR_HYC00, nullptr, 0);
216215
break;
217216
}
218217
return Env->Error.ReturnValue;

driver/ma_statement.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,5 @@ void MADB_CloseCursor (MADB_Stmt *Stmt);
131131
return MADB_SetError(&aStmt->Error, MADB_ERR_HY008, "Execution canceled by command from other thread", 0);\
132132
}} while(0)
133133
#define RESET_CANCELED(aStmt) (aStmt)->canceled= false
134-
#endif
134+
135+
#endif /* _ma_statement_h_ */

driver/maodbc.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ SQLAllocHandle;
66
SQLAllocStmt;
77
SQLBindCol;
88
SQLBindParameter;
9+
SQLBindParam;
910
SQLBrowseConnect;
1011
SQLBrowseConnectW;
1112
SQLBulkOperations;

driver/mariadb-odbc-driver.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ SQLAllocEnv
66
SQLAllocHandle
77
SQLAllocStmt
88
SQLBindCol
9+
SQLBindParam
910
SQLBindParameter
1011
SQLBrowseConnect
1112
SQLBrowseConnect@UNICODE@

0 commit comments

Comments
 (0)