win32 readline

Started by Magnus Haganderabout 22 years ago20 messagespatches
Jump to latest
#1Magnus Hagander
magnus@hagander.net

Readline is pretty badly broken under mingw. Basically, it disables the
alt-gr key, which renders psql almost useless on most locales (no way to
type backslash, and a whole lot of other characters, for example).

This patch disables readline on win32. (meaning it's back to working the
way it did in <= 7.4, since msvc compiles have never supported readline)

The patch also contains two definitions for win32/port/security.c that
were for some reason not included when the rest of the win32-admin-check
patch was applied earlier, that I stumbled on while making this patch.

//Magnus

Attachments:

readline_win32.patchapplication/octet-stream; name=readline_win32.patchDownload+13-0
#2Bruce Momjian
bruce@momjian.us
In reply to: Magnus Hagander (#1)
Re: win32 readline

Magnus Hagander wrote:

Readline is pretty badly broken under mingw. Basically, it disables the
alt-gr key, which renders psql almost useless on most locales (no way to
type backslash, and a whole lot of other characters, for example).

This patch disables readline on win32. (meaning it's back to working the
way it did in <= 7.4, since msvc compiles have never supported readline)

The patch also contains two definitions for win32/port/security.c that
were for some reason not included when the rest of the win32-admin-check
patch was applied earlier, that I stumbled on while making this patch.

I have added the following change to configure.in:

# readline on MinGW has problems with backslashes in psql and other bugs.
# This is particularly a problem with non-US code pages.
# Therefore disable its use until we understand the cause. 2004-07-20
case $host_os in mingw*)
if test "$with_readline" = yes; then
AC_MSG_WARN([*** Readline does not work on MinGW --- disabling])
with_readline=no
fi;;
esac

and will issue this warning during configure run:

configure: WARNING: *** Readline does not work on MinGW --- disabling

