Skip to content
Permalink
Browse files

Merge branch 'master' into develop(3.0 into 3.1)

  • Loading branch information...
lawrinn committed Apr 4, 2019
2 parents 482a2ab + 3b39fe0 commit 6d9ed8c404c4978faa8580a9efd3e436e18bf4f4
Showing with 601 additions and 223 deletions.
  1. +1 −1 .travis/script.sh
  2. +1 −1 CMakeLists.txt
  3. +27 −16 dsn/ma_odbc_setup.h
  4. +25 −3 dsn/odbc_dsn.c
  5. +23 −41 dsn/odbc_dsn.rc
  6. BIN dsn/resource.h
  7. +1 −1 libmariadb
  8. +80 −18 ma_connection.c
  9. +4 −8 ma_desc.c
  10. +56 −12 ma_dsn.c
  11. +17 −3 ma_dsn.h
  12. +4 −15 ma_helper.c
  13. +50 −50 ma_info.c
  14. +6 −0 ma_platform_win32.c
  15. +2 −0 ma_platform_win32.h
  16. +2 −1 ma_result.c
  17. +20 −12 ma_statement.c
  18. +4 −2 ma_statement.h
  19. +0 −1 maodbcu.rc
  20. +39 −1 test/catalog2.c
  21. +87 −1 test/connstring.c
  22. +1 −1 test/datetime.c
  23. +34 −1 test/desc.c
  24. +40 −1 test/multistatement.c
  25. +21 −0 test/result2.c
  26. +56 −9 test/tap.h
  27. +0 −24 win/ma_odbc_setup.h
@@ -63,7 +63,7 @@ export TEST_SCHEMA=odbc_test
export TEST_UID=bob
export TEST_PASSWORD=

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_OPENSSL=ON
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_OPENSSL=ON -DWITH_SSL=OPENSSL
# In Travis we are interested in tests with latest C/C version, while for release we must use only latest release tag
#git submodule update --remote
cmake --build . --config RelWithDebInfo
@@ -121,7 +121,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/libmariadb/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/libmariadb/include)

