branch: elpa/emacsql commit 5f4c2ed5a73fe658999a15b64a5d126f6af1833e Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Add emacsql-psql-unavailable-p. --- emacsql-psql.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/emacsql-psql.el b/emacsql-psql.el index 9406826b55..2e5cbfa081 100644 --- a/emacsql-psql.el +++ b/emacsql-psql.el @@ -9,6 +9,23 @@ (defvar emacsql-psql-executable "psql" "Path to the psql (PostgreSQL client) executable.") +(defun emacsql-psql-unavailable-p () + "Return a reason if the psql executable is not available. +:no-executable -- cannot find the executable +:cannot-execute -- cannot run the executable +:old-version -- sqlite3 version is too old" + (let ((psql emacsql-psql-executable)) + (if (null (executable-find psql)) + :no-executable + (condition-case _ + (with-temp-buffer + (call-process psql nil (current-buffer) nil "--version") + (let ((version (cl-third (split-string (buffer-string))))) + (if (version< version "1.0.0") + :old-version + nil))) + (error :cannot-execute))))) + (defclass emacsql-psql-connection (emacsql-connection) ((dbname :reader emacsql-psql-dbname :initarg :dbname)) (:documentation "A connection to a PostgreSQL database."))