From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Frankel Subject: Re: not handling failing sql statements in ob-sql.el with postgresql Date: Wed, 27 Nov 2013 09:28:17 -0500 Message-ID: <925ec24caf24dbf184ea266ac3b77fc6@mail.rickster.com> References: <87y54ab2db.fsf@snow.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vlg6M-0000cH-F9 for emacs-orgmode@gnu.org; Wed, 27 Nov 2013 09:28:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vlg6G-0001Fq-HJ for emacs-orgmode@gnu.org; Wed, 27 Nov 2013 09:28:26 -0500 Received: from mail.rickster.com ([204.62.15.78]:60041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vlg6G-0001Fi-DO for emacs-orgmode@gnu.org; Wed, 27 Nov 2013 09:28:20 -0500 In-Reply-To: <87y54ab2db.fsf@snow.nl> 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: emacs-orgmode@gnu.org On 2013-11-27 04:49, Joost Helberg wrote: > 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 > 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? Did a quick check, and this option goes all the way back to postgresql 7.1, so it looks like it won't break anything that shouldn't be broken :), and should be applied. rick