Re: [Dovecot] Dovecot SQL user_query

2010-05-03 Thread Timo Sirainen
On 4.5.2010, at 2.00, Alex wrote:

> Is it possible to setup in dovecot-sql.conf  file to run user_query
> twice if its first run didn't yield any values.

You can have two userdbs pointing to two separate dovecot-sql.conf files with 
different user_queries.



Re: [Dovecot] Dovecot SQL user_query

2010-05-03 Thread Gabriel Millerd
yes, something akin to this (assuming they are in the same schema) .
sorry i cannot be more helpful with the query. the secret is the
chance to retrieve multiple results, but limiting those results to one
row and having them priroritized mail > users

user_query =  select mail from (select mail from table where email = ?
union select home as mail from users where email = ?) limit 1



On Mon, May 3, 2010 at 6:00 PM, Alex  wrote:
> Hello folkz,
> Is it possible to setup in dovecot-sql.conf  file to run user_query
> twice if its first run didn't yield any values.
> And likewise don't proceed with the second run if the first user_query
> execution produced the result.
> I have to query two tables which specify there email messages shall be
> delivered via Dovecot deliver LDA
> depending on the incoming email addresses.
>
> Please don't question me about this setup. I inherited this mess from
> the previous Network Admin.
>
> First query should be ran like this:
> user_query = SELECT concat('maildir:/data/mail/',maildir) as mail FROM
> folders WHERE email = '%u'
>
> If the first query doesn't yield any result the second shall be ran like
> this:
> user_query = SELECT maildir as home FROM users WHERE email = '%u'
>
> Please advise if such user_query setup is possible at all.
>
> Thanks in advance,
>
> Alex
>
>
>



-- 
Gabriel Millerd


Re: [Dovecot] Dovecot SQL user_query

2010-05-03 Thread Noel Butler
On Mon, 2010-05-03 at 16:00 -0700, Alex wrote:

> Hello folkz,
> Is it possible to setup in dovecot-sql.conf  file to run user_query
> twice if its first run didn't yield any values.
> And likewise don't proceed with the second run if the first user_query
> execution produced the result.
> I have to query two tables which specify there email messages shall be
> delivered via Dovecot deliver LDA
> depending on the incoming email addresses.
> 


Not using normal dovecot methods, but you could in theory do it with
MySQL manipulation, but that's adding more complexity and can lead to
problems.  This might help
http://dev.mysql.com/doc/refman/5.1/en/if-statement.html  if you must go
down this terrible rocky bumpy country road (yep, I know some managers
just are too scared of change, but most are open to discussion).


> Please don't question me about this setup. I inherited this mess from
> the previous Network Admin.


Alex, maintaining a broken system, is not optimum, why not just fix it
so it's all in one?
Most employers want reliability and stability, if they are the obstacle,
explain to them the nightmare it is now and how easy it is to uniform
everything, if you do it right, they'll likely remember that when it
comes to future contract/salary/wage negotiations.

Cheers



Re: [Dovecot] Dovecot SQL user_query

2010-05-03 Thread Jerry
On Mon, 03 May 2010 16:00:41 -0700
Alex  articulated:

> Hello folkz,
> Is it possible to setup in dovecot-sql.conf  file to run user_query
> twice if its first run didn't yield any values.
> And likewise don't proceed with the second run if the first user_query
> execution produced the result.
> I have to query two tables which specify there email messages shall be
> delivered via Dovecot deliver LDA
> depending on the incoming email addresses.
> 
> Please don't question me about this setup. I inherited this mess from
> the previous Network Admin.
>  
> First query should be ran like this:
> user_query = SELECT concat('maildir:/data/mail/',maildir) as mail FROM
> folders WHERE email = '%u'
> 
> If the first query doesn't yield any result the second shall be ran
> like this:
> user_query = SELECT maildir as home FROM users WHERE email = '%u'
> 
> Please advise if such user_query setup is possible at all.

You probably want to do an "if condition" or similar type query. It has
been ages since I played with MySQL. You might want to read up on the
query syntax.

-- 
Jerry
dovecot.u...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__

Allen's Axiom:
When all else fails, read the instructions.