Re: [Exim] PostgreSQL & Aliassing Again

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Steve Haslam
Datum:  
To: exim-users
Betreff: Re: [Exim] PostgreSQL & Aliassing Again
On Wed, Aug 28, 2002 at 03:36:06PM +0100, Mark McRitchie wrote:
> Now, I'm not 100% convinced that this syntax will work (I use MySQL) but:
>
> if you put an entry in your exim_user_aliases with the PostgreSQL wildcard
> character in it (% under MySQL, not sure about PostgreSQL) as the localpart
> eg
>  |  id | localpart |     destination      |    owner
>  | ----+-----------+----------------------+-------------
>  |  24 | %         | ssmeenk@??? | domain.tld

>
> and then if you use the 'LIKE' operator instead of '=' in your where clause,
> but reverse the bits so that instead of matching the DB against the
> ${local_part} your matching the opposite way round:
>
> SELECT destination FROM exim_user_aliases WHERE
> lower('${quote_pgsql:$local_part}') LIKE lower(localpart) = AND lower(owner)
> = lower('${quote_pgsql:$domain}'


Yuk. It works on Oracle too, although I personally think it's nasty in
concept. Another possibility is:
(note that I've removed lower() calls and $quote_.. clauses for clarity)

SELECT destination FROM user_aliases
WHERE localpart IN ('$local_part', '%') AND domain = '$domain'
AND rownum <= 1

which does two unique scans rather than a range scan. If you have enough
entries to justify using an index at all, mind you :}

SRH
--
Steve Haslam      Reading, UK                           araqnid@???
Debian GNU/Linux Maintainer                               araqnid@???
but I won't admit to needing you
I'll never say that's true, not to you                  [sister machine gun]