--- Mail/SpamAssassin/BayesStore/SQL.pm.old 2005-10-18 19:28:25.000000000 -0700 +++ Mail/SpamAssassin/BayesStore/SQL.pm 2005-10-24 21:27:06.000000000 -0700 @@ -137,11 +137,15 @@ return 0; } - unless ($self->_initialize_db(0)) { + unless (my $init = $self->_initialize_db(0)) { dbg("bayes: unable to initialize database for ".$self->{_username}." user, aborting!"); $self->untie_db(); return 0; } + elsif ($init == -1) { + dbg("bayes: $self->{_username} has no data in database, aborting!"); + return 0; + } return 1; } @@ -164,6 +168,14 @@ if ($self->{_dbh}) { # already connected, but now it will be writable + if (!$self->{db_writable_p}) { + unless ($self->_initialize_db(1)) { + dbg("bayes: unable to initialize database for ".$self->{_username}." user, aborting!"); + + $self->untie_db(); + return 0; + } + } $self->{db_writable_p} = 1; return 1; } @@ -1770,7 +1782,7 @@ } # Do not create an entry for this user unless we were specifically asked to - return 0 unless ($create_entry_p); + return -1 unless ($create_entry_p); # For now let the database setup the other variables as defaults my $sqlinsert = "INSERT INTO bayes_vars (username) VALUES (?)";