Lists: | pgsql-hackers |
---|
From: | "Erik Rijkers" <er(at)xs4all(dot)nl> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | pg_restore ignores PGDATABASE |
Date: | 2012-02-18 16:58:19 |
Message-ID: | 71e857315a4f4cdeb903820c1b34a572.squirrel@webmail.xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
pg_restore ignores environment variable PGDATABASE.
Is this intentional? (perhaps because of the risk of restoring into the wrong db?)
I would prefer if it would honor the PGDATABASE variable, but if it does ignore it intentionally,
the following (from 9.2devel docs) is obviously incorrect:
"This utility, like most other PostgreSQL utilities, also uses the environment variables supported
by libpq (see Section 31.13)."
I could look into fixing one (binary) or the other (docs), but what /is/ the preferred behavior?
thanks,
Erik Rijkers
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Erik Rijkers <er(at)xs4all(dot)nl> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_restore ignores PGDATABASE |
Date: | 2012-02-19 05:27:59 |
Message-ID: | CA+TgmoZ1kyWcpxdLHQhaNM4wni5rKzNO4abU8YYxr80r8oKLig@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sat, Feb 18, 2012 at 11:58 AM, Erik Rijkers <er(at)xs4all(dot)nl> wrote:
> pg_restore ignores environment variable PGDATABASE.
What exactly do you mean by "ignores"? pg_restore prints results to
standard output unless a database name is specified. AFAIK, there's
no syntax to say "I want a direct-to-database restore to whatever you
think the default database is".
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From: | "Erik Rijkers" <er(at)xs4all(dot)nl> |
---|---|
To: | "Robert Haas" <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_restore ignores PGDATABASE |
Date: | 2012-02-19 06:18:56 |
Message-ID: | ccdc5f622952d885586a396fa133aa6d.squirrel@webmail.xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sun, February 19, 2012 06:27, Robert Haas wrote:
> On Sat, Feb 18, 2012 at 11:58 AM, Erik Rijkers <er(at)xs4all(dot)nl> wrote:
>> pg_restore ignores environment variable PGDATABASE.
>
> What exactly do you mean by "ignores"? pg_restore prints results to
> standard output unless a database name is specified. AFAIK, there's
> no syntax to say "I want a direct-to-database restore to whatever you
> think the default database is".
That's right, and that seems contradictory with:
"This utility [pg_restore], like most other PostgreSQL utilities, also uses the environment
variables supported by libpq (see Section 31.13)."
as pg_restore does 'ignore' (for want of a better word) PGDATABASE.
But I think I can conclude from your reply that that behaviour is indeed intentional.
thanks,
Erik Rijkers
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Erik Rijkers <er(at)xs4all(dot)nl> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_restore ignores PGDATABASE |
Date: | 2012-02-19 13:02:15 |
Message-ID: | CA+TgmoZybB5k7J01LeTSHX9bO2R+52mBwU_SudQRpm-P3SQu_g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sun, Feb 19, 2012 at 1:18 AM, Erik Rijkers <er(at)xs4all(dot)nl> wrote:
> On Sun, February 19, 2012 06:27, Robert Haas wrote:
>> On Sat, Feb 18, 2012 at 11:58 AM, Erik Rijkers <er(at)xs4all(dot)nl> wrote:
>>> pg_restore ignores environment variable PGDATABASE.
>>
>> What exactly do you mean by "ignores"? pg_restore prints results to
>> standard output unless a database name is specified. AFAIK, there's
>> no syntax to say "I want a direct-to-database restore to whatever you
>> think the default database is".
>
> That's right, and that seems contradictory with:
>
> "This utility [pg_restore], like most other PostgreSQL utilities, also uses the environment
> variables supported by libpq (see Section 31.13)."
>
> as pg_restore does 'ignore' (for want of a better word) PGDATABASE.
>
> But I think I can conclude from your reply that that behaviour is indeed intentional.
It is, because we want there to be a way of converting a custom or tar
format archive back to text. I think that probably works out for the
best anyway, since pg_restore is a sufficiently dangerous operation
that you want to be darn sure you're not doing it on the wrong
database. dropdb also requires a database name, while createdb does
not, for similar reasons...
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Erik Rijkers <er(at)xs4all(dot)nl>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_restore ignores PGDATABASE |
Date: | 2012-02-19 15:25:55 |
Message-ID: | 4F411483.6080207@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 02/19/2012 08:02 AM, Robert Haas wrote:
> On Sun, Feb 19, 2012 at 1:18 AM, Erik Rijkers<er(at)xs4all(dot)nl> wrote:
>> On Sun, February 19, 2012 06:27, Robert Haas wrote:
>>> On Sat, Feb 18, 2012 at 11:58 AM, Erik Rijkers<er(at)xs4all(dot)nl> wrote:
>>>> pg_restore ignores environment variable PGDATABASE.
>>> What exactly do you mean by "ignores"? pg_restore prints results to
>>> standard output unless a database name is specified. AFAIK, there's
>>> no syntax to say "I want a direct-to-database restore to whatever you
>>> think the default database is".
>> That's right, and that seems contradictory with:
>>
>> "This utility [pg_restore], like most other PostgreSQL utilities, also uses the environment
>> variables supported by libpq (see Section 31.13)."
>>
>> as pg_restore does 'ignore' (for want of a better word) PGDATABASE.
>>
>> But I think I can conclude from your reply that that behaviour is indeed intentional.
> It is, because we want there to be a way of converting a custom or tar
> format archive back to text. I think that probably works out for the
> best anyway, since pg_restore is a sufficiently dangerous operation
> that you want to be darn sure you're not doing it on the wrong
> database. dropdb also requires a database name, while createdb does
> not, for similar reasons...
Right, I think we probably need to adjust the docs slightly to match
this reality.
cheers
andrew
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_restore ignores PGDATABASE |
Date: | 2012-08-27 19:27:19 |
Message-ID: | 20120827192719.GU11088@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sun, Feb 19, 2012 at 10:25:55AM -0500, Andrew Dunstan wrote:
>
>
> On 02/19/2012 08:02 AM, Robert Haas wrote:
> >On Sun, Feb 19, 2012 at 1:18 AM, Erik Rijkers<er(at)xs4all(dot)nl> wrote:
> >>On Sun, February 19, 2012 06:27, Robert Haas wrote:
> >>>On Sat, Feb 18, 2012 at 11:58 AM, Erik Rijkers<er(at)xs4all(dot)nl> wrote:
> >>>>pg_restore ignores environment variable PGDATABASE.
> >>>What exactly do you mean by "ignores"? pg_restore prints results to
> >>>standard output unless a database name is specified. AFAIK, there's
> >>>no syntax to say "I want a direct-to-database restore to whatever you
> >>>think the default database is".
> >>That's right, and that seems contradictory with:
> >>
> >>"This utility [pg_restore], like most other PostgreSQL utilities, also uses the environment
> >>variables supported by libpq (see Section 31.13)."
> >>
> >>as pg_restore does 'ignore' (for want of a better word) PGDATABASE.
> >>
> >>But I think I can conclude from your reply that that behaviour is indeed intentional.
> >It is, because we want there to be a way of converting a custom or tar
> >format archive back to text. I think that probably works out for the
> >best anyway, since pg_restore is a sufficiently dangerous operation
> >that you want to be darn sure you're not doing it on the wrong
> >database. dropdb also requires a database name, while createdb does
> >not, for similar reasons...
>
> Right, I think we probably need to adjust the docs slightly to match
> this reality.
Done, with the attached patch.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachment | Content-Type | Size |
---|---|---|
env.diff | text/x-diff | 813 bytes |