Mail::...::MySQL(3pm)
π Mail::...::MySQL(3pm) π
okay bestie, you found the MySQL brain for SpamAssassin's bayes storage, and it's in the User Contributed Perl Documentation collection. pull up a chair, we're getting into it π
β¨ NAME β¨
Mail::SpamAssassin::BayesStore::MySQL β the MySQL-Specific Bayesian Storage Module Implementation. that's the whole thing. she does one job and she eats π
πΈ DESCRIPTION πΈ
okay so this module is the MySQL-flavored bayesian storage module. it's the girl who speaks MySQL and only MySQL.
β οΈ REAL TALK: she needs you to be running at least version 4.1 of MySQL. if you're on a version of MySQL < 4.1, then several aspects of this module will fail and possibly corrupt your bayes database data. not a vibe. do not do this. π
plus β and this is the slay part β this module will support rollback on error if you're using the InnoDB database table type in MySQL. for more info, please review the instructions in sql/README.bayes. (yes, actually go read it, i'm not kidding π)
this module is also compatible with MariaDB, and DBD::MariaDB can be used instead of the DBD::mysql driver. versatile queen π
π METHODS π
π token_expiration
public instance (Integer, Integer,
Integer, Integer) token_expiration(\% $opts,
Integer $newdelta,
@ @vars)
what she does: this method performs the database specific expiration of tokens, based on the $newdelta and @vars you hand her. bye bye old tokens π
π seen_put
public (Boolean) seen_put (string $msgid, char $flag)
what she does: this method records $msgid as the type given by $flag. and $flag is one of exactly two values, no in-between: 's' for spam and 'h' for ham. pick a lane bestie π¦
π seen_delete
public instance (Boolean) seen_delete (string $msgid)
what she does: this method removes $msgid from the database. gone, deleted, not coming back π
π set_last_expire
public instance (Boolean) set_last_expire (Integer $time)
what she does: this method sets the last expire time. that's it, that's the tweet β¨
π set_running_expire_tok
public instance (String $time) set_running_expire_tok ()
what she does: this method sets the time that an expire starts running. stopwatch started, no pressure β±οΈ
π remove_running_expire_tok
public instance (Boolean) remove_running_expire_tok ()
what she does: this method removes the row in the database that indicates that an expire is currently running. (the original says "that and expire is currently running" but we all know what she meant π )
π tok_get
public instance (Integer, Integer, Integer) tok_get (String $token)
what she does: this method retrieves a specified token ($token) from the database, and returns its spam_count, ham_count and last access time. the full trio, no crumbs left behind π₯
π tok_get_all
public instance (\@) tok_get (@ $tokens)
what she does: this method retrieves the specified tokens ($tokens) from storage, and returns an array ref of arrays β spam count, ham count and last access time. bulk energy, she's efficient π¦
π nspam_nham_change
public instance (Boolean) nspam_nham_change (Integer $num_spam,
Integer $num_ham)
what she does: this method updates the number of spam and the number of ham in the database. keeping score, lowkey obsessed π
π tok_touch
public instance (Boolean) tok_touch (String $token,
String $atime)
what she does: this method updates the given token's ($token) atime.
the assumption is that the token already exists in the database. don't come at her with tokens that aren't there π
π tok_touch_all
public instance (Boolean) tok_touch (\@ $tokens
String $atime)
what she does: this method does a mass update of the given list of tokens $tokens, if the existing token atime is < $atime. conditional queen π
the assumption is that the tokens already exist in the database.
also she wants you to know: we should never be touching more than N_SIGNIFICANT_TOKENS, so we can make some assumptions about how to handle the data (ie. no need to batch like we do in tok_get_all). iykyk π
π cleanup
public instance (Boolean) cleanup ()
what she does: this method performs any cleanup necessary before moving onto the next operation. tidy girl, clear skin, clear mind πΈ
π clear_database
public instance (Boolean) clear_database ()
what she does: this method deletes all records for a particular user. nuking it, respectfully π
β οΈ callers should be aware that any errors returned by this method could cause the database to be inconsistent for the given user. fr fr, proceed with care.
π Private Methods π
these are the backstage girls, the ones doing the actual work while nobody's watching. don't call them directly unless you know what you're doing π«Ά
π _connect_db
private instance (Boolean) _connect_db ()
what she does: this method connects to the SQL database. hi bestie, it's me π
π _initialize_db
private instance (Boolean) _initialize_db ()
what she does: this method will check to see if a user has had their bayes variables initialized. if not, then it will perform this initialization. she checks, then she does. thorough π
π _put_token
private instance (Boolean) _put_token (string $token,
integer $spam_count,
integer $ham_count,
string $atime)
what she does: this method performs the work of either inserting or updating a token in the database. insert-vs-update is giving whatever-the-data-wants energy β¨
π _put_tokens
private instance (Boolean) _put_tokens (\% $tokens,
integer $spam_count,
integer $ham_count,
string $atime)
what she does: this method performs the work of either inserting or updating tokens (plural, we're in bulk mode now) in the database. same job as her sister, bigger guest list π
π _token_select_string
private instance (String) _token_select_string
what she does: this method returns the string to be used in SELECT statements to represent the token column.
the default is to use the RPAD function to pad the token out to 5 characters. no cap, exactly five π
<div align="center">πΈ π¦ β¨ π π β π π π π§ π πΈ</div>
okay that's the whole page bestie, go forth and store your bayes data responsibly π this came out of perl v5.40.1, dated 2026-07-23, and it lives under the name Mail::...::MySQL(3pm) β mwah, periodt π
β¨
π¦ where this page comes from
- ubuntu stonking: spamassassin 4.0.2+svn1935691-1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms