Re: pg_restore WAS Re: BUG #13702: pg_dump interprets “=” in a db name incorrectly - Mailing list pgsql-bugs

From Felipe Gasper
Subject Re: pg_restore WAS Re: BUG #13702: pg_dump interprets “=” in a db name incorrectly
Date
Msg-id 562A8DA8.3090309@felipegasper.com
Whole thread Raw
In response to Re: pg_restore WAS Re: [BUGS] BUG #13702: pg_dump interprets “=” in a db name incorrectly  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
On 23 Oct 2015 2:14 PM, David G. Johnston wrote:
> On Fri, Oct 23, 2015 at 2:54 PM, Felipe Gasper <felipe@felipegasper.com
> <mailto:felipe@felipegasper.com>>wrote:
>
>     On 23 Oct 2015 1:33 PM, David G. Johnston wrote:
>
>         On Fri, Oct 23, 2015 at 2:20 PM, Felipe Gasper
>         <felipe@felipegasper.com <mailto:felipe@felipegasper.com>
>         <mailto:felipe@felipegasper.com
>         <mailto:felipe@felipegasper.com>>>wrote:
>
>
>
>         Again, the "--dbname" argument can either be an actual database
>         name or
>         a "connection info" object.
>
>
>     But the documentation doesn’t say that; it only says that it’s the
>     name of the database. Should the documentation be updated, then?
>
>           In the later case the "=" has a special
>         meaning.  If your database has an "=" in its name then it seems
>         like you
>         have to use the "connection info" definition form.  Note I
>         haven't dug
>         into this with respect to pg_restore but that is the findings
>         from the
>         brief psql test I performed.
>
>
>     Is “connection info” an option with pg_restore, though, which
>     mandates a --dbname argument?
>
>
> ​
> http://www.postgresql.org/docs/9.4/interactive/libpq-connect.html#LIBPQ-CONNECT-DBNAME
> ​
> dbname
> The database name. Defaults to be the same as the user name. In certain
> contexts, the value is checked for extended formats; see Section 31.1.1
> for more details on those.
>
> ​31.1.1
> http://www.postgresql.org/docs/9.4/interactive/libpq-connect.html#LIBPQ-CONNSTRING
> ​
> ​See "dbname" in particular
>
> So it is documented.​  Suggestions and patches welcomed if you think it
> should be covered differently.

Ah, ok.

The reason why I didn’t find this myself was that there’s nothing that
leads me from the pg_restore docs’ description of the --dbname parameter
to the sections you’ve mentioned above.

Maybe that’s the thing, then--would it work to add a link to describe
how pg_restore parses the argument to “--dbname”? A usage example, too,
perhaps, to show how any valid DB name that the PostgreSQL server
recognizes can be fed into pg_restore, pg_dump, etc.?

>
> ​pg_restore --dbname="dbname=crazy=db=name" [...] likely will work but I
> cannot quickly test it ATM.
>

Hooray! At least in 9.0.18, if I quote the DB name as conninfo string, I
can indeed restore to a DB with spaces, equals, etc. in its name.

Now to try it in 8.1. If it doesn’t work there, we’ll probably just
forbid “=” in DB names and call it a day.

Thank you for your responses. I hope I’ve not been untoward in any of this

-FG



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: pg_restore WAS Re: [BUGS] BUG #13702: pg_dump interprets “=” in a db name incorrectly
Next
From: yozh.ne@gmail.com
Date:
Subject: BUG #13708: strange behaviour instead of syntax error