From 37722eca39874bb6abdcd120e3e458bd62dea62b Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Wed, 5 Jul 2017 11:43:18 -0700 Subject: Bug 1377933 - Remove trailing whitespace from all perl files --- Bugzilla/DB/Schema/Mysql.pm | 32 ++++++++++----------- Bugzilla/DB/Schema/Oracle.pm | 66 ++++++++++++++++++++++---------------------- Bugzilla/DB/Schema/Pg.pm | 18 ++++++------ Bugzilla/DB/Schema/Sqlite.pm | 24 ++++++++-------- 4 files changed, 70 insertions(+), 70 deletions(-) (limited to 'Bugzilla/DB/Schema') diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm index 2e40e38cf..ec25bbac6 100644 --- a/Bugzilla/DB/Schema/Mysql.pm +++ b/Bugzilla/DB/Schema/Mysql.pm @@ -21,7 +21,7 @@ use Bugzilla::Error; use base qw(Bugzilla::DB::Schema); -# This is for column_info_to_column, to know when a tinyint is a +# This is for column_info_to_column, to know when a tinyint is a # boolean and when it's really a tinyint. This only has to be accurate # up to and through 2.19.3, because that's the only time we need # column_info_to_column. @@ -30,7 +30,7 @@ use base qw(Bugzilla::DB::Schema); # that should be interpreted as a BOOLEAN instead of as an INT1 when # reading in the Schema from the disk. The values are discarded; I just # used "1" for simplicity. -# +# # THIS CONSTANT IS ONLY USED FOR UPGRADES FROM 2.18 OR EARLIER. DON'T # UPDATE IT TO MODERN COLUMN NAMES OR DEFINITIONS. use constant BOOLEAN_MAP => { @@ -40,7 +40,7 @@ use constant BOOLEAN_MAP => { longdescs => {isprivate => 1, already_wrapped => 1}, attachments => {ispatch => 1, isobsolete => 1, isprivate => 1}, flags => {is_active => 1}, - flagtypes => {is_active => 1, is_requestable => 1, + flagtypes => {is_active => 1, is_requestable => 1, is_requesteeble => 1, is_multiplicable => 1}, fielddefs => {mailhead => 1, obsolete => 1}, bug_status => {isactive => 1}, @@ -88,7 +88,7 @@ sub _initialize { $self->{db_specific} = { BOOLEAN => 'tinyint', - FALSE => '0', + FALSE => '0', TRUE => '1', INT1 => 'tinyint', @@ -124,7 +124,7 @@ sub _get_create_table_ddl { my $charset = Bugzilla->dbh->bz_db_is_utf8 ? "CHARACTER SET utf8" : ''; my $type = grep($_ eq $table, MYISAM_TABLES) ? 'MYISAM' : 'InnoDB'; - return($self->SUPER::_get_create_table_ddl($table) + return($self->SUPER::_get_create_table_ddl($table) . " ENGINE = $type $charset"); } #eosub--_get_create_table_ddl @@ -150,7 +150,7 @@ sub get_create_database_sql { my ($self, $name) = @_; # We only create as utf8 if we have no params (meaning we're doing # a new installation) or if the utf8 param is on. - my $create_utf8 = Bugzilla->params->{'utf8'} + my $create_utf8 = Bugzilla->params->{'utf8'} || !defined Bugzilla->params->{'utf8'}; my $charset = $create_utf8 ? "CHARACTER SET utf8" : ''; return ("CREATE DATABASE $name $charset"); @@ -180,7 +180,7 @@ sub get_alter_column_ddl { delete $old_defaultless{DEFAULT}; delete $new_defaultless{DEFAULT}; if (!$self->columns_equal($old_def, $new_def) - && $self->columns_equal(\%new_defaultless, \%old_defaultless)) + && $self->columns_equal(\%new_defaultless, \%old_defaultless)) { if (!defined $new_def->{DEFAULT}) { push(@statements, @@ -193,7 +193,7 @@ sub get_alter_column_ddl { } else { my $new_ddl = $self->get_type_ddl(\%new_def_copy); - push(@statements, "ALTER TABLE $table CHANGE COLUMN + push(@statements, "ALTER TABLE $table CHANGE COLUMN $column $column $new_ddl"); } @@ -213,7 +213,7 @@ sub get_drop_fk_sql { # MySQL requires, and will create, an index on any column with # an FK. It will name it after the fk, which we never do. - # So if there's an index named after the fk, we also have to delete it. + # So if there's an index named after the fk, we also have to delete it. if ($dbh->bz_index_info_real($table, $fk_name)) { push(@sql, $self->get_drop_index_ddl($table, $fk_name)); } @@ -227,7 +227,7 @@ sub get_drop_index_ddl { } # A special function for MySQL, for renaming a lot of indexes. -# Index renames is a hash, where the key is a string - the +# Index renames is a hash, where the key is a string - the # old names of the index, and the value is a hash - the index # definition that we're renaming to, with an extra key of "NAME" # that contains the new index name. @@ -305,14 +305,14 @@ sub column_info_to_column { # be dropping it soon, or it's a custom end-user column, in which # case having a bogus default won't harm anything. my $schema_column = $self->get_column($table, $col_name); - unless ( (!$column_info->{COLUMN_DEF} + unless ( (!$column_info->{COLUMN_DEF} || $column_info->{COLUMN_DEF} eq '0000-00-00 00:00:00' || $column_info->{COLUMN_DEF} eq '0.00') - && $schema_column + && $schema_column && !exists $schema_column->{DEFAULT}) { - + my $default = $column_info->{COLUMN_DEF}; - # Schema uses '0' for the defaults for decimal fields. + # Schema uses '0' for the defaults for decimal fields. $default = 0 if $default =~ /^0\.0+$/; # If we're not a number, we're a string and need to be # quoted. @@ -353,7 +353,7 @@ sub column_info_to_column { } elsif ($type eq 'SMALLINT') { $type = 'SMALLSERIAL'; - } + } else { $type = 'INTSERIAL'; } @@ -362,7 +362,7 @@ sub column_info_to_column { } - # For all other db-specific types, check if they exist in + # For all other db-specific types, check if they exist in # REVERSE_MAPPING and use the type found there. if (exists REVERSE_MAPPING->{$type}) { $type = REVERSE_MAPPING->{$type}; diff --git a/Bugzilla/DB/Schema/Oracle.pm b/Bugzilla/DB/Schema/Oracle.pm index 7572f80cf..b67ddfd59 100644 --- a/Bugzilla/DB/Schema/Oracle.pm +++ b/Bugzilla/DB/Schema/Oracle.pm @@ -38,7 +38,7 @@ sub _initialize { $self->{db_specific} = { BOOLEAN => 'integer', - FALSE => '0', + FALSE => '0', TRUE => '1', INT1 => 'integer', @@ -77,8 +77,8 @@ sub get_table_ddl { while (@fields) { my $field_name = shift @fields; my $field_info = shift @fields; - # Create triggers to deal with empty string. - if ( $field_info->{TYPE} =~ /varchar|TEXT/i + # Create triggers to deal with empty string. + if ( $field_info->{TYPE} =~ /varchar|TEXT/i && $field_info->{NOTNULL} ) { push (@ddl, _get_notnull_trigger_ddl($table, $field_name)); } @@ -91,21 +91,21 @@ sub get_table_ddl { } #eosub--get_table_ddl -# Extend superclass method to create Oracle Text indexes if index type +# Extend superclass method to create Oracle Text indexes if index type # is FULLTEXT from schema. Returns a "create index" SQL statement. sub _get_create_index_ddl { my ($self, $table_name, $index_name, $index_fields, $index_type) = @_; $index_name = "idx_" . $self->_hash_identifier($index_name); if ($index_type eq 'FULLTEXT') { - my $sql = "CREATE INDEX $index_name ON $table_name (" + my $sql = "CREATE INDEX $index_name ON $table_name (" . join(',',@$index_fields) . ") INDEXTYPE IS CTXSYS.CONTEXT " . " PARAMETERS('LEXER BZ_LEX SYNC(ON COMMIT)')" ; return $sql; } - return($self->SUPER::_get_create_index_ddl($table_name, $index_name, + return($self->SUPER::_get_create_index_ddl($table_name, $index_name, $index_fields, $index_type)); } @@ -118,7 +118,7 @@ sub get_drop_index_ddl { return $self->SUPER::get_drop_index_ddl($table, $name); } -# Oracle supports the use of FOREIGN KEY integrity constraints +# Oracle supports the use of FOREIGN KEY integrity constraints # to define the referential integrity actions, including: # - Update and delete No Action (default) # - Delete CASCADE @@ -182,7 +182,7 @@ sub _get_fk_name { my $to_column = $references->{COLUMN}; my $fk_name = "${table}_${column}_${to_table}_${to_column}"; $fk_name = "fk_" . $self->_hash_identifier($fk_name); - + return $fk_name; } @@ -206,7 +206,7 @@ sub get_add_column_ddl { } else { @sql = $self->SUPER::get_add_column_ddl(@_); - # Create triggers to deal with empty string. + # Create triggers to deal with empty string. if ($definition->{TYPE} =~ /varchar|TEXT/i && $definition->{NOTNULL}) { push(@sql, _get_notnull_trigger_ddl($table, $column)); } @@ -224,7 +224,7 @@ sub get_alter_column_ddl { # If the types have changed, we have to deal with that. if (uc(trim($old_def->{TYPE})) ne uc(trim($new_def->{TYPE}))) { - push(@statements, $self->_get_alter_type_sql($table, $column, + push(@statements, $self->_get_alter_type_sql($table, $column, $new_def, $old_def)); } @@ -244,8 +244,8 @@ sub get_alter_column_ddl { . " DEFAULT NULL"); } # If we went from no default to a default, or we changed the default. - elsif ( (defined $default && !defined $default_old) || - ($default ne $default_old) ) + elsif ( (defined $default && !defined $default_old) || + ($default ne $default_old) ) { push(@statements, "ALTER TABLE $table MODIFY $column " . " DEFAULT $default"); @@ -256,8 +256,8 @@ sub get_alter_column_ddl { my $setdefault; # Handle any fields that were NULL before, if we have a default, $setdefault = $default if defined $default; - # But if we have a set_nulls_to, that overrides the DEFAULT - # (although nobody would usually specify both a default and + # But if we have a set_nulls_to, that overrides the DEFAULT + # (although nobody would usually specify both a default and # a set_nulls_to.) $setdefault = $set_nulls_to if defined $set_nulls_to; if (defined $setdefault) { @@ -275,7 +275,7 @@ sub get_alter_column_ddl { push(@statements, "ALTER TABLE $table MODIFY $column" . " NULL"); push(@statements, "DROP TRIGGER ${table}_${column}") - if $new_def->{TYPE} =~ /varchar|text/i + if $new_def->{TYPE} =~ /varchar|text/i && $old_def->{TYPE} =~ /varchar|text/i; } @@ -296,34 +296,34 @@ sub _get_alter_type_sql { my @statements; my $type = $new_def->{TYPE}; - $type = $self->{db_specific}->{$type} + $type = $self->{db_specific}->{$type} if exists $self->{db_specific}->{$type}; if ($type =~ /serial/i && $old_def->{TYPE} !~ /serial/i) { - die("You cannot specify a DEFAULT on a SERIAL-type column.") + die("You cannot specify a DEFAULT on a SERIAL-type column.") if $new_def->{DEFAULT}; } - if ( ($old_def->{TYPE} =~ /LONGTEXT/i && $new_def->{TYPE} !~ /LONGTEXT/i) + if ( ($old_def->{TYPE} =~ /LONGTEXT/i && $new_def->{TYPE} !~ /LONGTEXT/i) || ($old_def->{TYPE} !~ /LONGTEXT/i && $new_def->{TYPE} =~ /LONGTEXT/i) ) { - # LONG to VARCHAR or VARCHAR to LONG is not allowed in Oracle, + # LONG to VARCHAR or VARCHAR to LONG is not allowed in Oracle, # just a way to work around. # Determine whether column_temp is already exist. my $dbh=Bugzilla->dbh; my $column_exist = $dbh->selectcol_arrayref( - "SELECT CNAME FROM COL WHERE TNAME = UPPER(?) AND + "SELECT CNAME FROM COL WHERE TNAME = UPPER(?) AND CNAME = UPPER(?)", undef,$table,$column . "_temp"); if(!@$column_exist) { - push(@statements, - "ALTER TABLE $table ADD ${column}_temp $type"); + push(@statements, + "ALTER TABLE $table ADD ${column}_temp $type"); } push(@statements, "UPDATE $table SET ${column}_temp = $column"); push(@statements, "COMMIT"); push(@statements, "ALTER TABLE $table DROP COLUMN $column"); - push(@statements, + push(@statements, "ALTER TABLE $table RENAME COLUMN ${column}_temp TO $column"); - } else { + } else { push(@statements, "ALTER TABLE $table MODIFY $column $type"); } @@ -337,15 +337,15 @@ sub _get_alter_type_sql { push(@statements, "DROP SEQUENCE ${table}_${column}_SEQ"); push(@statements, "DROP TRIGGER ${table}_${column}_TR"); } - + # If this column is changed to type TEXT/VARCHAR, we need to deal with # empty string. - if ( $old_def->{TYPE} !~ /varchar|text/i - && $new_def->{TYPE} =~ /varchar|text/i + if ( $old_def->{TYPE} !~ /varchar|text/i + && $new_def->{TYPE} =~ /varchar|text/i && $new_def->{NOTNULL} ) { push (@statements, _get_notnull_trigger_ddl($table, $column)); - } + } # If this column is no longer TEXT/VARCHAR, we need to drop the trigger # that went along with it. if ( $old_def->{TYPE} =~ /varchar|text/i @@ -353,7 +353,7 @@ sub _get_alter_type_sql { && $new_def->{TYPE} !~ /varchar|text/i ) { push(@statements, "DROP TRIGGER ${table}_${column}"); - } + } return @statements; } @@ -495,13 +495,13 @@ sub _get_create_trigger_ddl { return $serial_sql; } -sub get_set_serial_sql { - my ($self, $table, $column, $value) = @_; +sub get_set_serial_sql { + my ($self, $table, $column, $value) = @_; my @sql; my $seq_name = "${table}_${column}_SEQ"; push(@sql, "DROP SEQUENCE ${seq_name}"); - push(@sql, $self->_get_create_seq_ddl($table, $column, $value)); + push(@sql, $self->_get_create_seq_ddl($table, $column, $value)); return @sql; -} +} 1; diff --git a/Bugzilla/DB/Schema/Pg.pm b/Bugzilla/DB/Schema/Pg.pm index d8550e2e8..7606faa3d 100644 --- a/Bugzilla/DB/Schema/Pg.pm +++ b/Bugzilla/DB/Schema/Pg.pm @@ -32,13 +32,13 @@ sub _initialize { if ($self->{schema}{$table}{INDEXES}) { foreach my $index (@{ $self->{schema}{$table}{INDEXES} }) { if (ref($index) eq 'HASH') { - delete($index->{TYPE}) if (exists $index->{TYPE} + delete($index->{TYPE}) if (exists $index->{TYPE} && $index->{TYPE} eq 'FULLTEXT'); } } foreach my $index (@{ $self->{abstract_schema}{$table}{INDEXES} }) { if (ref($index) eq 'HASH') { - delete($index->{TYPE}) if (exists $index->{TYPE} + delete($index->{TYPE}) if (exists $index->{TYPE} && $index->{TYPE} eq 'FULLTEXT'); } } @@ -48,7 +48,7 @@ sub _initialize { $self->{db_specific} = { BOOLEAN => 'smallint', - FALSE => '0', + FALSE => '0', TRUE => '1', INT1 => 'integer', @@ -98,7 +98,7 @@ sub get_rename_column_ddl { my $def = $self->get_column_abstract($table, $old_name); if ($def->{TYPE} =~ /SERIAL/i) { # We have to rename the series also. - push(@sql, "ALTER SEQUENCE ${table}_${old_name}_seq + push(@sql, "ALTER SEQUENCE ${table}_${old_name}_seq RENAME TO ${table}_${new_name}_seq"); } return @sql; @@ -148,11 +148,11 @@ sub _get_alter_type_sql { my @statements; my $type = $new_def->{TYPE}; - $type = $self->{db_specific}->{$type} + $type = $self->{db_specific}->{$type} if exists $self->{db_specific}->{$type}; if ($type =~ /serial/i && $old_def->{TYPE} !~ /serial/i) { - die("You cannot specify a DEFAULT on a SERIAL-type column.") + die("You cannot specify a DEFAULT on a SERIAL-type column.") if $new_def->{DEFAULT}; } @@ -171,16 +171,16 @@ sub _get_alter_type_sql { push(@statements, "SELECT setval('${table}_${column}_seq', MAX($table.$column)) FROM $table"); - push(@statements, "ALTER TABLE $table ALTER COLUMN $column + push(@statements, "ALTER TABLE $table ALTER COLUMN $column SET DEFAULT nextval('${table}_${column}_seq')"); } # If this column is no longer SERIAL, we need to drop the sequence # that went along with it. if ($old_def->{TYPE} =~ /serial/i && $new_def->{TYPE} !~ /serial/i) { - push(@statements, "ALTER TABLE $table ALTER COLUMN $column + push(@statements, "ALTER TABLE $table ALTER COLUMN $column DROP DEFAULT"); - push(@statements, "ALTER SEQUENCE ${table}_${column}_seq + push(@statements, "ALTER SEQUENCE ${table}_${column}_seq OWNED BY NONE"); push(@statements, "DROP SEQUENCE ${table}_${column}_seq"); } diff --git a/Bugzilla/DB/Schema/Sqlite.pm b/Bugzilla/DB/Schema/Sqlite.pm index 471df340c..6d524db59 100644 --- a/Bugzilla/DB/Schema/Sqlite.pm +++ b/Bugzilla/DB/Schema/Sqlite.pm @@ -28,7 +28,7 @@ sub _initialize { $self->{db_specific} = { BOOLEAN => 'integer', - FALSE => '0', + FALSE => '0', TRUE => '1', INT1 => 'integer', @@ -79,15 +79,15 @@ sub _sqlite_table_lines { # This does most of the "heavy lifting" of the schema-altering functions. sub _sqlite_alter_schema { my ($self, $table, $create_table, $options) = @_; - + # $create_table is sometimes an array in the form that _sqlite_table_lines # returns. if (ref $create_table) { $create_table = join(',', @$create_table) . "\n)"; } - + my $dbh = Bugzilla->dbh; - + my $random = generate_random_password(5); my $rename_to = "${table}_$random"; @@ -104,12 +104,12 @@ sub _sqlite_alter_schema { @insert_cols = map { $_ eq $from ? $to : $_ } @insert_cols; } } - + my $insert_str = join(',', @insert_cols); my $select_str = join(',', @select_cols); my $copy_sql = "INSERT INTO $table ($insert_str)" . " SELECT $select_str FROM $rename_to"; - + # We have to turn FKs off before doing this. Otherwise, when we rename # the table, all of the FKs in the other tables will be automatically # updated to point to the renamed table. Note that PRAGMA foreign_keys @@ -127,7 +127,7 @@ sub _sqlite_alter_schema { "DROP TABLE $rename_to", 'COMMIT TRANSACTION', 'PRAGMA foreign_keys = ON', - ); + ); } # For finding a particular column's definition in a CREATE TABLE statement. @@ -173,7 +173,7 @@ sub _get_create_table_ddl { sub get_type_ddl { my $self = shift; my $def = dclone($_[0]); - + my $ddl = $self->SUPER::get_type_ddl(@_); if ($def->{PRIMARYKEY} and $def->{TYPE} =~ /SERIAL/i) { $ddl =~ s/\bSERIAL\b/integer/; @@ -193,7 +193,7 @@ sub get_alter_column_ddl { my $self = shift; my ($table, $column, $new_def, $set_nulls_to) = @_; my $dbh = Bugzilla->dbh; - + my $table_sql = $self->_sqlite_create_table($table); my $new_ddl = $self->get_type_ddl($new_def); # When we do ADD COLUMN, columns can show up all on one line separated @@ -237,7 +237,7 @@ sub get_add_column_ddl { return $self->_sqlite_alter_schema($table, $table_sql, { pre_sql => \@pre_sql, extra_column => $column }); } - + return $self->SUPER::get_add_column_ddl(@_); } @@ -290,12 +290,12 @@ sub get_drop_fk_sql { my ($self, $table, $column, $references) = @_; my @clauses = $self->_sqlite_table_lines($table); my $fk_name = $self->_get_fk_name($table, $column, $references); - + my $line_re = qr/^\s+CONSTRAINT $fk_name /s; grep { $line_re } @clauses or die "Can't find $fk_name: " . join(',', @clauses); @clauses = grep { $_ !~ $line_re } @clauses; - + return $self->_sqlite_alter_schema($table, \@clauses); } -- cgit v1.2.3-24-g4f1b