Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
e9273ed3
Commit
e9273ed3
authored
Feb 19, 2005
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 281360: Checksetup should use the new DB-compatibility layer to create $dbh
Patch By Max Kanat-Alexander <mkanat@kerio.com> r=joel, r=glob, a=justdave
parent
f76ab38e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
32 deletions
+25
-32
DB.pm
Bugzilla/DB.pm
+22
-6
checksetup.pl
checksetup.pl
+3
-26
No files found.
Bugzilla/DB.pm
View file @
e9273ed3
...
...
@@ -133,8 +133,11 @@ sub connect_shadow {
Param
(
"shadowdbsock"
),
$db_user
,
$db_pass
);
}
sub
connect_main
{
return
_connect
(
$db_driver
,
$db_host
,
$db_name
,
$db_port
,
sub
connect_main
(;$) {
my
(
$no_db_name
)
=
@_
;
my
$connect_to_db
=
$db_name
;
$connect_to_db
=
""
if
$no_db_name
;
return
_connect
(
$db_driver
,
$db_host
,
$connect_to_db
,
$db_port
,
$db_sock
,
$db_user
,
$db_pass
);
}
...
...
@@ -147,7 +150,9 @@ sub _connect {
my
$pkg_module
=
"Bugzilla::DB::"
.
$db_module
;
# do the actual import
eval
(
"require $pkg_module"
)
||
die
(
$@
);
eval
(
"require $pkg_module"
)
||
die
(
"'$db_module' is not a valid choice for \$db_driver in "
.
" localconfig: "
.
$@
);
# instantiate the correct DB specific module
my
$dbh
=
$pkg_module
->
new
(
$user
,
$pass
,
$host
,
$dbname
,
$port
,
$sock
);
...
...
@@ -279,7 +284,7 @@ sub db_new {
# set up default attributes used to connect to the database
# (if not defined by DB specific implementation)
$attributes
=
{
RaiseError
=>
1
,
$attributes
=
{
RaiseError
=>
0
,
AutoCommit
=>
1
,
PrintError
=>
0
,
ShowErrorStatement
=>
1
,
...
...
@@ -294,7 +299,14 @@ sub db_new {
# connect using our known info to the specified db
# Apache::DBI will cache this when using mod_perl
my
$self
=
DBI
->
connect
(
$dsn
,
$user
,
$pass
,
$attributes
);
my
$self
=
DBI
->
connect
(
$dsn
,
$user
,
$pass
,
$attributes
)
or
die
"\nCan't connect to the database.\nError: $DBI::errstr\n"
.
" Is your database installed and up and running?\n Do you have"
.
"the correct username and password selected in localconfig?\n\n"
;
# RaiseError was only set to 0 so that we could catch the
# above "die" condition.
$self
->
{
RaiseError
}
=
1
;
# class variables
$self
->
{
private_bz_in_transaction
}
=
0
;
...
...
@@ -362,7 +374,11 @@ should not be called from anywhere else.
Description: Function to connect to the main database, returning a new
database handle.
Params: none
Params: $no_db_name (optional) - If true, Connect to the database
server, but don't connect to a specific database. This
is only used when creating a database. After you create
the database, you should re-create a new Bugzilla::DB object
without using this parameter.
Returns: new instance of the DB class
=item C<connect_shadow>
...
...
checksetup.pl
View file @
e9273ed3
...
...
@@ -803,12 +803,7 @@ if ($newstuff ne "") {
# care less whether they were defined ahead of time or not.
my
$my_db_check
=
$
{
*
{
$
main::
{
'db_check'
}}{
SCALAR
}};
my
$my_db_driver
=
$
{
*
{
$
main::
{
'db_driver'
}}{
SCALAR
}};
my
$my_db_host
=
$
{
*
{
$
main::
{
'db_host'
}}{
SCALAR
}};
my
$my_db_port
=
$
{
*
{
$
main::
{
'db_port'
}}{
SCALAR
}};
my
$my_db_name
=
$
{
*
{
$
main::
{
'db_name'
}}{
SCALAR
}};
my
$my_db_user
=
$
{
*
{
$
main::
{
'db_user'
}}{
SCALAR
}};
my
$my_db_sock
=
$
{
*
{
$
main::
{
'db_sock'
}}{
SCALAR
}};
my
$my_db_pass
=
$
{
*
{
$
main::
{
'db_pass'
}}{
SCALAR
}};
my
$my_index_html
=
$
{
*
{
$
main::
{
'index_html'
}}{
SCALAR
}};
my
$my_create_htaccess
=
$
{
*
{
$
main::
{
'create_htaccess'
}}{
SCALAR
}};
my
$my_webservergroup
=
$
{
*
{
$
main::
{
'webservergroup'
}}{
SCALAR
}};
...
...
@@ -1525,19 +1520,8 @@ if ($my_db_check) {
# Do we have the database itself?
my
$sql_want
=
"3.23.41"
;
# minimum version of MySQL
# original DSN line was:
# my $dsn = "DBI:$my_db_driver:$my_db_name;$my_db_host;$my_db_port";
# removed the $db_name because we don't know it exists yet, and this will fail
# if we request it here and it doesn't. - justdave@syndicomm.com 2000/09/16
my
$dsn
=
"DBI:$my_db_driver:;$my_db_host;$my_db_port"
;
if
(
$my_db_sock
ne
""
)
{
$dsn
.=
";mysql_socket=$my_db_sock"
;
}
my
$dbh
=
DBI
->
connect
(
$dsn
,
$my_db_user
,
$my_db_pass
)
or
die
"Can't connect to the $my_db_driver database. Is the database "
.
"installed and\nup and running? Do you have the correct username "
.
"and password selected in\nlocalconfig?\n\n"
;
my
$dbh
=
Bugzilla::DB::
connect_main
(
"no database connection"
);
printf
(
"Checking for %15s %-9s "
,
"MySQL Server"
,
"(v$sql_want)"
)
unless
$silent
;
my
$qh
=
$dbh
->
prepare
(
"SELECT VERSION()"
);
$qh
->
execute
;
...
...
@@ -1586,14 +1570,7 @@ EOF
}
# now get a handle to the database:
my
$connectstring
=
"dbi:$my_db_driver:$my_db_name:host=$my_db_host:port=$my_db_port"
;
if
(
$my_db_sock
ne
""
)
{
$connectstring
.=
";mysql_socket=$my_db_sock"
;
}
my
$dbh
=
DBI
->
connect
(
$connectstring
,
$my_db_user
,
$my_db_pass
)
or
die
"Can't connect to the table '$connectstring'.\n"
,
"Have you read the Bugzilla Guide in the doc directory? Have you read the doc of '$my_db_driver'?\n"
;
my
$dbh
=
Bugzilla::DB::
connect_main
();
END
{
$dbh
->
disconnect
if
$dbh
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment