unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
@ 2016-09-20 17:48 Michael Kleehammer
  2017-02-24 19:53 ` Pablo Mercader Alcántara
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Kleehammer @ 2016-09-20 17:48 UTC (permalink / raw)
  To: 24483

It looks like sql-interactive-remove-continuation-prompt needs to explicitly check for a nil sql-prompt-cont-regexp, which is the default value for some SQL products.

In particular, this line marked with an arrow on the left needs a guard:

    (when (and comint-prompt-regexp
               (or (> (length (or sql-preoutput-hold "")) 0)
                   (> (or sql-output-newline-count 0) 0)
                   (not (or (string-match sql-prompt-regexp oline)
    -->                     (string-match sql-prompt-cont-regexp oline)))))

In my case I am using a custom "SQL product" for a SQL Server command
line utility which prints "Connected to xyzzy\n" on startup but there
are some standard "products" that also don't have a prompt-cont-regexp
set.

It should be easy to reproduce using "ansi", but here is how I
reproduced it with PostgreSQL:

1) Set the PostgreSQL regexp to nil:

    (sql-set-product-feature 'postgres :prompt-cont-regexp nil)

2) Make sure psql prints something on connect.  I have this in my
   ~/.psqlrc:

    \pset null ¤

When you open a connection using sql-postgres you'll get:

    error in process filter: sql-interactive-remove-continuation-prompt: Wrong type argument: stringp, nil
    error in process filter: Wrong type argument: stringp, nil

This is new in 25.1.  I used 24.5 and did not have this issue. 

Thanks,
Michael Kleehammer
michael@kleehammer.com


In GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))
 of 2016-09-17 built on builder10-9.porkrind.org
Windowing system distributor 'Apple', version 10.3.1504
Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp''

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS

Important settings:
  value of $LANG: en_US.UTF8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  shell-dirtrack-mode: t
  ws-butler-global-mode: t
  ws-butler-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  ido-vertical-mode: t
  flx-ido-mode: t
  ido-everywhere: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  projectile-global-mode: t
  projectile-mode: t
  recentf-mode: t
  pcre-mode: t
  drag-stuff-global-mode: t
  drag-stuff-mode: t
  delete-selection-mode: t
  cua-mode: t
  highlight-changes-visible-mode: t
  show-paren-mode: t
  global-linum-mode: t
  linum-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
buf: nil
Login...done
w #<window 21 on sqlwchar.cpp>
Quit
uncompressing sql.el.gz...done
Mark saved where search started
Mark set
Mark saved where search started [4 times]
Mark set
Quit

Load-path shadows:
/Users/mkleehammer/.emacs.d/misc/expand-region/web-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/web-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/the-org-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/the-org-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/text-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/text-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/sml-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/sml-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/ruby-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/ruby-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/python-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/python-el-fgallina-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-el-fgallina-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/python-el-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-el-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/octave-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/octave-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/nxml-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/nxml-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/latex-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/latex-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/jsp-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/jsp-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/js2-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/js2-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/js-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/js-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/html-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/html-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/feature-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/feature-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/expand-region hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region
/Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-pkg hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-pkg
/Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-custom hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-custom
/Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-core hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-core
/Users/mkleehammer/.emacs.d/misc/expand-region/erlang-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/erlang-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/er-basic-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/er-basic-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/enh-ruby-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/enh-ruby-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/css-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/css-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/cperl-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/cperl-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/clojure-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/clojure-mode-expansions
/Users/mkleehammer/.emacs.d/misc/expand-region/cc-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/cc-mode-expansions
/Users/mkleehammer/.emacs.d/misc/undo-tree hides /Users/mkleehammer/.emacs.d/elpa/undo-tree-0.6.5/undo-tree
/Users/mkleehammer/.emacs.d/misc/python hides /Applications/Emacs.app/Contents/Resources/lisp/progmodes/python
/Users/mkleehammer/.emacs.d/elpa/seq-2.16/seq hides /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/seq

Features:
(shadow sort mail-extr emacsbug sendmail pp timezone parse-time
jka-compr shr-color color network-stream nsm starttls url-http tls
gnutls url-gw url-auth eww mm-url gnus gnus-ems nnheader url-queue shr
dom browse-url less-css-mode css-mode smie derived wdired web-mode
disp-table dabbrev misearch multi-isearch smex magit-blame magit-stash
magit-bisect magit-remote magit-commit magit-sequence magit magit-apply
magit-wip magit-log magit-diff smerge-mode diff-mode magit-core
magit-autorevert autorevert filenotify magit-process magit-popup
magit-mode magit-git crm magit-section magit-utils git-commit log-edit
message rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils gmm-utils
mailheader pcvs-util add-log with-editor async-bytecomp async python
tramp-sh tramp tramp-compat tramp-loaddefs trampver shell format-spec
dired-aux server sunshine url-cache url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util url-parse
auth-source gnus-util mm-util help-fns mail-prsvr password-cache
url-vars mailcap cal-china lunar solar cal-dst cal-bahai cal-islam
cal-hebrew holidays hol-loaddefs appt diary-lib diary-loaddefs cal-menu
calendar cal-loaddefs sql view tea-time pcomplete esh-var esh-io esh-cmd
esh-opt esh-ext esh-proc esh-arg esh-groups eshell esh-module esh-mode
esh-util js2-mode etags xref project eieio eieio-core js sgml-mode
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs imenu ws-butler whitespace yasnippet cl browse-kill-ring
avy ido-vertical-mode ido-ubiquitous cl-seq ido-completing-read+
cus-edit flx-ido flx ido undo-tree iedit iedit-lib flycheck json map
find-func subr-x projectile ibuf-ext ibuffer dash thingatpt recentf
tree-widget pcre2el rxt cl-macs re-builder rx drag-stuff
whole-line-or-region align2 edmacro kmacro wgrep reveal-in-osx-finder
dired-x dired exec-path-from-shell delsel cua-base hydra lv hilit-chg
wid-edit paren avoid linum zenburn-theme use-package diminish bind-key
easy-mmode finder-inf advice info package epg-config seq byte-opt gv
bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs
pcase cl-lib grep compile comint ansi-color ring cus-start cus-load
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel ns-win ucs-normalize term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information:
((conses 16 764072 122496)
 (symbols 48 50260 0)
 (miscs 40 1811 957)
 (strings 32 147544 5627)
 (string-bytes 1 4555893)
 (vectors 16 105142)
 (vector-slots 8 2292082 293693)
 (floats 8 12056 11134)
 (intervals 56 19325 3290)
 (buffers 976 43))






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

* bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
  2016-09-20 17:48 bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp Michael Kleehammer
@ 2017-02-24 19:53 ` Pablo Mercader Alcántara
  2017-05-29 16:52   ` Nikolay Kudryavtsev
  0 siblings, 1 reply; 8+ messages in thread
From: Pablo Mercader Alcántara @ 2017-02-24 19:53 UTC (permalink / raw)
  To: 24483

I'm having this same problem using ms-sql-server. I've been triying to
make it work playing with edebug but haven't made any progress, if I
find a way to work around this or something I'll place it here.

In GNU Emacs 25.1.1 (x86_64-w64-mingw32)
 of 2016-11-15 built on LAPHROAIG
Windowing system distributor 'Microsoft Corp.', version 10.0.10240
Configured using:
 'configure --without-dbus --without-compress-install 'CFLAGS=-O2
 -static -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:

Result: "(1 row affected)\nMsg 2812, Level 16, State 62, Server
INTRANETDB, Line 1\nCould not find stored procedure 'l'.\n
\n ----------- \n           1 \n\n"

Wrong type argument: stringp, nil

error in process filter: edebug-signal: Wrong type argument: stringp, nil
error in process filter: Wrong type argument: stringp, nil
Quit [2 times]
Mark set [2 times]
Mark saved where search started

Load-path shadows:
c:/Users/pmercader/AppData/Roaming/.emacs.d/elpa/cygwin-mount-20131111.1346/cygwin-mount
hides d:/share/emacs/share/emacs/site-lisp/cygwin/cygwin-mount

Features:
(shadow sort mail-extr emacsbug message dired rfc822 mml mml-sec epg
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils edebug debug
eieio-opt speedbar sb-image ezimage dframe magit-utils dash rect vc-git
diff-mode easy-mmode python tramp-sh tramp tramp-compat auth-source
eieio eieio-core cl-macs gnus-util mm-util mail-prsvr password-cache
tramp-loaddefs trampver ucs-normalize shell pcomplete format-spec advice
json map find-func help-fns sql view thingatpt misearch multi-isearch
vc-dispatcher vc-svn nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml
rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util
rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph
nxml-enc xmltok edmacro kmacro cus-edit cus-start cus-load wid-edit
setup-cygwin cygwin-mount ange-ftp comint ansi-color ring cl-seq
yasnippet misterioso-theme finder-inf info package epg-config windmove
ido seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu
cconv cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32
ls-lisp disp-table w32-win w32-vars term/common-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote w32notify w32 multi-tty
make-network-process emacs)

Memory information:
((conses 16 403940 43396)
 (symbols 56 32319 0)
 (miscs 48 187 569)
 (strings 32 61799 11981)
 (string-bytes 1 1812321)
 (vectors 16 49325)
 (vector-slots 8 907506 34336)
 (floats 8 863 484)
 (intervals 56 23167 362)
 (buffers 976 33))





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

* bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
  2017-02-24 19:53 ` Pablo Mercader Alcántara