IF(WIN32)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/win)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/dsn)
SET(ODBC_LIBS odbc32)
SET(ODBC_INSTLIBS odbccp32)
SET(MARIADB_ODBC_SOURCES ${MARIADB_ODBC_SOURCES}
@@ -1,20 +1,20 @@
/************************************************************************************
Copyright (C) 2013 SkySQL AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
Copyright (C) 2013,2014 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
*************************************************************************************/

#ifndef _ma_odbc_setup_h_
@@ -26,4 +26,15 @@
#define MA_WIN_SET_MAXLEN(Page, Field, Value) \
Edit_LimitText(GetDlgItem(hwndTab[(Page)],(Field)), (Value));



typedef struct
{
MADB_DsnKey *Key;
int Page;
int Item;
int MaxLength; /* For DSN_TYPE_CBOXGROUP that is the bit it represents */
my_bool Mandatory;
} MADB_DsnMap;

#endif /* _ma_odbc_setup_h_ */
@@ -1,5 +1,5 @@
/************************************************************************************
Copyright (C) 2013,2016 MariaDB Corporation AB
Copyright (C) 2013,2019 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -89,15 +89,23 @@ MADB_DsnMap DsnMap[] = {
{&DsnKeys[22], 4, txtSslCaPath, 260, 0},
{&DsnKeys[23], 4, txtSslCipher, 32, 0},
{&DsnKeys[24], 4, cbSslVerify, 0, 0},

{&DsnKeys[32], 4, cbTls11, 1, 0},
{&DsnKeys[32], 4, cbTls12, 2, 0},
{&DsnKeys[32], 4, cbTls13, 4, 0},
{NULL, 0, 0, 0, 0}
};

#define CBGROUP_BIT(MapIdx) (char)(DsnMap[MapIdx].MaxLength)
#define IS_CB_CHECKED(MapIdx) GetButtonState(DsnMap[MapIdx].Page, DsnMap[MapIdx].Item)
#define CBGROUP_SETBIT(_Dsn, MapIdx) *GET_FIELD_PTR(_Dsn, DsnMap[MapIdx].Key, char)|= CBGROUP_BIT(MapIdx)
#define CBGROUP_RESETBIT(_Dsn, MapIdx) *GET_FIELD_PTR(_Dsn, DsnMap[MapIdx].Key, char)&= ~CBGROUP_BIT(MapIdx)

MADB_OptionsMap OptionsMap[]= {
{1, rbPipe, MADB_OPT_FLAG_NAMED_PIPE},
{2, ckReconnect, MADB_OPT_FLAG_AUTO_RECONNECT},
{2, ckConnectPrompt, MADB_OPT_FLAG_NO_PROMPT},
{2, ckCompressed, MADB_OPT_FLAG_COMPRESSED_PROTO},
{2, ckUseMycnf, MADB_OPT_FLAG_USE_CNF},
{3, ckIgnoreSchema, MADB_OPT_FLAG_NO_SCHEMA},
{3, ckIgnoreSpace, MADB_OPT_FLAG_IGNORE_SPACE},
{3, ckMultiStmt, MADB_OPT_FLAG_MULTI_STATEMENTS},
@@ -148,6 +156,10 @@ my_bool SetDialogFields()
SendDlgItemMessage(hwndTab[DsnMap[i].Page], DsnMap[i].Item, BM_SETCHECK,
Val ? BST_CHECKED : BST_UNCHECKED, 0);
}
break;
case DSN_TYPE_CBOXGROUP:
SendDlgItemMessage(hwndTab[DsnMap[i].Page], DsnMap[i].Item, BM_SETCHECK,
(*GET_FIELD_PTR(Dsn, DsnMap[i].Key, char) & CBGROUP_BIT(i)) != '\0' ? BST_CHECKED : BST_UNCHECKED, 0);
}
i++;
}
@@ -333,7 +345,17 @@ void GetDialogFields()
*(int *)((char *)Dsn + DsnMap[i].Key->DsnOffset)= GetFieldIntVal(DsnMap[i].Page, DsnMap[i].Item);
break;
case DSN_TYPE_BOOL:
*(my_bool *)((char *)Dsn + DsnMap[i].Key->DsnOffset)= GetButtonState(DsnMap[i].Page, DsnMap[i].Item);
*GET_FIELD_PTR(Dsn, DsnMap[i].Key, my_bool)= IS_CB_CHECKED(i);
break;
case DSN_TYPE_CBOXGROUP:
if (IS_CB_CHECKED(i) != '\0')
{
CBGROUP_SETBIT(Dsn, i);
}
else
{
CBGROUP_RESETBIT(Dsn, i);
}
}
++i;
}
@@ -84,42 +84,19 @@ Tab_Cursor DIALOGEX 0, 0, 256, 172
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "Enable dynamic cursors",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,11,91,10
CONTROL "Disable driver provided cursor support",IDC_CHECK2,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,25,138,10
CONTROL "Don't cache results of forward only cursors",IDC_CHECK3,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,40,153,10
CONTROL "Force use of forward only cursors",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,55,124,10
CONTROL "Prefetch rows",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,70,61,10
CONTROL "Return matched rows instead of affected rows",IDC_CHECK6,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,84,165,10
CONTROL "Enable SQL_AUTO_IS_NULL",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,99,105,10
CONTROL "Pad Char to fulllength with SPACE",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,113,124,10
CONTROL "Return SQL_NULL_DATA for zero date",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,129,139,10
END

Tab_Metadata DIALOGEX 0, 0, 256, 172
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Initial Statement:",-1,8,15,56,8
EDITTEXT DSN_Name,73,14,169,40,ES_AUTOHSCROLL
CONTROL "Enable automatic reconnect",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,64,105,10
CONTROL "Allow big result sets",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,78,79,10
CONTROL "Allow multiple statements",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,93,97,10
CONTROL "Don't prompt when connecting",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,108,113,10
END

Tab_Connection DIALOGEX 0, 0, 256, 172
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Initial Statement:",-1,8,15,56,8,0,WS_EX_TRANSPARENT
EDITTEXT DSN_Name,73,14,169,40,ES_AUTOHSCROLL
CONTROL "Enable automatic reconnect",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,64,105,10,WS_EX_TRANSPARENT
CONTROL "Allow big result sets",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,78,79,10,WS_EX_TRANSPARENT
CONTROL "Allow multiple statements",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,93,97,10,WS_EX_TRANSPARENT
CONTROL "Don't prompt when connecting",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,108,113,10,WS_EX_TRANSPARENT
END

Page_1 DIALOGEX 0, 0, 299, 182
@@ -157,9 +134,10 @@ BEGIN
LTEXT "Statement(s):",IDC_STATIC,20,32,46,8,0,WS_EX_TRANSPARENT
RTEXT "Connection timeout in sec:",IDC_STATIC,17,77,86,8,0,WS_EX_TRANSPARENT
EDITTEXT txtConnectionTimeOut,111,75,40,14,ES_AUTOHSCROLL
CONTROL "Enable automatic &reconnect",ckReconnect,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,95,107,10,WS_EX_TRANSPARENT
CONTROL "Enable automatic &reconnect",ckReconnect,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,94,107,10,WS_EX_TRANSPARENT
CONTROL "Don't prompt when connecting",ckConnectPrompt,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,110,113,10,WS_EX_TRANSPARENT
CONTROL "Use compression",ckCompressed,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,94,107,10,WS_EX_TRANSPARENT
CONTROL "Read odbc section from my.cnf",ckUseMycnf,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,110,198,10,WS_EX_TRANSPARENT
PUSHBUTTON "Cancel",IDCANCEL,178,149,50,14
PUSHBUTTON "Next >",PB_NEXT,104,149,50,14
PUSHBUTTON "< Previous",PB_PREV,50,149,50,14,WS_DISABLED
@@ -193,28 +171,32 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "SSL Settings",IDC_STATIC,7,7,277,124,0,WS_EX_TRANSPARENT

LTEXT "Key",IDC_STATIC,15,25,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslKey,84,25,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbKeyBrowse,195,23,30,14
LTEXT "Key",IDC_STATIC,15,20,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslKey,84,20,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbKeyBrowse,195,18,30,14

LTEXT "Certificate",IDC_STATIC,15,39,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCert,84,39,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbCertBrowse,195,37,30,14
LTEXT "Certificate",IDC_STATIC,15,34,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCert,84,34,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbCertBrowse,195,32,30,14

LTEXT "Certificate Authority",IDC_STATIC,15,53,68,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCertAuth,84,53,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbCaCertBrowse,195,51,30,14
LTEXT "Certificate Authority",IDC_STATIC,15,48,68,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCertAuth,84,48,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbCaCertBrowse,195,46,30,14

LTEXT "CA Path",IDC_STATIC,15,67,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCaPath,84,67,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbCaPathBrowse,195,65,30,14
LTEXT "CA Path",IDC_STATIC,15,62,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCaPath,84,62,110,10,ES_AUTOHSCROLL
PUSHBUTTON "Browse",pbCaPathBrowse,195,60,30,14

LTEXT "Cipher",IDC_STATIC,15,81,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCipher,84,81,110,10,ES_AUTOHSCROLL
LTEXT "Cipher",IDC_STATIC,15,76,56,8,0,WS_EX_TRANSPARENT
EDITTEXT txtSslCipher,84,76,110,10,ES_AUTOHSCROLL

CONTROL "Verify Certificate",cbSslVerify,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,84,90,97,10,WS_EX_TRANSPARENT

LTEXT "Allowed TLS versions(Not checking any means that all are allowed)",IDC_STATIC,15,104,264,8,0,WS_EX_TRANSPARENT
CONTROL "v.1.1",cbTls11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,115,30,10,WS_EX_TRANSPARENT
CONTROL "v.1.2",cbTls12,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,115,30,10,WS_EX_TRANSPARENT
CONTROL "v.1.3",cbTls13,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,75,115,30,10,WS_EX_TRANSPARENT

CONTROL "Verify Certificate",cbSslVerify,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,84,95,97,10,WS_EX_TRANSPARENT
// CONTROL "Disable catalog support",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,39,91,10,WS_EX_TRANSPARENT
// CONTROL "Ignore space after function names",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,53,127,10,WS_EX_TRANSPARENT
PUSHBUTTON "Cancel",IDCANCEL,178,149,50,14
PUSHBUTTON "Next >",PB_NEXT,104,149,50,14
PUSHBUTTON "< Previous",PB_PREV,50,149,50,14,WS_DISABLED
BIN +194 Bytes (100%) dsn/resource.h
Binary file not shown.
@@ -1,5 +1,5 @@
/************************************************************************************
Copyright (C) 2013,2018 MariaDB Corporation AB
Copyright (C) 2013,2019 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -608,6 +608,10 @@ SQLRETURN MADB_DbcConnectDB(MADB_Dbc *Connection,
MADB_SetDefaultPluginsDir(Connection);
}

if (Dsn->ReadMycnf != '\0')
{
mysql_optionsv(Connection->mariadb, MYSQL_READ_DEFAULT_GROUP, (void *)"odbc");
}
/* If a client character set was specified in DSN, we will always use it.
Otherwise for ANSI applications we will use the current character set,
for unicode connections we use utf8
@@ -684,25 +688,83 @@ SQLRETURN MADB_DbcConnectDB(MADB_Dbc *Connection,
int protocol= MYSQL_PROTOCOL_SOCKET;
mysql_options(Connection->mariadb, MYSQL_OPT_PROTOCOL, (void*)&protocol);
}

if (!MADB_IS_EMPTY(Dsn->SslCa)
|| !MADB_IS_EMPTY(Dsn->SslCaPath)
|| !MADB_IS_EMPTY(Dsn->SslCipher)
|| !MADB_IS_EMPTY(Dsn->SslCert)
|| !MADB_IS_EMPTY(Dsn->SslKey))
{
mysql_ssl_set(Connection->mariadb, Dsn->SslKey, Dsn->SslCert, Dsn->SslCa, Dsn->SslCaPath, Dsn->SslCipher);
}
if (Dsn->SslVerify)
{
const unsigned int verify= 0x01010101;
mysql_options(Connection->mariadb, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char*)&verify);
}
else

{
const unsigned int verify= 0;
mysql_options(Connection->mariadb, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char*)&verify);
/* I don't think it's possible to have empty strings or only spaces in the string here, but I prefer
to have this paranoid check to make sure we dont' them */
const char *SslKey= ltrim(Dsn->SslKey);
const char *SslCert= ltrim(Dsn->SslCert);
const char *SslCa= ltrim(Dsn->SslCa);
const char *SslCaPath= ltrim(Dsn->SslCaPath);
const char *SslCipher= ltrim(Dsn->SslCipher);

if (!MADB_IS_EMPTY(SslCa)
|| !MADB_IS_EMPTY(SslCaPath)
|| !MADB_IS_EMPTY(SslCipher)
|| !MADB_IS_EMPTY(SslCert)
|| !MADB_IS_EMPTY(SslKey))
{
char Enable= 1;
mysql_optionsv(Connection->mariadb, MYSQL_OPT_SSL_ENFORCE, &Enable);

if (!MADB_IS_EMPTY(SslKey))
{
mysql_optionsv(Connection->mariadb, MYSQL_OPT_SSL_KEY, SslKey);
}
if (!MADB_IS_EMPTY(SslCert))
{
mysql_optionsv(Connection->mariadb, MYSQL_OPT_SSL_CERT, SslCert);
}
if (!MADB_IS_EMPTY(SslCa))
{
mysql_optionsv(Connection->mariadb, MYSQL_OPT_SSL_CA, SslCa);
}
if (!MADB_IS_EMPTY(SslCaPath))
{
mysql_optionsv(Connection->mariadb, MYSQL_OPT_SSL_CAPATH, SslCaPath);
}
if (!MADB_IS_EMPTY(SslCipher))
{
mysql_optionsv(Connection->mariadb, MYSQL_OPT_SSL_CIPHER, SslCipher);
}

if (Dsn->TlsVersion > 0)
{
char TlsVersion[sizeof(TlsVersionName) + sizeof(TlsVersionBits) - 1], *Ptr= TlsVersion; /* All names + (n-1) comma */
unsigned int i, NeedComma= 0;

for (i= 0; i < sizeof(TlsVersionBits); ++i)
{
if (Dsn->TlsVersion & TlsVersionBits[i])
{
if (NeedComma != 0)
{
*Ptr++= ',';
}
else
{
NeedComma= 1;
}
strcpy(Ptr, TlsVersionName[i]);
Ptr += strlen(TlsVersionName[i]);
}
}
mysql_optionsv(Connection->mariadb, MARIADB_OPT_TLS_VERSION, (void *)TlsVersion);
}
}

if (Dsn->SslVerify)
{
const unsigned int verify= 0x01010101;
mysql_options(Connection->mariadb, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char*)&verify);
}
else
{
const unsigned int verify= 0;
mysql_options(Connection->mariadb, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char*)&verify);
}
}


if (!MADB_IS_EMPTY(Dsn->SslCrlPath))
{

0 comments on commit 6d9ed8c

Please sign in to comment.
You can’t perform that action at this time.