From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: not handling failing sql statements in ob-sql.el with postgresql Date: Sun, 01 Dec 2013 11:07:36 -0700 Message-ID: <8738mctpg7.fsf@gmail.com> References: <87y54ab2db.fsf@snow.nl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnBRY-0006rw-Rr for emacs-orgmode@gnu.org; Sun, 01 Dec 2013 13:08:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnBRU-0001jR-BJ for emacs-orgmode@gnu.org; Sun, 01 Dec 2013 13:08:32 -0500 Received: from mail-pb0-x229.google.com ([2607:f8b0:400e:c01::229]:32976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnBRU-0001hZ-4E for emacs-orgmode@gnu.org; Sun, 01 Dec 2013 13:08:28 -0500 Received: by mail-pb0-f41.google.com with SMTP id jt11so17457465pbb.0 for ; Sun, 01 Dec 2013 10:08:27 -0800 (PST) In-Reply-To: <87y54ab2db.fsf@snow.nl> (Joost Helberg's message of "Wed, 27 Nov 2013 10:49:52 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Joost Helberg Cc: Emacs Org mode Joost Helberg writes: > Hi, > > in case psql (version 9.1 and later) encounters a SQL error, e.g. a > syntax error, it doesn't exit with an error-code. Instead it > continues and exits with 0. This means that evaluating faulty SQL-code > in org-mode/babel leaves the user with no clue of why the result set is > empty. > > I changed the code in ob-sql.el by adding the > --set="ON_ERROR_STOP-1" > command-line option to the psql command in order to make things work > correct. This option not only makes psql exit at the first error, it > also exits with a not 0 error-code. > > line 125 and further of my ob-sql.el: > ('postgresql (format > "psql --set=\"ON_ERROR_STOP=1\" -A -P footer=off -F \"\t\" -f %s -o %s %s" > (org-babel-process-file-name in-file) > (org-babel-process-file-name out-file) > (or cmdline ""))) > > Is this a change worth applying? Or will it break things? > > regards, > > Joost I just applied this change. Thanks, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D