Private Methods


Mail::SpamAssassin::BayesStore::PgSQL − PostgreSQL Specific Bayesian Storage Module Implementation



This module implements a PostgreSQL specific bayesian storage module.

It subclasses Mail::SpamAssassin::BayesStore::SQL and overrides any methods which makes SQL calls involving the token column. Since PostgreSQL uses BYTEA for the token column type you must make sure that the DBD driver does the proper quoting. You can accomplish this by binding the token column to a specific type.


public instance (Integer, Integer,
Integer, Integer) token_expiration(\% $opts,
Integer $newdelta,
@ @vars)

Description: This method performs the database specific expiration of tokens based on the passed in $newdelta and @vars.

public (Boolean) seen_put (string $msgid, char $flag)

Description: This method records $msgid as the type given by $flag. $flag is one of two values ’s’ for spam and ’h’ for ham.

public instance (Boolean) seen_delete (string $msgid)

Description: This method removes $msgid from the database.

public instance (Boolean) set_last_expire (Integer $time)

Description: This method sets the last expire time.

public instance (String $time) set_running_expire_tok ()

Description: This method sets the time that an expire starts running.

public instance (Boolean) remove_running_expire_tok ()

Description: This method removes the row in the database that indicates that and expire is currently running.

public instance (Integer, Integer, Integer) tok_get (String $token)

Description: This method retrieves a specificed token ($token) from the database and returns it’s spam_count, ham_count and last access time.

public instance (\@) tok_get (@ $tokens)

Description: This method retrieves the specified tokens ($tokens) from storage and returns an array ref of arrays spam count, ham acount and last access time.

public instance (Boolean) nspam_nham_change (Integer $num_spam,
Integer $num_ham)

Description: This method updates the number of spam and the number of ham in the database.

public instance (Boolean) tok_touch (String $token,
String $atime)

Description: This method updates the given tokens ($token) atime.

The assumption is that the token already exists in the database.

public instance (Boolean) tok_touch (\@ $tokens
String $atime)

Description: This method does a mass update of the given list of tokens $tokens, if the existing token atime is < $atime.

The assumption is that the tokens already exist in the database.

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)

public instance (Boolean) cleanup ()

Description: This method perfoms any cleanup necessary before moving onto the next operation.

public instance (Boolean) clear_database ()

Description: This method deletes all records for a particular user.

Callers should be aware that any errors returned by this method could causes the database to be inconsistent for the given user.

Private Methods

private instance (Boolean) _connect_db ()

Description: This method connects to the SQL database.

private instance (Boolean) _put_token (string $token,
integer $spam_count,

integer $ham_count, string $atime)

Description: This method performs the work of either inserting or updating a token in the database.

private instance (Boolean) _put_tokens (\% $token,
integer $spam_count,

integer $ham_count, string $atime)

Description: This method performs the work of either inserting or updating tokens in the database.

private instance (String) _token_select_string

Description: This method returns the string to be used in SELECT statements to represent the token column.


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.