Re: psql prompt

Started by Bruce Momjianabout 26 years ago3 messagespatches
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Not sure what to do with this patch. It appears most of it was already
applied.

On Thu, 9 Mar 2000, Bruce Momjian wrote:

Karel, can you submit a new patch to clean up these new items, rather
than just an entire new patch.

Here is a new patch (this patch remove my old code from psql.)
Bruce, will better if Peter check this patch first. He is really
pedantic :-) But I merit punishment...

1) updates the documentation and the comment on top of the function

Yes.

2) keeps the correct semantics of %m vs %M

Yes. My code in this patch is corrent for %m (hello) %M (hello.domain.xx).
But your code is not correct. See TCP/IP connection:

$ ./psql abil -h bootes -U zakkr

abil=# \set PROMPT1 %M:%/%#%32 <-- without a domainname
bootes:abil# \set PROMPT1 %m:%/%#%32
bootes:abil#

You use for prompt PQhost(), but in PGconn struct is (probably) save
hostname from psql's argv[]. But it is not always real and full hostname
(with domainname) - it can be a name from /etc/hosts. A solution is use
gethostbyaddr( conn->raddr ) instead simple PQhost().

But it is really cosmetic option. We have propably more interesting a work
(pg_acl ?) :-)

3) is portable to Windows (you can ifdef it out, since there are no domain
sockets on Windows)

Sorry. It correct now.

4) Uses gethostname. That's more portable.

I used gethostname() and gethostbyname() (for full domain name (%M)).

Well, Peter is all in this patch correct?

Karel

Content-Description:

[ application/x-gzip is not supported, skipping... ]

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Attachments:

/bjm/3text/plainDownload+81-38
#2Karel Zak
zakkr@zf.jcu.cz
In reply to: Bruce Momjian (#1)

On Fri, 9 Jun 2000, Bruce Momjian wrote:

Not sure what to do with this patch. It appears most of it was already
applied.

Yes it is already in 7.0. And what do it? It try set corrent
hostname to psql prompt without differention between TCP or UNIX
socket connection. Realy cool feature :-)

Karel

#3Bruce Momjian
bruce@momjian.us
In reply to: Karel Zak (#2)

Sounds good.

On Fri, 9 Jun 2000, Bruce Momjian wrote:

Not sure what to do with this patch. It appears most of it was already
applied.

Yes it is already in 7.0. And what do it? It try set corrent
hostname to psql prompt without differention between TCP or UNIX
socket connection. Realy cool feature :-)

Karel

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026