Commit 46aba0e7 authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 313209: Oracle requires "CASE WHEN" around boolean expressions in the SELECT column list

Patch By Lance Larsh <lance.larsh@oracle.com> r=mkanat, a=justdave
parent a637b882
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
# Dave Miller <justdave@bugzilla.org> # Dave Miller <justdave@bugzilla.org>
# Max Kanat-Alexander <mkanat@bugzilla.org> # Max Kanat-Alexander <mkanat@bugzilla.org>
# Frdric Buclin <LpSolit@gmail.com> # Frdric Buclin <LpSolit@gmail.com>
# Lance Larsh <lance.larsh@oracle.com>
package Bugzilla::Bug; package Bugzilla::Bug;
...@@ -547,7 +548,8 @@ sub groups { ...@@ -547,7 +548,8 @@ sub groups {
my $grouplist = Bugzilla->user->groups_as_string; my $grouplist = Bugzilla->user->groups_as_string;
my $sth = $dbh->prepare( my $sth = $dbh->prepare(
"SELECT DISTINCT groups.id, name, description," . "SELECT DISTINCT groups.id, name, description," .
" bug_group_map.group_id IS NOT NULL," . " CASE WHEN bug_group_map.group_id IS NOT NULL" .
" THEN 1 ELSE 0 END," .
" CASE WHEN groups.id IN($grouplist) THEN 1 ELSE 0 END," . " CASE WHEN groups.id IN($grouplist) THEN 1 ELSE 0 END," .
" isactive, membercontrol, othercontrol" . " isactive, membercontrol, othercontrol" .
" FROM groups" . " FROM groups" .
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# Shane H. W. Travis <travis@sedsystems.ca> # Shane H. W. Travis <travis@sedsystems.ca>
# Max Kanat-Alexander <mkanat@bugzilla.org> # Max Kanat-Alexander <mkanat@bugzilla.org>
# Gervase Markham <gerv@gerv.net> # Gervase Markham <gerv@gerv.net>
# Lance Larsh <lance.larsh@oracle.com>
################################################################################ ################################################################################
# Module Initialization # Module Initialization
...@@ -509,7 +510,8 @@ sub can_enter_product { ...@@ -509,7 +510,8 @@ sub can_enter_product {
trick_taint($product_name); trick_taint($product_name);
# Checks whether the user has access to the product. # Checks whether the user has access to the product.
my $has_access = $dbh->selectrow_array('SELECT group_id IS NULL my $has_access = $dbh->selectrow_array('SELECT CASE WHEN group_id IS NULL
THEN 1 ELSE 0 END
FROM products FROM products
LEFT JOIN group_control_map LEFT JOIN group_control_map
ON group_control_map.product_id = products.id ON group_control_map.product_id = products.id
...@@ -527,8 +529,10 @@ sub can_enter_product { ...@@ -527,8 +529,10 @@ sub can_enter_product {
# Checks whether the product is open for new bugs and # Checks whether the product is open for new bugs and
# has at least one component and one version. # has at least one component and one version.
my ($is_open, $has_version) = my ($is_open, $has_version) =
$dbh->selectrow_array('SELECT CASE WHEN disallownew = 0 THEN 1 ELSE 0 END, $dbh->selectrow_array('SELECT CASE WHEN disallownew = 0
versions.value IS NOT NULL THEN 1 ELSE 0 END,
CASE WHEN versions.value IS NOT NULL
THEN 1 ELSE 0 END
FROM products FROM products
INNER JOIN components INNER JOIN components
ON components.product_id = products.id ON components.product_id = products.id
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# Rights Reserved. # Rights Reserved.
# #
# Contributor(s): Gervase Markham <gerv@gerv.net> # Contributor(s): Gervase Markham <gerv@gerv.net>
# Lance Larsh <lance.larsh@oracle.com>
# Glossary: # Glossary:
# series: An individual, defined set of data plotted over time. # series: An individual, defined set of data plotted over time.
...@@ -207,7 +208,8 @@ sub assertCanEdit { ...@@ -207,7 +208,8 @@ sub assertCanEdit {
return if UserInGroup("admin"); return if UserInGroup("admin");
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $iscreator = $dbh->selectrow_array("SELECT creator = ? FROM series " . my $iscreator = $dbh->selectrow_array("SELECT CASE WHEN creator = ? " .
"THEN 1 ELSE 0 END FROM series " .
"WHERE series_id = ?", undef, "WHERE series_id = ?", undef,
$::userid, $series_id); $::userid, $series_id);
$iscreator || ThrowUserError("illegal_series_edit"); $iscreator || ThrowUserError("illegal_series_edit");
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# Gavin Shelley <bugzilla@chimpychompy.org> # Gavin Shelley <bugzilla@chimpychompy.org>
# Fr��ic Buclin <LpSolit@gmail.com> # Fr��ic Buclin <LpSolit@gmail.com>
# Greg Hendricks <ghendricks@novell.com> # Greg Hendricks <ghendricks@novell.com>
# Lance Larsh <lance.larsh@oracle.com>
# #
# Direct any questions on this source code to # Direct any questions on this source code to
# #
...@@ -624,7 +625,7 @@ if ($action eq 'updategroupcontrols') { ...@@ -624,7 +625,7 @@ if ($action eq 'updategroupcontrols') {
foreach my $groupid (@now_na) { foreach my $groupid (@now_na) {
my $count = 0; my $count = 0;
SendSQL("SELECT bugs.bug_id, SendSQL("SELECT bugs.bug_id,
(lastdiffed >= delta_ts) CASE WHEN (lastdiffed >= delta_ts) THEN 1 ELSE 0 END
FROM bugs, bug_group_map FROM bugs, bug_group_map
WHERE group_id = $groupid WHERE group_id = $groupid
AND bug_group_map.bug_id = bugs.bug_id AND bug_group_map.bug_id = bugs.bug_id
...@@ -658,7 +659,7 @@ if ($action eq 'updategroupcontrols') { ...@@ -658,7 +659,7 @@ if ($action eq 'updategroupcontrols') {
foreach my $groupid (@now_mandatory) { foreach my $groupid (@now_mandatory) {
my $count = 0; my $count = 0;
SendSQL("SELECT bugs.bug_id, SendSQL("SELECT bugs.bug_id,
(lastdiffed >= delta_ts) CASE WHEN (lastdiffed >= delta_ts) THEN 1 ELSE 0 END
FROM bugs FROM bugs
LEFT JOIN bug_group_map LEFT JOIN bug_group_map
ON bug_group_map.bug_id = bugs.bug_id ON bug_group_map.bug_id = bugs.bug_id
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# Joel Peshkin <bugreport@peshkin.net> # Joel Peshkin <bugreport@peshkin.net>
# Dave Lawrence <dkl@redhat.com> # Dave Lawrence <dkl@redhat.com>
# Max Kanat-Alexander <mkanat@bugzilla.org> # Max Kanat-Alexander <mkanat@bugzilla.org>
# Lance Larsh <lance.larsh@oracle.com>
# Contains some global variables and routines used throughout bugzilla. # Contains some global variables and routines used throughout bugzilla.
...@@ -734,7 +735,8 @@ sub get_legal_field_values { ...@@ -734,7 +735,8 @@ sub get_legal_field_values {
sub BugInGroupId { sub BugInGroupId {
my ($bugid, $groupid) = (@_); my ($bugid, $groupid) = (@_);
PushGlobalSQLState(); PushGlobalSQLState();
SendSQL("SELECT bug_id != 0 FROM bug_group_map SendSQL("SELECT CASE WHEN bug_id != 0 THEN 1 ELSE 0 END
FROM bug_group_map
WHERE bug_id = $bugid WHERE bug_id = $bugid
AND group_id = $groupid"); AND group_id = $groupid");
my $bugingroup = FetchOneColumn(); my $bugingroup = FetchOneColumn();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# Myk Melez <myk@mozilla.org> # Myk Melez <myk@mozilla.org>
# Jeff Hedlund <jeff.hedlund@matrixsi.com> # Jeff Hedlund <jeff.hedlund@matrixsi.com>
# Frédéric Buclin <LpSolit@gmail.com> # Frédéric Buclin <LpSolit@gmail.com>
# Lance Larsh <lance.larsh@oracle.com>
# Implementation notes for this file: # Implementation notes for this file:
# #
...@@ -1730,7 +1731,8 @@ foreach my $id (@idlist) { ...@@ -1730,7 +1731,8 @@ foreach my $id (@idlist) {
SendSQL("SELECT DISTINCT groups.id, isactive, " . SendSQL("SELECT DISTINCT groups.id, isactive, " .
"oldcontrolmap.membercontrol, newcontrolmap.membercontrol, " . "oldcontrolmap.membercontrol, newcontrolmap.membercontrol, " .
"CASE WHEN groups.id IN ($grouplist) THEN 1 ELSE 0 END, " . "CASE WHEN groups.id IN ($grouplist) THEN 1 ELSE 0 END, " .
"bug_group_map.group_id IS NOT NULL " . "CASE WHEN bug_group_map.group_id IS NOT NULL " .
"THEN 1 ELSE 0 END " .
"FROM groups " . "FROM groups " .
"LEFT JOIN group_control_map AS oldcontrolmap " . "LEFT JOIN group_control_map AS oldcontrolmap " .
"ON oldcontrolmap.group_id = groups.id " . "ON oldcontrolmap.group_id = groups.id " .
......
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