emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/emacsql 5f4c2ed5a7 166/427: Add emacsql-psql-unavailable-p


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 5f4c2ed5a7 166/427: Add emacsql-psql-unavailable-p.
Date: Tue, 13 Dec 2022 02:59:38 -0500 (EST)

branch: elpa/emacsql
commit 5f4c2ed5a73fe658999a15b64a5d126f6af1833e
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@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."))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]