Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0484700

Browse files
author
Hiroshi Inoue
committed
1) Fix a bug *double error message*.
2) Fix a bug *passowrd prompt in case of md5 authentication*.3) Improve the DSN setup dialog.
1 parent237fb9b commit0484700

File tree

9 files changed

+116
-27
lines changed

9 files changed

+116
-27
lines changed

‎src/interfaces/odbc/connection.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ PGAPI_Connect(
129129

130130
qlog("conn = %u, %s(DSN='%s', UID='%s', PWD='%s')\n",conn,func,ci->dsn,ci->username,ci->password);
131131

132-
if (CC_connect(conn,FALSE) <=0)
132+
if (CC_connect(conn,AUTH_REQ_OK,NULL) <=0)
133133
{
134134
/* Error messages are filled in */
135135
CC_log_error(func,"Error on CC_connect",conn);
@@ -608,7 +608,7 @@ md5_auth_send(ConnectionClass *self, const char *salt)
608608
}
609609

610610
char
611-
CC_connect(ConnectionClass*self,chardo_password)
611+
CC_connect(ConnectionClass*self,charpassword_req,char*salt_para)
612612
{
613613
StartupPacketsp;
614614
StartupPacket6_2sp62;
@@ -627,7 +627,7 @@ CC_connect(ConnectionClass *self, char do_password)
627627

628628
mylog("%s: entering...\n",func);
629629

630-
if (do_password)
630+
if (password_req!=AUTH_REQ_OK)
631631

632632
sock=self->sock;/* already connected, just authenticate */
633633

@@ -780,7 +780,7 @@ CC_connect(ConnectionClass *self, char do_password)
780780

781781
do
782782
{
783-
if (do_password)
783+
if (password_req!=AUTH_REQ_OK)
784784
beresp='R';
785785
else
786786
{
@@ -811,19 +811,21 @@ CC_connect(ConnectionClass *self, char do_password)
811811
return0;
812812
case'R':
813813

814-
if (do_password)
814+
if (password_req!=AUTH_REQ_OK)
815815
{
816-
mylog("in 'R' do_password\n");
817-
areq=AUTH_REQ_PASSWORD;
818-
do_password= FALSE;
816+
mylog("in 'R' password_req=%s\n",ci->password);
817+
areq=password_req;
818+
if (salt_para)
819+
memcpy(salt,salt_para,sizeof(salt));
820+
password_req=AUTH_REQ_OK;
819821
}
820822
else
821823
{
822824

823825
areq=SOCK_get_int(sock,4);
824826
if (areq==AUTH_REQ_MD5)
825827
SOCK_get_n_char(sock,salt,4);
826-
if (areq==AUTH_REQ_CRYPT)
828+
elseif (areq==AUTH_REQ_CRYPT)
827829
SOCK_get_n_char(sock,salt,2);
828830

829831
mylog("areq = %d\n",areq);
@@ -850,7 +852,7 @@ CC_connect(ConnectionClass *self, char do_password)
850852
{
851853
self->errornumber=CONNECTION_NEED_PASSWORD;
852854
self->errormsg="A password is required for this connection.";
853-
return-1;/* need password */
855+
return-areq;/* need password */
854856
}
855857

856858
mylog("past need password\n");
@@ -872,7 +874,9 @@ CC_connect(ConnectionClass *self, char do_password)
872874
{
873875
self->errornumber=CONNECTION_NEED_PASSWORD;
874876
self->errormsg="A password is required for this connection.";
875-
return-1;/* need password */
877+
if (salt_para)
878+
memcpy(salt_para,salt,sizeof(salt));
879+
return-areq;/* need password */
876880
}
877881
if (md5_auth_send(self,salt))
878882
{
@@ -1478,7 +1482,10 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
14781482
self->errornumber=CONNECTION_COULD_NOT_RECEIVE;
14791483
self->errormsg=QR_get_message(res);
14801484
ReadyToReturn= TRUE;
1481-
retres=NULL;
1485+
if (PGRES_FATAL_ERROR==QR_get_status(res))
1486+
retres=cmdres;
1487+
else
1488+
retres=NULL;
14821489
break;
14831490
}
14841491
query_completed= TRUE;

‎src/interfaces/odbc/connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ charCC_begin(ConnectionClass *self);
328328
charCC_commit(ConnectionClass*self);
329329
charCC_abort(ConnectionClass*self);
330330
intCC_set_translation(ConnectionClass*self);
331-
charCC_connect(ConnectionClass*self,chardo_password);
331+
charCC_connect(ConnectionClass*self,charpassword_req,char*salt);
332332
charCC_add_statement(ConnectionClass*self,StatementClass*stmt);
333333
charCC_remove_statement(ConnectionClass*self,StatementClass*stmt);
334334
charCC_get_error(ConnectionClass*self,int*number,char**message);

‎src/interfaces/odbc/dlg_specific.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ int CALLBACK driver_optionsProc(HWND hdlg,
174174
UINTwMsg,
175175
WPARAMwParam,
176176
LPARAMlParam);
177+
intCALLBACKglobal_optionsProc(HWNDhdlg,
178+
UINTwMsg,
179+
WPARAMwParam,
180+
LPARAMlParam);
177181
intCALLBACKds_options1Proc(HWNDhdlg,
178182
UINTwMsg,
179183
WPARAMwParam,

‎src/interfaces/odbc/dlg_wingui.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,43 @@ driver_optionsProc(HWND hdlg,
266266
return FALSE;
267267
}
268268

269+
intCALLBACK
270+
global_optionsProc(HWNDhdlg,
271+
UINTwMsg,
272+
WPARAMwParam,
273+
LPARAMlParam)
274+
{
275+
276+
switch (wMsg)
277+
{
278+
caseWM_INITDIALOG:
279+
CheckDlgButton(hdlg,DRV_COMMLOG,globals.commlog);
280+
#ifndefQ_LOG
281+
EnableWindow(GetDlgItem(hdlg,DRV_COMMLOG), FALSE);
282+
#endif/* Q_LOG */
283+
CheckDlgButton(hdlg,DRV_DEBUG,globals.debug);
284+
#ifndefMY_LOG
285+
EnableWindow(GetDlgItem(hdlg,DRV_DEBUG), FALSE);
286+
#endif/* MY_LOG */
287+
break;
288+
289+
caseWM_COMMAND:
290+
switch (GET_WM_COMMAND_ID(wParam,lParam))
291+
{
292+
caseIDOK:
293+
globals.commlog=IsDlgButtonChecked(hdlg,DRV_COMMLOG);
294+
globals.debug=IsDlgButtonChecked(hdlg,DRV_DEBUG);
295+
driver_options_update(hdlg,NULL, TRUE);
296+
297+
caseIDCANCEL:
298+
EndDialog(hdlg,GET_WM_COMMAND_ID(wParam,lParam)==IDOK);
299+
return TRUE;
300+
}
301+
}
302+
303+
return FALSE;
304+
}
305+
269306
intCALLBACK
270307
ds_options1Proc(HWNDhdlg,
271308
UINTwMsg,

‎src/interfaces/odbc/drvconn.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ PGAPI_DriverConnect(
7878
charconnStrIn[MAX_CONNECT_STRING];
7979
charconnStrOut[MAX_CONNECT_STRING];
8080
intretval;
81-
charpassword_required= FALSE;
81+
charsalt[5];
82+
charpassword_required=AUTH_REQ_OK;
8283
intlen=0;
8384
SWORDlenStrout;
8485

@@ -114,6 +115,7 @@ PGAPI_DriverConnect(
114115
getDSNdefaults(ci);
115116
/* initialize pg_version */
116117
CC_initialize_pg_version(conn);
118+
salt[0]='\0';
117119

118120
#ifdefWIN32
119121
dialog:
@@ -173,7 +175,7 @@ PGAPI_DriverConnect(
173175
}
174176

175177
/* do the actual connect */
176-
retval=CC_connect(conn,password_required);
178+
retval=CC_connect(conn,password_required,salt);
177179
if (retval<0)
178180
{/* need a password */
179181
if (fDriverCompletion==SQL_DRIVER_NOPROMPT)
@@ -185,7 +187,7 @@ PGAPI_DriverConnect(
185187
else
186188
{
187189
#ifdefWIN32
188-
password_required=TRUE;
190+
password_required=-retval;
189191
gotodialog;
190192
#else
191193
returnSQL_ERROR;/* until a better solution is found. */

‎src/interfaces/odbc/psqlodbc.rc

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ BEGIN
7979
GROUPBOX "Options (Advanced):",IDC_OPTIONS,141,72,140,35,
8080
BS_CENTER
8181
PUSHBUTTON "DataSource",IDC_DATASOURCE,149,89,50,14
82-
PUSHBUTTON "Default",IDC_DRIVER,221,88,50,14
82+
PUSHBUTTON "Global",IDC_DRIVER,221,88,50,14
8383
CTEXT "Please supply any missing information needed to connect.",
8484
DRV_MSG_LABEL,25,4,238,10
8585
END
@@ -195,6 +195,21 @@ BEGIN
195195
PUSHBUTTON "Cancel",IDCANCEL,126,195,50,14
196196
PUSHBUTTON "Apply",IDAPPLY,201,195,50,14
197197
END
198+
199+
DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE 0, 0, 306, 90
200+
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
201+
CAPTION "Global settings"
202+
FONT 10, "Terminal"
203+
BEGIN
204+
CTEXT"Logging before establishing connections(the default for new DSNs also)",
205+
DRV_MSG_LABEL,25,15,238,10
206+
CONTROL "Comm&Log (C:\\psqlodbc.log)",DRV_COMMLOG,"Button",
207+
BS_AUTOCHECKBOX | WS_TABSTOP,13,30,120,10
208+
CONTROL "Mylog(C:\\mylog_xxxx.log Detailed debug output)",DRV_DEBUG,"Button",
209+
BS_AUTOCHECKBOX | WS_TABSTOP,13,45,200,10
210+
DEFPUSHBUTTON "Save",IDOK,39,70,50,14,WS_GROUP
211+
PUSHBUTTON "Cancel",IDCANCEL,104,70,50,15
212+
END
198213
#else
199214
DLG_CONFIG DIALOG DISCARDABLE 65, 43, 292, 116
200215
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION |
@@ -221,7 +236,7 @@ BEGIN
221236
GROUPBOX "Options (Advanced):",IDC_OPTIONS,140,74,140,35,
222237
BS_CENTER
223238
PUSHBUTTON "DataSource",IDC_DATASOURCE,160,90,50,14
224-
PUSHBUTTON "Default",IDC_DRIVER,220,90,50,14
239+
PUSHBUTTON "Global",IDC_DRIVER,220,90,50,14
225240
CTEXT "Please supply any missing information needed to connect.",
226241
DRV_MSG_LABEL,36,5,220,15
227242
END
@@ -337,6 +352,21 @@ BEGIN
337352
PUSHBUTTON "Cancel",IDCANCEL,126,196,50,14
338353
PUSHBUTTON "Apply",IDAPPLY,201,196,50,14
339354
END
355+
356+
DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE 0, 0, 306, 90
357+
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
358+
CAPTION "Global settings"
359+
FONT 8, "MS Sans Serif"
360+
BEGIN
361+
CTEXT"Logging before establishing connections(the default for new DSNs also)",
362+
DRV_MSG_LABEL,25,15,238,10
363+
CONTROL "Comm&Log (C:\\psqlodbc.log)",DRV_COMMLOG,"Button",
364+
BS_AUTOCHECKBOX | WS_TABSTOP,13,30,120,10
365+
CONTROL "Mylog(C:\\mylog_xxxx.log Detailed debug output)",
366+
DRV_DEBUG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,45,200,10
367+
DEFPUSHBUTTON "Save",IDOK,39,70,50,14,WS_GROUP
368+
PUSHBUTTON "Cancel",IDCANCEL,104,70,50,15
369+
END
340370
#endif
341371

342372
/////////////////////////////////////////////////////////////////////////////

‎src/interfaces/odbc/qresult.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ QR_next_tuple(QResultClass *self)
456456
charfetch[128];
457457
QueryInfoqi;
458458
ConnInfo*ci=NULL;
459+
BOOLmsg_truncated;
459460
UDWORDabort_opt;
460461

461462
if (fetch_count<num_backend_rows)
@@ -665,9 +666,12 @@ QR_next_tuple(QResultClass *self)
665666
}
666667

667668
case'E':/* Error */
668-
SOCK_get_string(sock,msgbuffer,ERROR_MSG_LENGTH);
669-
QR_set_message(self,msgbuffer);
670-
self->status=PGRES_FATAL_ERROR;
669+
msg_truncated=SOCK_get_string(sock,msgbuffer,
670+
ERROR_MSG_LENGTH);
671+
672+
/* Remove a newline */
673+
if (msgbuffer[0]!='\0'&&msgbuffer[strlen(msgbuffer)-1]=='\n')
674+
msgbuffer[strlen(msgbuffer)-1]='\0';
671675

672676
abort_opt=0;
673677
if (!strncmp(msgbuffer,"FATAL",5))
@@ -679,14 +683,19 @@ QR_next_tuple(QResultClass *self)
679683

680684
mylog("ERROR from backend in next_tuple: '%s'\n",msgbuffer);
681685
qlog("ERROR from backend in next_tuple: '%s'\n",msgbuffer);
686+
while (msg_truncated)
687+
msg_truncated=SOCK_get_string(sock,cmdbuffer,ERROR_MSG_LENGTH);
682688

683689
return FALSE;
684690

685691
case'N':/* Notice */
686-
SOCK_get_string(sock,msgbuffer,ERROR_MSG_LENGTH);
687-
QR_set_message(self,msgbuffer);
688-
self->status=PGRES_NONFATAL_ERROR;
692+
msg_truncated=SOCK_get_string(sock,cmdbuffer,ERROR_MSG_LENGTH);
693+
QR_set_notice(self,cmdbuffer);
694+
if (QR_command_successful(self))
695+
QR_set_status(self,PGRES_NONFATAL_ERROR);
689696
qlog("NOTICE from backend in next_tuple: '%s'\n",msgbuffer);
697+
while (msg_truncated)
698+
msg_truncated=SOCK_get_string(sock,cmdbuffer,ERROR_MSG_LENGTH);
690699
continue;
691700

692701
default:/* this should only happen if the backend

‎src/interfaces/odbc/resource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#defineIDS_MSGTITLE2
77
#defineDLG_OPTIONS_DRV102
88
#defineDLG_OPTIONS_DS103
9+
#defineDLG_OPTIONS_GLOBAL104
910
#defineIDC_DSNAME400
1011
#defineIDC_DSNAMETEXT401
1112
#defineIDC_DESC404

‎src/interfaces/odbc/setup.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,8 @@ ConfigDlgProc(HWND hdlg,
290290

291291
caseIDC_DRIVER:
292292
lpsetupdlg= (LPSETUPDLG)GetWindowLong(hdlg,DWL_USER);
293-
294-
DialogBoxParam(s_hModule,MAKEINTRESOURCE(DLG_OPTIONS_DRV),
295-
hdlg,driver_optionsProc, (LPARAM)&lpsetupdlg->ci);
293+
DialogBoxParam(s_hModule,MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
294+
hdlg,global_optionsProc, (LPARAM)&lpsetupdlg->ci);
296295

297296
return TRUE;
298297
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp