PostgreSQL (DB) lookup interface

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Chris Harris
Fecha:  
A: exim-users
Asunto: PostgreSQL (DB) lookup interface
FYI, I'm currently implimenting some exim lookup types for the (free)
PostgreSQL database program while allow for SQL database queries in
${lookup} bits. Here is an example address-rewriting line that this would
allow:

*@* "${lookup pgsql {select outaddr from accounts where inaddr = '$1@$2'} \
     {$value} fail}" f


(This rewrites the "From:" field of messages with the value from the
"outaddr" column that corresponds to the value of the "inaddr" column that
is equal to the original "From:" field.)

Currently, only ${lookup} support is provided, though I plan to provide a
"pgsql;" interface, so that config file lines similar to
    local_domains = dbm;/local/domain/list
will be possible with my interface.  Basically, my plan is to get an
interface that is as featureful as the nis+ interface.


Although PostgreSQL lookups are probably slower than dbm (or similar)
lookups and though its queries might be more verbose than other sorts of
queries, they do come in very handy when you wish to do something a little
more complicated than usual -- all SQL databases are powerful, and
PostgreSQL is even more powerful and extendable (through
dynamically-loaded C functions) than most. If you'd like more info on
this nifty database program, check out http://www.postgresql.org

If anyone would be interested in trying out the code, I can set up
some patches once I'm satisfied that things are stable.

I should mention that, overall, the source definintely wins as far as
readability is concerned -- particularly when compared to some other
mailers (such as qmail); both the function names and the comments have
been very helpful. At the same time, I think it might be helpful to make
a more standard/documented process for adding lookup types, just as there
is already a standard/documented process for adding transports and
directors. Is there something that would prevent this from being a
reasonable idea?

-Chris