Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Windows build errors, most config-dependent. #568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ucko
Copy link
Contributor

@ucko ucko commented May 30, 2024

  • In the absence of an external SQLGetPrivateProfileString, fail the build only when expecting to use an external driver manager, and expose tds_SQLGetPrivateProfileString to the odbc "connect" unit test. Don't let that test attempt to use SQLGetPrivateProfileStringW even in Unicode builds.
  • src/odbc/win*.c: Accommodate static builds, with no hinstFreeTDS; in particular, never attempt to show FreeTDS dialog boxes there.
  • src/utils/unittests/challenge.c: #include <freetds/sysdep_private.h>
    to ensure the availability of strcasecmp.

Split from #555.

* In the absence of an external SQLGetPrivateProfileString, fail the
  build only when expecting to use an external driver manager, and
  expose tds_SQLGetPrivateProfileString to the odbc "connect" unit test.
  Don't let that test attempt to use SQLGetPrivateProfileStringW even in
  Unicode builds.
* src/odbc/win*.c: Accommodate static builds, with no hinstFreeTDS; in
  particular, never attempt to show FreeTDS dialog boxes there.
* src/utils/unittests/challenge.c: #include <freetds/sysdep_private.h>
  to ensure the availability of strcasecmp.

Signed-off-by: Aaron M. Ucko <[email protected]>
@@ -556,7 +560,7 @@ odbc_build_connect_string(TDS_ERRS *errs, TDS_PARSED_PARAM *params, char **out)

#if !HAVE_SQLGETPRIVATEPROFILESTRING

#ifdef _WIN32
#if defined(_WIN32) && !defined(TDS_NO_DM)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would avoid this, Windows has a standard driver manager which should be used

@ucko
Copy link
Contributor Author

ucko commented Jun 3, 2024

I acknowledge that bypassing Windows' native DM is unconventional, but it's logistically simpler to use driverless mode everywhere than to arrange to link this API's tests directly against it only in the absence of a system DM. (The C++ Toolkit's build system covers bundled projects itself rather than using their own build systems.) I also seem to recall that the system DM insisted on sticking to drivers that had been registered system-wide, but perhaps that's not actually a problem, at least nowadays.

@freddy77
Copy link
Contributor

freddy77 commented Jun 3, 2024

Reasonable.

About the connect.c test... does it make sense to execute that part of the test that requires get_entry and so currently system SQLGetPrivateProfileString? It requires the driver to be registered as FreeTDS (see DRIVER=FreeTDS;SERVER=%s;UID=%s;PWD=%s;DATABASE=%s; connection string) which is only implemented by Driver Manager.

UPDATE: other parts of the connect.c test use DRIVER too. However it's still easier to disable this part if a driver manager is not used.

@ucko
Copy link
Contributor Author

ucko commented Jun 17, 2024

AFAICT, that part of the test does actually succeed with this change in place, at least if I point the test at appropriate freetds.conf and odbc.ini files. (I know there's logic to bypass that part when unable to look up the server name via get_entry, but it gets past that logic and proceeds with the remainder of that part.)

Comment on lines +16 to +20
#if !HAVE_SQLGETPRIVATEPROFILESTRING
# define SQLGetPrivateProfileString tds_SQLGetPrivateProfileString
int tds_SQLGetPrivateProfileString(LPCSTR pszSection, LPCSTR pszEntry,
LPCSTR pszDefault, LPSTR pRetBuffer,
int nRetBuffer, LPCSTR pszFileName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we use a DLL here? I would assume this test will refer to an undefined symbol and fail to load.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, (conditional) exporting is in order here. However, I need a static build anyway for the sake of the all_types, connection_string_parse, and utf8_4 tests, so our Windows builds leave this library static-only for simplicity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to sort out this last hunk. Maybe code for that specific function could be just duplicated somehow? I tried to build for Windows and SQLGetPrivateProfileString from odbc system libraries was used, not the version from shared library.

@ucko
Copy link
Contributor Author

ucko commented Sep 24, 2024

I've added CMake tuneups I'd missed earlier and rebased against master. With these tuneups in place, Windows builds still naturally default to the system driver manager, but I can build the connect test against tds_SQLGetPrivateProfileString by editing config.h to comment out HAVE_SQLGETPRIVATEPROFILESTRING's definition and instead predefine TDS_NO_DM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants