unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#66983: 29.1; sql-sqlite prompt-cont-regexp incompatible since sqlite 3.41.0
@ 2023-11-07 10:20 Gustav Broberg
  2023-11-10  9:41 ` bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt Gustav Broberg
  0 siblings, 1 reply; 7+ messages in thread
From: Gustav Broberg @ 2023-11-07 10:20 UTC (permalink / raw)
  To: 66983

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

The continuation prompt regexp for sql.el's sqlite product is hard coded as
"   ...> ":
http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/sql.el?id=a1abb6a85e6605c256595b8d7b885018e5421c28#n497

But since SQLite version 3.41.0 this prompt is no longer static but dynamic
and contains information about current context (unclosed string,
parentheses, etc.):
https://www.sqlite.org/releaselog/3_41_0.html

For example, sending a multi-line query with an unclosed string like:

  SELECT 1
  AS "two lines
  ";

will give an output like:

  SQLite version 3.44.0 2023-11-01 11:23:50
  Enter ".help" for usage hints.
  sqlite>
  "  ...> ┌───────────┐
  │ two lines │
  ├───────────┤
  │ 1         │
  └───────────┘
  Run Time: real 0.000 user 0.000118 sys 0.000076

because the continuation prompt is '"  ...> '.

Setting a custom sqlite continuation prompt regexp to match the dynamic
prompt
fixes this:

  (sql-set-product-feature 'sqlite :prompt-cont-regexp "^...\\.\\.\\.> ")

I suggest updating the regexp in sql.el to this (or some more specific)
regexp.

Thanks!
-- 
Gustav

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

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

* bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt
  2023-11-07 10:20 bug#66983: 29.1; sql-sqlite prompt-cont-regexp incompatible since sqlite 3.41.0 Gustav Broberg
@ 2023-11-10  9:41 ` Gustav Broberg
  2023-11-10 12:06   ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Gustav Broberg @ 2023-11-10  9:41 UTC (permalink / raw)
  To: 66983


