Re: libpq analog of \c

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: libpq analog of \c
Date: 2026-10-05 15:55:15
Message-ID: CA+FnnTy8_TPOtyuDSHz7r9ukW4KZPiZEjyBPfY0Y4Ds9VN+H8A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thx.

On Mon, Oct 5, 2026 at 8:12 AM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 10/5/26 7:57 AM, Igor Korot wrote:
> > Hi,
> >
> >
> >
> > On Sun, Oct 4, 2026, 11:35 PM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at
> > <mailto:laurenz(dot)albe(at)cybertec(dot)at>> wrote:
> >
> > On Sun, 2026-10-04 at 23:09 -0700, Igor Korot wrote:
> > > What do issue in the libpq interface to
> > > select the current database?
> >
> > You cannot select the current database. A database connection
> remains
> > connected to the same database for the entire time of the connection.
> > You'll have to do what psql does: connect to the second database, and
> > if that succeeds, disconnect from the first one.
> >
> >
> > Where do I look for that code?
>
> https://github.com/postgres/postgres/blob/master/src/bin/psql/command.c
>
> As a starting point, section beginning with:
>
> /*
> * \c or \connect -- connect to database using the specified parameters.
> *
> * \c [-reuse-previous=BOOL] dbname user host port
>
> ...
> >
> > Thank you.
> >
> >
> > Yours,
> > Laurenz Albe
> >
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Juan Rodrigo Alejandro Burgos Mella 2026-10-05 20:09:02 Re: libpq analog of \c
Previous Message Adrian Klaver 2026-10-05 15:12:01 Re: libpq analog of \c