Refactor libodbc bindings#421
Draft
georgestagg wants to merge 8 commits intomainfrom
Draft
Conversation
459e4f2 to
97ba2c7
Compare
Collaborator
Author
|
Converting to draft until I can test some more next week... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors how we connect to ODBC databases using libodbc. It removes the dependency on
odbc-api, instead loading the dynamic library at runtime usinglibloadingand managing the FFI ourselves.The
odic-apicrate requires us to dynamically link with the library at build time. On Windows this is fine because it's shipped with Windows, but it has the following consequences for Linux/macOS:libodbc.dylib/.solibrary needs to be available at startup, even if you are not doing ODBC connections.We did this in v0.3.0+, and it turns out to be very fragile:
ggsql-jupytercannot be moved without also moving the dynamic libraries to match. This breaks the Jupyter installation process that copiesggsql-jupyterinto place.libodbc.sodynamic library bundled with the "manylinux" release may not work on other Linux distributions (e.g. workbench).By switching to
libloadingand handling the ODBC FFI ourselves, the library is loaded at runtime on demand. That is, it's only pulled in if a user is trying to use anodbc://connection. In that case, it is highly likely the required libraries are already installed on the machine at the system level. If not, we show an error asking the user to install unixodbc.For everyone else, the library isn't loaded at all. This simplifies things massively. We don't have to worry about building dylibs in GHA release CI, we don't have to set RPATHs or use other linker tricks, the binary works as expected if it is moved or linked somewhere else, and we don't have to worry about cross-Linux compatibility.
These changes should fix #416 and #417.