@ 2017-05-29 16:52   ` Nikolay Kudryavtsev
  2017-05-29 21:10     ` Pablo Mercader Alcántara
  0 siblings, 1 reply; 8+ messages in thread
From: Nikolay Kudryavtsev @ 2017-05-29 16:52 UTC (permalink / raw)
  To: Pablo Mercader Alcántara, 24483

Hello, Pablo.

I don't think you have the same bug as OP.

In your case it seems that you're trying to execute some stored 
procedure that does not exist and Emacs fails at parsing the reply.

Can you try adding:

(add-to-list 'process-coding-system-alist '("sqlcmd" . cp866))

to your init and see if anything changes. Also, you're using sqlcmd, right?

-- 
Best Regards,
Nikolay Kudryavtsev






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

* bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
  2017-05-29 16:52   ` Nikolay Kudryavtsev
@ 2017-05-29 21:10     ` Pablo Mercader Alcántara
  2017-05-29 21:50       ` Nikolay Kudryavtsev
  0 siblings, 1 reply; 8+ messages in thread
From: Pablo Mercader Alcántara @ 2017-05-29 21:10 UTC (permalink / raw)
  To: Nikolay Kudryavtsev; +Cc: 24483

[-- Attachment #1: Type: text/plain, Size: 2226 bytes --]

Hello Nikolay Kudryavtsev ! thanks for your interest in this little problem.

I do think it is the same problem. I think that emacs tries to erase the
sql prompt from the response and fails to do it. I'm getting the same
problem that OP describes, when I open an interactive sql buffer and try to
execute anything emacs answers with the error "Wrong type argument:
stringp, nil" and no clue of the actual data. The moment in which I decided
to report the bug might be while executing an stored procedure that doesn't
exist, but this problem shows every time I execute ANYTHING, even a simple
"select 1\ngo\n". You can see by your self that the "Wrong type argument"
error is in the emacs output in my mail.

To tell you the truth I did find a little workaround, that's why I didn't
bother with the problem to much. This bug is in my "todo" list but I'm a
little bussy to try to understand it and make a proper repair. What I did
to workaround it using the ideas provided in the mail of the OP and
watching what was happening in edebug, was to modify sql-product-alist in
sql.el, the "prompt-cont-regexp" in the "ms" product was not even there, so
I put the property and set it to " " ( <- a blank space) and that did the
trick. It now shows the results but when showing those ms-sql-server
results it always eats some spaces in the first column making the rows and
the head of the rows misaligned.

Also as OP said I didn't had this problem in the previous version (24.5)
either.

I'm using osql, and I'm already using cp850 with it, I think that's the
right encoding I should use because its what the command prompt of windows
is using. Why do you think I should use cp866.

Thanks again! I hope this information helps.


2017-05-29 12:52 GMT-04:00 Nikolay Kudryavtsev <
nikolay.kudryavtsev@gmail.com>:

> Hello, Pablo.
>
> I don't think you have the same bug as OP.
>
> In your case it seems that you're trying to execute some stored procedure
> that does not exist and Emacs fails at parsing the reply.
>
> Can you try adding:
>
> (add-to-list 'process-coding-system-alist '("sqlcmd" . cp866))
>
> to your init and see if anything changes. Also, you're using sqlcmd, right?
>
> --
> Best Regards,
> Nikolay Kudryavtsev
>
>

[-- Attachment #2: Type: text/html, Size: 2928 bytes --]

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

* bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
  2017-05-29 21:10     ` Pablo Mercader Alcántara
