Thread: psql and Gnu readline
I've just installed PostgreSQL 7.02 on my OpenBSD box. Everything is working fine. I made sure to link in gnu readline in psql. It seems to be working, because I can edit a line. For instance, Ctl-A takes me to the beginning of a line, Ctl-K kills it, etc. However, Ctl-P doesn't go up a line, so I can't access previous lines, and lines are not saved in the .psql_history file which is mentioned on the man page. Any idea what to do? Line editing is so handy to have in something like this. Thanks, e
Erich wrote: > > I've just installed PostgreSQL 7.02 on my OpenBSD box. Everything is > working fine. I made sure to link in gnu readline in psql. It seems > to be working, because I can edit a line. For instance, Ctl-A takes > me to the beginning of a line, Ctl-K kills it, etc. However, Ctl-P > doesn't go up a line, so I can't access previous lines, and lines are > not saved in the .psql_history file which is mentioned on the man > page. > > Any idea what to do? Line editing is so handy to have in something > like this. Strange, it works for me. I don't suppose you have a .inputrc stuffing things up?
> > me to the beginning of a line, Ctl-K kills it, etc. However, Ctl-P > > doesn't go up a line, so I can't access previous lines, and lines are > > not saved in the .psql_history file which is mentioned on the man > > page. Did the configure script find using_history in your readline library? Regards, Mit freundlichem Gruß, Holger Klawitter -- Holger Klawitter +49 (0)251 484 0637 holger@klawitter.de http://www.klawitter.de/
> Erich wrote: >> I've just installed PostgreSQL 7.02 on my OpenBSD box. Everything is >> working fine. I made sure to link in gnu readline in psql. It seems >> to be working, because I can edit a line. For instance, Ctl-A takes >> me to the beginning of a line, Ctl-K kills it, etc. However, Ctl-P >> doesn't go up a line, so I can't access previous lines, and lines are >> not saved in the .psql_history file which is mentioned on the man >> page. IIRC the "history" facility is separate from the core of libreadline. You may not have libhistory installed, or at least our configure script failed to notice that it's there. Check the xxxHISTORY defines in config.h. regards, tom lane
> Did the configure script find using_history in your readline library? Mmm, since the platform is OpenBSD did configure really find the readline library, or did it find libedit pretending to be readline? (NetBSD's libedit is just about good enough to satisfy psql; I don't know if OpenBSD has picked up the libedit extensions or not though.) Regards, Giles
I had this same problem. Thanks to a suggestion from Bruce Momjian, I noticed that the configure script was not finding the readline libraries. I checked, and found that though I did have the readline package installed, I did not have the readline-devel package installed. Once I installed that package, the configure script found readline and after recompiling everything works fine. Erich wrote: > > I've just installed PostgreSQL 7.02 on my OpenBSD box. Everything is > working fine. I made sure to link in gnu readline in psql. It seems > to be working, because I can edit a line. For instance, Ctl-A takes > me to the beginning of a line, Ctl-K kills it, etc. However, Ctl-P > doesn't go up a line, so I can't access previous lines, and lines are > not saved in the .psql_history file which is mentioned on the man > page. > > Any idea what to do? Line editing is so handy to have in something > like this. > > Thanks, > > e
With some helpful hints from various people, I figured out how to get this to work, and now my life is more pleasant and meaningful. Situation: Stock installation of OpenBSD 2.7, with PostgreSQL 7.0.2. I installed postgres by downloading the source tar and compiling, not by going through /usr/ports. Anyway, I'm not sure if OpenBSD ships with readline or whatever, so I downloaded the latest readline (4.1) and compiled and installed it. I then did ./configure in postgres, and recompiled psql, and it still didn't have history. Following some sugestions on this group, I figured out the problem. First, there is no history.h with readline 4.1. There's readline/history.h. So I modified Makefile.global to include that file. Also, I had to edit config.h, with several tweaks to various defines. I had to tell it that there is no history.h, but there is a readline/history.h. I had to put in that there is no history function in libreadline, and it must also use libhistory. Etc. After doing all that, it worked beautifully. I often have to do a sequence of slighly varied inserts, etc, and this is much better. Maybe for the next release, there should be better handling of gnu readline 4.1? Or maybe it should come with the package? Just a thought. e -- This message was my two cents worth. Please deposit two cents into my e-gold account by following this link: http://rootworks.com/twocentsworth.cgi?102861 275A B627 1826 D627 ED35 B8DF 7DDE 4428 0F5C 4454
Erich <hh@cyberpass.net> writes: > Following some sugestions on this group, I figured out the problem. > First, there is no history.h with readline 4.1. There's > readline/history.h. So I modified Makefile.global to include that > file. Also, I had to edit config.h, with several tweaks to various > defines. I had to tell it that there is no history.h, but there is a > readline/history.h. I had to put in that there is no history function > in libreadline, and it must also use libhistory. Etc. configure is supposed to handle all that for you ... if it failed to find the right location of libreadline and associated includes then the question is why. You sure you ran configure after installing the include files? regards, tom lane
> configure is supposed to handle all that for you ... if it failed to > find the right location of libreadline and associated includes then > the question is why. You sure you ran configure after installing > the include files? I just deleted my postgres tree, and then unpacked it again, and ran configure again. libreadline.a and libhistory.a are in /usr/local/lib/. readline.h and history.h are in /usr/local/include/readline/. I then ran ./configure. When I look at config.h, I can see that it failed to detect /usr/local/include/readline/history.h. Also, I see that it did define HAVE_HISTORY_IN_READLINE 1 which is incorrect. I would have to make the change by hand to the file. I think it may be a bug. e
Erich <hh@cyberpass.net> writes: >> configure is supposed to handle all that for you ... if it failed to >> find the right location of libreadline and associated includes then >> the question is why. You sure you ran configure after installing >> the include files? > I just deleted my postgres tree, and then unpacked it again, and ran > configure again. libreadline.a and libhistory.a are in > /usr/local/lib/. readline.h and history.h are in > /usr/local/include/readline/. OK ... my setup has the same files in the same places ... > I then ran ./configure. > When I look at config.h, I can see that it failed to detect > /usr/local/include/readline/history.h. Also, I see that it did define > HAVE_HISTORY_IN_READLINE 1 which is incorrect. I would have to make > the change by hand to the file. Well, that's darn peculiar. configure.in has a test for readline/history.h, big as life: AC_CHECK_HEADERS(readline/history.h) Does the config.log file show why it failed to find the include? HAVE_HISTORY_IN_READLINE seems to get defined if libreadline.a contains a "using_history" symbol: AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE), AC_CHECK_LIB(history, main) ) On my setup, which is readline 4.0 if I'm checking the right files, HAVE_HISTORY_IN_READLINE does get defined, and AFAICT libhistory.a doesn't get linked, but I most certainly do get history support. Which readline version are you using? Maybe the GNU guys rearranged which functions live in which library. If so, we probably need to be probing for a different symbol in libreadline to be compatible across more libreadline versions ... regards, tom lane
> Well, that's darn peculiar. configure.in has a test for > readline/history.h, big as life: > AC_CHECK_HEADERS(readline/history.h) > Does the config.log file show why it failed to find the include? Here's the lines from config.log: configure:2539: checking for main in -lreadline configure:2554: gcc -o conftest -O2 -pipe conftest.c -lreadline -ltermcap -lcurses 1>&5 configure:2582: checking for using_history in -lreadline configure:2601: gcc -o conftest -O2 -pipe conftest.c -lreadline -lreadline -ltermcap -lcurses 1>&5 configure:3833: checking for history.h configure:3843: gcc -E conftest.c >/dev/null 2>conftest.out configure:3839: history.h: No such file or directory configure: failed program was: #line 3838 "configure" #include "confdefs.h" #include <history.h> configure:3873: checking for ieeefp.h configure:3883: gcc -E conftest.c >/dev/null 2>conftest.out configure:3913: checking for limits.h configure:3923: gcc -E conftest.c >/dev/null 2>conftest.out configure:3953: checking for netdb.h configure:3963: gcc -E conftest.c >/dev/null 2>conftest.out configure:3993: checking for netinet/in.h configure:4003: gcc -E conftest.c >/dev/null 2>conftest.out configure:4033: checking for readline.h configure:4043: gcc -E conftest.c >/dev/null 2>conftest.out configure:4039: readline.h: No such file or directory configure: failed program was: #line 4038 "configure" #include "confdefs.h" #include <readline.h> configure:4073: checking for readline/history.h configure:4083: gcc -E conftest.c >/dev/null 2>conftest.out configure:4079: readline/history.h: No such file or directory configure: failed program was: #line 4078 "configure" #include "confdefs.h" #include <readline/history.h> configure:4113: checking for readline/readline.h configure:4123: gcc -E conftest.c >/dev/null 2>conftest.out configure:4153: checking for sys/select.h configure:4163: gcc -E conftest.c >/dev/null 2>conftest.out configure:4193: checking for termios.h configure:4203: gcc -E conftest.c >/dev/null 2>conftest.out configure:4233: checking for unistd.h configure:4243: gcc -E conftest.c >/dev/null 2>conftest.out configure:4273: checking for values.h configure:4283: gcc -E conftest.c >/dev/null 2>conftest.out configure:4279: values.h: No such file or directory configure: failed program was: #line 4278 "configure" > On my setup, which is readline 4.0 if I'm checking the right files, > HAVE_HISTORY_IN_READLINE does get defined, and AFAICT libhistory.a > doesn't get linked, but I most certainly do get history support. > > Which readline version are you using? Maybe the GNU guys rearranged > which functions live in which library. If so, we probably need > to be probing for a different symbol in libreadline to be compatible > across more libreadline versions ... I'm using readline 4.1, compiled from the distribution. In other words, I didn't get it from /usr/ports, which is what OpenBSD normally uses. I have a stupid ./configure question: Whenever I compile something, I never want to have -g as a CC option. How do I tell configure not to use -g as a CC option? I only want -O2. Usually I go through and edit Makefiles by hand after configure is done, but that's annoying. e
Here's a stupid question, What happens if you do the same kind of compile on a similar program from your shell (a simple program that includes <readline/history.h>, with and without -I/usr/local/include? I'm just wondering if the compiler is not looking in /usr/local/include by default and is not finding the header because of that... ----- Original Message ----- From: "Erich" <hh@cyberpass.net> To: <tgl@sss.pgh.pa.us> Cc: <pgsql-general@postgresql.org> Sent: Wednesday, July 12, 2000 6:12 PM Subject: Re: [GENERAL] Figured it out (psql and Gnu readline) > > > Well, that's darn peculiar. configure.in has a test for > > readline/history.h, big as life: > > AC_CHECK_HEADERS(readline/history.h) > > Does the config.log file show why it failed to find the include? > > Here's the lines from config.log: > > configure:2539: checking for main in -lreadline > configure:2554: gcc -o conftest -O2 -pipe conftest.c -lreadline -ltermcap -lcurses 1>&5 > configure:2582: checking for using_history in -lreadline > configure:2601: gcc -o conftest -O2 -pipe conftest.c -lreadline -lreadline -ltermcap -lcurses 1>&5 > configure:3833: checking for history.h > configure:3843: gcc -E conftest.c >/dev/null 2>conftest.out > configure:3839: history.h: No such file or directory > configure: failed program was: > #line 3838 "configure" > #include "confdefs.h" > #include <history.h> > configure:3873: checking for ieeefp.h > configure:3883: gcc -E conftest.c >/dev/null 2>conftest.out > configure:3913: checking for limits.h > configure:3923: gcc -E conftest.c >/dev/null 2>conftest.out > configure:3953: checking for netdb.h > configure:3963: gcc -E conftest.c >/dev/null 2>conftest.out > configure:3993: checking for netinet/in.h > configure:4003: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4033: checking for readline.h > configure:4043: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4039: readline.h: No such file or directory > configure: failed program was: > #line 4038 "configure" > #include "confdefs.h" > #include <readline.h> > configure:4073: checking for readline/history.h > configure:4083: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4079: readline/history.h: No such file or directory > configure: failed program was: > #line 4078 "configure" > #include "confdefs.h" > #include <readline/history.h> > configure:4113: checking for readline/readline.h > configure:4123: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4153: checking for sys/select.h > configure:4163: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4193: checking for termios.h > configure:4203: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4233: checking for unistd.h > configure:4243: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4273: checking for values.h > configure:4283: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4279: values.h: No such file or directory > configure: failed program was: > #line 4278 "configure" > > > > On my setup, which is readline 4.0 if I'm checking the right files, > > HAVE_HISTORY_IN_READLINE does get defined, and AFAICT libhistory.a > > doesn't get linked, but I most certainly do get history support. > > > > Which readline version are you using? Maybe the GNU guys rearranged > > which functions live in which library. If so, we probably need > > to be probing for a different symbol in libreadline to be compatible > > across more libreadline versions ... > > I'm using readline 4.1, compiled from the distribution. In other > words, I didn't get it from /usr/ports, which is what OpenBSD normally > uses. > > I have a stupid ./configure question: Whenever I compile something, I > never want to have -g as a CC option. How do I tell configure not to > use -g as a CC option? I only want -O2. Usually I go through and > edit Makefiles by hand after configure is done, but that's annoying. > > e >
On Wed, Jul 12, 2000 at 08:50:58PM -0400, Tom Lane wrote: ... > HAVE_HISTORY_IN_READLINE seems to get defined if libreadline.a contains > a "using_history" symbol: > > AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE), > AC_CHECK_LIB(history, main) ) .. of course for me it's in libedit: % nm -g /usr/lib/libedit.a | grep using_history 0000028c T using_history Cheers, Patrick
Patrick Welche writes: > > AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE), > > AC_CHECK_LIB(history, main) ) > > .. of course for me it's in libedit: > > % nm -g /usr/lib/libedit.a | grep using_history > 0000028c T using_history Is libedit readline compatible now? -- Peter Eisentraut Sernanders väg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden
Erich writes: > configure:4073: checking for readline/history.h > configure:4083: gcc -E conftest.c >/dev/null 2>conftest.out > configure:4079: readline/history.h: No such file or directory > configure: failed program was: > #line 4078 "configure" > #include "confdefs.h" > #include <readline/history.h> > configure:4113: checking for readline/readline.h > configure:4123: gcc -E conftest.c >/dev/null 2>conftest.out Shot in the dark: you have some other readline'ish library (libedit?) installed somewhere (/usr/{lib,include}?), which configure picks up here. But that library only provides a readline/readline.h header, no history.h. If so, reconfigure --with-includes=/usr/local/include --with-libraries=/usr/local/lib. > I have a stupid ./configure question: Whenever I compile something, I > never want to have -g as a CC option. How do I tell configure not to > use -g as a CC option? I only want -O2. Usually I go through and > edit Makefiles by hand after configure is done, but that's annoying. If the package respects the environment (which PostgreSQL doesn't, unfortunately) then CFLAGS=-O2 ./configure should work. In PostgreSQL we don't put any -g into CFLAGS by default. If the package uses Automake then you can also do `make install-strip' to remove the debugging symbols at install time. -- Peter Eisentraut Sernanders väg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden
On Fri, Jul 14, 2000 at 12:33:20AM +0200, Peter Eisentraut wrote: > Patrick Welche writes: > > > .. of course for me it's in libedit: > > > > % nm -g /usr/lib/libedit.a | grep using_history > > 0000028c T using_history > > Is libedit readline compatible now? On a NetBSD-1.5B/i386 box, according to editline(3): HISTORY The editline library first appeared in 4.4BSD. CC_REDISPLAY appeared in NetBSD 1.3. CC_REFRESH_BEEP, EL_EDITMODE and the readline emulation ap- peared in NetBSD 1.4. EL_RPROMPT appeared in NetBSD 1.5. AUTHORS The editline library was written by Christos Zoulas. Luke Mewburn wrote this manual and implemented CC_REDISPLAY, CC_REFRESH_BEEP, EL_EDITMODE, and EL_RPROMPT. Jaromir Dolecek implemented the readline emulation. So I suspect the answer is "yes"? Cheers, Patrick
Patrick Welche writes: > > Is libedit readline compatible now? > So I suspect the answer is "yes"? I guess it would be nice if ???BSD users could use their libedit instead of GNU readline if they wanted. The problem is that readline is often not even compatible to itself, so I'm not sure how feasible this would be. -- Peter Eisentraut Sernanders väg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden