From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Newsgroups: gmane.emacs.bugs Subject: bug#25236: 26.0.50; sql-postgres not working on master Date: Thu, 10 Aug 2017 23:26:13 +0200 Message-ID: <1502400373.1756.3@smtp.gmail.com> References: <87vauftgz2.fsf@caral.i-did-not-set--mail-host-address--so-tickle-me> <1483121873.22754.0@smtp.gmail.com> <1397003198.5767161.1483499760212@mail.yahoo.com> <1501345582.29622.0@smtp.gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-lsA/bBhhXnkXMmmbNvis" X-Trace: blaine.gmane.org 1502400436 8104 195.159.176.226 (10 Aug 2017 21:27:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 10 Aug 2017 21:27:16 +0000 (UTC) Cc: Michael Mauger , =?UTF-8?Q?andr=C3=A9s_?= =?UTF-8?Q?ram=C3=ADrez?= , "sunshavi@fastmail.fm" , "25236@debbugs.gnu.org" <25236@debbugs.gnu.org> To: Michael Mauger Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 10 23:27:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfuyy-0001Wr-EI for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Aug 2017 23:27:08 +0200 Original-Received: from localhost ([::1]:55379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfuz3-00070Y-8z for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Aug 2017 17:27:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfuyx-00070S-GX for bug-gnu-emacs@gnu.org; Thu, 10 Aug 2017 17:27:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfuys-0008Sf-Rk for bug-gnu-emacs@gnu.org; Thu, 10 Aug 2017 17:27:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dfuys-0008Sa-NL for bug-gnu-emacs@gnu.org; Thu, 10 Aug 2017 17:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dfuys-0004OA-FK for bug-gnu-emacs@gnu.org; Thu, 10 Aug 2017 17:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Aug 2017 21:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25236 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25236-submit@debbugs.gnu.org id=B25236.150240038416819 (code B ref 25236); Thu, 10 Aug 2017 21:27:02 +0000 Original-Received: (at 25236) by debbugs.gnu.org; 10 Aug 2017 21:26:24 +0000 Original-Received: from localhost ([127.0.0.1]:54803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfuyG-0004ND-BY for submit@debbugs.gnu.org; Thu, 10 Aug 2017 17:26:24 -0400 Original-Received: from mail-qk0-f177.google.com ([209.85.220.177]:37067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfuyE-0004N0-2m for 25236@debbugs.gnu.org; Thu, 10 Aug 2017 17:26:22 -0400 Original-Received: by mail-qk0-f177.google.com with SMTP id z18so11441660qka.4 for <25236@debbugs.gnu.org>; Thu, 10 Aug 2017 14:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=r9K1eWKd3os2rbxee3nQo62MM8Www86aL/sIDyOCFjs=; b=CB+UmcH7BhpmN7FR4oOMh5Gwdy623Fzze1EB0tmD5k/NtScKNK9NYPTQWPHekTXGaD hdcDUDtDl4nhdINGcKgs7NVsc5IxiDBi/fqgrH1U59fbYiF+13i0XmtnvtLDQZNYHYiT vEOHUtmfZydgLsF7B0wyiMq4tZBijyhb1grIDeBZ2hU3JIKR5MpW+tTbr/+5ftPursix JWl7fKSFWIsBHEyc2D/XGBViKYKbKfigCTdn80bl8fyS4MOlRNzZPdc+/P3+pW3p+i0Y sEzDyOl2OrKXzlNsSPd1Sgcskz5sC92zLFZg7AmggXfNnaBlFwAPLEqmvLcZUBWvXmJo Q51w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=r9K1eWKd3os2rbxee3nQo62MM8Www86aL/sIDyOCFjs=; b=nS36OeBrvIScDv1HwrPQrtKJp1/Ydv1YPAgLEN+9Kp3KwFz5ccE2UJXkbLKGnXI6iT rXJo0MUad+HgwABhLTTzekGNm0enoh/xNwZeb3r14UOP8YhgUhfmlb4H3jUg0LK/nbVC Si7R/QP9UsDsLhy7S81hHRWPJwLWLM8yfRLCRMv4GoZPSeAq9m1AfPUEYenMLqyOWrXV pPddsHqbZ2lU7Y4yQNVZaCguDzeArAurGlny6vvnta2oDkQnYRYe9cnjlgNPgpT+DTcF 0G6lCy8hkoVi2UxuZ9Kj+5nj0riEurSx/xuW/JYpcLK4sR5pwr9DQQjPZVhd9/qeNR+7 HeMg== X-Gm-Message-State: AHYfb5hZpTMzxv7GSs2WjepredoFxORF7+6dMKM2q8lNNLPt5GFYp5Br ufKo4IWonliuAA== X-Received: by 10.55.212.129 with SMTP id s1mr5636272qks.41.1502400376374; Thu, 10 Aug 2017 14:26:16 -0700 (PDT) Original-Received: from [192.168.2.165] (216-164-224-125.c3-0.tlg-cbr3.atw-tlg.pa.cable.rcn.com. [216.164.224.125]) by smtp.gmail.com with ESMTPSA id 22sm4526228qto.36.2017.08.10.14.26.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Aug 2017 14:26:15 -0700 (PDT) In-Reply-To: X-Mailer: geary/0.11.3 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135629 Archived-At: --=-lsA/bBhhXnkXMmmbNvis Content-Type: text/plain; charset=utf-8; format=flowed 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 --=-lsA/bBhhXnkXMmmbNvis Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-non-zero-exit-status-from-psql-more-gracefull.patch >From a12099e443e9ab1a26715daafca6abb6c99f29ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= 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 --=-lsA/bBhhXnkXMmmbNvis--