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, 18 Feb 2017 18:01:55 +0100 Message-ID: <1487437315.31870.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="=-eP+PXK3nq7kqlavqWb3y" X-Trace: blaine.gmane.org 1487437449 11555 195.159.176.226 (18 Feb 2017 17:04:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Feb 2017 17:04:09 +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 Feb 18 18:04:02 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 1cf8QS-0001tq-J2 for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Feb 2017 18:04:00 +0100 Original-Received: from localhost ([::1]:59257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cf8QU-0001Lh-OZ for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Feb 2017 12:04:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cf8Pa-0000so-NH for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 12:03:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cf8PW-0003WY-PC for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 12:03:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47026) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cf8PW-0003WE-Ka for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 12:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cf8PW-0001Hx-D5 for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 12:03:02 -0500 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, 18 Feb 2017 17:03: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.14874373254883 (code B ref 25236); Sat, 18 Feb 2017 17:03:02 +0000 Original-Received: (at 25236) by debbugs.gnu.org; 18 Feb 2017 17:02:05 +0000 Original-Received: from localhost ([127.0.0.1]:45225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cf8Ob-0001Gh-4b for submit@debbugs.gnu.org; Sat, 18 Feb 2017 12:02:05 -0500 Original-Received: from mail-lf0-f41.google.com ([209.85.215.41]:36659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cf8OZ-0001G6-Ca for 25236@debbugs.gnu.org; Sat, 18 Feb 2017 12:02:03 -0500 Original-Received: by mail-lf0-f41.google.com with SMTP id z134so34124791lff.3 for <25236@debbugs.gnu.org>; Sat, 18 Feb 2017 09:02:03 -0800 (PST) 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=xRkEXbpK1HVrCv5m9huZ0u/w7jQnqvpPp5LdQMoXfQI=; b=kH4Hg5ZknqqTqEA93V7WSgkk2hH/m9sH3QmZ8yL0foskmHrzTgkwMclx6egCrV9XKo Ah+DZ8KNslq6ggipalcptcq51YXUusHHfeizCkcpFNLXP8Q51vsvtYRCPko1k9STEEag umILTNzrkjnqyFDTfmJoBxsF9Cufq0dL6WaujOsZTzZnhtpFwbfEVqRJX4PkhUdbPASp cRK5DhHmTyCM7LgvL5dQQyunWSc8lD6tUI5vRXfsQOOSSB9z3JEmWusCtMobjdwlyX9x kTeAdbe9RdiLIxYCyBvVuBc9Biz+Wv2A+ADz+uaChytv1KHfOBSzkxKVt0E/WeREq0xw mgpg== 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=xRkEXbpK1HVrCv5m9huZ0u/w7jQnqvpPp5LdQMoXfQI=; b=t4Bg0aVshupSHCbT8jgiV6qUaPiWAxUyPc+82nIShHbHb2BYdptNAc8GC9ua0GxkC1 C8YAoIELofQZ2WxT83s0XGNn7dP89IhUvhbKhf4I7yg664KLp8BanvbV9LIrvNISUhiP 3kIs2wToVu34/bqM90/Zvf3uH0a2cU4YQegKEfSmQtJKgqNbCw1P9HCEjAUnWcDlNThj xaRdFuRI7IAgH2WuuCRusjEUEyF/CbaVJpOiiiq7sbWtDH3W/fcOrqMHQANZ0oLs+Akx NZjhFLHrZVDLldS7xuE7/O0QZXcNxccsXjc2d7qyFC9O1YaSBq2roY5iHgsFdDak/AHU iScg== X-Gm-Message-State: AMke39lk3TTUJs+aIiL+Zvs9qSoDiMA3LpfPd6nhLE0HBX9ItUQ0ZXk2A9LZ1DL833qR/g== X-Received: by 10.25.199.14 with SMTP id x14mr3234905lff.13.1487437317421; Sat, 18 Feb 2017 09:01:57 -0800 (PST) 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 e23sm3646818lji.29.2017.02.18.09.01.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Feb 2017 09:01:56 -0800 (PST) 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:129512 Archived-At: --=-eP+PXK3nq7kqlavqWb3y Content-Type: text/plain; charset=utf-8; format=flowed On Wed, Jan 4, 2017 at 4:16 AM, Michael Mauger wrote: > Just got back after the holiday. Makes sense that could be a problem. > I'm getting ready to push a change related to completing-read so let > me take a look. > > Thanks for staying on top of this... I think the attached patch fixes half of the problem. Then we need to do something about the `completing-read' to make it possible to still select a database when `sql-postgres-list-databases' returns nil. -- Simen --=-eP+PXK3nq7kqlavqWb3y Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-non-zero-exit-status-from-psql-more-gracefull.patch >From 100fc2038511a10edbda1fbf0c877bef33efbe4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Sat, 18 Feb 2017 17:50:16 +0100 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 8868343129..4a936a6b45 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -1087,9 +1087,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.11.0 --=-eP+PXK3nq7kqlavqWb3y--