@ 2017-05-29 21:50       ` Nikolay Kudryavtsev
  2017-06-05 15:31         ` Pablo Mercader Alcántara
       [not found]         ` <CAPQ4eM+sS59iSFCy+udWntvWpGEBHCvjg=dEMb+e4zbw1zkVeQ@mail.gmail.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Nikolay Kudryavtsev @ 2017-05-29 21:50 UTC (permalink / raw)
  To: Pablo Mercader Alcántara; +Cc: 24483

Oh, sorry for the cp866 suggestion, my bad, cp850 is probably right for you.

If you're using osql, can you try switching to sqlcmd? Osql had been 
considered deprected by Microsoft for many years. Sqlcmd is freely 
downloadable and should be usable with any more or less modern version 
of SQL Server. The configuration for it that I use looks like this:

(setq sql-ms-program "sqlcmd"
           sql-ms-options (quote ("-W" "-s" "|" "-I")))

-- 
Best Regards,
Nikolay Kudryavtsev






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

* bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
  2017-05-29 21:50       ` Nikolay Kudryavtsev
@ 2017-06-05 15:31         ` Pablo Mercader Alcántara
       [not found]         ` <CAPQ4eM+sS59iSFCy+udWntvWpGEBHCvjg=dEMb+e4zbw1zkVeQ@mail.gmail.com>
  1 sibling, 0 replies; 8+ messages in thread
