From: "Simen Heggestøyl" <simenheg@gmail.com>
To: Michael Mauger <mmauger@protonmail.com>
Cc: "Michael Mauger" <michael@mauger.com>,
"andrés ramírez" <rrandresf@gmail.com>,
"sunshavi@fastmail.fm" <sunshavi@fastmail.fm>,
"25236@debbugs.gnu.org" <25236@debbugs.gnu.org>
Subject: bug#25236: 26.0.50; sql-postgres not working on master
Date: Thu, 10 Aug 2017 23:26:13 +0200 [thread overview]
Message-ID: <1502400373.1756.3@smtp.gmail.com> (raw)
In-Reply-To: <a5m7xFNQkeRpgX_47Xz0JyMFjnO9mnKQXGyJcUcNrsv4THBUs3MB-WRw95G3uMKydbmO6iqKmCjp Nw-fgmo4vg==@protonmail.com>
[-- Attachment #1: Type: text/plain, Size: 146 bytes --]
Thanks Michael. There's still a problem when psql exists with a
non-zero exit status. I think the attached patch is needed in
addition.
-- Simen
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Handle-non-zero-exit-status-from-psql-more-gracefull.patch --]
[-- Type: text/x-patch, Size: 2118 bytes --]
From a12099e443e9ab1a26715daafca6abb6c99f29ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
Date: Wed, 9 Aug 2017 15:34:34 +0200
Subject: [PATCH] Handle non-zero exit status from psql more gracefully
* lisp/progmodes/sql.el (sql-postgres-list-databases): Handle non-zero
exit statuses from `psql -ltX' more gracefully by returning nil.
* test/lisp/progmodes/sql-tests.el
(sql-tests-postgres-list-databases-error): New test.
---
lisp/progmodes/sql.el | 7 ++++---
test/lisp/progmodes/sql-tests.el | 10 ++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index b176e52950..48e21605a3 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -1095,9 +1095,10 @@ sql-postgres-list-databases
"Return a list of available PostgreSQL databases."
(when (executable-find sql-postgres-program)
(let ((res '()))
- (dolist (row (process-lines sql-postgres-program "-ltX"))
- (when (string-match "^ \\([[:alnum:]-_]+\\) +|.*" row)
- (push (match-string 1 row) res)))
+ (ignore-errors
+ (dolist (row (process-lines sql-postgres-program "-ltX"))
+ (when (string-match "^ \\([[:alnum:]-_]+\\) +|.*" row)
+ (push (match-string 1 row) res))))
(nreverse res))))
;; Customization for Interbase
diff --git a/test/lisp/progmodes/sql-tests.el b/test/lisp/progmodes/sql-tests.el
index 27a72aa2c2..f75005f737 100644
--- a/test/lisp/progmodes/sql-tests.el
+++ b/test/lisp/progmodes/sql-tests.el
@@ -43,5 +43,15 @@
(should (equal (sql-postgres-list-databases)
'("db-name-1" "db_name_2")))))
+(ert-deftest sql-tests-postgres-list-databases-error ()
+ "Test that nil is returned when `psql -ltX' fails."
+ (cl-letf
+ (((symbol-function 'executable-find)
+ (lambda (_command) t))
+ ((symbol-function 'process-lines)
+ (lambda (_program &rest _args)
+ (error))))
+ (should-not (sql-postgres-list-databases))))
+
(provide 'sql-tests)
;;; sql-tests.el ends here
--
2.13.2
next prev parent reply other threads:[~2017-08-10 21:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-20 3:30 bug#25236: 26.0.50; sql-postgres not working on master sunshavi
2016-12-30 18:17 ` Simen Heggestøyl
2017-01-04 3:16 ` Michael Mauger
2017-02-18 17:01 ` Simen Heggestøyl
2017-05-04 19:57 ` erreina
2017-07-29 16:26 ` Simen Heggestøyl
2017-07-29 17:15 ` bug#25236: new mail address (was: bug#25236: 26.0.50; sql-postgres not working on master) andrés ramírez
2017-08-07 1:01 ` bug#25236: 26.0.50; sql-postgres not working on master Michael Mauger
[not found] ` <a5m7xFNQkeRpgX_47Xz0JyMFjnO9mnKQXGyJcUcNrsv4THBUs3MB-WRw95G3uMKydbmO6iqKmCjp Nw-fgmo4vg==@protonmail.com>
2017-08-10 21:26 ` Simen Heggestøyl [this message]
2017-09-02 13:09 ` Eli Zaretskii
2017-09-05 0:18 ` Michael Mauger
[not found] ` <Q9cdamlTWxEGS1Mjo7CPiTh35FxxlG4lWUukF0rR8xem_cIYrZKxQNoZtk0gBkPL393mVJg0kbSA 1hMZFvOoTQ==@protonmail.com>
2017-09-05 18:36 ` Simen Heggestøyl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502400373.1756.3@smtp.gmail.com \
--to=simenheg@gmail.com \
--cc=25236@debbugs.gnu.org \
--cc=michael@mauger.com \
--cc=mmauger@protonmail.com \
--cc=rrandresf@gmail.com \
--cc=sunshavi@fastmail.fm \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).