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

2006-08-25 Thread Tom Lane
Martin Atukunda [EMAIL PROTECTED] writes:
 On 8/25/06, Tom Lane [EMAIL PROTECTED] wrote:
 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?

 If this is OK, I can up with a patch that special cases /dev/null as a
 HISTFILE if libedit is found.

I was thinking of basically a one-liner addition to write_history
to skip the whole thing if strcmp(fname, DEVNULL) == 0.  Should be
reasonably inoffensive on anyone's machine.

regards, tom lane

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


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

2006-08-25 Thread Martin Atukunda

On 8/25/06, Tom Lane [EMAIL PROTECTED] wrote:

Martin Atukunda [EMAIL PROTECTED] writes:
 On 8/25/06, Tom Lane [EMAIL PROTECTED] wrote:
 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?

 If this is OK, I can up with a patch that special cases /dev/null as a
 HISTFILE if libedit is found.

I was thinking of basically a one-liner addition to write_history
to skip the whole thing if strcmp(fname, DEVNULL) == 0.  Should be
reasonably inoffensive on anyone's machine.


I guess you meant saveHistory instead of write_history here. :)

something like the attached diff

- Martin -


special_case_DEVNULL.diff
Description: Binary data

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


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

2006-08-25 Thread Peter Eisentraut
Am Freitag, 25. August 2006 17:03 schrieb Martin Atukunda:
 hmm, setting HISTFILE to /dev/null doesn't work on my MacOSX here.

Please elaborate on doesn't work.

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

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


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

2006-08-25 Thread Martin Atukunda

On 8/25/06, Peter Eisentraut [EMAIL PROTECTED] wrote:

Am Freitag, 25. August 2006 17:03 schrieb Martin Atukunda:
 hmm, setting HISTFILE to /dev/null doesn't work on my MacOSX here.

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

When I set HISTFILE to /dev/null I get the following:

could not save history to file /dev/null: Operation not permitted

- Martin -

---(end of broadcast)---
TIP 6: explain analyze is your friend


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

2006-08-25 Thread Tom Lane
Martin Atukunda [EMAIL PROTECTED] writes:
 On 8/25/06, Peter Eisentraut [EMAIL PROTECTED] 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,0xb180,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

---(end of broadcast)---
TIP 6: explain analyze is your friend


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

2006-08-25 Thread Martin Atukunda

On 8/25/06, Tom Lane [EMAIL PROTECTED] wrote:

 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,0xb180,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?


If this is OK, I can up with a patch that special cases /dev/null as a
HISTFILE if libedit is found.

- Martin -

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly