Kim Christensen wrote:
> * Jorge Cardona <[EMAIL PROTECTED]> [2007-01-29 23:48:52 -0500]:
> 
>> Hi.
>> I got a question about this parameter, the spamassassin documentation
>> tells this:
>>
>> 1) Current default query:
>>    SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_
>> OR username = '@GLOBAL' ORDER BY username ASC
>>
>> 2) Use global and then domain level defaults:
>>    SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_
>> OR username = '@GLOBAL' OR username = '@~'||_DOMAIN_ ORDER BY username
>> ASC
>>
>> 3) Maybe global prefs should override user prefs:
>>    SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_
>> OR username = '@GLOBAL' ORDER BY username DESC
>>
>> In 1) and 3) is possible that the query return a table with 2 users
>> ,@GLOBAL, and the user that call spamassassin, what i understand it's
>> that SA only use the preferences for the first user , thats why in 3)
>> the global overrride the user prefs ("ORDER BY username DESC").
>>
>> What i can't understand is whats do the 2) query, and also his
>> description, "Use global and then domain level defaults" .
>> Spamassassin use all the prefs from the @GLOBAL and work with it, and
>> after that use the Domains prefs and wort again, thats what its does?
>> or take the @GLOBAL prefs, and then override the prefs with the
>> Domains prefs.?
>>
>> Please, can anyone explain to me this?
> 
> As Michael said, your query will simply return ALL rows matching your
> control statements. You need to limit the query to return the first
> matching row, by simply adding "LIMIT 1" to the end of the query.
> 
> SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_ \
>   OR username = '@GLOBAL' OR username = '@~'||_DOMAIN_ \
>   ORDER BY username ASC LIMIT 1
> 

You DON'T want to do this.

If you did that then you could only have 1 config row.

The given examples work well for most use cases.

Michael


> I guess you could call this method ghetto-XOR :-)
> 
> This would return a row for the matching username, fall back to the
> global user, and last fall back to the default domain settings.
> 
> But why would you want the global user to have precedence over the
> domain specific settings for the requested user? My tip is to have the
> following hierarchical order:
> 
>       1: User specific settings
>       2: Domain specific settings (if user settings are non-existant)
>       3: Global settings (if neither user or domain settings exist)
> 
> 
> Best of luck

Reply via email to