|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: $lookup variable and MySQL tables
From: Mike M (mike
opennix.com)
Date: Thu Dec 02 2004 - 16:30:36 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Magnus Bäck said:
> On Thursday, December 02, 2004 at 22:22 CET,
> Mike M <mike
opennix.com> wrote:
>
> [...]
>
>> For instance, I have written a Perl script that enumerates all valid
>> recipients, forwards, and aliases on the systems and creates a hash
>> file to be used by Postfix via relay_recipient_maps. The script runs
>> from a cron job so that Postfix can be made aware of changes
>> automatically. The problem is the delay between the time the changes
>> are made and the running of the cron job, which runs every two hours.
>> This isn't a big deal, but I'd like to eliminate the delay if
>> possible.
>
> Running the cron job more often is not an alternative, I gather?
That is certainly an alternative. However, I wouldn't want to run it too
often, and no matter how often it was run, there would still be a delay.
This isn't a huge problem I'm trying to solve. Users are mostly
understanding of why the delay exists.
>>
>> When I tested this out on a dev box, I found that vpopmail stores the
>> local part and domain part of accounts in separate fields. As I
>> understand it the value of $lookup when querying relay_recipient_maps is
>> user
domain.tld. Therefore, this will not work with the structure set
>> up
>> by vpopmail.
>
> Sure it will. Construct a query on this form:
>
> SELECT ... FROM ... WHERE CONCAT(user, '
', domain) = '%s'
>
> I don't the query optimizer can do a very good job, though. The
> where_field parameter doesn't have to specify just the name of
> a column; the string is just inserted into the query.. Behold
> dict_mysql.c:
>
> vstring_sprintf(query, "select %s from %s where %s = '%s' %s",
> dict_mysql->name->select_field,
> dict_mysql->name->table,
> dict_mysql->name->where_field,
> name_escaped,
> dict_mysql->name->additional_conditions);
>
*Bangs head on desk* Thank you for clarifying that. I should have looked
at the code myself (assuming I could have found the correct snippet).
That makes queries a whole lot more flexible that I had initially thought.
>> I would need Postfix to split $lookup into something like $user and
>> $domain.
>
> This is *currently* not possible with dict_mysql. This feature is
> present in dict_pgsql, and I think Victor Duckovni is going to merge
> that functionaliy over to dict_mysql. If not, I'd be happy to do it.
>
I didn't even bother to look at pgsql_table(5), or consider PostgreSQL.
Thank you again for bringing something new to light. Is there a technical
reason why this functionality exists for pgsql, but not mysql? Or is it a
"when we get around to it" type of thing? I think this would be very
handy for the MySQL table type.
I appreciate you taking the time to answer me. You have given me a few
alternatives that are likely better than what I was going to explore.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]