Registering DSN with odbcconf.exe overwrites the connection attributes with defaults

Haribabu Kommi <[email protected]>
Newsgroups gmane.comp.db.postgresql.odbc
Message-ID <CAJrrPGf4zVF+3myOFXJYPSoN90hOMRWzK9jnQkGp0j4Lt08RYA@mail.gmail.com>
With the following command, the SSLmode of the DSN is defaults to disable,
even the "prefer" option is provided in the connection attributes.

odbcconf.exe /A {CONFIGDSN "PostgreSQL Unicode(x64)"
"DSN=test3|SSLmode=prefer"}

During the configDSN, first the connection attributes are parsed in
ParseAttributes function and later all the values are replaced with
defaults using getCiAllDefaults. Because of this reason, all the provided
connection options are ignored.

By changing it as first fill the ci with defaults and later update it with
connection attributes works fine with connection attributes. Patch
attached. Am I missing anything?

Regards,
Hari Babu
Fujitsu Australia
0001-Initialize-the-RegisterDSN-default-values-first-and-.patch (application/octet-stream, 1 KB)
From 9cf4e24d24b25c973cd27a621171b3486b9afdc2 Mon Sep 17 00:00:00 2001
From: kommih <[email protected]>
Date: Mon, 23 Apr 2018 19:14:07 +1000
Subject: [PATCH] Initialize the RegisterDSN default values first and then
 replace them with provided connection string attributes

---
 setup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index 0d8a8a7..66551fa 100644
--- a/setup.c
+++ b/setup.c
@@ -118,8 +118,6 @@ ConfigDSN(HWND hwnd,
 		}
 		else if (lpsetupdlg->ci.dsn[0])
 		{
-			MYLOG(0, "about to getCiAllDefaults\n");
-			getCiAllDefaults(&lpsetupdlg->ci);
 			fSuccess = SetDSNAttributes(hwnd, lpsetupdlg, NULL);
 		}
 		else
@@ -581,6 +579,10 @@ ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg)
 
 	CC_conninfo_init(&(lpsetupdlg->ci), INIT_GLOBALS);
 
+	/* Initialize defaults and replace it with attribute string */
+	MYLOG(0, "about to getCiAllDefaults\n");
+	getCiAllDefaults(&lpsetupdlg->ci);
+
 	for (lpsz = lpszAttributes; *lpsz; lpsz++)
 	{
 		/*
-- 
2.16.1.windows.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.