Commit 430ebc94 authored by Vitaly Lipatov's avatar Vitaly Lipatov

quota groups table and all $table

parent 8e2759c5
...@@ -3995,7 +3995,7 @@ sub groups { ...@@ -3995,7 +3995,7 @@ sub groups {
. " THEN 1 ELSE 0 END," . " 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`"
. " LEFT JOIN bug_group_map" . " LEFT JOIN bug_group_map"
. " ON bug_group_map.group_id = groups.id" . " ON bug_group_map.group_id = groups.id"
. " AND bug_id = ?" . " AND bug_id = ?"
......
...@@ -700,7 +700,7 @@ sub bz_alter_column { ...@@ -700,7 +700,7 @@ sub bz_alter_column {
{ {
# Check for NULLs # Check for NULLs
my $any_nulls my $any_nulls
= $self->selectrow_array("SELECT 1 FROM $table WHERE $name IS NULL"); = $self->selectrow_array("SELECT 1 FROM `$table` WHERE $name IS NULL");
ThrowCodeError('column_not_null_no_default_alter', {name => "$table.$name"}) ThrowCodeError('column_not_null_no_default_alter', {name => "$table.$name"})
if ($any_nulls); if ($any_nulls);
} }
...@@ -1121,7 +1121,7 @@ sub bz_rename_table { ...@@ -1121,7 +1121,7 @@ sub bz_rename_table {
sub bz_set_next_serial_value { sub bz_set_next_serial_value {
my ($self, $table, $column, $value) = @_; my ($self, $table, $column, $value) = @_;
if (!$value) { if (!$value) {
$value = $self->selectrow_array("SELECT MAX($column) FROM $table") || 0; $value = $self->selectrow_array("SELECT MAX($column) FROM `$table`") || 0;
$value++; $value++;
} }
my @sql = $self->_bz_real_schema->get_set_serial_sql($table, $column, $value); my @sql = $self->_bz_real_schema->get_set_serial_sql($table, $column, $value);
...@@ -1520,7 +1520,7 @@ sub _check_references { ...@@ -1520,7 +1520,7 @@ sub _check_references {
# reserved words. # reserved words.
my $bad_values = $self->selectcol_arrayref( my $bad_values = $self->selectcol_arrayref(
"SELECT DISTINCT tabl.$column "SELECT DISTINCT tabl.$column
FROM $table AS tabl LEFT JOIN $foreign_table AS forn FROM `$table` AS tabl LEFT JOIN $foreign_table AS forn
ON tabl.$column = forn.$foreign_column ON tabl.$column = forn.$foreign_column
WHERE forn.$foreign_column IS NULL WHERE forn.$foreign_column IS NULL
AND tabl.$column IS NOT NULL" AND tabl.$column IS NOT NULL"
...@@ -1530,7 +1530,7 @@ sub _check_references { ...@@ -1530,7 +1530,7 @@ sub _check_references {
my $delete_action = $fk->{DELETE} || ''; my $delete_action = $fk->{DELETE} || '';
if ($delete_action eq 'CASCADE') { if ($delete_action eq 'CASCADE') {
$self->do( $self->do(
"DELETE FROM $table WHERE $column IN (" . join(',', ('?') x @$bad_values) . ")", "DELETE FROM `$table` WHERE $column IN (" . join(',', ('?') x @$bad_values) . ")",
undef, @$bad_values undef, @$bad_values
); );
if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) { if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
...@@ -1551,7 +1551,7 @@ sub _check_references { ...@@ -1551,7 +1551,7 @@ sub _check_references {
} }
elsif ($delete_action eq 'SET NULL') { elsif ($delete_action eq 'SET NULL') {
$self->do( $self->do(
"UPDATE $table SET $column = NULL "UPDATE `$table` SET $column = NULL
WHERE $column IN (" WHERE $column IN ("
. join(',', ('?') x @$bad_values) . ")", undef, @$bad_values . join(',', ('?') x @$bad_values) . ")", undef, @$bad_values
); );
......
...@@ -700,7 +700,7 @@ sub bz_setup_database { ...@@ -700,7 +700,7 @@ sub bz_setup_database {
print "Converting table storage format to UTF-8. This may take a", " while.\n"; print "Converting table storage format to UTF-8. This may take a", " while.\n";
foreach my $table ($self->bz_table_list_real) { foreach my $table ($self->bz_table_list_real) {
my $info_sth = $self->prepare("SHOW FULL COLUMNS FROM $table"); my $info_sth = $self->prepare("SHOW FULL COLUMNS FROM `$table`");
$info_sth->execute(); $info_sth->execute();
my (@binary_sql, @utf8_sql); my (@binary_sql, @utf8_sql);
while (my $column = $info_sth->fetchrow_hashref) { while (my $column = $info_sth->fetchrow_hashref) {
...@@ -980,7 +980,7 @@ sub _bz_raw_column_info { ...@@ -980,7 +980,7 @@ sub _bz_raw_column_info {
sub bz_index_info_real { sub bz_index_info_real {
my ($self, $table, $index) = @_; my ($self, $table, $index) = @_;
my $sth = $self->prepare("SHOW INDEX FROM $table"); my $sth = $self->prepare("SHOW INDEX FROM `$table`");
$sth->execute; $sth->execute;
my @fields; my @fields;
...@@ -1028,7 +1028,7 @@ sub bz_index_info_real { ...@@ -1028,7 +1028,7 @@ sub bz_index_info_real {
sub bz_index_list_real { sub bz_index_list_real {
my ($self, $table) = @_; my ($self, $table) = @_;
my $sth = $self->prepare("SHOW INDEX FROM $table"); my $sth = $self->prepare("SHOW INDEX FROM `$table`");
# Column 3 of a SHOW INDEX statement contains the name of the index. # Column 3 of a SHOW INDEX statement contains the name of the index.
return @{$self->selectcol_arrayref($sth, {Columns => [3]})}; return @{$self->selectcol_arrayref($sth, {Columns => [3]})};
......
...@@ -2282,7 +2282,7 @@ sub get_add_column_ddl { ...@@ -2282,7 +2282,7 @@ sub get_add_column_ddl {
# XXX - Note that although this works for MySQL, most databases will fail # XXX - Note that although this works for MySQL, most databases will fail
# before this point, if we haven't set a default. # before this point, if we haven't set a default.
(push(@statements, "UPDATE $table SET $column = $init_value")) (push(@statements, "UPDATE `$table` SET $column = $init_value"))
if defined $init_value; if defined $init_value;
if (defined $definition->{REFERENCES}) { if (defined $definition->{REFERENCES}) {
...@@ -2427,7 +2427,7 @@ sub _set_nulls_sql { ...@@ -2427,7 +2427,7 @@ sub _set_nulls_sql {
} }
my @sql; my @sql;
if (defined $default) { if (defined $default) {
push(@sql, "UPDATE $table SET $column = $default" . " WHERE $column IS NULL"); push(@sql, "UPDATE `$table` SET $column = $default" . " WHERE $column IS NULL");
} }
return @sql; return @sql;
} }
......
...@@ -191,7 +191,7 @@ sub get_alter_column_ddl { ...@@ -191,7 +191,7 @@ sub get_alter_column_ddl {
my @statements; my @statements;
push( push(
@statements, "UPDATE $table SET $column = $set_nulls_to @statements, "UPDATE `$table` SET $column = $set_nulls_to
WHERE $column IS NULL" WHERE $column IS NULL"
) if defined $set_nulls_to; ) if defined $set_nulls_to;
...@@ -385,7 +385,7 @@ sub column_info_to_column { ...@@ -385,7 +385,7 @@ sub column_info_to_column {
# Unfortunately, the only way to do this in DBI is to query the # Unfortunately, the only way to do this in DBI is to query the
# database, so we have to break the rule here that Schema normally # database, so we have to break the rule here that Schema normally
# doesn't touch the live DB. # doesn't touch the live DB.
my $ref_sth = $dbh->prepare("SELECT $col_name FROM $table LIMIT 1"); my $ref_sth = $dbh->prepare("SELECT $col_name FROM `$table` LIMIT 1");
$ref_sth->execute; $ref_sth->execute;
if ($ref_sth->{mysql_is_auto_increment}->[0]) { if ($ref_sth->{mysql_is_auto_increment}->[0]) {
if ($type eq 'MEDIUMINT') { if ($type eq 'MEDIUMINT') {
......
...@@ -440,7 +440,7 @@ sub create { ...@@ -440,7 +440,7 @@ sub create {
sub ValidateGroupName { sub ValidateGroupName {
my ($name, @users) = (@_); my ($name, @users) = (@_);
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $query = "SELECT id FROM groups " . "WHERE name = ?"; my $query = "SELECT id FROM `groups` " . "WHERE name = ?";
if (Bugzilla->params->{'usevisibilitygroups'}) { if (Bugzilla->params->{'usevisibilitygroups'}) {
my @visible = (-1); my @visible = (-1);
foreach my $user (@users) { foreach my $user (@users) {
......
...@@ -1025,7 +1025,7 @@ sub _add_unique_login_name_index_to_profiles { ...@@ -1025,7 +1025,7 @@ sub _add_unique_login_name_index_to_profiles {
my ($table, $field) = (@$i); my ($table, $field) = (@$i);
if ($dbh->bz_table_info($table)) { if ($dbh->bz_table_info($table)) {
print " Updating $table.$field...\n"; print " Updating $table.$field...\n";
$dbh->do("UPDATE $table SET $field = $u1 " . "WHERE $field = $u2"); $dbh->do("UPDATE `$table` SET $field = $u1 " . "WHERE $field = $u2");
} }
} }
$dbh->do("DELETE FROM profiles WHERE userid = $u2"); $dbh->do("DELETE FROM profiles WHERE userid = $u2");
...@@ -1651,7 +1651,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1651,7 +1651,7 @@ sub _convert_groups_system_from_groupset {
# Convert all existing groupset records to map entries before removing # Convert all existing groupset records to map entries before removing
# groupset fields or removing "bit" from groups. # groupset fields or removing "bit" from groups.
my $sth = $dbh->prepare("SELECT bit, id FROM groups WHERE bit > 0"); my $sth = $dbh->prepare("SELECT bit, id FROM `groups` WHERE bit > 0");
$sth->execute(); $sth->execute();
while (my ($bit, $gid) = $sth->fetchrow_array) { while (my ($bit, $gid) = $sth->fetchrow_array) {
...@@ -1746,7 +1746,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1746,7 +1746,7 @@ sub _convert_groups_system_from_groupset {
# Get names of groups added. # Get names of groups added.
my $sth2 = $dbh->prepare( my $sth2 = $dbh->prepare(
"SELECT name FROM groups "SELECT name FROM `groups`
WHERE (bit & $added) != 0 WHERE (bit & $added) != 0
AND (bit & $removed) = 0" AND (bit & $removed) = 0"
); );
...@@ -1758,7 +1758,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1758,7 +1758,7 @@ sub _convert_groups_system_from_groupset {
# Get names of groups removed. # Get names of groups removed.
$sth2 = $dbh->prepare( $sth2 = $dbh->prepare(
"SELECT name FROM groups "SELECT name FROM `groups`
WHERE (bit & $removed) != 0 WHERE (bit & $removed) != 0
AND (bit & $added) = 0" AND (bit & $added) = 0"
); );
...@@ -1772,7 +1772,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1772,7 +1772,7 @@ sub _convert_groups_system_from_groupset {
# missing groups. # missing groups.
$sth2 = $dbh->prepare( $sth2 = $dbh->prepare(
"SELECT ($added & ~BIT_OR(bit)) "SELECT ($added & ~BIT_OR(bit))
FROM groups" FROM `groups`"
); );
$sth2->execute(); $sth2->execute();
my ($miss) = $sth2->fetchrow_array; my ($miss) = $sth2->fetchrow_array;
...@@ -1786,7 +1786,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1786,7 +1786,7 @@ sub _convert_groups_system_from_groupset {
# missing groups. # missing groups.
$sth2 = $dbh->prepare( $sth2 = $dbh->prepare(
"SELECT ($removed & ~BIT_OR(bit)) "SELECT ($removed & ~BIT_OR(bit))
FROM groups" FROM `groups`"
); );
$sth2->execute(); $sth2->execute();
($miss) = $sth2->fetchrow_array; ($miss) = $sth2->fetchrow_array;
...@@ -1823,7 +1823,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1823,7 +1823,7 @@ sub _convert_groups_system_from_groupset {
# Get names of groups added. # Get names of groups added.
my $sth2 = $dbh->prepare( my $sth2 = $dbh->prepare(
"SELECT name FROM groups "SELECT name FROM `groups`
WHERE (bit & $added) != 0 WHERE (bit & $added) != 0
AND (bit & $removed) = 0" AND (bit & $removed) = 0"
); );
...@@ -1835,7 +1835,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1835,7 +1835,7 @@ sub _convert_groups_system_from_groupset {
# Get names of groups removed. # Get names of groups removed.
$sth2 = $dbh->prepare( $sth2 = $dbh->prepare(
"SELECT name FROM groups "SELECT name FROM `groups`
WHERE (bit & $removed) != 0 WHERE (bit & $removed) != 0
AND (bit & $added) = 0" AND (bit & $added) = 0"
); );
...@@ -1864,7 +1864,7 @@ sub _convert_groups_system_from_groupset { ...@@ -1864,7 +1864,7 @@ sub _convert_groups_system_from_groupset {
# Identify admin group. # Identify admin group.
my ($admin_gid) my ($admin_gid)
= $dbh->selectrow_array("SELECT id FROM groups WHERE name = 'admin'"); = $dbh->selectrow_array("SELECT id FROM `groups` WHERE name = 'admin'");
if (!$admin_gid) { if (!$admin_gid) {
$dbh->do(q{INSERT INTO groups (name, description) $dbh->do(q{INSERT INTO groups (name, description)
VALUES ('admin', 'Administrators')} VALUES ('admin', 'Administrators')}
...@@ -2134,7 +2134,7 @@ sub _setup_usebuggroups_backward_compatibility { ...@@ -2134,7 +2134,7 @@ sub _setup_usebuggroups_backward_compatibility {
my $sth = $dbh->prepare( my $sth = $dbh->prepare(
"SELECT groups.id, products.id, groups.name, "SELECT groups.id, products.id, groups.name,
products.name products.name
FROM groups, products FROM `groups`, products
WHERE isbuggroup != 0" WHERE isbuggroup != 0"
); );
$sth->execute(); $sth->execute();
...@@ -2495,7 +2495,7 @@ sub _fix_group_with_empty_name { ...@@ -2495,7 +2495,7 @@ sub _fix_group_with_empty_name {
# Note that there can be at most one such group (because of # Note that there can be at most one such group (because of
# the SQL index on the name column). # the SQL index on the name column).
my ($emptygroupid) my ($emptygroupid)
= $dbh->selectrow_array("SELECT id FROM groups where name = ''"); = $dbh->selectrow_array("SELECT id FROM `groups` where name = ''");
if ($emptygroupid) { if ($emptygroupid) {
# There is a group with an empty name; find a name to rename it # There is a group with an empty name; find a name to rename it
...@@ -2503,7 +2503,7 @@ sub _fix_group_with_empty_name { ...@@ -2503,7 +2503,7 @@ sub _fix_group_with_empty_name {
# group_$gid and add _<n> if necessary. # group_$gid and add _<n> if necessary.
my $trycount = 0; my $trycount = 0;
my $trygroupname; my $trygroupname;
my $sth = $dbh->prepare("SELECT 1 FROM groups where name = ?"); my $sth = $dbh->prepare("SELECT 1 FROM `groups` where name = ?");
my $name_exists = 1; my $name_exists = 1;
while ($name_exists) { while ($name_exists) {
...@@ -2948,7 +2948,7 @@ sub _rederive_regex_groups { ...@@ -2948,7 +2948,7 @@ sub _rederive_regex_groups {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $regex_groups_exist = $dbh->selectrow_array( my $regex_groups_exist = $dbh->selectrow_array(
"SELECT 1 FROM groups WHERE userregexp = '' " . $dbh->sql_limit(1)); "SELECT 1 FROM `groups` WHERE userregexp = '' " . $dbh->sql_limit(1));
return if !$regex_groups_exist; return if !$regex_groups_exist;
my $regex_derivations my $regex_derivations
...@@ -4154,13 +4154,13 @@ sub _fix_flagclusions_indexes { ...@@ -4154,13 +4154,13 @@ sub _fix_flagclusions_indexes {
# Remove duplicated entries # Remove duplicated entries
my $dupes = $dbh->selectall_arrayref(" my $dupes = $dbh->selectall_arrayref("
SELECT type_id, product_id, component_id, COUNT(*) AS count SELECT type_id, product_id, component_id, COUNT(*) AS count
FROM $table " FROM `$table` "
. $dbh->sql_group_by('type_id, product_id, component_id') . " . $dbh->sql_group_by('type_id, product_id, component_id') . "
HAVING COUNT(*) > 1", {Slice => {}}); HAVING COUNT(*) > 1", {Slice => {}});
say "Removing duplicated entries from the '$table' table..." if @$dupes; say "Removing duplicated entries from the '$table' table..." if @$dupes;
foreach my $dupe (@$dupes) { foreach my $dupe (@$dupes) {
$dbh->do( $dbh->do(
"DELETE FROM $table "DELETE FROM `$table`
WHERE type_id = ? AND product_id = ? AND component_id = ?", WHERE type_id = ? AND product_id = ? AND component_id = ?",
undef, $dupe->{type_id}, $dupe->{product_id}, $dupe->{component_id} undef, $dupe->{type_id}, $dupe->{product_id}, $dupe->{component_id}
); );
......
...@@ -128,7 +128,7 @@ sub _load_from_db { ...@@ -128,7 +128,7 @@ sub _load_from_db {
$object_data = $dbh->selectrow_hashref( $object_data = $dbh->selectrow_hashref(
qq{ qq{
SELECT $columns FROM $table SELECT $columns FROM `$table`
WHERE $id_field = ?}, undef, $id WHERE $id_field = ?}, undef, $id
); );
} }
...@@ -159,7 +159,7 @@ sub _load_from_db { ...@@ -159,7 +159,7 @@ sub _load_from_db {
map { trick_taint($_) } @values; map { trick_taint($_) } @values;
$object_data $object_data
= $dbh->selectrow_hashref("SELECT $columns FROM $table WHERE $condition", = $dbh->selectrow_hashref("SELECT $columns FROM `$table` WHERE $condition",
undef, @values); undef, @values);
} }
return $object_data; return $object_data;
...@@ -386,7 +386,7 @@ sub _do_list_select { ...@@ -386,7 +386,7 @@ sub _do_list_select {
} }
if (!$objects) { if (!$objects) {
my $sql = "SELECT $cols FROM $table"; my $sql = "SELECT $cols FROM `$table`";
if (defined $where) { if (defined $where) {
$sql .= " WHERE $where "; $sql .= " WHERE $where ";
} }
...@@ -533,7 +533,7 @@ sub update { ...@@ -533,7 +533,7 @@ sub update {
my $columns = join(', ', map {"$_ = ?"} @update_columns); my $columns = join(', ', map {"$_ = ?"} @update_columns);
$dbh->do("UPDATE $table SET $columns WHERE $id_field = ?", $dbh->do("UPDATE `$table` SET $columns WHERE $id_field = ?",
undef, @values, $self->id) undef, @values, $self->id)
if @values; if @values;
...@@ -565,7 +565,7 @@ sub remove_from_db { ...@@ -565,7 +565,7 @@ sub remove_from_db {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
$dbh->bz_start_transaction(); $dbh->bz_start_transaction();
$self->audit_log(AUDIT_REMOVE) if $self->AUDIT_REMOVES; $self->audit_log(AUDIT_REMOVE) if $self->AUDIT_REMOVES;
$dbh->do("DELETE FROM $table WHERE $id_field = ?", undef, $self->id); $dbh->do("DELETE FROM `$table` WHERE $id_field = ?", undef, $self->id);
$dbh->bz_commit_transaction(); $dbh->bz_commit_transaction();
if ($self->USE_MEMCACHED) { if ($self->USE_MEMCACHED) {
...@@ -645,7 +645,7 @@ sub any_exist { ...@@ -645,7 +645,7 @@ sub any_exist {
my $table = $class->DB_TABLE; my $table = $class->DB_TABLE;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $any_exist my $any_exist
= $dbh->selectrow_array("SELECT 1 FROM $table " . $dbh->sql_limit(1)); = $dbh->selectrow_array("SELECT 1 FROM `$table` " . $dbh->sql_limit(1));
return $any_exist ? 1 : 0; return $any_exist ? 1 : 0;
} }
......
...@@ -625,7 +625,7 @@ sub group_controls { ...@@ -625,7 +625,7 @@ sub group_controls {
# Include name to the list, to allow us sorting data more easily. # Include name to the list, to allow us sorting data more easily.
my $query = qq{SELECT id, name, entry, membercontrol, othercontrol, my $query = qq{SELECT id, name, entry, membercontrol, othercontrol,
canedit, editcomponents, editbugs, canconfirm canedit, editcomponents, editbugs, canconfirm
FROM groups FROM `groups`
LEFT JOIN group_control_map LEFT JOIN group_control_map
ON id = group_id ON id = group_id
$where_or_and product_id = ? $where_or_and product_id = ?
......
...@@ -2054,12 +2054,12 @@ sub build_subselect { ...@@ -2054,12 +2054,12 @@ sub build_subselect {
# unconditionally, so we return the subselect and let the DB optimizer # unconditionally, so we return the subselect and let the DB optimizer
# restrict the search based on other search criteria. # restrict the search based on other search criteria.
my $not = $negate ? "NOT" : ""; my $not = $negate ? "NOT" : "";
return "$outer $not IN (SELECT DISTINCT $inner FROM $table WHERE $cond)"; return "$outer $not IN (SELECT DISTINCT $inner FROM `$table` WHERE $cond)";
} }
# Execute subselects immediately to avoid dependent subqueries, which are # Execute subselects immediately to avoid dependent subqueries, which are
# large performance hits on MySql # large performance hits on MySql
my $q = "SELECT DISTINCT $inner FROM $table WHERE $cond"; my $q = "SELECT DISTINCT $inner FROM `$table` WHERE $cond";
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $list = $dbh->selectcol_arrayref($q); my $list = $dbh->selectcol_arrayref($q);
return $negate ? "1=1" : "1=2" unless @$list; return $negate ? "1=1" : "1=2" unless @$list;
...@@ -2484,7 +2484,7 @@ sub _user_nonchanged { ...@@ -2484,7 +2484,7 @@ sub _user_nonchanged {
my $table = $first_join->{table}; my $table = $first_join->{table};
my $columns = "bug_id"; my $columns = "bug_id";
$columns .= ",isprivate" if @{$first_join->{extra}}; $columns .= ",isprivate" if @{$first_join->{extra}};
my $new_table = "SELECT DISTINCT $columns FROM $table AS $as $join_sql"; my $new_table = "SELECT DISTINCT $columns FROM `$table` AS $as $join_sql";
$first_join->{table} = "($new_table)"; $first_join->{table} = "($new_table)";
# We always want to LEFT JOIN the generated table. # We always want to LEFT JOIN the generated table.
......
...@@ -176,7 +176,7 @@ sub rename_field_value { ...@@ -176,7 +176,7 @@ sub rename_field_value {
my %queries = @{ my %queries = @{
$dbh->selectcol_arrayref( $dbh->selectcol_arrayref(
"SELECT $id_field, query FROM $table WHERE query LIKE ?", "SELECT $id_field, query FROM `$table` WHERE query LIKE ?",
{Columns => [1, 2]}, {Columns => [1, 2]},
"\%$old_sql\%" "\%$old_sql\%"
) )
...@@ -193,7 +193,7 @@ sub rename_field_value { ...@@ -193,7 +193,7 @@ sub rename_field_value {
# boolean charts. Users will have to fix those themselves. # boolean charts. Users will have to fix those themselves.
$query =~ s/\bvalue\Q$chart_id\E=\Q$old\E\b/value$chart_id=$new/i; $query =~ s/\bvalue\Q$chart_id\E=\Q$old\E\b/value$chart_id=$new/i;
} }
$dbh->do("UPDATE $table SET query = ? WHERE $id_field = ?", undef, $query, $id); $dbh->do("UPDATE `$table` SET query = ? WHERE $id_field = ?", undef, $query, $id);
Bugzilla->memcached->clear({table => $table, id => $id}); Bugzilla->memcached->clear({table => $table, id => $id});
} }
......
...@@ -276,7 +276,7 @@ sub GenerateUniqueToken { ...@@ -276,7 +276,7 @@ sub GenerateUniqueToken {
$column ||= "token"; $column ||= "token";
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $sth = $dbh->prepare("SELECT 1 FROM $table WHERE $column = ?"); my $sth = $dbh->prepare("SELECT 1 FROM `$table` WHERE $column = ?");
while ($duplicate) { while ($duplicate) {
++$tries; ++$tries;
......
...@@ -1630,7 +1630,7 @@ sub visible_groups_direct { ...@@ -1630,7 +1630,7 @@ sub visible_groups_direct {
} }
else { else {
# All groups are visible if usevisibilitygroups is off. # All groups are visible if usevisibilitygroups is off.
$sth = $dbh->prepare('SELECT id FROM groups'); $sth = $dbh->prepare('SELECT id FROM `groups`');
} }
$sth->execute(); $sth->execute();
...@@ -1694,7 +1694,7 @@ sub derive_regexp_groups { ...@@ -1694,7 +1694,7 @@ sub derive_regexp_groups {
$sth = $dbh->prepare( $sth = $dbh->prepare(
"SELECT id, userregexp, user_group_map.group_id "SELECT id, userregexp, user_group_map.group_id
FROM groups FROM `groups`
LEFT JOIN user_group_map LEFT JOIN user_group_map
ON groups.id = user_group_map.group_id ON groups.id = user_group_map.group_id
AND user_group_map.user_id = ? AND user_group_map.user_id = ?
......
...@@ -48,7 +48,7 @@ sub CheckGroupID { ...@@ -48,7 +48,7 @@ sub CheckGroupID {
ThrowUserError("group_not_specified") unless $group_id; ThrowUserError("group_not_specified") unless $group_id;
( (
detaint_natural($group_id) && Bugzilla->dbh->selectrow_array( detaint_natural($group_id) && Bugzilla->dbh->selectrow_array(
"SELECT id FROM groups WHERE id = ?", "SELECT id FROM `groups` WHERE id = ?",
undef, $group_id undef, $group_id
) )
) || ThrowUserError("invalid_group_ID"); ) || ThrowUserError("invalid_group_ID");
......
...@@ -717,7 +717,7 @@ sub userDataToVars { ...@@ -717,7 +717,7 @@ sub userDataToVars {
) THEN 1 ELSE 0 END) ) THEN 1 ELSE 0 END)
AS derivedmember, AS derivedmember,
COUNT(directbless.group_id) AS directbless COUNT(directbless.group_id) AS directbless
FROM groups FROM `groups`
LEFT JOIN user_group_map AS directmember LEFT JOIN user_group_map AS directmember
ON directmember.group_id = id ON directmember.group_id = id
AND directmember.user_id = ? AND directmember.user_id = ?
......
...@@ -391,7 +391,7 @@ sub DoPermissions { ...@@ -391,7 +391,7 @@ sub DoPermissions {
my $groups my $groups
= $dbh->selectall_arrayref( = $dbh->selectall_arrayref(
"SELECT DISTINCT name, description FROM groups WHERE id IN (" "SELECT DISTINCT name, description FROM `groups` WHERE id IN ("
. $user->groups_as_string . $user->groups_as_string
. ") ORDER BY name"); . ") ORDER BY name");
foreach my $group (@$groups) { foreach my $group (@$groups) {
......
...@@ -250,7 +250,7 @@ sub get_next_event { ...@@ -250,7 +250,7 @@ sub get_next_event {
} }
} }
elsif ($mailto_type == MAILTO_GROUP) { elsif ($mailto_type == MAILTO_GROUP) {
my $sth = $dbh->prepare("SELECT name FROM groups " . "WHERE id=?"); my $sth = $dbh->prepare("SELECT name FROM `groups` " . "WHERE id=?");
$sth->execute($mailto); $sth->execute($mailto);
my $groupname = $sth->fetch->[0]; my $groupname = $sth->fetch->[0];
my $group_id = Bugzilla::Group::ValidateGroupName($groupname, $owner); my $group_id = Bugzilla::Group::ValidateGroupName($groupname, $owner);
......
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