emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* not handling failing sql statements in ob-sql.el with postgresql
@ 2013-11-27  9:49 Joost Helberg
  2013-11-27 14:28 ` Rick Frankel
  2013-12-01 18:07 ` Eric Schulte
  0 siblings, 2 replies; 3+ messages in thread
From: Joost Helberg @ 2013-11-27  9:49 UTC (permalink / raw)
  To: Emacs Org mode

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-12-01 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-27  9:49 not handling failing sql statements in ob-sql.el with postgresql Joost Helberg
2013-11-27 14:28 ` Rick Frankel
2013-12-01 18:07 ` Eric Schulte

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).