[-- Attachment #1.1: Type: text/plain, Size: 91 bytes --]

Patch for changing sql.el sqlite's prompt-cont-regexp to be compatible with
SQLite 3.41.0.

[-- Attachment #1.2: Type: text/html, Size: 116 bytes --]

[-- Attachment #2: 0001-sql.el-Let-sqlite-s-prompt-cont-regexp-accept-new-dy.patch --]
[-- Type: application/octet-stream, Size: 1200 bytes --]

From e242d621ea65c5163ee6dc9ed5025a40308319e1 Mon Sep 17 00:00:00 2001
From: Gustav Broberg <gustav.broberg@gmail.com>
Date: Fri, 10 Nov 2023 10:16:29 +0100
Subject: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic
 prompt

Since SQLite version 3.41.0 the continuation prompt is dynamic and
shows open parentheses, quotes, comments, etc. Update sql.el sqlite
prompt-cont-regexp to match not only the static prompt ("   ...> ")
but the new dynamic ones. The possible continuation prompts are:

     ...>
  `  ...>
  '  ...>
  "  ...>
  /* ...>
  (xN...> (where N is 1 to 9)
  (.....>
  )x!...>
---
 lisp/progmodes/sql.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 004ae50ef50..a99e94acf79 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -507,7 +507,7 @@ file.  Since that is a plaintext file, this could be dangerous."
      :completion-object sql-sqlite-completion-object
      :prompt-regexp "^sqlite> "
      :prompt-length 8
-     :prompt-cont-regexp "^   \\.\\.\\.> ")
+     :prompt-cont-regexp "^[`'\"/() ][x*. ][1-9!. ]\\.\\.\\.> ")
 
     (sybase
      :name "Sybase"
-- 
2.42.1


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

* bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt
  2023-11-10  9:41 ` bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt Gustav Broberg
@ 2023-11-10 12:06   ` Eli Zaretskii
  2023-11-25  9:26     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-11-10 12:06 UTC (permalink / raw)
  To: Gustav Broberg, Michael R. Mauger; +Cc: 66983

> From: Gustav Broberg <gustav.broberg@gmail.com>
> Date: Fri, 10 Nov 2023 10:41:03 +0100
> 
> Patch for changing sql.el sqlite's prompt-cont-regexp to be compatible with SQLite 3.41.0.

Thanks.

Michael, any comments or suggestions?





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

* bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt
  2023-11-10 12:06   ` Eli Zaretskii
@ 2023-11-25  9:26     ` Eli Zaretskii
  2023-12-15  1:28       ` Stefan Kangas
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-11-25  9:26 UTC (permalink / raw)
  To: michael; +Cc: 66983, gustav.broberg

Ping!  Michael, can you please look into this?

> Cc: 66983@debbugs.gnu.org
> Date: Fri, 10 Nov 2023 14:06:20 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> > From: Gustav Broberg <gustav.broberg@gmail.com>
> > Date: Fri, 10 Nov 2023 10:41:03 +0100
> > 
> > Patch for changing sql.el sqlite's prompt-cont-regexp to be compatible with SQLite 3.41.0.
> 
> Thanks.
> 
> Michael, any comments or suggestions?
> 
> 
> 
> 





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

* bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt
  2023-11-25  9:26     ` Eli Zaretskii
@ 2023-12-15  1:28       ` Stefan Kangas
  2023-12-15  8:39         ` Eli Zaretskii
  2023-12-15 10:05         ` Gustav Broberg
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Kangas @ 2023-12-15  1:28 UTC (permalink / raw)
  To: Eli Zaretskii, michael; +Cc: 66983, gustav.broberg

Eli Zaretskii <eliz@gnu.org> writes:

> Ping!  Michael, can you please look into this?
>
>> Cc: 66983@debbugs.gnu.org
>> Date: Fri, 10 Nov 2023 14:06:20 +0200
>> From: Eli Zaretskii <eliz@gnu.org>
>>
>> > From: Gustav Broberg <gustav.broberg@gmail.com>
>> > Date: Fri, 10 Nov 2023 10:41:03 +0100
>> >
>> > Patch for changing sql.el sqlite's prompt-cont-regexp to be compatible with SQLite 3.41.0.
>>
>> Thanks.
>>
>> Michael, any comments or suggestions?

It would be nice to get this fixed already in Emacs 29.2, given that
SQLite is so common.

FWIW, if Michael doesn't have time to look into this, the patch seems to
make sense.  It just allows a few more prompts that weren't allowed
before.

At the same time, if these are indeed the only allowed prompts:

      ...>
   `  ...>
   '  ...>
   "  ...>
   /* ...>
   (xN...> (where N is 1 to 9)
   (.....>
   )x!...>

we could probably make something a bit more strict.  Where do we find
the documentation for that though?  Gustav, where is that from?





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

* bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt
  2023-12-15  1:28       ` Stefan Kangas
@ 2023-12-15  8:39         ` Eli Zaretskii
  2023-12-15 10:05         ` Gustav Broberg
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2023-12-15  8:39 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: michael, gustav.broberg, 66983

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Thu, 14 Dec 2023 17:28:39 -0800
> Cc: 66983@debbugs.gnu.org, gustav.broberg@gmail.com
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Ping!  Michael, can you please look into this?
> >
> >> Cc: 66983@debbugs.gnu.org
> >> Date: Fri, 10 Nov 2023 14:06:20 +0200
> >> From: Eli Zaretskii <eliz@gnu.org>
> >>
> >> > From: Gustav Broberg <gustav.broberg@gmail.com>
> >> > Date: Fri, 10 Nov 2023 10:41:03 +0100
> >> >
> >> > Patch for changing sql.el sqlite's prompt-cont-regexp to be compatible with SQLite 3.41.0.
> >>
> >> Thanks.
> >>
> >> Michael, any comments or suggestions?
> 
> It would be nice to get this fixed already in Emacs 29.2, given that
> SQLite is so common.

Agreed.  I hope Michael will chime in soon enough.





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

* bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt
  2023-12-15  1:28       ` Stefan Kangas
  2023-12-15  8:39         ` Eli Zaretskii
@ 2023-12-15 10:05         ` Gustav Broberg
  1 sibling, 0 replies; 7+ messages in thread
From: Gustav Broberg @ 2023-12-15 10:05 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: michael, Eli Zaretskii, 66983

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

On Fri, Dec 15, 2023 at 2:28 AM Stefan Kangas <stefankangas@gmail.com>
wrote:

> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Ping!  Michael, can you please look into this?
> >
> >> Cc: 66983@debbugs.gnu.org
> >> Date: Fri, 10 Nov 2023 14:06:20 +0200
> >> From: Eli Zaretskii <eliz@gnu.org>
> >>
> >> > From: Gustav Broberg <gustav.broberg@gmail.com>
> >> > Date: Fri, 10 Nov 2023 10:41:03 +0100
> >> >
> >> > Patch for changing sql.el sqlite's prompt-cont-regexp to be
> compatible with SQLite 3.41.0.
> >>
> >> Thanks.
> >>
> >> Michael, any comments or suggestions?
>
> It would be nice to get this fixed already in Emacs 29.2, given that
> SQLite is so common.
>
> FWIW, if Michael doesn't have time to look into this, the patch seems to
> make sense.  It just allows a few more prompts that weren't allowed
> before.
>
> At the same time, if these are indeed the only allowed prompts:
>
>       ...>
>    `  ...>
>    '  ...>
>    "  ...>
>    /* ...>
>    (xN...> (where N is 1 to 9)
>    (.....>
>    )x!...>
>
> we could probably make something a bit more strict.  Where do we find
> the documentation for that though?  Gustav, where is that from?
>

Thanks,

Not sure if it was clear, but the regexp in my actual patch is more strict
than in my first email: ^[`'\"/() ][x*. ][1-9!. ]\\.\\.\\.>

Unfortunately I've found no documentation listing the continuation prompts
– I derived this list by inspecting the sqlite source code. For example:
https://github.com/sqlite/sqlite/blob/e98238561911f85e54af3e6f26e47c2de8d1cda1/src/shell.c.in#L583-L611

-- Gustav

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

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

end of thread, other threads:[~2023-12-15 10:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07 10:20 bug#66983: 29.1; sql-sqlite prompt-cont-regexp incompatible since sqlite 3.41.0 Gustav Broberg
2023-11-10  9:41 ` bug#66983: [PATCH] sql.el: Let sqlite's prompt-cont-regexp accept new dynamic prompt Gustav Broberg
2023-11-10 12:06   ` Eli Zaretskii
2023-11-25  9:26     ` Eli Zaretskii
2023-12-15  1:28       ` Stefan Kangas
2023-12-15  8:39         ` Eli Zaretskii
2023-12-15 10:05         ` Gustav Broberg

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