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
b9402d3e
Commit
b9402d3e
authored
Feb 19, 2005
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 280497: Replace "LIMIT" with Bugzilla::DB function call
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat,a=justdave
parent
62eecf24
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
26 deletions
+42
-26
Search.pm
Bugzilla/Search.pm
+3
-1
Token.pm
Bugzilla/Token.pm
+3
-2
User.pm
Bugzilla/User.pm
+3
-2
buglist.cgi
buglist.cgi
+4
-4
checksetup.pl
checksetup.pl
+5
-3
collectstats.pl
collectstats.pl
+7
-4
globals.pl
globals.pl
+9
-4
process_bug.cgi
process_bug.cgi
+1
-1
sanitycheck.cgi
sanitycheck.cgi
+3
-3
userprefs.cgi
userprefs.cgi
+2
-1
whine.pl
whine.pl
+2
-1
No files found.
Bugzilla/Search.pm
View file @
b9402d3e
...
...
@@ -1393,6 +1393,8 @@ sub ListIDsForEmail {
my
$old
=
$self
->
{
"emailcache"
}{
"$type,$email"
};
return
undef
if
(
$old
&&
$old
eq
"---"
);
return
$old
if
$old
;
my
$dbh
=
Bugzilla
->
dbh
;
my
@list
=
();
my
$list
=
"---"
;
if
(
$type
eq
'anyexact'
)
{
...
...
@@ -1406,7 +1408,7 @@ sub ListIDsForEmail {
$list
=
join
(
','
,
@list
);
}
elsif
(
$type
eq
'substring'
)
{
&::
SendSQL
(
"SELECT userid FROM profiles WHERE INSTR(login_name, "
.
&::
SqlQuote
(
$email
)
.
")
LIMIT 51"
);
&::
SqlQuote
(
$email
)
.
")
"
.
$dbh
->
sql_limit
(
51
)
);
while
(
&::
MoreSQLData
())
{
my
(
$id
)
=
&::
FetchSQLData
();
push
(
@list
,
$id
);
...
...
Bugzilla/Token.pm
View file @
b9402d3e
...
...
@@ -260,10 +260,11 @@ sub HasEmailChangeToken {
# Returns an email change token if the user has one.
my
(
$userid
)
=
@_
;
my
$dbh
=
Bugzilla
->
dbh
;
&::
SendSQL
(
"SELECT token FROM tokens WHERE userid = $userid "
.
"AND (tokentype = 'emailnew' OR tokentype = 'emailold') "
.
"LIMIT 1"
);
$dbh
->
sql_limit
(
1
)
);
my
(
$token
)
=
&::
FetchSQLData
();
return
$token
;
...
...
Bugzilla/User.pm
View file @
b9402d3e
...
...
@@ -539,6 +539,7 @@ sub match {
my
$wildstr
=
$str
;
my
$user
=
Bugzilla
->
user
;
my
$dbh
=
Bugzilla
->
dbh
;
if
(
$wildstr
=~
s/\*/\%/g
&&
# don't do wildcards if no '*' in the string
Param
(
'usermatchmode'
)
ne
'off'
)
{
# or if we only want exact matches
...
...
@@ -561,7 +562,7 @@ sub match {
}
$query
.=
" AND disabledtext = '' "
if
$exclude_disabled
;
$query
.=
"ORDER BY length(login_name) "
;
$query
.=
"LIMIT $limit "
if
$limit
;
$query
.=
$dbh
->
sql_limit
(
$limit
)
if
$limit
;
# Execute the query, retrieve the results, and make them into
# User objects.
...
...
@@ -611,7 +612,7 @@ sub match {
}
$query
.=
" AND disabledtext = '' "
if
$exclude_disabled
;
$query
.=
"ORDER BY length(login_name) "
;
$query
.=
"LIMIT $limit "
if
$limit
;
$query
.=
$dbh
->
sql_limit
(
$limit
)
if
$limit
;
&::
PushGlobalSQLState
();
&::
SendSQL
(
$query
);
push
(
@users
,
new
Bugzilla::
User
(
&::
FetchSQLData
()))
while
&::
MoreSQLData
();
...
...
buglist.cgi
View file @
b9402d3e
...
...
@@ -294,8 +294,8 @@ sub GetQuip {
.
" FROM quips WHERE approved = 1"
);
my
$random
=
int
(
rand
(
$count
));
my
$quip
=
$dbh
->
selectrow_array
(
"SELECT quip FROM quips
"
.
" WHERE approved = 1 LIMIT $random,1"
);
$dbh
->
selectrow_array
(
"SELECT quip FROM quips
WHERE approved = 1 "
.
$dbh
->
sql_limit
(
1
,
$random
)
);
return
$quip
;
}
...
...
@@ -746,10 +746,10 @@ my $search = new Bugzilla::Search('fields' => \@selectnames,
my
$query
=
$search
->
getSQL
();
if
(
$::FORM
{
'limit'
}
&&
detaint_natural
(
$::FORM
{
'limit'
}))
{
$query
.=
"
LIMIT $::FORM{'limit'}"
;
$query
.=
"
"
.
$dbh
->
sql_limit
(
$::FORM
{
'limit'
})
;
}
elsif
(
$fulltext
)
{
$query
.=
"
LIMIT 200"
;
$query
.=
"
"
.
$dbh
->
sql_limit
(
200
)
;
}
...
...
checksetup.pl
View file @
b9402d3e
...
...
@@ -3552,7 +3552,9 @@ if (($fielddef = GetFieldDef("attachments", "creation_ts")) &&
# Restrict this as much as possible in order to avoid false positives, and
# keep the db search time down
my
$sth2
=
$dbh
->
prepare
(
"SELECT bug_when FROM longdescs WHERE bug_id=? AND who=? AND thetext LIKE ? ORDER BY bug_when LIMIT 1"
);
my
$sth2
=
$dbh
->
prepare
(
"SELECT bug_when FROM longdescs
WHERE bug_id=? AND who=? AND thetext LIKE ?
ORDER BY bug_when "
.
$dbh
->
sql_limit
(
1
));
while
(
my
(
$bug_id
,
$attach_id
,
$submitter_id
)
=
$sth
->
fetchrow_array
())
{
$sth2
->
execute
(
$bug_id
,
$submitter_id
,
"Created an attachment (id=$attach_id)%"
);
my
(
$when
)
=
$sth2
->
fetchrow_array
();
...
...
@@ -4037,8 +4039,8 @@ if (TableExists("user_series_map")) {
# 2003-06-26 Copy the old charting data into the database, and create the
# queries that will keep it all running. When the old charting system goes
# away, if this code ever runs, it'll just find no files and do nothing.
my
$series_exists
=
$dbh
->
selectrow_array
(
"SELECT 1 FROM series
LIMIT 1"
);
my
$series_exists
=
$dbh
->
selectrow_array
(
"SELECT 1 FROM series
"
.
$dbh
->
sql_limit
(
1
));
if
(
!
$series_exists
)
{
print
"Migrating old chart data into database ...\n"
unless
$silent
;
...
...
collectstats.pl
View file @
b9402d3e
...
...
@@ -258,8 +258,9 @@ sub calculate_dupes {
sub
regenerate_stats
{
my
$dir
=
shift
;
my
$product
=
shift
;
my
$when
=
localtime
(
time
());
my
$dbh
=
Bugzilla
->
dbh
;
my
$when
=
localtime
(
time
());
my
$tstart
=
time
();
# NB: Need to mangle the product for the filename, but use the real
...
...
@@ -287,7 +288,7 @@ sub regenerate_stats {
"to_days('1970-01-01') "
.
"FROM bugs $from_product WHERE to_days(creation_ts) != 'NULL' "
.
$and_product
.
"ORDER BY start
LIMIT 1"
);
"ORDER BY start
"
.
$dbh
->
sql_limit
(
1
)
);
my
(
$start
,
$end
,
$base
)
=
FetchSQLData
();
if
(
!
defined
$start
)
{
...
...
@@ -353,7 +354,8 @@ FIN
"AND fielddefs.name = 'bug_status' "
.
"AND bugs_activity.bug_id = $bug "
.
"AND bugs_activity.bug_when >= from_days($day) "
.
"ORDER BY bugs_activity.bug_when LIMIT 1"
);
"ORDER BY bugs_activity.bug_when "
.
$dbh
->
sql_limit
(
1
));
my
$status
;
if
(
@row
=
FetchSQLData
())
{
...
...
@@ -374,7 +376,8 @@ FIN
"AND fielddefs.name = 'resolution' "
.
"AND bugs_activity.bug_id = $bug "
.
"AND bugs_activity.bug_when >= from_days($day) "
.
"ORDER BY bugs_activity.bug_when LIMIT 1"
);
"ORDER BY bugs_activity.bug_when "
.
$dbh
->
sql_limit
(
1
));
if
(
@row
=
FetchSQLData
())
{
$status
=
$row
[
0
];
...
...
globals.pl
View file @
b9402d3e
...
...
@@ -386,10 +386,11 @@ sub AnyEntryGroups {
$product_id
=
0
unless
(
$product_id
);
return
$::CachedAnyEntryGroups
{
$product_id
}
if
defined
(
$::CachedAnyEntryGroups
{
$product_id
});
my
$dbh
=
Bugzilla
->
dbh
;
PushGlobalSQLState
();
my
$query
=
"SELECT 1 FROM group_control_map WHERE entry != 0"
;
$query
.=
" AND product_id = $product_id"
if
(
$product_id
);
$query
.=
"
LIMIT 1"
;
$query
.=
"
"
.
$dbh
->
sql_limit
(
1
)
;
SendSQL
(
$query
);
if
(
MoreSQLData
())
{
$::CachedAnyEntryGroups
{
$product_id
}
=
MoreSQLData
();
...
...
@@ -406,13 +407,14 @@ sub AnyEntryGroups {
# one bug to another.
sub
AnyDefaultGroups
{
return
$::CachedAnyDefaultGroups
if
defined
(
$::CachedAnyDefaultGroups
);
my
$dbh
=
Bugzilla
->
dbh
;
PushGlobalSQLState
();
SendSQL
(
"SELECT 1 FROM group_control_map, groups WHERE "
.
"groups.id = group_control_map.group_id "
.
"AND isactive != 0 AND "
.
"(membercontrol = "
.
CONTROLMAPDEFAULT
.
" OR othercontrol = "
.
CONTROLMAPDEFAULT
.
")
LIMIT 1"
);
")
"
.
$dbh
->
sql_limit
(
1
)
);
$::CachedAnyDefaultGroups
=
MoreSQLData
();
FetchSQLData
();
PopGlobalSQLState
();
...
...
@@ -424,6 +426,7 @@ sub AnyDefaultGroups {
# bugs in this product at all.
sub
CanEditProductId
{
my
(
$productid
)
=
@_
;
my
$dbh
=
Bugzilla
->
dbh
;
my
$query
=
"SELECT group_id FROM group_control_map "
.
"WHERE product_id = $productid "
.
"AND canedit != 0 "
;
...
...
@@ -431,7 +434,7 @@ sub CanEditProductId {
$query
.=
"AND group_id NOT IN("
.
join
(
','
,
values
(
%
{
Bugzilla
->
user
->
groups
}))
.
") "
;
}
$query
.=
"LIMIT 1"
;
$query
.=
$dbh
->
sql_limit
(
1
)
;
PushGlobalSQLState
();
SendSQL
(
$query
);
my
(
$result
)
=
FetchSQLData
();
...
...
@@ -462,6 +465,7 @@ sub IsInClassification {
# product.
sub
CanEnterProduct
{
my
(
$productname
)
=
@_
;
my
$dbh
=
Bugzilla
->
dbh
;
my
$query
=
"SELECT group_id IS NULL "
.
"FROM products "
.
"LEFT JOIN group_control_map "
.
...
...
@@ -471,7 +475,8 @@ sub CanEnterProduct {
$query
.=
"AND group_id NOT IN("
.
join
(
','
,
values
(
%
{
Bugzilla
->
user
->
groups
}))
.
") "
;
}
$query
.=
"WHERE products.name = "
.
SqlQuote
(
$productname
)
.
" LIMIT 1"
;
$query
.=
"WHERE products.name = "
.
SqlQuote
(
$productname
)
.
" "
.
$dbh
->
sql_limit
(
1
);
PushGlobalSQLState
();
SendSQL
(
$query
);
my
(
$ret
)
=
FetchSQLData
();
...
...
process_bug.cgi
View file @
b9402d3e
...
...
@@ -696,7 +696,7 @@ if ($::FORM{'product'} ne $::FORM{'dontchange'}) {
$::query
.=
"product_id = $prod_id"
;
}
else
{
SendSQL
(
"SELECT DISTINCT product_id FROM bugs WHERE bug_id IN ("
.
join
(
','
,
@idlist
)
.
")
LIMIT 2"
);
join
(
','
,
@idlist
)
.
")
"
.
$dbh
->
sql_limit
(
2
)
);
$prod_id
=
FetchOneColumn
();
$prod_id
=
undef
if
(
FetchOneColumn
());
}
...
...
sanitycheck.cgi
View file @
b9402d3e
...
...
@@ -118,7 +118,7 @@ if (defined $cgi->param('rebuildvotecache')) {
if
(
defined
$cgi
->
param
(
'rederivegroups'
))
{
Status
(
"OK, All users' inherited permissions will be rechecked when "
.
"they next access Bugzilla."
);
SendSQL
(
"UPDATE groups SET last_changed = NOW()
LIMIT 1"
);
SendSQL
(
"UPDATE groups SET last_changed = NOW()
"
.
$dbh
->
sql_limit
(
1
)
);
}
# rederivegroupsnow is REALLY only for testing.
...
...
@@ -152,8 +152,8 @@ if (defined $cgi->param('cleangroupsnow')) {
$dbh
->
bz_lock_tables
(
'user_group_map WRITE'
,
'profiles WRITE'
);
SendSQL
(
"SELECT userid FROM profiles "
.
"WHERE refreshed_when > 0 "
.
"AND refreshed_when < "
.
SqlQuote
(
$cutoff
)
.
" LIMIT 1000"
);
"AND refreshed_when < "
.
SqlQuote
(
$cutoff
)
.
" "
.
$dbh
->
sql_limit
(
1000
)
);
my
$count
=
0
;
while
((
my
$id
)
=
FetchSQLData
())
{
$count
++
;
...
...
userprefs.cgi
View file @
b9402d3e
...
...
@@ -49,6 +49,7 @@ my @reasons = ("Removeme", "Comments", "Attachments", "Status", "Resolved",
# SaveFoo may be called before DoFoo.
###############################################################################
sub
DoAccount
{
my
$dbh
=
Bugzilla
->
dbh
;
SendSQL
(
"SELECT realname FROM profiles WHERE userid = $userid"
);
$vars
->
{
'realname'
}
=
FetchSQLData
();
...
...
@@ -57,7 +58,7 @@ sub DoAccount {
FROM tokens
WHERE userid = $userid
AND tokentype LIKE 'email%'
ORDER BY tokentype ASC
LIMIT 1"
);
ORDER BY tokentype ASC
"
.
$dbh
->
sql_limit
(
1
)
);
if
(
MoreSQLData
())
{
my
(
$tokentype
,
$change_date
,
$eventdata
)
=
&::
FetchSQLData
();
$vars
->
{
'login_change_date'
}
=
$change_date
;
...
...
whine.pl
View file @
b9402d3e
...
...
@@ -69,7 +69,8 @@ my $sth_next_scheduled_event = $dbh->prepare(
"LEFT JOIN whine_events "
.
" ON whine_events.id = whine_schedules.eventid "
.
"WHERE run_next <= NOW() "
.
"ORDER BY run_next LIMIT 1"
"ORDER BY run_next "
.
$dbh
->
sql_limit
(
1
)
);
# get all pending schedules matching an eventid
...
...
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