From 0615e645c717c318930c773ab21e2ed809beb5dc Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Tue, 16 Oct 2007 21:43:57 +0000 Subject: [PATCH] - fix a MySQL vs. PgSQL problem (True vs. 1) in vacation.pl https://sourceforge.net/forum/forum.php?thread_id=1845361&forum_id=676076 git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@157 a1433add-5e2c-0410-b055-b7f2511e0802 --- VIRTUAL_VACATION/vacation.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index 184d8115..f3aa5431 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -115,9 +115,13 @@ if (!$dbh) { exit(0); } -# mysql only, needs FIX for ALL databases +my $db_true; # MySQL and PgSQL use different values for TRUE if ($db_type eq "mysql") { $dbh->do("SET CHARACTER SET utf8;"); + $db_true = '1'; +} else { # Pg + # TODO: SET CHARACTER SET is mysql only, needs FIX for ALL databases + $db_true = 'True'; } # used to detect infinite address lookup loops @@ -233,7 +237,7 @@ sub find_real_address { panic("possible infinite loop in find_real_address for <$email>. Check for alias loop\n"); } my $realemail; - my $query = qq{SELECT email FROM vacation WHERE email=? and active=true}; + my $query = qq{SELECT email FROM vacation WHERE email=? and active=$db_true}; my $stm = $dbh->prepare($query) or panic_prepare($query); $stm->execute($email) or panic_execute($query,"email='$email'"); my $rv = $stm->rows; @@ -251,7 +255,7 @@ sub find_real_address { if ($rv == 1) { my @row = $stm->fetchrow_array; my $alias = $row[0]; - $query = qq{SELECT email FROM vacation WHERE email=? and active=true}; + $query = qq{SELECT email FROM vacation WHERE email=? and active=$db_true}; $stm = $dbh->prepare($query) or panic_prepare($query); $stm->execute($alias) or panic_prepare($query,"email='$alias'"); $rv = $stm->rows;