Skip to content

Commit

Permalink
ODBC-334 If TcpIp is selected, and port is 0, default port will be used
Browse files Browse the repository at this point in the history
by setup library(to test/save) dsn, and by connection procedure.
Made text field larger to make the work "interactive" completely visible.
  • Loading branch information
lawrinn committed Aug 8, 2021
1 parent 0c7ff3a commit 61a7763
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ If you need msi package to be generated by the build process, you also need:
- WiX Toolset https://wixtoolset.org/releases/
and provide WIX_DIR parameter for cmake with path to WiX binaries, or set WIX env variable with path to WiX installation directory.

If you need 32bit(or 64bit) build, you may need to give cmake -A Win32 parameter(or -A Win64), or specify correct cmake generator name using option -G

```
git clone https://github.com/MariaDB/mariadb-connector-odbc.git
cd mariadb-connector-odbc
Expand Down
17 changes: 17 additions & 0 deletions dsn/odbc_dsn.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ MADB_OptionsMap OptionsMap[]= {
void GetDialogFields(void);
HBRUSH hbrBg= NULL;


void DsnApplyDefaults(MADB_Dsn* Dsn)
{
/* Setting default port number if Tcp/Ip selected, and the port is 0 */
if (Dsn->IsTcpIp && Dsn->Port == 0)
{
Dsn->Port = 3306;
}
}


my_bool SetDialogFields()
{
int i= 0;
Expand Down Expand Up @@ -225,8 +236,10 @@ my_bool GetButtonState(int Dialog, int Button)
return (my_bool)IsDlgButtonChecked(hwndTab[Dialog], Button);
}


my_bool SaveDSN(HWND hDlg, MADB_Dsn *Dsn)
{
DsnApplyDefaults(Dsn);
if (Dsn->SaveFile != NULL || MADB_SaveDSN(Dsn))
return TRUE;
MessageBox(hDlg, Dsn->ErrorMsg, "Error", MB_OK);
Expand Down Expand Up @@ -475,6 +488,10 @@ static SQLRETURN TestDSN(MADB_Dsn *Dsn, SQLHANDLE *Conn, SQLCHAR *ConnStrBuffer)
{
ConnStr= ConnStrBuffer;
}

DsnApplyDefaults(Dsn);
/* If defaults has changed actual values - let them be reflected in the dialog */
SetDialogFields();
MADB_DsnToString(Dsn, ConnStr, CONNSTR_BUFFER_SIZE);

SQLAllocHandle(SQL_HANDLE_DBC, Environment, (SQLHANDLE *)&Connection);
Expand Down
2 changes: 1 addition & 1 deletion dsn/odbc_dsn.rc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ BEGIN
LTEXT "Statement(s):",IDC_STATIC,20,17,46,8,0,WS_EX_TRANSPARENT
RTEXT "Connection timeout in sec:",IDC_STATIC,17,62,86,8,0,WS_EX_TRANSPARENT
EDITTEXT txtConnectionTimeOut,111,60,40,14,ES_AUTOHSCROLL
CONTROL "The client is interactive",cbInteractive,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,62,80,10
CONTROL "The client is interactive",cbInteractive,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,154,62,84,10
CONTROL "Enable automatic &reconnect",ckReconnect,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,79,107,10,WS_EX_TRANSPARENT
CONTROL "Don't prompt when connecting",ckConnectPrompt,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,95,113,10,WS_EX_TRANSPARENT
CONTROL "Use compression",ckCompressed,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,79,107,10,WS_EX_TRANSPARENT
Expand Down
4 changes: 4 additions & 0 deletions ma_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,10 @@ SQLRETURN MADB_DbcConnectDB(MADB_Dbc *Connection,
else if (Dsn->Port > 0 || Dsn->IsTcpIp)
{
protocol = MYSQL_PROTOCOL_TCP;
if (Dsn->Port == 0)
{
Dsn->Port= 3306;
}
}
mysql_optionsv(Connection->mariadb, MYSQL_OPT_PROTOCOL, (void*)&protocol);

Expand Down

0 comments on commit 61a7763

Please sign in to comment.