mirror of
https://github.com/dimitri/pgloader.git
synced 2026-03-25 05:51:08 +01:00
Improve loading of external libs, fixes #142.
Loading external libs at application startup time is not convenient as it forces users to install freetds everywhere even when they don't need it. This patch makes it so that freetds is only loaded when pgloader is asked to load from a MS SQL database source. Note that we could have done the same for SSL if it wasn't possibly used to connect to PostgreSQL, which isn't optional in current pgloader implementation.
This commit is contained in:
parent
9da649d028
commit
5f520737e6
@ -11,18 +11,21 @@
|
||||
|
||||
(in-package #:cl-user)
|
||||
|
||||
#+ccl
|
||||
(progn
|
||||
(push (lambda () (cffi:close-foreign-library 'CL+SSL::LIBSSL))
|
||||
*save-exit-functions*)
|
||||
(defun close-foreign-libs ()
|
||||
"Close Foreign libs in use by pgloader at application save time."
|
||||
(let ((sb-ext:*muffled-warnings* 'style-warning))
|
||||
(mapc #'cffi:close-foreign-library '(cl+ssl::libssl
|
||||
mssql::sybdb))))
|
||||
|
||||
(push (lambda () (cffi:load-foreign-library 'CL+SSL::LIBSSL))
|
||||
*lisp-startup-functions*))
|
||||
(defun open-foreign-libs ()
|
||||
"Open Foreign libs in use by pgloader at application start time."
|
||||
(let ((sb-ext:*muffled-warnings* 'style-warning))
|
||||
;; we specifically don't load mssql::sybdb eagerly, it's getting loaded
|
||||
;; in only when the data source is a MS SQL database.
|
||||
(cffi:load-foreign-library 'cl+ssl::libssl)))
|
||||
|
||||
#+sbcl
|
||||
(progn
|
||||
(push (lambda () (cffi:close-foreign-library 'CL+SSL::LIBSSL))
|
||||
sb-ext:*save-hooks*)
|
||||
#+ccl (push #'open-foreign-libs *lisp-startup-functions*)
|
||||
#+sbcl (push #'open-foreign-libs sb-ext:*save-hooks*)
|
||||
|
||||
(push (lambda () (cffi:load-foreign-library 'CL+SSL::LIBSSL))
|
||||
sb-ext:*init-hooks*))
|
||||
#+ccl (push #'close-foreign-libs *save-exit-functions*)
|
||||
#+sbcl (push #'close-foreign-libs sb-ext:*init-hooks*)
|
||||
|
||||
@ -116,6 +116,10 @@
|
||||
(including)
|
||||
(excluding))
|
||||
`(lambda ()
|
||||
;; now is the time to load the CFFI lib we need (freetds)
|
||||
(let ((sb-ext:*muffled-warnings* 'style-warning))
|
||||
(cffi:load-foreign-library 'mssql::sybdb))
|
||||
|
||||
(let* ((state-before (pgloader.utils:make-pgstate))
|
||||
(*state* (or *state* (pgloader.utils:make-pgstate)))
|
||||
(state-idx (pgloader.utils:make-pgstate))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user