psql \s not working - OS X

Lists: pgsql-bugspgsql-general
From: Joel Jacobson <joel(at)gluefinance(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: psql \s not working - OS X
Date: 2011-06-15 07:03:58
Message-ID: BANLkTikehhEPdKESpbrqo=KMmSS71QeDOQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-general

I'm trying the new 9.1b2 release and got a weird problem with the \s
command to show the latest history, for some reason it's trying to
write to /dev/tty instead of printing out to stdout:

Joel-Jacobsons-MacBook-Pro:~ joel$ uname -a
Darwin Joel-Jacobsons-MacBook-Pro.local 10.7.4 Darwin Kernel Version
10.7.4: Mon Apr 18 21:24:17 PDT 2011;
root:xnu-1504.14.12~3/RELEASE_X86_64 x86_64
Joel-Jacobsons-MacBook-Pro:~ joel$ export
declare -x Apple_PubSub_Socket_Render="/tmp/launch-pOTElL/Render"
declare -x COMMAND_MODE="unix2003"
declare -x DISPLAY="/tmp/launch-QNeAJR/org.x:0"
declare -x HOME="/Users/joel"
declare -x LC_CTYPE="UTF-8"
declare -x LOGNAME="joel"
declare -x OLDPWD="/Users/joel/Downloads/postgresql-9.1beta2"
declare -x PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/opt/local/bin:/usr/X11/bin"
declare -x PWD="/Users/joel"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_AUTH_SOCK="/tmp/launch-ejCA6e/Listeners"
declare -x TERM="xterm-color"
declare -x TERM_PROGRAM="Apple_Terminal"
declare -x TERM_PROGRAM_VERSION="273.1"
declare -x TMPDIR="/var/folders/FZ/FZOPIjkcF2GR0xFiNEkxME+++TI/-Tmp-/"
declare -x USER="joel"
declare -x __CF_USER_TEXT_ENCODING="0x1F5:0:0"
Joel-Jacobsons-MacBook-Pro:~ joel$ /Library/PostgreSQL/9.1b2/bin/psql glue
psql (9.1beta2)
Type "help" for help.

glue=# SELECT version();

version
-------------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.1beta2 on x86_64-apple-darwin10.7.4, compiled by
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot
3), 64-bit
(1 row)

glue=# \s
could not save history to file "/dev/tty": Operation not permitted

glue=#


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joel Jacobson <joel(at)gluefinance(dot)com>
Cc: pgsql-bugs(at)postgreSQL(dot)org
Subject: Re: [GENERAL] psql \s not working - OS X
Date: 2011-06-15 15:16:35
Message-ID: 28664.1308150995@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-general

Joel Jacobson <joel(at)gluefinance(dot)com> writes:
> I'm trying the new 9.1b2 release and got a weird problem with the \s
> command to show the latest history, for some reason it's trying to
> write to /dev/tty instead of printing out to stdout:

> glue=# \s
> could not save history to file "/dev/tty": Operation not permitted

Yeah, it's always done that. libedit thinks it should do chmod()
on the target file, which while not inherently unreasonable is
guaranteed to spit up on /dev/tty.

Another problem with implementing \s-to-display as save-to-/dev/tty
is that if something did come out, it would be in libedit's rather ugly
encoded format. libreadline happens to save the history file without
any decoration, but it's improper of us to depend on that.

We really ought to get rid of that implementation entirely and have
a separate code path for \s-to-display, which for extra credit could
go through the pager.

regards, tom lane