From: Joost Helberg <joost@snow.nl>
To: Emacs Org mode <emacs-orgmode@gnu.org>
Subject: not handling failing sql statements in ob-sql.el with postgresql
Date: Wed, 27 Nov 2013 10:49:52 +0100 [thread overview]
Message-ID: <87y54ab2db.fsf@snow.nl> (raw)
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
--
Snow B.V. http://snow.nl
next reply other threads:[~2013-11-27 9:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 9:49 Joost Helberg [this message]
2013-11-27 14:28 ` not handling failing sql statements in ob-sql.el with postgresql Rick Frankel
2013-12-01 18:07 ` Eric Schulte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y54ab2db.fsf@snow.nl \
--to=joost@snow.nl \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).