ToDomain and FromDomain in the Qurantine |
Post Reply |
Author | |
atifghaffar
Senior Member Joined: 31 May 2006 Location: Switzerland Status: Offline Points: 104 |
Post Options
Thanks(0)
Posted: 12 June 2006 at 1:01pm |
Hi all,
I have made a feature request to add FromDomain and ToDomain in the Quarantine database. This makes it easy to make reports based on Domain name and for ISPs to let their customer manage all the Domain's blocked email. The Quarantine database I have is quiet large to search with substrings etc. I also tried the full-text index on mysql but the full text search syntax does not like some characters used in the domain names: such as "-" match (EmailFrom) against "some-domain.com" would match everything where there is "some", ".com" and no "-domain". I have added the ToDomain and FromDomain fields and Indexex in the tblQuarantine and am now periodically filling them up with a perl script. Anyone knows how to achieve this without having the ToDomain, FromDomain fields? |
|
best regards
Atif |
|
sgeorge
Senior Member Joined: 23 August 2005 Status: Offline Points: 178 |
Post Options
Thanks(0)
|
Hi Atif,
It sounds like what would be ideal for you would be to have an indexed view of your tblQuarantine table - one where whole domain names could be derived as new columns based on the EmailFrom and EmailTo columns, but indexed, so that the domains aren't derived every time you pull up the view. This seems easy in SQL 2000: http://www.sqlteam.com/item.asp?ItemID=1015 But it seems that for MySql, like you said, doing a full-text search is the way to go. I found other people out there who were frustrated by MySql interpreting the hyphen character as a word-seperator, and hence, not interpreting your seach for some-domain.com as a single word. But I happened upon this comment responding to someone who was trying to search for "kk-4835": http://archives.neohapsis.com/archives/mysql/2003-q4/2803.ht ml
Good luck! Stephen |
|
LogSat
Admin Group Joined: 25 January 2005 Location: United States Status: Offline Points: 4104 |
Post Options
Thanks(0)
|
Atif,
Another solution can be implemented using a database trigger that will updated those fields for you on the fly each time a new record is added. Please execute the following script on MySQL (We tested it using Query Browser v1.1). It will (1) add the two extra fields to the database, (2) create indexes for them, and (3) create a trigger that will automatically populate those fields every time a new record is entered. ALTER TABLE `spamfilter`.`tblquarantine` ADD COLUMN `ToDomain` VARCHAR(100) AFTER `ServerID`, ADD COLUMN `FromDomain` VARCHAR(100) AFTER `ToDomain`; ALTER TABLE `spamfilter`.`tblquarantine` MODIFY COLUMN `ToDomain` VARCHAR(100), MODIFY COLUMN `FromDomain` VARCHAR(100), ADD INDEX `ToDomain`(`ToDomain`), ADD INDEX `FromDomain`(`FromDomain`); DROP TRIGGER trAddExtraData; DELIMITER // CREATE TRIGGER trAddExtraData BEFORE INSERT ON tblQuarantine FOR EACH ROW BEGIN SET NEW.ToDomain = MID(NEW.EmailTo, POSITION("@" IN NEW.EmailTO)+1, LENGTH(NEW.EMailTo)); SET NEW.FromDomain = MID(NEW.EmailFrom, POSITION("@" IN NEW.EmailFrom)+1, LENGTH(NEW.EMailFrom)); END; // DELIMITER; |
|
sgeorge
Senior Member Joined: 23 August 2005 Status: Offline Points: 178 |
Post Options
Thanks(0)
|
mmm, nice.
|
|
atifghaffar
Senior Member Joined: 31 May 2006 Location: Switzerland Status: Offline Points: 104 |
Post Options
Thanks(0)
|
Thankyou so much. It works great.
|
|
best regards
Atif |
|
ImInAfrica
Groupie Joined: 27 June 2006 Location: FL, USA Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Hi,
I have tried to run the 3 sql statements in Roberto's post. the first 2 run fine and create the fields and the indexes. The third command executes correctly, but then i get this error in the log: 06/29/06 15:56:16:656 -- (7808) Error occurred during TAddToQuarantineThread when accessing the quarantine database: [MySQL][ODBC 3.51 Driver][mysqld-5.0.22-community-nt]Unknown column '@' in 'field list' ( 83 84 85 86 86a 86b 86c 87 88 89 90 91 92 93 94) Can anyone shed some light on this? Thanks Amir |
|
LogSat
Admin Group Joined: 25 January 2005 Location: United States Status: Offline Points: 4104 |
Post Options
Thanks(0)
|
Amir,
Can you access the MySQL's command line interface (use the "mysql" command from a DOS/terminal), and type: use SpamFilter; desc tblQuarantine; show Triggers FROM SpamFilter \G; and let us know what the output is so we can see the table and trigger structures? |
|
ImInAfrica
Groupie Joined: 27 June 2006 Location: FL, USA Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Hi,
Silly me. I never did "use spamfilter;" seems to be working ok now. Thanks. Amir |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
This page was generated in 0.258 seconds.