the default value is &"exim"&.
The full syntax of each item in &%mysql_servers%& is:
.display
-<&'hostname'&>::<&'port'&>(<&'socket name'&>)[<&'option group'&>]/&&&
- <&'database'&>/<&'user'&>/<&'password'&>
+<&'hostspec'&><&'portspec'&>(<&'socket name'&>)[<&'option group'&>]/&&&
+ <&'database'&>/<&'user'&>/<&'password'&>
.endd
Any of the four sub-parts of the first field can be omitted. For normal use on
the local host it can be left blank or set to just &"localhost"&.
+.new
+A &'hostspec'& can be a hostname, an IPv4 address or an IPv6 address.
+For the latter, a &'portspec'& is a dot followed by a port number;
+for the other two a &'portspec'& is a colon followed by a port number.
+.wen
+
+Note that the default list-separator for the list of servers is a colon so
+(unless that is changed) all colons in list items must be doubled.
+
No database need be supplied &-- but if it is absent here, it must be given in
the queries.
.subsection "Special PostgreSQL features" SECID74
+.new
+The &'hostspec'& for PostgreSQL follows the same rules as for MySQL above.
+.wen
+
PostgreSQL lookups can also use Unix domain socket connections to the database.
This is usually faster and costs less CPU time than a TCP/IP connection.
However it can be used only if the mail server runs on the same machine as the
8. ATRN provider support
+ 9. IPv6 address support for mysql and pgsql lookups
+
Version 4.98
------------
1. The dkim_status ACL condition may now be used in data ACLs
*p = 0;
}
- if ((p = Ustrchr(sdata[0], ':')))
- {
- *p++ = 0;
- port = Uatoi(p);
- }
+ /* If there is a colon (":") it could be a port number after an ipv4 or
+ hostname, or could be an ipv6. The latter must have at least two colons,
+ and we look instead for a period ("."). */
+
+ if ((p = Ustrrchr(sdata[0], ':')))
+ if ( Ustrchr(sdata[0], ':') == p /* only one colon */
+ || (p = Ustrrchr(sdata[0], '.')) /* >1 colon, and a period */
+ )
+ {
+ *p++ = 0;
+ port = Uatoi(p);
+ }
if (Ustrchr(sdata[0], '/'))
{
if (!pp)
{
*errmsg = string_sprintf("incomplete pgSQL server data: %s",
- (i == 2)? server : server_copy);
+ i == 2 ? server : server_copy);
*defer_break = TRUE;
return DEFER;
}
else
{
- uschar *p;
- if ((p = Ustrchr(server, ':')))
- {
- *p++ = 0;
- port = p;
- }
+ uschar * p;
+
+ /* If there is a colon (":") it could be a port number after an ipv4 or
+ hostname, or could be an ipv6. The latter must have at least two colons,
+ and we look instead for a period ("."). We assume a hostname never
+ contains a colon. */
+
+ if ((p = Ustrrchr(server, ':')))
+ if ( Ustrchr(server, ':') == p /* only one colon */
+ || (p = Ustrrchr(server, '.')) /* >1 colon, and a period */
+ )
+ {
+ *p++ = 0;
+ port = p;
+ }
if (Ustrchr(server, '/'))
{
${lookup mysql {servers=x:127.0.0.1::PORT_N; select name from them where id='ph10';}}
${lookup mysql {servers=127.0.0.1::PORT_N:x; select name from them where id='ph10';}}
${lookup mysql {servers=127.0.0.1::PORT_N/test/root/:x; select name from them where id='ph10';}}
+oldsyntax ipv6: ${lookup mysql {servers=<!::1.PORT_N/test/root/pass!x; select name from them where id='ph10';}}
+newsyntax ipv6: ${lookup mysql,servers=<!::1.PORT_N/test/root/pass!x {select name from them where id='ph10';}}
${lookup mysql {servers=HOSTIPV4::PORT_N/test/root/:127.0.0.1::PORT_N; select name from them where id='ph10';}}
${lookup mysql {servers=localhost(DIR/mysql/sock)/test/root/pass; select name from them where id='ph10';}}
x
${lookup pgsql {select * from them where name='${quote_pgsql:'stquot}';}}
${lookup pgsql {servers=x:localhost; select name from them where id='ph10';}}
${lookup pgsql {servers=localhost::PORT_N:x; select name from them where id='ph10';}}
-${lookup pgsql {servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';}}
+name: ${lookup pgsql {servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';}}
+ipv4: ${lookup pgsql {servers=127.0.0.1::PORT_N/test/CALLER/:x; select name from them where id='ph10';}}
+oldsyntax ipv6: ${lookup pgsql {servers=<!::1.PORT_N/test/CALLER/!x; select name from them where id='ph10';}}
+newsyntax ipv6: ${lookup pgsql,servers=<!::1.PORT_N/test/CALLER/!x { select name from them where id='ph10';}}
${lookup pgsql {servers=(DIR/pgsql/.s.PGSQL.PORT_N)/test/CALLER/:x; select name from them where id='ph10';}}
x
${lookup pgsql {SELECT name FROM them WHERE id IN ('ph10', 'aaaa');}}
MYSQL using cached connection for 127.0.0.1:PORT_N/test/root
creating new cache entry
lookup yielded: Philip░Hazel
+ search_open: mysql "NULL"
+ cached open
+ search_find: file="NULL"
+ key="servers=<!::1.1223/test/root/pass!x; select name from them where id='ph10';" partial=-1 affix=NULL starflags=0 opts=NULL
+ LRU list:
+ internal_search_find: file="NULL"
+ type=mysql key="servers=<!::1.1223/test/root/pass!x; select name from them where id='ph10';" opts=NULL
+ database lookup required for servers=<!::1.1223/test/root/pass!x; select name from them where id='ph10';
+ MySQL query: "servers=<!::1.1223/test/root/pass!x; select name from them where id='ph10';" opts 'NULL'
+LOG: MAIN
+ Exim configuration error in line 14 of -be stdin:
+ WARNING: obsolete syntax used for lookup
+ MYSQL new connection: host=::1 port=PORT_N socket=NULL database=test user=root
+ creating new cache entry
+ lookup yielded: Philip░Hazel
+ search_open: mysql "NULL"
+ cached open
+ search_find: file="NULL"
+ key="select name from them where id='ph10';" partial=-1 affix=NULL starflags=0 opts="servers=<!::1.1223/test/root/pass!x"
+ LRU list:
+ internal_search_find: file="NULL"
+ type=mysql key="select name from them where id='ph10';" opts="servers=<!::1.1223/test/root/pass!x"
+ database lookup required for select name from them where id='ph10';
+ MySQL query: "select name from them where id='ph10';" opts 'servers=<!::1.1223/test/root/pass!x'
+ MYSQL using cached connection for ::1.1223/test/root
+ creating new cache entry
+ lookup yielded: Philip░Hazel
search_open: mysql "NULL"
cached open
search_find: file="NULL"
database lookup required for servers=ip4.ip4.ip4.ip4::1223/test/root/:127.0.0.1::PORT_N; select name from them where id='ph10';
MySQL query: "servers=ip4.ip4.ip4.ip4::1223/test/root/:127.0.0.1::PORT_N; select name from them where id='ph10';" opts 'NULL'
LOG: MAIN
- Exim configuration error in line 14 of -be stdin:
+ Exim configuration error in line 16 of -be stdin:
WARNING: obsolete syntax used for lookup
MYSQL new connection: host=ip4.ip4.ip4.ip4 port=PORT_N socket=NULL database=test user=root
creating new cache entry
database lookup required for servers=localhost(TESTSUITE/mysql/sock)/test/root/pass; select name from them where id='ph10';
MySQL query: "servers=localhost(TESTSUITE/mysql/sock)/test/root/pass; select name from them where id='ph10';" opts 'NULL'
LOG: MAIN
- Exim configuration error in line 15 of -be stdin:
+ Exim configuration error in line 17 of -be stdin:
WARNING: obsolete syntax used for lookup
MYSQL new connection: host=localhost port=0 socket=TESTSUITE/mysql/sock database=test user=root
creating new cache entry
search_tidyup called
close MYSQL connection: localhost(TESTSUITE/mysql/sock)/test/root
close MYSQL connection: ip4.ip4.ip4.ip4:1223/test/root
+close MYSQL connection: ::1.1223/test/root
close MYSQL connection: 127.0.0.1:PORT_N/test/root
>>>>>>>>>>>>>>>> Exim pid=p1234 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>
01:01:01 p1235 Exim version x.yz uid=CALLER_UID gid=CALLER_GID pid=p1235 D=fff9ffff
PGSQL using cached connection for localhost:PORT_N/test/CALLER
creating new cache entry
lookup yielded: Philip░Hazel
+ search_open: pgsql "NULL"
+ cached open
+ search_find: file="NULL"
+ key="servers=127.0.0.1::PORT_N/test/CALLER/:x; select name from them where id='ph10';" partial=-1 affix=NULL starflags=0 opts=NULL
+ LRU list:
+ internal_search_find: file="NULL"
+ type=pgsql key="servers=127.0.0.1::PORT_N/test/CALLER/:x; select name from them where id='ph10';" opts=NULL
+ database lookup required for servers=127.0.0.1::PORT_N/test/CALLER/:x; select name from them where id='ph10';
+ PostgreSQL query: "servers=127.0.0.1::PORT_N/test/CALLER/:x; select name from them where id='ph10';" opts 'NULL'
+LOG: MAIN
+ Exim configuration error in line 14 of -be stdin:
+ WARNING: obsolete syntax used for lookup
+ PGSQL new connection: host=127.0.0.1 port=PORT_N database=test user=CALLER
+ creating new cache entry
+ lookup yielded: Philip░Hazel
+ search_open: pgsql "NULL"
+ cached open
+ search_find: file="NULL"
+ key="servers=<!::1.1223/test/CALLER/!x; select name from them where id='ph10';" partial=-1 affix=NULL starflags=0 opts=NULL
+ LRU list:
+ internal_search_find: file="NULL"
+ type=pgsql key="servers=<!::1.1223/test/CALLER/!x; select name from them where id='ph10';" opts=NULL
+ database lookup required for servers=<!::1.1223/test/CALLER/!x; select name from them where id='ph10';
+ PostgreSQL query: "servers=<!::1.1223/test/CALLER/!x; select name from them where id='ph10';" opts 'NULL'
+LOG: MAIN
+ Exim configuration error in line 15 of -be stdin:
+ WARNING: obsolete syntax used for lookup
+ PGSQL new connection: host=::1 port=PORT_N database=test user=CALLER
+ creating new cache entry
+ lookup yielded: Philip░Hazel
+ search_open: pgsql "NULL"
+ cached open
+ search_find: file="NULL"
+ key="select name from them where id='ph10';" partial=-1 affix=NULL starflags=0 opts="servers=<!::1.1223/test/CALLER/!x"
+ LRU list:
+ internal_search_find: file="NULL"
+ type=pgsql key="select name from them where id='ph10';" opts="servers=<!::1.1223/test/CALLER/!x"
+ database lookup required for select name from them where id='ph10';
+ PostgreSQL query: "select name from them where id='ph10';" opts 'servers=<!::1.1223/test/CALLER/!x'
+ PGSQL using cached connection for ::1.1223/test/CALLER
+ creating new cache entry
+ lookup yielded: Philip░Hazel
search_open: pgsql "NULL"
cached open
search_find: file="NULL"
database lookup required for servers=(TESTSUITE/pgsql/.s.PGSQL.1223)/test/CALLER/:x; select name from them where id='ph10';
PostgreSQL query: "servers=(TESTSUITE/pgsql/.s.PGSQL.1223)/test/CALLER/:x; select name from them where id='ph10';" opts 'NULL'
LOG: MAIN
- Exim configuration error in line 14 of -be stdin:
+ Exim configuration error in line 17 of -be stdin:
WARNING: obsolete syntax used for lookup
PGSQL new connection: socket=TESTSUITE/pgsql/.s.PGSQL.1223 database=test user=CALLER
creating new cache entry
lookup yielded: 1
search_tidyup called
close PGSQL connection: (TESTSUITE/pgsql/.s.PGSQL.1223)/test/CALLER
+close PGSQL connection: ::1.1223/test/CALLER
+close PGSQL connection: 127.0.0.1:PORT_N/test/CALLER
close PGSQL connection: localhost:PORT_N/test/CALLER
>>>>>>>>>>>>>>>> Exim pid=p1235 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>
Exim version x.yz ....
> Failed: lookup of "servers=x:127.0.0.1::1223; select name from them where id='ph10';" gave DEFER: MySQL server "x" not found in mysql_servers
> Philip Hazel
> Philip Hazel
+> oldsyntax ipv6: Philip Hazel
+> newsyntax ipv6: Philip Hazel
> Philip Hazel
> Philip Hazel
> x
> name='stquot id=quote1
> Failed: lookup of "servers=x:localhost; select name from them where id='ph10';" gave DEFER: PostgreSQL server "x" not found in pgsql_servers
> Philip Hazel
-> Philip Hazel
+> name: Philip Hazel
+> ipv4: Philip Hazel
+> oldsyntax ipv6: Philip Hazel
+> newsyntax ipv6: Philip Hazel
> Philip Hazel
> x
> Philip Hazel