Re: psql patch: new host/port without leaving session

Lists: pgsql-patches
From: David Fetter <david(at)fetter(dot)org>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: psql patch: new host/port without leaving session
Date: 2005-12-14 00:29:43
Message-ID: 20051214002943.GB7463@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Folks,

Please find enclosed a patch that lets you use \c to connect
(optionally) to a new host and port without exiting psql. This
eliminates, IMHO, a surprise in that you can now connect to PostgreSQL
on a differnt machine from the one where you started your session.
This should help people who use psql as an administrative tool.

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 415 235 3778

Remember to vote!

Attachment Content-Type Size
psql_host_port.diff text/plain 10.7 KB

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: David Fetter <david(at)fetter(dot)org>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-02-12 02:54:34
Message-ID: 200602120254.k1C2sYx28934@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

David Fetter wrote:
> Folks,
>
> Please find enclosed a patch that lets you use \c to connect
> (optionally) to a new host and port without exiting psql. This
> eliminates, IMHO, a surprise in that you can now connect to PostgreSQL
> on a differnt machine from the one where you started your session.
> This should help people who use psql as an administrative tool.
>
> Cheers,
> D
> --
> David Fetter david(at)fetter(dot)org http://fetter.org/
> phone: +1 415 235 3778
>
> Remember to vote!

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-03-12 17:59:10
Message-ID: 20060312175910.GC490@alamut
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Hi,

I've written do_connect() and \c handling part from scratch in the
attached patch. Here are some features introduced:

- \c syntax is extended. (See comment lines just above \c stuff.)
- do_connect() AI (like used for prompting password or informing
client about connect attempt's result.) improved.
- Some code clean up.

If you'd agree with the style, I'll add patch for the documentation and
PO files too.

Regards.

P.S. Patch passed regressions tests on CVS tip.

On Dec 13 04:29, David Fetter wrote:
> Please find enclosed a patch that lets you use \c to connect
> (optionally) to a new host and port without exiting psql. This
> eliminates, IMHO, a surprise in that you can now connect to PostgreSQL
> on a differnt machine from the one where you started your session.
> This should help people who use psql as an administrative tool.

Attachment Content-Type Size
psql_connect.0 text/plain 15.0 KB

From: Neil Conway <neilc(at)samurai(dot)com>
To: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-04-02 00:07:23
Message-ID: 1143936443.21012.32.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Sun, 2006-03-12 at 19:59 +0200, Volkan YAZICI wrote:
> I've written do_connect() and \c handling part from scratch in the
> attached patch.

Attached is a revised version of this patch. I rewrote most of the code,
because the existing stuff was in pretty bad style IMHO. I haven't
updated the documentation yet, but I'll do that if no one objects to
this version of the patch.

One question about behavior: in the attached patch, omitting an argument
to \connect or specifying "-" are treated equivalently -- the value for
that parameter from the previous connection is used, otherwise NULL (for
the libpq default). Is this what people want? (One possible complaint is
that once you specify a parameter, you can't get back to the libpq
default without specifying it explicitly.)

-Neil

Attachment Content-Type Size
psql_connect_fix-3.patch text/x-patch 17.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>, pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-04-02 00:46:07
Message-ID: 16410.1143938767@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Neil Conway <neilc(at)samurai(dot)com> writes:
> One question about behavior: in the attached patch, omitting an argument
> to \connect or specifying "-" are treated equivalently -- the value for
> that parameter from the previous connection is used, otherwise NULL (for
> the libpq default). Is this what people want?

Yes, that's the behavior I'd expect. The traditional \c behavior for
the two longstanding options (dbname and username) was exactly that,
no?

regards, tom lane


From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-04-02 11:38:12
Message-ID: 20060402113812.GA8318@alamut
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Apr 01 07:07, Neil Conway wrote:
> One question about behavior: in the attached patch, omitting an argument
> to \connect or specifying "-" are treated equivalently -- the value for
> that parameter from the previous connection is used, otherwise NULL (for
> the libpq default). Is this what people want? (One possible complaint is
> that once you specify a parameter, you can't get back to the libpq
> default without specifying it explicitly.)

Won't it be better if we distinguish between "default" and "current"
value of a parameter with '-' (for the "current") and '+' (for the
"default") characters? For example:

\c + - hst
Connect to "default" database with "current" user on host hst.
(Omitted values can be treated as "current".)

\c + + hst -
Connect to "default" database with "default" user on host hst on
"current" port.

So we'll still have chance to get back to the libpq defaults.

Regards.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
Cc: Neil Conway <neilc(at)samurai(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-04-02 16:37:02
Message-ID: 23653.1143995822@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr> writes:
> On Apr 01 07:07, Neil Conway wrote:
>> One question about behavior: in the attached patch, omitting an argument
>> to \connect or specifying "-" are treated equivalently -- the value for
>> that parameter from the previous connection is used, otherwise NULL (for
>> the libpq default). Is this what people want? (One possible complaint is
>> that once you specify a parameter, you can't get back to the libpq
>> default without specifying it explicitly.)

> Won't it be better if we distinguish between "default" and "current"
> value of a parameter with '-' (for the "current") and '+' (for the
> "default") characters? For example:

That seems like a frammish without sufficient use-case. You can always
quit and restart psql to get back to the defaults.

regards, tom lane


From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Neil Conway <neilc(at)samurai(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-04-02 19:43:29
Message-ID: 20060402194329.GA176@alamut
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Apr 02 12:37, Tom Lane wrote:
> Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr> writes:
> > Won't it be better if we distinguish between "default" and "current"
> > value of a parameter with '-' (for the "current") and '+' (for the
> > "default") characters? For example:
>
> That seems like a frammish without sufficient use-case. You can always
> quit and restart psql to get back to the defaults.

You can always quit and restart psql with new connection parameters.
In this situation, we shouldn't bother with \c too. Don't they share
the same use-case? (If there's any.)

Regards.


From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>, pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-04-02 20:11:08
Message-ID: 1144008668.21012.39.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Sun, 2006-04-02 at 12:37 -0400, Tom Lane wrote:
> That seems like a frammish without sufficient use-case. You can always
> quit and restart psql to get back to the defaults.

Patch applied to HEAD.

If folks want to argue for the ability to instruct psql to use the libpq
default for a parameter, I'm not fundamentally opposed, but that change
can be made subsequently.

-Neil


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>, pgsql-patches(at)postgresql(dot)org
Subject: Re: psql patch: new host/port without leaving session
Date: 2006-04-03 02:02:45
Message-ID: 200604030202.k3322jE11237@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Neil Conway wrote:
> On Sun, 2006-04-02 at 12:37 -0400, Tom Lane wrote:
> > That seems like a frammish without sufficient use-case. You can always
> > quit and restart psql to get back to the defaults.
>
> Patch applied to HEAD.
>
> If folks want to argue for the ability to instruct psql to use the libpq
> default for a parameter, I'm not fundamentally opposed, but that change
> can be made subsequently.

I think what is applied is enough. That +/- syntax was too confusing to
be useful.

--
Bruce Momjian http://candle.pha.pa.us

+ If your life is a hard drive, Christ can be your backup. +