Display MSDTC error messages properly in Distributed Transaction related settings...
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Wed, 31 May 2017 01:48:32 +0000 (10:48 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Wed, 31 May 2017 01:50:16 +0000 (10:50 +0900)
setup.c

diff --git a/setup.c b/setup.c
index c9a05911a26c8b814a60283224360ece09291fe2..53d51309d3a5f89098b87d9a289c21cad7718c9c 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -514,12 +514,16 @@ mylog("conn_string=%s\n", out_conn);
            }
            else
            {
-               SQLGETDIAGRECFUNC(SQL_HANDLE_DBC, conn, 1, NULL, &errnum, szMsg, _countof(szMsg), &str_len);
-               if (szMsg[0] != 0)
+               int strl;
+
+               snprintf(szMsg, _countof(szMsg), _T("%s\nMSDTC error:"), ermsg);
+               for (strl = 0; strl < SQL_MAX_MESSAGE_LENGTH; strl++)
                {
-                   snprintf(szMsg, _countof(szMsg), _T("%s\nMSDTC error:%s"), ermsg, szMsg);
-                   ermsg = szMsg;
+                   if (!szMsg[strl])
+                       break;
                }
+               SQLGETDIAGRECFUNC(SQL_HANDLE_DBC, conn, 1, NULL, &errnum, szMsg + strl, _countof(szMsg) - strl, &str_len);
+               ermsg = szMsg;
            }
            CALL_ReleaseTransactionObject(pObj);
        }