On Mon Sep 16 05:27:35 2013, MICHIELB wrote:
Show quoted text> On Wed Aug 31 11:41:43 2011, roblang wrote:
> > $ perl -MDBI -e 'DBI->connect("DBI:mysql:database=foobar;host=[::1]",
> > "", "")'
> > DBI connect('database=foobar;host=[::1]','',...) failed: Unknown
> > MySQL
> > server host '[' (2) at -e line 1
> > $
> >
> > This is because the colon is interpreted as a separator in the DSN
> > string.
>
> While this is true, if I do not use the square brackets:
>
> $ perl -MDBI -e 'DBI->connect("DBI:mysql:database=foobar;host=::1","",
> "")'
>
> I can connect without problems.
>
> This is consistent with how DBD::Pg treats connection strings; with
> the quare brackets it does not work, without them it just works.
>
> If there would be some compelling reason to insist on having the
> possibility to use square brackets, please let me know.
> --
> Mike
I've found that:
perl -MDBI -e 'DBI->connect("DBI:mysql:database=foobar;host=::1","", "")'
works only as an edge case. I.e., the _OdbcParse function interprets ::1 as an empty host value. This works as well:
perl -MDBI -e 'DBI->connect("DBI:mysql:database=foobar;host=;","", "")'
If I supply a whole IPv6 address:
perl -MDBI -e 'DBI->connect("DBI:mysql:database=foobar;host= 2620:0:28a0:2107:2718::3","", "")'
Then I get an error:
failed: Can't connect to MySQL server on '2620' (107) at -e line 1
The regular expression is only allowing the first segment of the IPv6 address to appear due to the use of colons as separators.