Unverified Commit 4cebf590 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #1173 from ikedas/issue-1163 by ikedas

Error emails to listmaster from repeated set_netidtoemail_db calls (#1163)
parents 74852a61 2a4dc2ed
......@@ -61,11 +61,19 @@ sub connect {
# - Configure Postgres to use ISO format dates.
# - Set client encoding to UTF8.
# - Create a temporary view "dual" for portable SQL statements.
# Note: utf8 flagging must be disabled so that we will consistently use
# UTF-8 bytestring as internal format.
# UTF-8 bytestring as internal format.
# Note: PostgreSQL <= 8.0.x didn't support temporary view but >= 7.3.x
# supported CREATE OR REPLACE statement.
$self->__dbh->{pg_enable_utf8} = 0; # For DBD::Pg 3.x
$self->__dbh->do("SET DATESTYLE TO 'ISO';");
$self->__dbh->do("SET NAMES 'utf8'");
defined $self->__dbh->do(
q{CREATE TEMPORARY VIEW dual AS SELECT 'X'::varchar(1) AS dummy;}
) or $self->__dbh->do(
q{CREATE OR REPLACE VIEW dual AS SELECT 'X'::varchar(1) AS dummy;}
);
return 1;
}
......
......@@ -63,6 +63,8 @@ sub connect {
} else {
$self->__dbh->func(5000, 'busy_timeout');
}
# Create a temoprarhy view "dual" for portable SQL statements.
$self->__dbh->do(q{CREATE TEMPORARY VIEW dual AS SELECT 'X' AS dummy;});
return 1;
}
......
......@@ -123,7 +123,15 @@ sub set_netidtoemail_db {
q{INSERT INTO netidmap_table
(netid_netidmap, serviceid_netidmap, email_netidmap,
robot_netidmap)
VALUES (?, ?, ?, ?)},
SELECT ?, ?, ?, ?
FROM dual
WHERE NOT EXISTS (
SELECT 1
FROM netidmap_table
WHERE netid_netidmap = ? AND serviceid_netidmap = ? AND
email_netidmap = ? AND robot_netidmap = ?
)},
$netid, $idpname, $email, $robot,
$netid, $idpname, $email, $robot
)
) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment