* 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
* Re: not handling failing sql statements in ob-sql.el with postgresql
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
1 sibling, 0 replies; 3+ messages in thread
From: Rick Frankel @ 2013-11-27 14:28 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: not handling failing sql statements in ob-sql.el with postgresql
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
1 sibling, 0 replies; 3+ messages in thread
From: Eric Schulte @ 2013-12-01 18:07 UTC (permalink / raw)
To: Joost Helberg; +Cc: Emacs Org mode
Joost Helberg <joost@snow.nl> 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
^ 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).