Bug 367836: Let the shadowdb connection have its own username and password
r=bear git-svn-id: svn://10.0.0.236/trunk@219464 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -136,6 +136,11 @@ DefParam("cvsadmin",
|
||||
"t",
|
||||
'%maintainer%');
|
||||
|
||||
DefParam("dbiparam",
|
||||
"The first parameter to pass to the DBI->connect() method.<br>Example: <code>DBI:mysql:host=localhost;database=bonsai</code>",
|
||||
"t",
|
||||
"DBI:mysql:database=bonsai;");
|
||||
|
||||
DefParam("mysqluser",
|
||||
"The username of the bonsai database user.",
|
||||
"t",
|
||||
@@ -146,16 +151,21 @@ DefParam("mysqlpassword",
|
||||
"p",
|
||||
"");
|
||||
|
||||
DefParam("dbiparam",
|
||||
"The first parameter to pass to the DBI->connect() method.<br>Example: <code>DBI:mysql:host=localhost;database=bonsai</code>",
|
||||
"t",
|
||||
"DBI:mysql:database=bonsai;");
|
||||
|
||||
DefParam("shadowdbiparam",
|
||||
"The first parameter to pass to the DBI->connect() method of a read-only replicated slave database to use for queries, to help with performance on high-traffic systems. If left blank, queries will be made against the primary database and this param will be ignored.<br>Example: <code>DBI:mysql:host=slaveserver;database=bonsai</code>",
|
||||
"t",
|
||||
"");
|
||||
|
||||
DefParam("shadowmysqluser",
|
||||
"The username of the bonsai database user for the shadow database.",
|
||||
"t",
|
||||
"nobody");
|
||||
|
||||
DefParam("shadowmysqlpassword",
|
||||
"The password of the bonsai database user for the shadow database.",
|
||||
"p",
|
||||
"");
|
||||
|
||||
DefParam("readonly",
|
||||
"Are the hook files readonly. (This value gets changed on the fly,
|
||||
so it is ok to leave the way it is.)",
|
||||
|
||||
@@ -109,11 +109,18 @@ sub ConnectToDatabase {
|
||||
my ($dsn);
|
||||
|
||||
if (!defined $::readdb) {
|
||||
$dsn = Param('shadowdbiparam') || Param('dbiparam');
|
||||
my $dsn = Param('dbiparam');
|
||||
my $dbuser = Param('mysqluser');
|
||||
my $dbpass = Param('mysqlpassword');
|
||||
if (Param('shadowdbiparam')) {
|
||||
$dsn = Param('shadowdbiparam');
|
||||
$dbuser = Param('shadowmysqluser');
|
||||
$dbpass = Param('shadowmysqlpassword');
|
||||
}
|
||||
|
||||
# DBI->trace(1, "/tmp/dbi.out");
|
||||
|
||||
$::readdb = DBI->connect($dsn, Param('mysqluser'), Param('mysqlpassword'))
|
||||
$::readdb = DBI->connect($dsn, $dbuser, $dbpass)
|
||||
|| die "Can't connect to database server.";
|
||||
$::db = $::readdb;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user