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
73a4dd56
Commit
73a4dd56
authored
Aug 01, 2008
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 440188: buglist.cgi should display EXPLAIN output when &debug=1
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
parent
d165b778
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
1 deletion
+56
-1
DB.pm
Bugzilla/DB.pm
+1
-1
Mysql.pm
Bugzilla/DB/Mysql.pm
+26
-0
Oracle.pm
Bugzilla/DB/Oracle.pm
+9
-0
Pg.pm
Bugzilla/DB/Pg.pm
+6
-0
buglist.cgi
buglist.cgi
+7
-0
buglist.css
skins/standard/buglist.css
+4
-0
list.html.tmpl
template/en/default/list/list.html.tmpl
+3
-0
No files found.
Bugzilla/DB.pm
View file @
73a4dd56
...
...
@@ -273,7 +273,7 @@ EOT
# List of abstract methods we are checking the derived class implements
our
@_abstract_methods
=
qw(REQUIRED_VERSION PROGRAM_NAME DBD_VERSION
new sql_regexp sql_not_regexp sql_limit sql_to_days
sql_date_format sql_interval)
;
sql_date_format sql_interval
bz_explain
)
;
# This overridden import method will check implementation of inherited classes
# for missing implementation of abstract methods
...
...
Bugzilla/DB/Mysql.pm
View file @
73a4dd56
...
...
@@ -48,6 +48,8 @@ use Bugzilla::Util;
use
Bugzilla::
Error
;
use
Bugzilla::DB::Schema::
Mysql
;
use
List::
Util
qw(max)
;
# This module extends the DB interface via inheritance
use
base
qw(Bugzilla::DB)
;
...
...
@@ -204,6 +206,30 @@ sub sql_group_by {
return
"GROUP BY $needed_columns"
;
}
sub
bz_explain
{
my
(
$self
,
$sql
)
=
@_
;
my
$sth
=
$self
->
prepare
(
"EXPLAIN $sql"
);
$sth
->
execute
();
my
$columns
=
$sth
->
{
'NAME'
};
my
$lengths
=
$sth
->
{
'mysql_max_length'
};
my
$format_string
=
'|'
;
my
$i
=
0
;
foreach
my
$column
(
@$columns
)
{
# Sometimes the column name is longer than the contents.
my
$length
=
max
(
$lengths
->
[
$i
],
length
(
$column
));
$format_string
.=
' %-'
.
$length
.
's |'
;
$i
++
;
}
my
$first_row
=
sprintf
(
$format_string
,
@$columns
);
my
@explain_rows
=
(
$first_row
,
'-'
x
length
(
$first_row
));
while
(
my
$row
=
$sth
->
fetchrow_arrayref
)
{
my
@fixed
=
map
{
defined
$_
?
$_
:
'NULL'
}
@$row
;
push
(
@explain_rows
,
sprintf
(
$format_string
,
@fixed
));
}
return
join
(
"\n"
,
@explain_rows
);
}
sub
_bz_get_initial_schema
{
my
(
$self
)
=
@_
;
...
...
Bugzilla/DB/Oracle.pm
View file @
73a4dd56
...
...
@@ -104,6 +104,15 @@ sub bz_check_regexp {
{
value
=>
$pattern
,
dberror
=>
$self
->
errstr
});
}
sub
bz_explain
{
my
(
$self
,
$sql
)
=
@_
;
my
$sth
=
$self
->
prepare
(
"EXPLAIN PLAN FOR $sql"
);
$sth
->
execute
();
my
$explain
=
$self
->
selectcol_arrayref
(
"SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY)"
);
return
join
(
"\n"
,
@$explain
);
}
sub
sql_regexp
{
my
(
$self
,
$expr
,
$pattern
,
$nocheck
)
=
@_
;
...
...
Bugzilla/DB/Pg.pm
View file @
73a4dd56
...
...
@@ -171,6 +171,12 @@ sub bz_sequence_exists {
return
$exists
||
0
;
}
sub
bz_explain
{
my
(
$self
,
$sql
)
=
@_
;
my
$explain
=
$self
->
selectcol_arrayref
(
"EXPLAIN ANALYZE $sql"
);
return
join
(
"\n"
,
@$explain
);
}
#####################################################################
# Custom Database Setup
#####################################################################
...
...
buglist.cgi
View file @
73a4dd56
...
...
@@ -994,6 +994,13 @@ elsif ($fulltext) {
if
(
$cgi
->
param
(
'debug'
))
{
$vars
->
{
'debug'
}
=
1
;
$vars
->
{
'query'
}
=
$query
;
# Explains are limited to admins because you could use them to figure
# out how many hidden bugs are in a particular product (by doing
# searches and looking at the number of rows the explain says it's
# examining).
if
(
Bugzilla
->
user
->
in_group
(
'admin'
))
{
$vars
->
{
'query_explain'
}
=
$dbh
->
bz_explain
(
$query
);
}
$vars
->
{
'debugdata'
}
=
$search
->
getDebugData
();
}
...
...
skins/standard/buglist.css
View file @
73a4dd56
...
...
@@ -64,3 +64,7 @@ tr.bz_secure_mode_manual td.first-child {
#commit
,
#action
{
margin-top
:
.25em
;
}
.bz_query_explain
{
text-align
:
left
;
}
template/en/default/list/list.html.tmpl
View file @
73a4dd56
...
...
@@ -68,6 +68,9 @@
[% END %]
</p>
<p class="bz_query">[% query FILTER html %]</p>
[% IF query_explain.defined %]
<pre class="bz_query_explain">[% query_explain FILTER html %]</pre>
[% END %]
[% END %]
[% IF user.settings.display_quips.value == 'on' %]
...
...
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