From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Alain_Cl=C3=A9ment?= Subject: Re: Babel sql code block issue and patch proposal Date: Thu, 3 Mar 2011 20:34:15 +0100 Message-ID: References: <87sjv4pcwf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e64c3e6690e6b0049d991e8d Return-path: Received: from [140.186.70.92] (port=45244 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvEIL-0001Mb-RJ for emacs-orgmode@gnu.org; Thu, 03 Mar 2011 14:34:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvEIK-0002mz-8h for emacs-orgmode@gnu.org; Thu, 03 Mar 2011 14:34:41 -0500 Received: from mailc1.unil.ch ([130.223.27.61]:50305) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvEIJ-0002ma-RS for emacs-orgmode@gnu.org; Thu, 03 Mar 2011 14:34:40 -0500 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by mailc1.unil.ch stage1 with esmtpsa (Exim MailCleaner) id 1PvEIG-000524-8o for from ; Thu, 03 Mar 2011 20:34:36 +0100 Received: by wwj40 with SMTP id 40so1542651wwj.30 for ; Thu, 03 Mar 2011 11:34:35 -0800 (PST) In-Reply-To: <87sjv4pcwf.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org --0016e64c3e6690e6b0049d991e8d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Eric, Thanks for your prompt answer! Actually, it doesn't work since mysql interprets backslashes as options, even between quotes. The value of my `org-babel-temporary-directory' is "/var/folders/9E/9EMu+g0oHBSrq-h9sX6i1U+++TM/-Tmp-/babel-86766893", but "+"'s are escaped with a backslash at some stage. Thanks, - Alain 2011/3/3 Eric Schulte > Hi Alain, > > Does the following alternative fix work for you? > > #+begin_src diff > Changes in HEAD > Modified lisp/ob-sql.el > diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el > index 364070e..604d444 100644 > --- a/lisp/ob-sql.el > +++ b/lisp/ob-sql.el > @@ -71,7 +71,7 @@ This function is called by > `org-babel-execute-src-block'." > (or cmdline "") > (org-babel-process-file-name > in-file) > (org-babel-process-file-name > out-file))) > - ('mysql (format "mysql %s -e \"source %s\" > %s" > + ('mysql (format "mysql %s -e 'source %s' > %s" > (or cmdline "") > (org-babel-process-file-name in-file= ) > (org-babel-process-file-name > out-file))) > #+end_src > > Also, just out of curiosity would you mind sharing an example result of > `org-babel-temporary-directory' which contains backslashes? > > Thanks -- Eric > > Alain Cl=C3=A9ment writes: > > > Hi everyone, > > > > The =3Dorg-babel-temp-file=3D string seems to be escaped with backslash= es on > > some platforms (like MacOSX), which is not very appreciated by the =3Dm= ysql > > -e=3D command. I suggest the following patch for =3Dob-sql.el=3D (Org-m= ode > Version > > 7.4 (release_7.4.590.g85d4d)): > > > > 74c74 > > < ('mysql (format "mysql %s < %s > %s" > > --- > >> ('mysql (format "mysql %s -e \"source %s\" > %s" > > > > Best regards, > > -- Alain > > > > -- > > > > > > > > Alain Cl=C3=A9ment > > Dr =C3=A8s sc. math=C3=A9matiques > > > > Universit=C3=A9 de Lausanne > > Quartier UNIL-Centre > > B=C3=A2timent Unicentre > > Bureau 339 > > CH-1015 Lausanne > > > > T. +41 21 692 20 36 (direct) > > T. +41 21 692 20 60 (secr=C3=A9tariat) > > > > alain.clement@unil.ch > --=20 Alain Cl=C3=A9ment Dr =C3=A8s sc. math=C3=A9matiques Universit=C3=A9 de Lausanne Quartier UNIL-Centre B=C3=A2timent Unicentre Bureau 339 CH-1015 Lausanne T. +41 21 692 20 36 (direct) T. +41 21 692 20 60 (secr=C3=A9tariat) alain.clement@unil.ch --0016e64c3e6690e6b0049d991e8d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Eric,

Thanks for your prompt answer! Actually, it doe= sn't work since mysql interprets backslashes as options, even between q= uotes. The value of my `org-babel-temporary-directory' is "/var/fo= lders/9E/9EMu+g0oHBSrq-h9sX6i1U+++TM/-Tmp-/babel-86766893", but "= +"'s are escaped with a backslash at some stage.

Thanks,
- Alain

2011/3/3 Eric Schulte <schulte.eric@gmail.com>
Hi Alain,

Does the following alternative fix work for you?

#+begin_src diff
=C2=A0Changes in HEAD
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Modified lisp/ob-sql.el
=C2=A0diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
=C2=A0index 364070e..604d444 100644
=C2=A0--- a/lisp/ob-sql.el
=C2=A0+++ b/lisp/ob-sql.el
=C2=A0@@ -71,7 +71,7 @@ This function is called by `org-babel-execute-src-= block'."
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(or cmdli= ne "")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-babe= l-process-file-name in-file)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-babe= l-process-file-name out-file)))
=C2=A0- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0('mysql (format "mysql %s -e \"source %s\" > %s&qu= ot;
=C2=A0+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0('mysql (format "mysql %s -e 'source %s' > %s"<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (or cmdline &qu= ot;")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-babel-proce= ss-file-name in-file)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-babel-proce= ss-file-name out-file)))
#+end_src

Also, just out of curiosity would you mind sharing an example result of
`org-babel-temporary-directory' which contains backslashes?

Thanks -- Eric

Alain Cl=C3=A9ment <alain.cleme= nt@unil.ch> writes:

> Hi everyone,
>
> The =3Dorg-babel-temp-file=3D string seems to be escaped with backslas= hes on
> some platforms (like MacOSX), which is not very appreciated by the =3D= mysql
> -e=3D command. I suggest the following patch for =3Dob-sql.el=3D (Org-= mode Version
> 7.4 (release_7.4.590.g85d4d)):
>
> 74c74
> < =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ('mysql (format "mysql %s < %s > %s"
> ---
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ('mysql (format "mysql %s -e \"source %s\" > %s&q= uot;
>
> Best regards,
> -- Alain
>
> --
>
>
>
> Alain Cl=C3=A9ment
> Dr =C3=A8s sc. math=C3=A9matiques
>
> Universit=C3=A9 de Lausanne
> Quartier UNIL-Centre
> B=C3=A2timent Unicentre
> Bureau 339
> CH-1015 Lausanne
>
> T. +41 21 692 20 36 (direct)
> T. +41 21 692 20 60 (secr=C3=A9tariat)
>
> alain.clement@unil.ch



--



Alai= n Cl=C3=A9ment
Dr =C3=A8s sc. math=C3=A9matiques

Universit=C3=A9 de Lausanne
Qua= rtier UNIL-Centre
B=C3=A2timent Unicentre
Bureau 339
CH-1015 Lausa= nne

T. +41 21 692 20 36 (direct)
T. +41 21 692 20 60 (secr=C3=A9t= ariat)

al= ain.clement@unil.ch
--0016e64c3e6690e6b0049d991e8d--