Subject: bug#47357: 28.0.50; sql-list-tables: Executing SQL command... takes indefinite time after creation of new table

From: Michael Mauger <[email-masked]>
Date: Sun, 24 Oct 2021 22:05:41 +0000

On Thursday, October 21st, 2021 at 5:02 PM, Stefan Kangas <[email-masked]> wrote:
> Jean Louis [email-masked] writes:
>
> > I have noticed, but have not researched why, is that function
> > `sql-list-tables' takes indefinite time without completing or giving
> > result when I do following:
> >
> > -   M-x sql-postgres RET and more entries until I get into the SQL buffer
> > -   create new table
> > -   C-c C-l t with new table name is then taking indefinite time.
> >
> > Maybe the library is reading tables only at initializations, I may be
> > wrong. In SQL buffer there is no problem to inspect the table, but C-c
> > C-l t does not allow it for new table created.
> >
> > This may all be wrong and related to some other bug there, I do not
> > know. I was interrupting the indefinite message with C-g.
>
> I'm copying in the sql.el maintainer here. Michael, could you please
> take a look at the above bug report?

The problem here is that the `sql-list-tables' feature uses the
`comint-redirect-send-command-to-process' procedure to capture the SQL
interpreter response and that relies upon the `comint-prompt-regexp'
variable to be set appropriately. Comint Mode itself no longer relies
upon the regexp to spot the prompt but the redirect logic does.

The default prompt regexp for Postgres in sql.el is not correct and a
fix will be made for Emacs 28 and master for that.

I will also add a function to sql.el to verify the prompt as best I can
to Emacs-28 so at least an error message or workaround can be provided.

On master, I'll submit a similar change to comint.el to protect all
Comint derived modes if they use the redirect logic and prevent the
hanging behavior.

I was aware of the bad prompt regexp but had forgotten to commit that
change. I'll go ahead and do that now.
--
[email-masked] // FSF and EFF member // GNU Emacs sql.el maintainer