You can suppress this warning by running configure using
--without-readline. If we find a fix for this we can remove this code.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Peter Eisentraut
peter_e@gmx.net
In reply to: Magnus Hagander (#1)
Re: win32 readline

Magnus Hagander wrote:

Readline is pretty badly broken under mingw. Basically, it disables
the alt-gr key, which renders psql almost useless on most locales (no
way to type backslash, and a whole lot of other characters, for
example).

I can't reproduce that. It works perfectly fine here.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#4Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#3)
Re: win32 readline

Peter Eisentraut wrote:

Magnus Hagander wrote:

Readline is pretty badly broken under mingw. Basically, it disables
the alt-gr key, which renders psql almost useless on most locales (no
way to type backslash, and a whole lot of other characters, for
example).

I can't reproduce that. It works perfectly fine here.

Peter, I have received multiple reports that psql readline doesn't work
on MinGW. Can you get together with Magnus and others to find out why
you aren't seeing the failure and they are. What code page are you
using for testing?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Mark Kirkwood
mark.kirkwood@catalyst.net.nz
In reply to: Peter Eisentraut (#3)
Re: win32 readline

To add to the confusion it works for me as well - Windows 2003 with
Mingw 3.1.0

Peter Eisentraut wrote:

Show quoted text

Magnus Hagander wrote:

Readline is pretty badly broken under mingw. Basically, it disables
the alt-gr key, which renders psql almost useless on most locales (no
way to type backslash, and a whole lot of other characters, for
example).

I can't reproduce that. It works perfectly fine here.

#6Magnus Hagander
magnus@hagander.net
In reply to: Mark Kirkwood (#5)
Re: win32 readline

Hmm. And this is a cvs pull that was before Bruce actually disabled
readline? What locale are you in?

Peter - what OS are you on, and what mingw version? And what locale?

I've done my tests on Win XP, and it elcearly does not work (locale =
Swedish). I've also talked to Merlin, and he had the same problems
(backslash worked bceauase his locale didn't require Alt-Gr for it, but
other Alt keysequences didn't)

//Magnus

Show quoted text

-----Original Message-----
From: Mark Kirkwood [mailto:markir@coretech.co.nz]

To add to the confusion it works for me as well - Windows
2003 with Mingw 3.1.0

Peter Eisentraut wrote:

Magnus Hagander wrote:

Readline is pretty badly broken under mingw. Basically, it disables
the alt-gr key, which renders psql almost useless on most

locales (no

way to type backslash, and a whole lot of other characters, for
example).

I can't reproduce that. It works perfectly fine here.

#7Mark Cave-Ayland
m.cave-ayland@webbased.co.uk
In reply to: Magnus Hagander (#6)
Re: win32 readline

FYI:

I've been using a CVS pull from the middle of May with readline under
Win32 without any problems. Firing up the database and doing a 'show
all' shows all lc_* vars set to English_United Kingdom.1252. This was
compiled using MingW-3.1.0-1 and MSYS-1.0.10, running under Windows XP
Pro. The only issues I have found with testing are that the history is
not maintained between psql sessions, and completion doesn't work with
\i when using a backslash (\) as a separator or when including a drive
specifier.

Hope this helps,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.

Show quoted text

-----Original Message-----
From: pgsql-patches-owner@postgresql.org
[mailto:pgsql-patches-owner@postgresql.org] On Behalf Of
Magnus Hagander
Sent: 21 July 2004 09:13
To: Mark Kirkwood; Peter Eisentraut
Cc: pgsql-patches@postgresql.org
Subject: Re: [PATCHES] win32 readline

Hmm. And this is a cvs pull that was before Bruce actually
disabled readline? What locale are you in?

Peter - what OS are you on, and what mingw version? And what locale?

I've done my tests on Win XP, and it elcearly does not work
(locale = Swedish). I've also talked to Merlin, and he had
the same problems (backslash worked bceauase his locale
didn't require Alt-Gr for it, but other Alt keysequences didn't)

//Magnus

-----Original Message-----
From: Mark Kirkwood [mailto:markir@coretech.co.nz]

To add to the confusion it works for me as well - Windows
2003 with Mingw 3.1.0

Peter Eisentraut wrote:

Magnus Hagander wrote:

Readline is pretty badly broken under mingw. Basically,

it disables

the alt-gr key, which renders psql almost useless on most

locales (no

way to type backslash, and a whole lot of other characters, for
example).

I can't reproduce that. It works perfectly fine here.

---------------------------(end of
broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)

#8Magnus Hagander
magnus@hagander.net
In reply to: Mark Cave-Ayland (#7)
Re: win32 readline

The locale that's interesting is the Windows locale, not the pg one.
And I assume you are on english locale? Then you don't need Alt-Gr for
backslash at least, but you're saying other Alt-Gr-key based
combinations did work?

(I've also had reports of history problems, which in at least one case
has been fixed by the disabling of readline)

//Magnus

Show quoted text

-----Original Message-----
From: Mark Cave-Ayland [mailto:m.cave-ayland@webbased.co.uk]
Sent: Wednesday, July 21, 2004 12:38 PM
To: Magnus Hagander; 'Mark Kirkwood'; 'Peter Eisentraut'
Cc: pgsql-patches@postgresql.org
Subject: RE: [PATCHES] win32 readline

FYI:

I've been using a CVS pull from the middle of May with readline under
Win32 without any problems. Firing up the database and doing
a 'show all' shows all lc_* vars set to English_United
Kingdom.1252. This was compiled using MingW-3.1.0-1 and
MSYS-1.0.10, running under Windows XP Pro. The only issues I
have found with testing are that the history is not
maintained between psql sessions, and completion doesn't work
with \i when using a backslash (\) as a separator or when
including a drive specifier.

Hope this helps,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446

This email and any attachments are confidential to the
intended recipient and may also be privileged. If you are not
the intended recipient please delete it from your system and
notify the sender. You should not copy it or use it for any
purpose nor disclose or distribute its contents to any other person.

-----Original Message-----
From: pgsql-patches-owner@postgresql.org
[mailto:pgsql-patches-owner@postgresql.org] On Behalf Of Magnus
Hagander
Sent: 21 July 2004 09:13
To: Mark Kirkwood; Peter Eisentraut
Cc: pgsql-patches@postgresql.org
Subject: Re: [PATCHES] win32 readline

Hmm. And this is a cvs pull that was before Bruce actually disabled
readline? What locale are you in?

Peter - what OS are you on, and what mingw version? And what locale?

I've done my tests on Win XP, and it elcearly does not work

(locale =

Swedish). I've also talked to Merlin, and he had the same problems
(backslash worked bceauase his locale didn't require Alt-Gr for it,
but other Alt keysequences didn't)

//Magnus

-----Original Message-----
From: Mark Kirkwood [mailto:markir@coretech.co.nz]

To add to the confusion it works for me as well - Windows
2003 with Mingw 3.1.0

Peter Eisentraut wrote:

Magnus Hagander wrote:

Readline is pretty badly broken under mingw. Basically,

it disables

the alt-gr key, which renders psql almost useless on most

locales (no

way to type backslash, and a whole lot of other characters, for
example).

I can't reproduce that. It works perfectly fine here.

---------------------------(end of
broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)

#9Mark Cave-Ayland
m.cave-ayland@webbased.co.uk
In reply to: Magnus Hagander (#8)
Re: win32 readline

-----Original Message-----
From: pgsql-patches-owner@postgresql.org
[mailto:pgsql-patches-owner@postgresql.org] On Behalf Of
Magnus Hagander
Sent: 21 July 2004 11:49
To: Mark Cave-Ayland
Cc: pgsql-patches@postgresql.org
Subject: Re: [PATCHES] win32 readline

The locale that's interesting is the Windows locale, not the
pg one. And I assume you are on english locale? Then you
don't need Alt-Gr for backslash at least, but you're saying
other Alt-Gr-key based combinations did work?

(I've also had reports of history problems, which in at least
one case has been fixed by the disabling of readline)

//Magnus

Ah sorry, I misunderstood that you needed the Windows locale. Assuming
that the locale is the one that's set in Control Panel, Regional Options
then on my PC it's set to "English (United Kingdom)". As you suggest, I
don't need to use Alt-Gr for a backslash, but I can happily write all
sorts of strange characters (particularly lots of DOS characters) by
holding down Alt-Gr and tapping other keys on the keyboard. I can even
include these strange characters in SELECT queries, plus they display
correctly when cycling through the history.

Note this is running psql from cmd.exe instead of through the MSYS
terminal - for some reason psql.exe hangs when I try and run it from the
MSYS terminal at the moment....

Kind regards,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.

#10Mark Kirkwood
mark.kirkwood@catalyst.net.nz
In reply to: Magnus Hagander (#6)
Re: win32 readline

- CVS HEAD from approx 19 Jul
- locale is 'English_New Zealand.1252'

Magnus Hagander wrote:

Show quoted text

Hmm. And this is a cvs pull that was before Bruce actually disabled
readline? What locale are you in?

#11Mark Kirkwood
mark.kirkwood@catalyst.net.nz
In reply to: Mark Kirkwood (#10)
Re: win32 readline

Sorry - I have done it too:

Windows Locale is : English (New Zealand)

Mark Kirkwood wrote:

Show quoted text

- CVS HEAD from approx 19 Jul
- locale is 'English_New Zealand.1252'

Magnus Hagander wrote:

Hmm. And this is a cvs pull that was before Bruce actually disabled
readline? What locale are you in?

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

#12Peter Eisentraut
peter_e@gmx.net
In reply to: Magnus Hagander (#6)
Re: win32 readline

Magnus Hagander wrote:

Hmm. And this is a cvs pull that was before Bruce actually disabled
readline? What locale are you in?

Actually, I just just typed away in the bash shell, which uses readline
as well.

Peter - what OS are you on, and what mingw version? And what locale?

Windows XP Pro, MinGW 2.0.0, MSys 1.0.8, locale German (Germany)

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#13Magnus Hagander
magnus@hagander.net
In reply to: Peter Eisentraut (#12)
Re: win32 readline

Hmm. And this is a cvs pull that was before Bruce actually disabled
readline? What locale are you in?

Actually, I just just typed away in the bash shell, which
uses readline as well.

Ok, then we're testing completely different things. I'm talking about
the psql client when running under CMD.EXE, *not* in the msys shell.
(backslash works fine in the bash shell)

//Magnus

#14Peter Eisentraut
peter_e@gmx.net
In reply to: Magnus Hagander (#13)
Re: win32 readline

Magnus Hagander wrote:

Ok, then we're testing completely different things. I'm talking about
the psql client when running under CMD.EXE, *not* in the msys shell.
(backslash works fine in the bash shell)

OK, I'll try that later. As an additional data point, running sh.exe
from within cmd.exe also gives a functional readline environment. So
either there are local difficulties with some people, or psql is not
using readline as well as it could. In any case, there is still hope
for readline on Windows.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#15Magnus Hagander
magnus@hagander.net
In reply to: Peter Eisentraut (#14)
Re: win32 readline

Magnus Hagander wrote:

Ok, then we're testing completely different things. I'm talking about
the psql client when running under CMD.EXE, *not* in the msys shell.
(backslash works fine in the bash shell)

OK, I'll try that later. As an additional data point, running sh.exe
from within cmd.exe also gives a functional readline environment. So
either there are local difficulties with some people, or psql is not
using readline as well as it could. In any case, there is still hope
for readline on Windows.

Right. sh does work for me.

Just for reference, what features are we losing without readline. Tab
completion, but what more?

//Magnus

#16Peter Eisentraut
peter_e@gmx.net
In reply to: Magnus Hagander (#15)
Re: win32 readline

Magnus Hagander wrote:

Just for reference, what features are we losing without readline. Tab
completion, but what more?

Command history, customizable key bindings, cut and paste, cursor keys
come to mind.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#17Magnus Hagander
magnus@hagander.net
In reply to: Peter Eisentraut (#16)
Re: win32 readline

Magnus Hagander wrote:

Just for reference, what features are we losing without

readline. Tab

completion, but what more?

Command history, customizable key bindings, cut and paste,
cursor keys come to mind.

Command history, cut-and-paste and cursor keys definitly work in my
build *without* readline. (Command history works better without
readline than with, according to a couple of reports I've had). Don't
know about the key bindings, never used those :-)

//Magnus

#18Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#16)
Re: win32 readline

Where are we on this? Right now readline is disabled on Win32. psql
works fine for me. In fact it is more native because the delete key
deletes, and control-d doesn't exit.

I am inclined to leave the code unchanged and we can revisit this later
after we figure out why readline doesn't work on some Win32 versions.

---------------------------------------------------------------------------

Peter Eisentraut wrote:

Magnus Hagander wrote:

Just for reference, what features are we losing without readline. Tab
completion, but what more?

Command history, customizable key bindings, cut and paste, cursor keys
come to mind.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#19The Hermit Hacker
scrappy@hub.org
In reply to: Bruce Momjian (#18)
Re: win32 readline

On Mon, 2 Aug 2004, Bruce Momjian wrote:

Where are we on this? Right now readline is disabled on Win32. psql
works fine for me. In fact it is more native because the delete key
deletes, and control-d doesn't exit.

I am inclined to leave the code unchanged and we can revisit this later
after we figure out why readline doesn't work on some Win32 versions.

Stupid question, but for Windows ... how many will actually use psql, vs
something like PgAdmin? I'd say revisit it later myself ... it isn't
critical to the operation of the server, only a 'luxury item' that we've
all gotten used to being there :)

---------------------------------------------------------------------------

Peter Eisentraut wrote:

Magnus Hagander wrote:

Just for reference, what features are we losing without readline. Tab
completion, but what more?

Command history, customizable key bindings, cut and paste, cursor keys
come to mind.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

--
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 359-1001
+  If your life is a hard drive,     |  13 Roberts Road
+  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664

#20Peter Eisentraut
peter_e@gmx.net
In reply to: The Hermit Hacker (#19)
Re: win32 readline

Marc G. Fournier wrote:

Stupid question, but for Windows ... how many will actually use psql,
vs something like PgAdmin?

I don't see any reason to believe that it would be significantly less
than now.

I'd say revisit it later myself ... it
isn't critical to the operation of the server, only a 'luxury item'
that we've all gotten used to being there :)

By that logic, approximately 37% of all features count as luxury items.
:)

--
Peter Eisentraut
http://developer.postgresql.org/~petere/