[Exim] slightly baffled (postgresql query question)

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Richard Welty
Dátum:  
Címzett: exim-users
Tárgy: [Exim] slightly baffled (postgresql query question)
i'm trying to get something to work, and i'm not making the kind of
progress i'd like.

first, the context:

exim 4.20
postgresql 7.3.2

i have a query which is supposed to lookup up an ip address in a table of
hosts which are allowed to relay through the mail server. for efficieny
reasons [1] i've implemented the query in a pl/pgsql function buried in the
database which is intended to be called like this:

foo=# select test_relay_ip( '205.164.80.5');
test_relay_ip
---------------
t
(1 row)

foo=# select test_relay_ip( '192.94.170.8');
test_relay_ip
---------------
f
(1 row)

foo=# \q

the function returns t if the ip address is found, and false otherwise.

my plan was that it could then be used in a lookup like this:

hostlist relay_hosts                    = pgsql;select test_relay_ip( \
                                                '${quote_pgsql:$sender_host_address}');


however, what i'm seeing is that any return value (t or f) from the query
is being treated by exim as success in the lookup. i'm not quite seeing
what change i need to make to get this to work. anyone got any hints?

thanks,
richard

[1] current postgresql does not cache query plans for ordinary selects, but
it does cache query plans for pl/pgsql functions. since for many lookups,
including, i suspect, these, the query planner actually takes longer than
the query, it makes sense to only take the query planner hit once.
--
Richard Welty                                         rwelty@???
Averill Park Networking                                         518-573-7592
    Java, PHP, PostgreSQL, Unix, Linux, IP Network Engineering, Security