On 01/06/07, Mark Martinec <[EMAIL PROTECTED]> wrote:
>
> Riaan,
>
> > (line 910 in V2.5.1 of amavisd)
> > 'sel_penpals_msgid' =>  # with a nonempty message-id references list
> >   "SELECT msgs.time_num, msgs.mail_id, subject, message_id, rid".
> >   " FROM msgs JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id".
> >   " WHERE sid=? AND content!='V' AND ds='P' AND message_id IN (%m)".
> >     " AND rid!=sid".
> >   " ORDER BY rid=? DESC, msgs.time_num DESC LIMIT 1",
> >
> > That last line, "ORDER BY rid=?"..  a condition inside the order clause?
> > hmm.  Looks wrong to me, but the evidence to the contrary is that nobody
> > has reported sql errors yet!
>
> It is correct as it stands. It is not a condition, it is an expresion.
>
> SELECT ...
>   ORDER BY expression [ ASC | DESC | USING operator ] [, ...]
>
> The rid=? compares the rid from a field with a recipient id
> we have in the message under test, returning true or false.
>
> The ORDER BY rid=? DESC ensures we get an exactly matching
> record first (metching e-mail address as well as a message-id),
> and if there are none than a match by message id suffices.
>
>   Mark
>
>
Ah,  I must be used to a different dialect of SQL.

It seems like the only advantage of that preferential ordering is for the
snmp counter, as the 'rid' return value from that query is not used anywhere
else, and the other 4 return values are all from the msgs table (static for
multiple recipients)..  Unless I'm missing something, I'm happy here.

thanks!

Riaan
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to