From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: Return from executed SQL block sometimes generates a backtrace Date: Fri, 07 Sep 2012 15:41:15 +0200 Message-ID: <80y5kmrlvo.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Return-path: 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-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hello, Code blocks which return (almost) nothing aren't correctly handled by Babel. When they really don't return anything, "error" displayed in the echo area; when they return the empty string, a backtrace is generated. * Examples #+PROPERTY: engine msosql #+PROPERTY: cmdline -S server -U user -P password -d database -n -w 234 #+PROPERTY: results output #+PROPERTY: exports both ** Block with no return #+begin_src sql :tangle no :eval yes ALTER TABLE tableindb ADD rol1 smalldatetime NULL #+end_src - does not add any "results" block - echoes "progn: Beginning of buffer" in the echo area ** Block with empty string returned #+begin_src sql :tangle no :eval yes ALTER TABLE tableindb ADD rol22 smalldatetime NULL PRINT '' #+end_src #+results: - adds the above "results" block - but generates an error: #+begin_example Debugger entered--Lisp error: (args-out-of-range 0 1) buffer-substring(1 0) (progn (insert (orgtbl-to-generic table params)) (goto-char (point-min)) = (while (re-search-forward org-table-hline-regexp nil t) (org-table-align)) = (buffer-substring 1 (buffer-size))) (unwind-protect (progn (insert (orgtbl-to-generic table params)) (goto-ch= ar (point-min)) (while (re-search-forward org-table-hline-regexp nil t) (or= g-table-align)) (buffer-substring 1 (buffer-size))) (and (buffer-name temp-= buffer) (kill-buffer temp-buffer))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (ins= ert (orgtbl-to-generic table params)) (goto-char (point-min)) (while (re-se= arch-forward org-table-hline-regexp nil t) (org-table-align)) (buffer-subst= ring 1 (buffer-size))) (and (buffer-name temp-buffer) (kill-buffer temp-buf= fer)))) (with-current-buffer temp-buffer (unwind-protect (progn (insert (orgtbl-t= o-generic table params)) (goto-char (point-min)) (while (re-search-forward = org-table-hline-regexp nil t) (org-table-align)) (buffer-substring 1 (buffe= r-size))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (with-current-buffer= temp-buffer (unwind-protect (progn (insert (orgtbl-to-generic table params= )) (goto-char (point-min)) (while (re-search-forward org-table-hline-regexp= nil t) (org-table-align)) (buffer-substring 1 (buffer-size))) (and (buffer= -name temp-buffer) (kill-buffer temp-buffer))))) (with-temp-buffer (insert (orgtbl-to-generic table params)) (goto-char (p= oint-min)) (while (re-search-forward org-table-hline-regexp nil t) (org-tab= le-align)) (buffer-substring 1 (buffer-size))) (let* ((params2 (list :remove-newlines t :tstart nil :tend nil :hline "|-= --" :sep " | " :lstart "| " :lend " |")) (params (org-combine-plists params= 2 params))) (with-temp-buffer (insert (orgtbl-to-generic table params)) (go= to-char (point-min)) (while (re-search-forward org-table-hline-regexp nil t= ) (org-table-align)) (buffer-substring 1 (buffer-size)))) orgtbl-to-orgtbl((nil) (:fmt (lambda (cell) (format "%s" cell)))) (concat (orgtbl-to-orgtbl (if (or (eq (quote hline) (car result)) (and (l= istp (car result)) (listp (cdr (car result))))) result (list result)) (quot= e (:fmt (lambda (cell) (format "%s" cell))))) "\n") (insert (concat (orgtbl-to-orgtbl (if (or (eq (quote hline) (car result))= (and (listp (car result)) (listp (cdr ...)))) result (list result)) (quote= (:fmt (lambda (cell) (format "%s" cell))))) "\n")) (cond ((null result)) ((member "list" result-params) (insert (org-babel-t= rim (org-list-to-generic (cons (quote unordered) (mapcar (lambda ... ...) (= if ... result ...))) (quote (:splicep nil :istart "- " :iend "\n")))) "\n")= ) ((funcall proper-list-p result) (goto-char beg) (insert (concat (orgtbl-t= o-orgtbl (if (or (eq ... ...) (and ... ...)) result (list result)) (quote (= :fmt (lambda ... ...)))) "\n")) (goto-char beg) (when (org-at-table-p) (org= -table-align))) ((and (listp result) (not (funcall proper-list-p result))) = (insert (format "%s\n" result))) ((member "file" result-params) (when inlin= ep (goto-char inlinep)) (insert result)) (t (goto-char beg) (insert result)= )) (let ((wrap (lambda (start finish) (goto-char end) (insert (concat finish= "\n")) (goto-char beg) (insert (concat start "\n")) (goto-char end) (goto-= char (point-at-eol)) (setq end (point-marker)))) (proper-list-p (lambda (it= ) (and (listp it) (null (cdr (last it))))))) (cond ((null result)) ((member= "list" result-params) (insert (org-babel-trim (org-list-to-generic (cons (= quote unordered) (mapcar ... ...)) (quote (:splicep nil :istart "- " :iend = "\n")))) "\n")) ((funcall proper-list-p result) (goto-char beg) (insert (co= ncat (orgtbl-to-orgtbl (if (or ... ...) result (list result)) (quote (:fmt = ...))) "\n")) (goto-char beg) (when (org-at-table-p) (org-table-align))) ((= and (listp result) (not (funcall proper-list-p result))) (insert (format "%= s\n" result))) ((member "file" result-params) (when inlinep (goto-char inli= nep)) (insert result)) (t (goto-char beg) (insert result))) (when (funcall = proper-list-p result) (goto-char (org-table-end))) (setq end (point-marker)= ) (cond ((assoc :wrap (nth 2 info)) (let ((name (or (cdr ...) "RESULTS"))) = (funcall wrap (concat "#+BEGIN_" name) (concat "#+END_" name)))) ((member "= html" result-params) (funcall wrap "#+BEGIN_HTML" "#+END_HTML")) ((member "= latex" result-params) (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX")) ((membe= r "code" result-params) (funcall wrap (format "#+BEGIN_SRC %s%s" (or lang "= none") results-switches) "#+END_SRC")) ((member "org" result-params) (funca= ll wrap "#+BEGIN_ORG" "#+END_ORG")) ((member "raw" result-params) (goto-cha= r beg) (if (org-at-table-p) (org-cycle))) ((member "wrap" result-params) (f= uncall wrap ":RESULTS:" ":END:")) ((and (not (funcall proper-list-p result)= ) (not (member "file" result-params))) (org-babel-examplize-region beg end = results-switches) (setq end (point))))) (let* ((inlinep (save-excursion (when (or (org-babel-get-inline-src-block= -matches) (org-babel-get-lob-one-liner-matches)) (goto-char (match-end 0)) = (insert (if (listp result) "\n" " ")) (point)))) (existing-result (unless i= nlinep (org-babel-where-is-src-block-result t info hash indent))) (results-= switches (cdr (assoc :results_switches (nth 2 info)))) beg end) (when (and = (stringp result) (not inlinep) (> (length result) 0) (not (or (string-equal= (substring result -1) "\n") (string-equal (substring result -1) "")))) (se= tq result (concat result "\n"))) (if (not existing-result) (setq beg (or in= linep (point))) (goto-char existing-result) (save-excursion (re-search-forw= ard "#" nil t) (setq indent (- (current-column) 1))) (forward-line 1) (setq= beg (point)) (cond ((member "replace" result-params) (delete-region (point= ) (org-babel-result-end))) ((member "append" result-params) (goto-char (org= -babel-result-end)) (setq beg (point-marker))) ((member "prepend" result-pa= rams)))) (setq results-switches (if results-switches (concat " " results-sw= itches) "")) (let ((wrap (lambda (start finish) (goto-char end) (insert (co= ncat finish "\n")) (goto-char beg) (insert (concat start "\n")) (goto-char = end) (goto-char (point-at-eol)) (setq end (point-marker)))) (proper-list-p = (lambda (it) (and (listp it) (null (cdr ...)))))) (cond ((null result)) ((m= ember "list" result-params) (insert (org-babel-trim (org-list-to-generic (c= ons ... ...) (quote ...))) "\n")) ((funcall proper-list-p result) (goto-cha= r beg) (insert (concat (orgtbl-to-orgtbl (if ... result ...) (quote ...)) "= \n")) (goto-char beg) (when (org-at-table-p) (org-table-align))) ((and (lis= tp result) (not (funcall proper-list-p result))) (insert (format "%s\n" res= ult))) ((member "file" result-params) (when inlinep (goto-char inlinep)) (i= nsert result)) (t (goto-char beg) (insert result))) (when (funcall proper-l= ist-p result) (goto-char (org-table-end))) (setq end (point-marker)) (cond = ((assoc :wrap (nth 2 info)) (let ((name (or ... "RESULTS"))) (funcall wrap = (concat "#+BEGIN_" name) (concat "#+END_" name)))) ((member "html" result-p= arams) (funcall wrap "#+BEGIN_HTML" "#+END_HTML")) ((member "latex" result-= params) (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX")) ((member "code" resul= t-params) (funcall wrap (format "#+BEGIN_SRC %s%s" (or lang "none") results= -switches) "#+END_SRC")) ((member "org" result-params) (funcall wrap "#+BEG= IN_ORG" "#+END_ORG")) ((member "raw" result-params) (goto-char beg) (if (or= g-at-table-p) (org-cycle))) ((member "wrap" result-params) (funcall wrap ":= RESULTS:" ":END:")) ((and (not (funcall proper-list-p result)) (not (member= "file" result-params))) (org-babel-examplize-region beg end results-switch= es) (setq end (point))))) (when (and (not inlinep) (numberp indent) indent = (> indent 0) (not (and (listp result) (member "append" result-params)))) (i= ndent-rigidly beg end indent))) (save-excursion (let* ((inlinep (save-excursion (when (or (org-babel-get-= inline-src-block-matches) (org-babel-get-lob-one-liner-matches)) (goto-char= (match-end 0)) (insert (if ... "\n" " ")) (point)))) (existing-result (unl= ess inlinep (org-babel-where-is-src-block-result t info hash indent))) (res= ults-switches (cdr (assoc :results_switches (nth 2 info)))) beg end) (when = (and (stringp result) (not inlinep) (> (length result) 0) (not (or (string-= equal (substring result -1) "\n") (string-equal (substring result -1) "")))= ) (setq result (concat result "\n"))) (if (not existing-result) (setq beg (= or inlinep (point))) (goto-char existing-result) (save-excursion (re-search= -forward "#" nil t) (setq indent (- (current-column) 1))) (forward-line 1) = (setq beg (point)) (cond ((member "replace" result-params) (delete-region (= point) (org-babel-result-end))) ((member "append" result-params) (goto-char= (org-babel-result-end)) (setq beg (point-marker))) ((member "prepend" resu= lt-params)))) (setq results-switches (if results-switches (concat " " resul= ts-switches) "")) (let ((wrap (lambda (start finish) (goto-char end) (inser= t (concat finish "\n")) (goto-char beg) (insert (concat start "\n")) (goto-= char end) (goto-char (point-at-eol)) (setq end (point-marker)))) (proper-li= st-p (lambda (it) (and (listp it) (null ...))))) (cond ((null result)) ((me= mber "list" result-params) (insert (org-babel-trim (org-list-to-generic ...= ...)) "\n")) ((funcall proper-list-p result) (goto-char beg) (insert (conc= at (orgtbl-to-orgtbl ... ...) "\n")) (goto-char beg) (when (org-at-table-p)= (org-table-align))) ((and (listp result) (not (funcall proper-list-p resul= t))) (insert (format "%s\n" result))) ((member "file" result-params) (when = inlinep (goto-char inlinep)) (insert result)) (t (goto-char beg) (insert re= sult))) (when (funcall proper-list-p result) (goto-char (org-table-end))) (= setq end (point-marker)) (cond ((assoc :wrap (nth 2 info)) (let ((name ...)= ) (funcall wrap (concat "#+BEGIN_" name) (concat "#+END_" name)))) ((member= "html" result-params) (funcall wrap "#+BEGIN_HTML" "#+END_HTML")) ((member= "latex" result-params) (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX")) ((mem= ber "code" result-params) (funcall wrap (format "#+BEGIN_SRC %s%s" (or lang= "none") results-switches) "#+END_SRC")) ((member "org" result-params) (fun= call wrap "#+BEGIN_ORG" "#+END_ORG")) ((member "raw" result-params) (goto-c= har beg) (if (org-at-table-p) (org-cycle))) ((member "wrap" result-params) = (funcall wrap ":RESULTS:" ":END:")) ((and (not (funcall proper-list-p resul= t)) (not (member "file" result-params))) (org-babel-examplize-region beg en= d results-switches) (setq end (point))))) (when (and (not inlinep) (numberp= indent) indent (> indent 0) (not (and (listp result) (member "append" resu= lt-params)))) (indent-rigidly beg end indent)))) (if (and result-params (member "silent" result-params)) (progn (message (= replace-regexp-in-string "%" "%%" (format "%S" result))) result) (save-excu= rsion (let* ((inlinep (save-excursion (when (or ... ...) (goto-char ...) (i= nsert ...) (point)))) (existing-result (unless inlinep (org-babel-where-is-= src-block-result t info hash indent))) (results-switches (cdr (assoc :resul= ts_switches (nth 2 info)))) beg end) (when (and (stringp result) (not inlin= ep) (> (length result) 0) (not (or (string-equal ... "\n") (string-equal ..= . "")))) (setq result (concat result "\n"))) (if (not existing-result) (set= q beg (or inlinep (point))) (goto-char existing-result) (save-excursion (re= -search-forward "#" nil t) (setq indent (- (current-column) 1))) (forward-l= ine 1) (setq beg (point)) (cond ((member "replace" result-params) (delete-r= egion (point) (org-babel-result-end))) ((member "append" result-params) (go= to-char (org-babel-result-end)) (setq beg (point-marker))) ((member "prepen= d" result-params)))) (setq results-switches (if results-switches (concat " = " results-switches) "")) (let ((wrap (lambda (start finish) (goto-char end)= (insert ...) (goto-char beg) (insert ...) (goto-char end) (goto-char ...) = (setq end ...))) (proper-list-p (lambda (it) (and ... ...)))) (cond ((null = result)) ((member "list" result-params) (insert (org-babel-trim ...) "\n"))= ((funcall proper-list-p result) (goto-char beg) (insert (concat ... "\n"))= (goto-char beg) (when (org-at-table-p) (org-table-align))) ((and (listp re= sult) (not ...)) (insert (format "%s\n" result))) ((member "file" result-pa= rams) (when inlinep (goto-char inlinep)) (insert result)) (t (goto-char beg= ) (insert result))) (when (funcall proper-list-p result) (goto-char (org-ta= ble-end))) (setq end (point-marker)) (cond ((assoc :wrap (nth 2 info)) (let= (...) (funcall wrap ... ...))) ((member "html" result-params) (funcall wra= p "#+BEGIN_HTML" "#+END_HTML")) ((member "latex" result-params) (funcall wr= ap "#+BEGIN_LaTeX" "#+END_LaTeX")) ((member "code" result-params) (funcall = wrap (format "#+BEGIN_SRC %s%s" ... results-switches) "#+END_SRC")) ((membe= r "org" result-params) (funcall wrap "#+BEGIN_ORG" "#+END_ORG")) ((member "= raw" result-params) (goto-char beg) (if (org-at-table-p) (org-cycle))) ((me= mber "wrap" result-params) (funcall wrap ":RESULTS:" ":END:")) ((and (not .= ..) (not ...)) (org-babel-examplize-region beg end results-switches) (setq = end (point))))) (when (and (not inlinep) (numberp indent) indent (> indent = 0) (not (and (listp result) (member "append" result-params)))) (indent-rigi= dly beg end indent)))) (if (null result) (if (member "value" result-params)= (message "Code block returned no value.") (message "Code block produced no= output.")) (message "Code block evaluation complete."))) (save-restriction (widen) (if (stringp result) (progn (setq result (org-n= o-properties result)) (when (member "file" result-params) (setq result (org= -babel-result-to-file result (when (assoc :file-desc ...) (or ... result)))= ))) (unless (listp result) (setq result (format "%S" result)))) (if (and re= sult-params (member "silent" result-params)) (progn (message (replace-regex= p-in-string "%" "%%" (format "%S" result))) result) (save-excursion (let* (= (inlinep (save-excursion (when ... ... ... ...))) (existing-result (unless = inlinep (org-babel-where-is-src-block-result t info hash indent))) (results= -switches (cdr (assoc :results_switches ...))) beg end) (when (and (stringp= result) (not inlinep) (> (length result) 0) (not (or ... ...))) (setq resu= lt (concat result "\n"))) (if (not existing-result) (setq beg (or inlinep (= point))) (goto-char existing-result) (save-excursion (re-search-forward "#"= nil t) (setq indent (- ... 1))) (forward-line 1) (setq beg (point)) (cond = ((member "replace" result-params) (delete-region ... ...)) ((member "append= " result-params) (goto-char ...) (setq beg ...)) ((member "prepend" result-= params)))) (setq results-switches (if results-switches (concat " " results-= switches) "")) (let ((wrap (lambda ... ... ... ... ... ... ... ...)) (prope= r-list-p (lambda ... ...))) (cond ((null result)) ((member "list" result-pa= rams) (insert ... "\n")) ((funcall proper-list-p result) (goto-char beg) (i= nsert ...) (goto-char beg) (when ... ...)) ((and ... ...) (insert ...)) ((m= ember "file" result-params) (when inlinep ...) (insert result)) (t (goto-ch= ar beg) (insert result))) (when (funcall proper-list-p result) (goto-char (= org-table-end))) (setq end (point-marker)) (cond ((assoc :wrap ...) (let ..= . ...)) ((member "html" result-params) (funcall wrap "#+BEGIN_HTML" "#+END_= HTML")) ((member "latex" result-params) (funcall wrap "#+BEGIN_LaTeX" "#+EN= D_LaTeX")) ((member "code" result-params) (funcall wrap ... "#+END_SRC")) (= (member "org" result-params) (funcall wrap "#+BEGIN_ORG" "#+END_ORG")) ((me= mber "raw" result-params) (goto-char beg) (if ... ...)) ((member "wrap" res= ult-params) (funcall wrap ":RESULTS:" ":END:")) ((and ... ...) (org-babel-e= xamplize-region beg end results-switches) (setq end ...)))) (when (and (not= inlinep) (numberp indent) indent (> indent 0) (not (and ... ...))) (indent= -rigidly beg end indent)))) (if (null result) (if (member "value" result-pa= rams) (message "Code block returned no value.") (message "Code block produc= ed no output.")) (message "Code block evaluation complete.")))) org-babel-insert-result((nil) ("output" "replace") ("sql" "ALTER TABLE ta= bleindb\nADD rol22 smalldatetime NULL\n\nPRINT ''" ((:comments . "yes") (:s= hebang . "") (:cache . "no") (:padline . "") (:noweb . "yes") (:tangle . "n= o") (:exports . "both") (:results . "replace output") (:session . "none") (= :hlines . "no") (:padnewline . "yes") (:engine . "msosql") (:cmdline . "-S = cauchy -U sa -P LpmdlP -d pfi-dev -n -w 234") (:eval . "yes") (:result-type= . output) (:result-params "output" "replace") (:rowname-names) (:colname-n= ames)) "" nil 0) nil 0 "sql") (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (g= oto-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (f= orward-char 1) (setq result (org-babel-read-result)) (message (replace-rege= xp-in-string "%" "%%" (format "%S" result))) result) (message "executing %s= code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4= info)) "")) (setq result ((lambda (result) (if (and (eq (cdr ...) (quote v= alue)) (or (member "vector" result-params) (member "table" result-params)) = (not (listp result))) (list (list result)) result)) (funcall cmd body param= s))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr (as= soc :file params)) (insert (org-babel-format-result result (cdr (assoc :sep= ...)))))) (setq result (cdr (assoc :file params)))) (org-babel-insert-resu= lt result result-params info new-hash indent lang) (run-hooks (quote org-ba= bel-after-execute-hook)) result) (let ((call-process-region (lambda (&rest args) (apply (quote org-babel-t= ramp-handle-call-process-region) args)))) (let ((lang-check (lambda (f) (le= t ((f ...)) (when (fboundp f) f))))) (setq cmd (or (funcall lang-check lang= ) (funcall lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) = (error "No org-babel-execute function for %s!" lang)))) (if (and (not arg) = new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org-babel-w= here-is-src-block-result nil info)) (end-of-line 1) (forward-char 1) (setq = result (org-babel-read-result)) (message (replace-regexp-in-string "%" "%%"= (format "%S" result))) result) (message "executing %s code block%s..." (ca= pitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq re= sult ((lambda (result) (if (and (eq ... ...) (or ... ...) (not ...)) (list = (list result)) result)) (funcall cmd body params))) (when (cdr (assoc :file= params)) (when result (with-temp-file (cdr (assoc :file params)) (insert (= org-babel-format-result result (cdr ...))))) (setq result (cdr (assoc :file= params)))) (org-babel-insert-result result result-params info new-hash ind= ent lang) (run-hooks (quote org-babel-after-execute-hook)) result)) (unwind-protect (let ((call-process-region (lambda (&rest args) (apply (q= uote org-babel-tramp-handle-call-process-region) args)))) (let ((lang-check= (lambda (f) (let (...) (when ... f))))) (setq cmd (or (funcall lang-check = lang) (funcall lang-check (symbol-name (cdr ...))) (error "No org-babel-exe= cute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-hash= old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-result= nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read-r= esult)) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) = result) (message "executing %s code block%s..." (capitalize lang) (if (nth = 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) (= if (and ... ... ...) (list ...) result)) (funcall cmd body params))) (when = (cdr (assoc :file params)) (when result (with-temp-file (cdr (assoc :file p= arams)) (insert (org-babel-format-result result ...)))) (setq result (cdr (= assoc :file params)))) (org-babel-insert-result result result-params info n= ew-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) resul= t)) (setq call-process-region (quote org-babel-call-process-region-original= ))) (let* ((lang (nth 0 info)) (params (if params (org-babel-process-params (= org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\? (and (= not arg) (cdr (assoc :cache params)) (string=3D "yes" (cdr (assoc :cache pa= rams))))) (result-params (cdr (assoc :result-params params))) (new-hash (wh= en cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-= current-result-hash))) (body (setf (nth 1 info) (if (org-babel-noweb-p para= ms :eval) (org-babel-expand-noweb-references info) (nth 1 info)))) (dir (cd= r (assoc :dir params))) (default-directory (or (and dir (file-name-as-direc= tory (expand-file-name dir))) default-directory)) (org-babel-call-process-r= egion-original (if (boundp (quote org-babel-call-process-region-original)) = org-babel-call-process-region-original (symbol-function (quote call-process= -region)))) (indent (car (last info))) result cmd) (unwind-protect (let ((c= all-process-region (lambda (&rest args) (apply (quote org-babel-tramp-handl= e-call-process-region) args)))) (let ((lang-check (lambda (f) (let ... ...)= ))) (setq cmd (or (funcall lang-check lang) (funcall lang-check (symbol-nam= e ...)) (error "No org-babel-execute function for %s!" lang)))) (if (and (n= ot arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char (org= -babel-where-is-src-block-result nil info)) (end-of-line 1) (forward-char 1= ) (setq result (org-babel-read-result)) (message (replace-regexp-in-string = "%" "%%" (format "%S" result))) result) (message "executing %s code block%s= ..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) = (setq result ((lambda (result) (if ... ... result)) (funcall cmd body param= s))) (when (cdr (assoc :file params)) (when result (with-temp-file (cdr ...= ) (insert ...))) (setq result (cdr (assoc :file params)))) (org-babel-inser= t-result result result-params info new-hash indent lang) (run-hooks (quote = org-babel-after-execute-hook)) result)) (setq call-process-region (quote or= g-babel-call-process-region-original)))) (progn (let* ((lang (nth 0 info)) (params (if params (org-babel-process-p= arams (org-babel-merge-params (nth 2 info) params)) (nth 2 info))) (cache\?= (and (not arg) (cdr (assoc :cache params)) (string=3D "yes" (cdr (assoc :c= ache params))))) (result-params (cdr (assoc :result-params params))) (new-h= ash (when cache\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org= -babel-current-result-hash))) (body (setf (nth 1 info) (if (org-babel-noweb= -p params :eval) (org-babel-expand-noweb-references info) (nth 1 info)))) (= dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-a= s-directory (expand-file-name dir))) default-directory)) (org-babel-call-pr= ocess-region-original (if (boundp (quote org-babel-call-process-region-orig= inal)) org-babel-call-process-region-original (symbol-function (quote call-= process-region)))) (indent (car (last info))) result cmd) (unwind-protect (= let ((call-process-region (lambda (&rest args) (apply ... args)))) (let ((l= ang-check (lambda ... ...))) (setq cmd (or (funcall lang-check lang) (funca= ll lang-check ...) (error "No org-babel-execute function for %s!" lang)))) = (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (got= o-char (org-babel-where-is-src-block-result nil info)) (end-of-line 1) (for= ward-char 1) (setq result (org-babel-read-result)) (message (replace-regexp= -in-string "%" "%%" ...)) result) (message "executing %s code block%s..." (= capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (setq result ((= lambda ... ...) (funcall cmd body params))) (when (cdr (assoc :file params)= ) (when result (with-temp-file ... ...)) (setq result (cdr ...))) (org-babe= l-insert-result result result-params info new-hash indent lang) (run-hooks = (quote org-babel-after-execute-hook)) result)) (setq call-process-region (q= uote org-babel-call-process-region-original))))) (if (org-babel-confirm-evaluate (let ((i info)) (setf (nth 2 i) (org-babe= l-merge-params (nth 2 info) params)) i)) (progn (let* ((lang (nth 0 info)) = (params (if params (org-babel-process-params (org-babel-merge-params ... pa= rams)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params)) (= string=3D "yes" (cdr ...)))) (result-params (cdr (assoc :result-params para= ms))) (new-hash (when cache\? (org-babel-sha1-hash info))) (old-hash (when = cache\? (org-babel-current-result-hash))) (body (setf (nth 1 info) (if (org= -babel-noweb-p params :eval) (org-babel-expand-noweb-references info) (nth = 1 info)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir = (file-name-as-directory ...)) default-directory)) (org-babel-call-process-r= egion-original (if (boundp (quote org-babel-call-process-region-original)) = org-babel-call-process-region-original (symbol-function (quote call-process= -region)))) (indent (car (last info))) result cmd) (unwind-protect (let ((c= all-process-region (lambda ... ...))) (let ((lang-check ...)) (setq cmd (or= ... ... ...))) (if (and (not arg) new-hash (equal new-hash old-hash)) (sav= e-excursion (goto-char ...) (end-of-line 1) (forward-char 1) (setq result .= ..) (message ...) result) (message "executing %s code block%s..." (capitali= ze lang) (if ... ... "")) (setq result (... ...)) (when (cdr ...) (when res= ult ...) (setq result ...)) (org-babel-insert-result result result-params i= nfo new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) = result)) (setq call-process-region (quote org-babel-call-process-region-ori= ginal)))))) (when (org-babel-confirm-evaluate (let ((i info)) (setf (nth 2 i) (org-ba= bel-merge-params (nth 2 info) params)) i)) (let* ((lang (nth 0 info)) (para= ms (if params (org-babel-process-params (org-babel-merge-params (nth 2 info= ) params)) (nth 2 info))) (cache\? (and (not arg) (cdr (assoc :cache params= )) (string=3D "yes" (cdr (assoc :cache params))))) (result-params (cdr (ass= oc :result-params params))) (new-hash (when cache\? (org-babel-sha1-hash in= fo))) (old-hash (when cache\? (org-babel-current-result-hash))) (body (setf= (nth 1 info) (if (org-babel-noweb-p params :eval) (org-babel-expand-noweb-= references info) (nth 1 info)))) (dir (cdr (assoc :dir params))) (default-d= irectory (or (and dir (file-name-as-directory (expand-file-name dir))) defa= ult-directory)) (org-babel-call-process-region-original (if (boundp (quote = org-babel-call-process-region-original)) org-babel-call-process-region-orig= inal (symbol-function (quote call-process-region)))) (indent (car (last inf= o))) result cmd) (unwind-protect (let ((call-process-region (lambda (&rest = args) (apply ... args)))) (let ((lang-check (lambda ... ...))) (setq cmd (o= r (funcall lang-check lang) (funcall lang-check ...) (error "No org-babel-e= xecute function for %s!" lang)))) (if (and (not arg) new-hash (equal new-ha= sh old-hash)) (save-excursion (goto-char (org-babel-where-is-src-block-resu= lt nil info)) (end-of-line 1) (forward-char 1) (setq result (org-babel-read= -result)) (message (replace-regexp-in-string "%" "%%" ...)) result) (messag= e "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format= " (%s)" ...) "")) (setq result ((lambda ... ...) (funcall cmd body params)= )) (when (cdr (assoc :file params)) (when result (with-temp-file ... ...)) = (setq result (cdr ...))) (org-babel-insert-result result result-params info= new-hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) res= ult)) (setq call-process-region (quote org-babel-call-process-region-origin= al))))) (let ((info (or info (org-babel-get-src-block-info)))) (when (org-babel-c= onfirm-evaluate (let ((i info)) (setf (nth 2 i) (org-babel-merge-params (nt= h 2 info) params)) i)) (let* ((lang (nth 0 info)) (params (if params (org-b= abel-process-params (org-babel-merge-params ... params)) (nth 2 info))) (ca= che\? (and (not arg) (cdr (assoc :cache params)) (string=3D "yes" (cdr ...)= ))) (result-params (cdr (assoc :result-params params))) (new-hash (when cac= he\? (org-babel-sha1-hash info))) (old-hash (when cache\? (org-babel-curren= t-result-hash))) (body (setf (nth 1 info) (if (org-babel-noweb-p params :ev= al) (org-babel-expand-noweb-references info) (nth 1 info)))) (dir (cdr (ass= oc :dir params))) (default-directory (or (and dir (file-name-as-directory .= ..)) default-directory)) (org-babel-call-process-region-original (if (bound= p (quote org-babel-call-process-region-original)) org-babel-call-process-re= gion-original (symbol-function (quote call-process-region)))) (indent (car = (last info))) result cmd) (unwind-protect (let ((call-process-region (lambd= a ... ...))) (let ((lang-check ...)) (setq cmd (or ... ... ...))) (if (and = (not arg) new-hash (equal new-hash old-hash)) (save-excursion (goto-char ..= .) (end-of-line 1) (forward-char 1) (setq result ...) (message ...) result)= (message "executing %s code block%s..." (capitalize lang) (if ... ... ""))= (setq result (... ...)) (when (cdr ...) (when result ...) (setq result ...= )) (org-babel-insert-result result result-params info new-hash indent lang)= (run-hooks (quote org-babel-after-execute-hook)) result)) (setq call-proce= ss-region (quote org-babel-call-process-region-original)))))) org-babel-execute-src-block(nil ("sql" "ALTER TABLE tableindb\nADD rol22 = smalldatetime NULL\n\nPRINT ''" ((:comments . "yes") (:shebang . "") (:cach= e . "no") (:padline . "") (:noweb . "yes") (:tangle . "no") (:exports . "bo= th") (:results . "replace output") (:session . "none") (:hlines . "no") (:p= adnewline . "yes") (:engine . "msosql") (:cmdline . "-S cauchy -U sa -P Lpm= dlP -d pfi-dev -n -w 234") (:eval . "yes") (:result-type . output) (:result= -params "output" "replace") (:rowname-names) (:colname-names)) "" nil 0)) (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block cu= rrent-prefix-arg info) t) (if info (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src= -block current-prefix-arg info) t) nil) (let ((info (org-babel-get-src-block-info))) (if info (progn (org-babel-e= val-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg info= ) t) nil)) org-babel-execute-src-block-maybe() (or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe)) org-babel-execute-maybe() call-interactively(org-babel-execute-maybe nil nil) #+end_example ** Block with non-empty string returned #+begin_src sql :tangle no :eval yes ALTER TABLE tableindb ADD rol333 smalldatetime NULL PRINT 'OK' #+end_src #+results: | OK | ... does work OK. Best regards, Seb --=20 Sebastien Vauban