]> granicus.if.org Git - postgresql/commitdiff
1) Fix a bug *double error message*.
authorHiroshi Inoue <inoue@tpf.co.jp>
Wed, 12 Jun 2002 02:27:44 +0000 (02:27 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Wed, 12 Jun 2002 02:27:44 +0000 (02:27 +0000)
2) Fix a bug *passowrd prompt in case of md5 authentication*.
3) Improve the DSN setup dialog.

src/interfaces/odbc/connection.c
src/interfaces/odbc/connection.h
src/interfaces/odbc/dlg_specific.h
src/interfaces/odbc/dlg_wingui.c
src/interfaces/odbc/drvconn.c
src/interfaces/odbc/psqlodbc.rc
src/interfaces/odbc/qresult.c
src/interfaces/odbc/resource.h
src/interfaces/odbc/setup.c

index 9ae47052f785298dd9fbc80ffedd8656c920d21a..c9b0c01c30c1c2b7ac7915e6dceb621a1eab3b1b 100644 (file)
@@ -129,7 +129,7 @@ PGAPI_Connect(
 
        qlog("conn = %u, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password);
 
-       if (CC_connect(conn, FALSE) <= 0)
+       if (CC_connect(conn, AUTH_REQ_OK, NULL) <= 0)
        {
                /* Error messages are filled in */
                CC_log_error(func, "Error on CC_connect", conn);
@@ -608,7 +608,7 @@ md5_auth_send(ConnectionClass *self, const char *salt)
 }
 
 char
-CC_connect(ConnectionClass *self, char do_password)
+CC_connect(ConnectionClass *self, char password_req, char *salt_para)
 {
        StartupPacket sp;
        StartupPacket6_2 sp62;
@@ -627,7 +627,7 @@ CC_connect(ConnectionClass *self, char do_password)
 
        mylog("%s: entering...\n", func);
 
-       if (do_password)
+       if (password_req != AUTH_REQ_OK)
 
                sock = self->sock;              /* already connected, just authenticate */
 
@@ -780,7 +780,7 @@ another_version_retry:
 
                do
                {
-                       if (do_password)
+                       if (password_req != AUTH_REQ_OK)
                                beresp = 'R';
                        else
                        {
@@ -811,11 +811,13 @@ another_version_retry:
                                        return 0;
                                case 'R':
 
-                                       if (do_password)
+                                       if (password_req != AUTH_REQ_OK)
                                        {
-                                               mylog("in 'R' do_password\n");
-                                               areq = AUTH_REQ_PASSWORD;
-                                               do_password = FALSE;
+                                               mylog("in 'R' password_req=%s\n", ci->password);
+                                               areq = password_req;
+                                               if (salt_para)
+                                                       memcpy(salt, salt_para, sizeof(salt));
+                                               password_req = AUTH_REQ_OK;
                                        }
                                        else
                                        {
@@ -823,7 +825,7 @@ another_version_retry:
                                                areq = SOCK_get_int(sock, 4);
                                                if (areq == AUTH_REQ_MD5)
                                                        SOCK_get_n_char(sock, salt, 4);
-                                               if (areq == AUTH_REQ_CRYPT)
+                                               else if (areq == AUTH_REQ_CRYPT)
                                                        SOCK_get_n_char(sock, salt, 2);
 
                                                mylog("areq = %d\n", areq);
@@ -850,7 +852,7 @@ another_version_retry:
                                                        {
                                                                self->errornumber = CONNECTION_NEED_PASSWORD;
                                                                self->errormsg = "A password is required for this connection.";
-                                                               return -1;              /* need password */
+                                                               return -areq;           /* need password */
                                                        }
 
                                                        mylog("past need password\n");
@@ -872,7 +874,9 @@ another_version_retry:
                                                        {
                                                                self->errornumber = CONNECTION_NEED_PASSWORD;
                                                                self->errormsg = "A password is required for this connection.";
-                                                               return -1; /* need password */
+                                                               if (salt_para)
+                                                                       memcpy(salt_para, salt, sizeof(salt));
+                                                               return -areq; /* need password */
                                                        }
                                                        if (md5_auth_send(self, salt))
                                                        {
@@ -1478,7 +1482,10 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi, UDWORD flag)
                                                self->errornumber = CONNECTION_COULD_NOT_RECEIVE;
                                                self->errormsg = QR_get_message(res);
                                                ReadyToReturn = TRUE;
-                                               retres = NULL;
+                                               if (PGRES_FATAL_ERROR == QR_get_status(res))
+                                                       retres = cmdres;
+                                               else
+                                                       retres = NULL;
                                                break;
                                        }
                                        query_completed = TRUE;
index 925efde3cde3956a1dfde497228dd3149db15dc8..5a26c29d781e87528175dc7b2aa5076dc7bfda35 100644 (file)
@@ -328,7 +328,7 @@ char                CC_begin(ConnectionClass *self);
 char           CC_commit(ConnectionClass *self);
 char           CC_abort(ConnectionClass *self);
 int                    CC_set_translation(ConnectionClass *self);
-char           CC_connect(ConnectionClass *self, char do_password);
+char           CC_connect(ConnectionClass *self, char password_req, char *salt);
 char           CC_add_statement(ConnectionClass *self, StatementClass *stmt);
 char           CC_remove_statement(ConnectionClass *self, StatementClass *stmt);
 char           CC_get_error(ConnectionClass *self, int *number, char **message);
index 9899bdac34b3ea9edd0f8ebc98d7fc5c70d0c5f4..99005d3a3384cad98000954364d1fb9ac55d48ca 100644 (file)
@@ -174,6 +174,10 @@ int CALLBACK driver_optionsProc(HWND hdlg,
                                   UINT wMsg,
                                   WPARAM wParam,
                                   LPARAM lParam);
+int CALLBACK global_optionsProc(HWND hdlg,
+                                  UINT wMsg,
+                                  WPARAM wParam,
+                                  LPARAM lParam);
 int CALLBACK ds_options1Proc(HWND hdlg,
                           UINT wMsg,
                           WPARAM wParam,
index 27075d757e01d9ca6d335a6bd5dba19b9dd77b78..88c2e9f4c45a366e619276dc78816d6df5c96827 100644 (file)
@@ -266,6 +266,43 @@ driver_optionsProc(HWND hdlg,
        return FALSE;
 }
 
+int                    CALLBACK
+global_optionsProc(HWND hdlg,
+                                  UINT wMsg,
+                                  WPARAM wParam,
+                                  LPARAM lParam)
+{
+
+       switch (wMsg)
+       {
+               case WM_INITDIALOG:
+                       CheckDlgButton(hdlg, DRV_COMMLOG, globals.commlog);
+#ifndef Q_LOG
+                       EnableWindow(GetDlgItem(hdlg, DRV_COMMLOG), FALSE);
+#endif /* Q_LOG */
+                       CheckDlgButton(hdlg, DRV_DEBUG, globals.debug);
+#ifndef MY_LOG
+                       EnableWindow(GetDlgItem(hdlg, DRV_DEBUG), FALSE);
+#endif /* MY_LOG */
+                       break;
+
+               case WM_COMMAND:
+                       switch (GET_WM_COMMAND_ID(wParam, lParam))
+                       {
+                               case IDOK:
+                                       globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
+                                       globals.debug = IsDlgButtonChecked(hdlg, DRV_DEBUG);
+                                       driver_options_update(hdlg, NULL, TRUE);
+
+                               case IDCANCEL:
+                                       EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
+                                       return TRUE;
+                       }
+       }
+
+       return FALSE;
+}
+
 int                    CALLBACK
 ds_options1Proc(HWND hdlg,
                                   UINT wMsg,
index 1fb91550df81333e267f776e5d4ad1619ceffe67..6c08376ac4bc05de7097e7cca498e906a9fd104a 100644 (file)
@@ -78,7 +78,8 @@ PGAPI_DriverConnect(
        char            connStrIn[MAX_CONNECT_STRING];
        char            connStrOut[MAX_CONNECT_STRING];
        int                     retval;
-       char            password_required = FALSE;
+       char            salt[5];
+       char            password_required = AUTH_REQ_OK;
        int                     len = 0;
        SWORD           lenStrout;
 
@@ -114,6 +115,7 @@ PGAPI_DriverConnect(
        getDSNdefaults(ci);
        /* initialize pg_version */
        CC_initialize_pg_version(conn);
+       salt[0] = '\0';
 
 #ifdef WIN32
 dialog:
@@ -173,7 +175,7 @@ dialog:
        }
 
        /* do the actual connect */
-       retval = CC_connect(conn, password_required);
+       retval = CC_connect(conn, password_required, salt);
        if (retval < 0)
        {                                                       /* need a password */
                if (fDriverCompletion == SQL_DRIVER_NOPROMPT)
@@ -185,7 +187,7 @@ dialog:
                else
                {
 #ifdef WIN32
-                       password_required = TRUE;
+                       password_required = -retval;
                        goto dialog;
 #else
                        return SQL_ERROR;       /* until a better solution is found. */
index 054179e5fb70ea92ef497cd726a6d685033160e5..540ca4053cec86385f55c31391087ae4353d6c02 100644 (file)
@@ -79,7 +79,7 @@ BEGIN
     GROUPBOX        "Options (Advanced):",IDC_OPTIONS,141,72,140,35,
                     BS_CENTER
     PUSHBUTTON      "DataSource",IDC_DATASOURCE,149,89,50,14
-    PUSHBUTTON      "Default",IDC_DRIVER,221,88,50,14
+    PUSHBUTTON      "Global",IDC_DRIVER,221,88,50,14
     CTEXT           "Please supply any missing information needed to connect.",
                     DRV_MSG_LABEL,25,4,238,10
 END
@@ -195,6 +195,21 @@ BEGIN
     PUSHBUTTON      "Cancel",IDCANCEL,126,195,50,14
     PUSHBUTTON      "Apply",IDAPPLY,201,195,50,14
 END
+
+DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE  0, 0, 306, 90
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Global settings"
+FONT 10, "Terminal"
+BEGIN
+    CTEXT      "Logging before establishing connections(the default for new DSNs also)",
+                    DRV_MSG_LABEL,25,15,238,10
+    CONTROL         "Comm&Log (C:\\psqlodbc.log)",DRV_COMMLOG,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,30,120,10
+    CONTROL         "Mylog(C:\\mylog_xxxx.log Detailed debug output)",DRV_DEBUG,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,45,200,10
+    DEFPUSHBUTTON   "Save",IDOK,39,70,50,14,WS_GROUP
+    PUSHBUTTON      "Cancel",IDCANCEL,104,70,50,15
+END
 #else
 DLG_CONFIG DIALOG DISCARDABLE  65, 43, 292, 116
 STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | 
@@ -221,7 +236,7 @@ BEGIN
     GROUPBOX        "Options (Advanced):",IDC_OPTIONS,140,74,140,35,
                     BS_CENTER
     PUSHBUTTON      "DataSource",IDC_DATASOURCE,160,90,50,14
-    PUSHBUTTON      "Default",IDC_DRIVER,220,90,50,14
+    PUSHBUTTON      "Global",IDC_DRIVER,220,90,50,14
     CTEXT           "Please supply any missing information needed to connect.",
                     DRV_MSG_LABEL,36,5,220,15
 END
@@ -337,6 +352,21 @@ BEGIN
     PUSHBUTTON      "Cancel",IDCANCEL,126,196,50,14
     PUSHBUTTON      "Apply",IDAPPLY,201,196,50,14
 END
+
+DLG_OPTIONS_GLOBAL DIALOG DISCARDABLE  0, 0, 306, 90
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Global settings"
+FONT 8, "MS Sans Serif"
+BEGIN
+    CTEXT      "Logging before establishing connections(the default for new DSNs also)",
+                    DRV_MSG_LABEL,25,15,238,10
+    CONTROL         "Comm&Log (C:\\psqlodbc.log)",DRV_COMMLOG,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,13,30,120,10
+    CONTROL         "Mylog(C:\\mylog_xxxx.log Detailed debug output)",
+                   DRV_DEBUG,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,13,45,200,10
+    DEFPUSHBUTTON   "Save",IDOK,39,70,50,14,WS_GROUP
+    PUSHBUTTON      "Cancel",IDCANCEL,104,70,50,15
+END
 #endif
 
 /////////////////////////////////////////////////////////////////////////////
index b10408207ffa48eac4bdacde8d6aaca74b3d7e5d..bb5f5ba246f1e88052c9b6f1cfaadfa5d9fd7628 100644 (file)
@@ -456,6 +456,7 @@ QR_next_tuple(QResultClass *self)
        char            fetch[128];
        QueryInfo       qi;
        ConnInfo   *ci = NULL;
+       BOOL            msg_truncated;
        UDWORD          abort_opt;
 
        if (fetch_count < num_backend_rows)
@@ -665,9 +666,12 @@ QR_next_tuple(QResultClass *self)
                                }
 
                        case 'E':                       /* Error */
-                               SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
-                               QR_set_message(self, msgbuffer);
-                               self->status = PGRES_FATAL_ERROR;
+                               msg_truncated = SOCK_get_string(sock, msgbuffer,
+ ERROR_MSG_LENGTH);
+
+                               /* Remove a newline */
+                               if (msgbuffer[0] != '\0' && msgbuffer[strlen(msgbuffer) - 1] == '\n')
+                                       msgbuffer[strlen(msgbuffer) - 1] = '\0';
 
                                abort_opt = 0;
                                if (!strncmp(msgbuffer, "FATAL", 5))
@@ -679,14 +683,19 @@ QR_next_tuple(QResultClass *self)
 
                                mylog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
                                qlog("ERROR from backend in next_tuple: '%s'\n", msgbuffer);
+                               while (msg_truncated)
+                                       msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
 
                                return FALSE;
 
                        case 'N':                       /* Notice */
-                               SOCK_get_string(sock, msgbuffer, ERROR_MSG_LENGTH);
-                               QR_set_message(self, msgbuffer);
-                               self->status = PGRES_NONFATAL_ERROR;
+                               msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
+                               QR_set_notice(self, cmdbuffer);
+                               if (QR_command_successful(self))
+                                       QR_set_status(self, PGRES_NONFATAL_ERROR);
                                qlog("NOTICE from backend in next_tuple: '%s'\n", msgbuffer);
+                               while (msg_truncated)
+                                       msg_truncated = SOCK_get_string(sock, cmdbuffer, ERROR_MSG_LENGTH);
                                continue;
 
                        default:                        /* this should only happen if the backend
index 570ba5c6e8ac1920b1868ddd6149f4a1f3d402ad..13c0a4ff757b55bbf177557b9791834ce93c6a6d 100644 (file)
@@ -6,6 +6,7 @@
 #define IDS_MSGTITLE                                   2\r
 #define DLG_OPTIONS_DRV                                        102\r
 #define DLG_OPTIONS_DS                                 103\r
+#define DLG_OPTIONS_GLOBAL                             104\r
 #define IDC_DSNAME                                             400\r
 #define IDC_DSNAMETEXT                                 401\r
 #define IDC_DESC                                               404\r
index aefeb5d42184f0fcdbc1098c5a91506d4a3274ea..51173ec39ec1f226206dcee9fa1845dba32d3b54 100644 (file)
@@ -290,9 +290,8 @@ ConfigDlgProc(HWND hdlg,
 
                                case IDC_DRIVER:
                                        lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWL_USER);
-
-                                       DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
-                                                hdlg, driver_optionsProc, (LPARAM) &lpsetupdlg->ci);
+                                       DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
+                                                hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci);
 
                                        return TRUE;
                        }