From: Pablo Mercader Alcántara @ 2017-06-05 15:31 UTC (permalink / raw)
  To: 24483

[-- Attachment #1: Type: text/plain, Size: 1035 bytes --]

Ok, I tried using "sqlcmd" instead of "osql" and the problem remains. Also
tried using MySQL instead of MS-SQL-Server to see if I could reproduce the
problem, and it has a similar problem, doesn't show any results to any
query I write, but doesn't spit the "Wrong type argument: stringp, nil"
message.

So the problem is not the executable program used to talk to the database.
I'm still beating to a problem in sql.el.

Thanks for your help!


2017-05-29 17:50 GMT-04:00 Nikolay Kudryavtsev <
nikolay.kudryavtsev@gmail.com>:

> Oh, sorry for the cp866 suggestion, my bad, cp850 is probably right for
> you.
>
> If you're using osql, can you try switching to sqlcmd? Osql had been
> considered deprected by Microsoft for many years. Sqlcmd is freely
> downloadable and should be usable with any more or less modern version of
> SQL Server. The configuration for it that I use looks like this:
>
> (setq sql-ms-program "sqlcmd"
>           sql-ms-options (quote ("-W" "-s" "|" "-I")))
>
>
> --
> Best Regards,
> Nikolay Kudryavtsev
>
>

[-- Attachment #2: Type: text/html, Size: 1609 bytes --]

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

* bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
       [not found]         ` <CAPQ4eM+sS59iSFCy+udWntvWpGEBHCvjg=dEMb+e4zbw1zkVeQ@mail.gmail.com>
@ 2017-06-05 22:25           ` Nikolay Kudryavtsev
  0 siblings, 0 replies; 8+ messages in thread
From: Nikolay Kudryavtsev @ 2017-06-05 22:25 UTC (permalink / raw)
  To: Pablo Mercader Alcántara; +Cc: 24483

Hello, Pablo.

It's not clear from your letter whether you still have an error with 
prompt-cont-regexp when using sqlcmd. If so, could you please set 
debug-on-error to t and paste the debug log here.

For mysql I use (setq sql-mysql-options '("-C" "-f" "-t" "-n")). Also 
don't forget the statement terminator there: either put ";" or "\go" at 
the end query.

-- 
Best Regards,
Nikolay Kudryavtsev






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

* Re: bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp
       [not found] <mailman.2708.1474393810.22741.bug-gnu-emacs@gnu.org>
@ 2018-01-18 21:52 ` Nesa K
  0 siblings, 0 replies; 8+ messages in thread
From: Nesa K @ 2018-01-18 21:52 UTC (permalink / raw)
  To: bug-gnu-emacs

On Tuesday, September 20, 2016 at 1:50:11 PM UTC-4, Michael Kleehammer wrote:
> It looks like sql-interactive-remove-continuation-prompt needs to explicitly check for a nil sql-prompt-cont-regexp, which is the default value for some SQL products.
> 
> In particular, this line marked with an arrow on the left needs a guard:
> 
>     (when (and comint-prompt-regexp
>                (or (> (length (or sql-preoutput-hold "")) 0)
>                    (> (or sql-output-newline-count 0) 0)
>                    (not (or (string-match sql-prompt-regexp oline)
>     -->                     (string-match sql-prompt-cont-regexp oline)))))
> 
> In my case I am using a custom "SQL product" for a SQL Server command
> line utility which prints "Connected to xyzzy\n" on startup but there
> are some standard "products" that also don't have a prompt-cont-regexp
> set.
> 
> It should be easy to reproduce using "ansi", but here is how I
> reproduced it with PostgreSQL:
> 
> 1) Set the PostgreSQL regexp to nil:
> 
>     (sql-set-product-feature 'postgres :prompt-cont-regexp nil)
> 
> 2) Make sure psql prints something on connect.  I have this in my
>    ~/.psqlrc:
> 
>     \pset null ¤
> 
> When you open a connection using sql-postgres you'll get:
> 
>     error in process filter: sql-interactive-remove-continuation-prompt: Wrong type argument: stringp, nil
>     error in process filter: Wrong type argument: stringp, nil
> 
> This is new in 25.1.  I used 24.5 and did not have this issue. 
> 
> Thanks,
> Michael Kleehammer
> michael@kleehammer.com
> 
> 
> In GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))
>  of 2016-09-17 built on builder10-9.porkrind.org
> Windowing system distributor 'Apple', version 10.3.1504
> Configured using:
>  'configure --with-ns '--enable-locallisppath=/Library/Application
>  Support/Emacs/${version}/site-lisp:/Library/Application
>  Support/Emacs/site-lisp''
> 
> Configured features:
> NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS
> 
> Important settings:
>   value of $LANG: en_US.UTF8
>   locale-coding-system: utf-8-unix
> 
> Major mode: Emacs-Lisp
> 
> Minor modes in effect:
>   diff-auto-refine-mode: t
>   magit-auto-revert-mode: t
>   global-git-commit-mode: t
>   shell-dirtrack-mode: t
>   ws-butler-global-mode: t
>   ws-butler-mode: t
>   yas-global-mode: t
>   yas-minor-mode: t
>   ido-vertical-mode: t
>   flx-ido-mode: t
>   ido-everywhere: t
>   global-undo-tree-mode: t
>   undo-tree-mode: t
>   projectile-global-mode: t
>   projectile-mode: t
>   recentf-mode: t
>   pcre-mode: t
>   drag-stuff-global-mode: t
>   drag-stuff-mode: t
>   delete-selection-mode: t
>   cua-mode: t
>   highlight-changes-visible-mode: t
>   show-paren-mode: t
>   global-linum-mode: t
>   linum-mode: t
>   override-global-mode: t
>   global-eldoc-mode: t
>   electric-indent-mode: t
>   mouse-wheel-mode: t
>   menu-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>   column-number-mode: t
>   line-number-mode: t
>   transient-mark-mode: t
> 
> Recent messages:
> buf: nil
> Login...done
> w #<window 21 on sqlwchar.cpp>
> Quit
> uncompressing sql.el.gz...done
> Mark saved where search started
> Mark set
> Mark saved where search started [4 times]
> Mark set
> Quit
> 
> Load-path shadows:
> /Users/mkleehammer/.emacs.d/misc/expand-region/web-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/web-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/the-org-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/the-org-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/text-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/text-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/sml-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/sml-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/ruby-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/ruby-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/python-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/python-el-fgallina-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-el-fgallina-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/python-el-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/python-el-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/octave-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/octave-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/nxml-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/nxml-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/latex-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/latex-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/jsp-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/jsp-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/js2-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/js2-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/js-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/js-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/html-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/html-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/feature-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/feature-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region
> /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-pkg hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-pkg
> /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-custom hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-custom
> /Users/mkleehammer/.emacs.d/misc/expand-region/expand-region-core hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/expand-region-core
> /Users/mkleehammer/.emacs.d/misc/expand-region/erlang-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/erlang-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/er-basic-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/er-basic-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/enh-ruby-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/enh-ruby-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/css-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/css-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/cperl-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/cperl-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/clojure-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/clojure-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/expand-region/cc-mode-expansions hides /Users/mkleehammer/.emacs.d/elpa/expand-region-0.10.0/cc-mode-expansions
> /Users/mkleehammer/.emacs.d/misc/undo-tree hides /Users/mkleehammer/.emacs.d/elpa/undo-tree-0.6.5/undo-tree
> /Users/mkleehammer/.emacs.d/misc/python hides /Applications/Emacs.app/Contents/Resources/lisp/progmodes/python
> /Users/mkleehammer/.emacs.d/elpa/seq-2.16/seq hides /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/seq
> 
> Features:
> (shadow sort mail-extr emacsbug sendmail pp timezone parse-time
> jka-compr shr-color color network-stream nsm starttls url-http tls
> gnutls url-gw url-auth eww mm-url gnus gnus-ems nnheader url-queue shr
> dom browse-url less-css-mode css-mode smie derived wdired web-mode
> disp-table dabbrev misearch multi-isearch smex magit-blame magit-stash
> magit-bisect magit-remote magit-commit magit-sequence magit magit-apply
> magit-wip magit-log magit-diff smerge-mode diff-mode magit-core
> magit-autorevert autorevert filenotify magit-process magit-popup
> magit-mode magit-git crm magit-section magit-utils git-commit log-edit
> message rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode mail-parse
> rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils gmm-utils
> mailheader pcvs-util add-log with-editor async-bytecomp async python
> tramp-sh tramp tramp-compat tramp-loaddefs trampver shell format-spec
> dired-aux server sunshine url-cache url url-proxy url-privacy url-expand
> url-methods url-history url-cookie url-domsuf url-util url-parse
> auth-source gnus-util mm-util help-fns mail-prsvr password-cache
> url-vars mailcap cal-china lunar solar cal-dst cal-bahai cal-islam
> cal-hebrew holidays hol-loaddefs appt diary-lib diary-loaddefs cal-menu
> calendar cal-loaddefs sql view tea-time pcomplete esh-var esh-io esh-cmd
> esh-opt esh-ext esh-proc esh-arg esh-groups eshell esh-module esh-mode
> esh-util js2-mode etags xref project eieio eieio-core js sgml-mode
> cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
> cc-vars cc-defs imenu ws-butler whitespace yasnippet cl browse-kill-ring
> avy ido-vertical-mode ido-ubiquitous cl-seq ido-completing-read+
> cus-edit flx-ido flx ido undo-tree iedit iedit-lib flycheck json map
> find-func subr-x projectile ibuf-ext ibuffer dash thingatpt recentf
> tree-widget pcre2el rxt cl-macs re-builder rx drag-stuff
> whole-line-or-region align2 edmacro kmacro wgrep reveal-in-osx-finder
> dired-x dired exec-path-from-shell delsel cua-base hydra lv hilit-chg
> wid-edit paren avoid linum zenburn-theme use-package diminish bind-key
> easy-mmode finder-inf advice info package epg-config seq byte-opt gv
> bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs
> pcase cl-lib grep compile comint ansi-color ring cus-start cus-load
> time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
> lisp-float-type mwheel ns-win ucs-normalize term/common-win tool-bar dnd
> fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
> lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
> scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame
> cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
> tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
> slovak czech european ethiopic indian cyrillic chinese charscript
> case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
> cl-preloaded nadvice loaddefs button faces cus-face macroexp files
> text-properties overlay sha1 md5 base64 format env code-pages mule
> custom widget hashtable-print-readable backquote kqueue cocoa ns
> multi-tty make-network-process emacs)
> 
> Memory information:
> ((conses 16 764072 122496)
>  (symbols 48 50260 0)
>  (miscs 40 1811 957)
>  (strings 32 147544 5627)
>  (string-bytes 1 4555893)
>  (vectors 16 105142)
>  (vector-slots 8 2292082 293693)
>  (floats 8 12056 11134)
>  (intervals 56 19325 3290)
>  (buffers 976 43))

The bug is present in emacs version 25.3.1 as well. The same error happens if I use sql-ms mode. As Michael noted the error happens within sql-interactive-remove-continuation-prompt (oline) function at the line he marked with an arrow above. 

I was able to workaround the bug by overriding the function in my .emacs file with the following code:

(eval-after-load "sql"
  '(defun sql-interactive-remove-continuation-prompt (oline)
     "Strip out continuation prompts out of the OLINE.

Added to the `comint-preoutput-filter-functions' hook in a SQL
interactive buffer.  If `sql-output-newline-count' is greater than
zero, then an output line matching the continuation prompt is filtered
out.  If the count is zero, then a newline is inserted into the output
to force the output from the query to appear on a new line.

The complication to this filter is that the continuation prompts
may arrive in multiple chunks.  If they do, then the function
saves any unfiltered output in a buffer and prepends that buffer
to the next chunk to properly match the broken-up prompt.

If the filter gets confused, it should reset and stop filtering
to avoid deleting non-prompt output."

     ;; continue gathering lines of text iff
     ;;  + we know what a prompt looks like, and
     ;;  + there is held text, or
     ;;  + there are continuation prompt yet to come, or
     ;;  + not just a prompt string
     (when (and comint-prompt-regexp
                (or (> (length (or sql-preoutput-hold "")) 0)
                    (> (or sql-output-newline-count 0) 0)
                    (not (or (string-match sql-prompt-regexp oline)
                             (and sql-prompt-cont-regexp
                                  (string-match sql-prompt-cont-regexp oline))))))

       (save-match-data
         (let (prompt-found last-nl)

           ;; Add this text to what's left from the last pass
           (setq oline (concat sql-preoutput-hold oline)
                 sql-preoutput-hold "")

           ;; If we are looking for multiple prompts
           (when (and (integerp sql-output-newline-count)
                      (>= sql-output-newline-count 1))
             ;; Loop thru each starting prompt and remove it
             (let ((start-re (sql-starts-with-prompt-re)))
               (while (and (not (string= oline ""))
                           (> sql-output-newline-count 0)
                           (string-match start-re oline))
                 (setq oline (replace-match "" nil nil oline)
                       sql-output-newline-count (1- sql-output-newline-count)
                       prompt-found t)))

             ;; If we've found all the expected prompts, stop looking
             (if (= sql-output-newline-count 0)
                 (setq sql-output-newline-count nil
                       oline (concat "\n" oline))

               ;; Still more possible prompts, leave them for the next pass
               (setq sql-preoutput-hold oline
                     oline "")))

           ;; If no prompts were found, stop looking
           (unless prompt-found
             (setq sql-output-newline-count nil
                   oline (concat oline sql-preoutput-hold)
                   sql-preoutput-hold ""))

           ;; Break up output by physical lines if we haven't hit the final prompt
           (let ((end-re (sql-ends-with-prompt-re)))
             (unless (and (not (string= oline ""))
                          (string-match end-re oline)
                          (>= (match-end 0) (length oline)))
               ;; Find everything upto the last nl
               (setq last-nl 0)
               (while (string-match "\n" oline last-nl)
                 (setq last-nl (match-end 0)))
               ;; Hold after the last nl, return upto last nl
               (setq sql-preoutput-hold (concat (substring oline last-nl)
                                                sql-preoutput-hold)
                     oline (substring oline 0 last-nl)))))))
     oline))


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

end of thread, other threads:[~2018-01-18 21:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-20 17:48 bug#24483: 25.1; sql-mode error due to nil prompt-cont-regexp Michael Kleehammer
2017-02-24 19:53 ` Pablo Mercader Alcántara
2017-05-29 16:52   ` Nikolay Kudryavtsev
2017-05-29 21:10     ` Pablo Mercader Alcántara
2017-05-29 21:50       ` Nikolay Kudryavtsev
2017-06-05 15:31         ` Pablo Mercader Alcántara
     [not found]         ` <CAPQ4eM+sS59iSFCy+udWntvWpGEBHCvjg=dEMb+e4zbw1zkVeQ@mail.gmail.com>
2017-06-05 22:25           ` Nikolay Kudryavtsev
     [not found] <mailman.2708.1474393810.22741.bug-gnu-emacs@gnu.org>
2018-01-18 21:52 ` Nesa K

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).