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: Sat, 29 Jul 2017 18:26:22 +0200 Message-ID: <1501345582.29622.0@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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-Bu0Z26b11s9E7j9epyRo" X-Trace: blaine.gmane.org 1501345676 2286 195.159.176.226 (29 Jul 2017 16:27:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 29 Jul 2017 16:27:56 +0000 (UTC) Cc: "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 Sat Jul 29 18:27:52 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 1dbUai-0000BH-6V for geb-bug-gnu-emacs@m.gmane.org; Sat, 29 Jul 2017 18:27:48 +0200 Original-Received: from localhost ([::1]:52868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbUao-0005Ko-5t for geb-bug-gnu-emacs@m.gmane.org; Sat, 29 Jul 2017 12:27:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbUa2-000520-A7 for bug-gnu-emacs@gnu.org; Sat, 29 Jul 2017 12:27:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbUZy-0006a3-9p for bug-gnu-emacs@gnu.org; Sat, 29 Jul 2017 12:27:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58831) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dbUZy-0006Zz-5M for bug-gnu-emacs@gnu.org; Sat, 29 Jul 2017 12:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dbUZx-0004il-V3 for bug-gnu-emacs@gnu.org; Sat, 29 Jul 2017 12:27:01 -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: Sat, 29 Jul 2017 16:27:01 +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.150134559418110 (code B ref 25236); Sat, 29 Jul 2017 16:27:01 +0000 Original-Received: (at 25236) by debbugs.gnu.org; 29 Jul 2017 16:26:34 +0000 Original-Received: from localhost ([127.0.0.1]:33275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbUZV-0004i2-Rw for submit@debbugs.gnu.org; Sat, 29 Jul 2017 12:26:34 -0400 Original-Received: from mail-lf0-f44.google.com ([209.85.215.44]:34019) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbUZT-0004ho-UF for 25236@debbugs.gnu.org; Sat, 29 Jul 2017 12:26:32 -0400 Original-Received: by mail-lf0-f44.google.com with SMTP id g25so97015822lfh.1 for <25236@debbugs.gnu.org>; Sat, 29 Jul 2017 09:26:31 -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=MR7S9eHRflnlWIEIcIJ6ZHyHIwGU3jB0z15ImnoJtRA=; b=WO8luTU8OuhHNEG4+uBcLLc0FdLmgoxg8W4KlMDyJkPK8S4rA+fVth0y4BQHc3SPqk o55xt9Jbd45nUsjTCR/QbYgvWUxw65lyj0VYnujgNJi17VBJbCZE83PbHjesquk4fi5x yjk8/khQaPvs8Ivm9jFKseVV681VF8t8MG0m6AkWT+rqWIENI7sAWhf08B01HhiMwWi/ 4J+MQVsWeLZ1Lz8Rb9Q8MYcZDSiWm2kt58gDN0huGQ2WItASzR2zWLfFoCwIUJJCofkN hSKYJ2L4Z0SKPnPFa3Ybessjl0P18fXHwMme44tkNQusNB+wJBRNjPNPfZmKZAbF5K+U BaNQ== 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=MR7S9eHRflnlWIEIcIJ6ZHyHIwGU3jB0z15ImnoJtRA=; b=t38HwqypaRC1ov5YZJsRR07oaZBBfI3m+JcDz3nBkLe1NNDX5TkPTGgIf2hIuFRfi3 yC65sGhTb6PahbfAlRJcqwR86ZkzHIdkOD6HWAhxe9VSwwR6FlZNYX1L3DTaFv03fqzP hYaKvayvrrw2C9P5KNJdn0AQEnhnb7rW5R1UgjrrLdO/Y3kM8ouq0Mv0s8vrMXuEP+9J 28HN1Vbo6EAlXakL9aRf0nARyWOUYQ0mFiGobbhel398fKjPHk8EOIfK9zj3yeMWRTXH RnX37lh/NNU37y2aqmLnck4STjYif7cZUJ1pdrWjahXPimLMTR1xTEAjG0f5H/vx7Yr8 l1gg== X-Gm-Message-State: AIVw110nD4K2migWBTTYNnGzv+0S6VhqGuvE85RnjrtK71p6cGGgMpG3 7ThpZx/dYaucKQ== X-Received: by 10.25.15.74 with SMTP id e71mr888801lfi.13.1501345586016; Sat, 29 Jul 2017 09:26:26 -0700 (PDT) Original-Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id h22sm1170106ljb.41.2017.07.29.09.26.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 29 Jul 2017 09:26:24 -0700 (PDT) In-Reply-To: <1397003198.5767161.1483499760212@mail.yahoo.com> 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:135118 Archived-At: --=-Bu0Z26b11s9E7j9epyRo Content-Type: text/plain; charset=utf-8; format=flowed On Wed, Jan 4, 2017 at 4:16 AM, Michael Mauger wrote: > I'm getting ready to push a change related to completing-read so let > me take a look. Hi Michael, any progress on this? Otherwise, does the attached patch look OK to install? I think it should fix the described problem. -- Simen --=-Bu0Z26b11s9E7j9epyRo Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-non-zero-exit-status-from-psql-more-gracefull.patch >From 6a203bdf63bda37a28d5f4ae51386f552e337895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Sat, 29 Jul 2017 18:20:43 +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. (sql-get-login-ext): Don't require a database name match. * test/lisp/progmodes/sql-tests.el (sql-tests-postgres-list-databases-error): New test. --- lisp/progmodes/sql.el | 9 +++++---- test/lisp/progmodes/sql-tests.el | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 68ca37207e..05370ba0aa 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -1090,9 +1090,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 @@ -2971,7 +2972,7 @@ sql-get-login-ext (expand-file-name file-name)))) ((plist-member plist :completion) - (completing-read prompt-def (plist-get plist :completion) nil t + (completing-read prompt-def (plist-get plist :completion) nil nil last-value history-var default)) ((plist-get plist :number) 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 --=-Bu0Z26b11s9E7j9epyRo--