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?
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.
------------- [archiver (db)] connection to database "" failed: missing "=" after "weird" in connection info string -------------
It makes sense that the “=” would be interpreted as a special character in pg_dump when there is no --dbname parameter. But the docs say that --dbname is for a database name; there is no mention of any kind of parsing otherwise. Should it not work that way? What purpose is served by passing configuration parameters in the database name?
At this point "purpose" doesn't really enter into it. That is how it was decided things would work and we have to live with it. As your particular situation makes perfectly even if we were to design a better API it wouldn't apply retroactively. So while fixes for found issues in the current architecture are welcomed there is likely zero interest in improving an architecture that while probably imperfect is at least functional.
This does work with 9.4 when I use the “postgres:///…” syntax; however, as we’re stuck supporting older PgSQLs for the time being (*sigh* even back to 8.1), and as PGDATABASE doesn’t work with pg_restore, are we left with having to prohibit “=” in database names?
pg_restore --dbname="dbname=crazy=db=name" [...] likely will work but I cannot quickly test it ATM.