Re: [HACKERS] psql 'none' as a HISTFILE special case

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org, "Martin Atukunda" <matlads(at)gmail(dot)com>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "Bruce Momjian" <bruce(at)momjian(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] psql 'none' as a HISTFILE special case
Date: 2006-08-25 16:28:16
Message-ID: 2342.1156523296@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Martin Atukunda" <matlads(at)gmail(dot)com> writes:
> On 8/25/06, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> Please elaborate on "doesn't work".

> without any .psqlrc file I get the following error when quitting a psql session:
> could not save history to file "/Users/matlads/.psql_history": Invalid argument

That is fixed in CVS HEAD. The current coding looks like:

/*
* return value of write_history is not standardized across GNU
* readline and libedit. Therefore, check for errno becoming set
* to see if the write failed.
*/
errno = 0;
(void) write_history(fname);
if (errno == 0)
return true;

psql_error("could not save history to file \"%s\": %s\n",
fname, strerror(errno));

> When I set HISTFILE to /dev/null I get the following:
> could not save history to file "/dev/null": Operation not permitted

Hm. ktrace shows this happening:

23279 psql CALL open(0x302d70,0x601,0x1b6)
23279 psql NAMI "/dev/null"
23279 psql RET open 3
23279 psql CALL fchmod(0x3,0x180)
23279 psql RET fchmod -1 errno 1 Operation not permitted
23279 psql CALL close(0x3)
23279 psql RET close 0
23279 psql CALL write(0x2,0xbffff180,0x44)
23279 psql GIO fd 2 wrote 68 bytes
"could not save history to file "/dev/null": Operation not permitted
"
23279 psql RET write 68/0x44
23279 psql CALL exit(0)

There's probably no way to get Apple's libedit to not try the fchmod,
so what do we want to do here? Maybe special-case the string
"/dev/null"?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2006-08-25 16:31:55 Re: Replication
Previous Message Alvaro Herrera 2006-08-25 16:16:33 [Open Item] Re: Autovacuum on by default?

Browse pgsql-patches by date

  From Date Subject
Next Message Martin Atukunda 2006-08-25 17:20:34 Re: [HACKERS] psql 'none' as a HISTFILE special case
Previous Message Martin Atukunda 2006-08-25 16:01:38 Re: [HACKERS] psql 'none' as a HISTFILE special case