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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
6f4d125a
Commit
6f4d125a
authored
Aug 03, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 508018: Speed up _fix_defaults for MySQL checksetup upgrades
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat
parent
e9024051
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
Mysql.pm
Bugzilla/DB/Mysql.pm
+22
-4
No files found.
Bugzilla/DB/Mysql.pm
View file @
6f4d125a
...
...
@@ -814,22 +814,40 @@ sub _fix_defaults {
# a default.
return
unless
(
defined
$assi_default
&&
$assi_default
ne
''
);
my
%
fix_columns
;
foreach
my
$table
(
$self
->
_bz_real_schema
->
get_table_list
())
{
foreach
my
$column
(
$self
->
bz_table_columns
(
$table
))
{
my
$abs_def
=
$self
->
bz_column_info
(
$table
,
$column
);
my
$abs_def
=
$self
->
bz_column_info
(
$table
,
$column
);
# BLOB/TEXT columns never have defaults
next
if
$abs_def
->
{
TYPE
}
=~
/BLOB|TEXT/i
;
if
(
!
defined
$abs_def
->
{
DEFAULT
})
{
# Get the exact default from the database without any
# "fixing" by bz_column_info_real.
my
$raw_info
=
$self
->
_bz_raw_column_info
(
$table
,
$column
);
my
$raw_default
=
$raw_info
->
{
COLUMN_DEF
};
if
(
defined
$raw_default
)
{
$self
->
bz_alter_column_raw
(
$table
,
$column
,
$abs_def
);
$raw_default
=
"''"
if
$raw_default
eq
''
;
print
"Removed incorrect DB default: $raw_default\n"
;
if
(
$raw_default
eq
''
)
{
# Only (var)char columns can have empty strings as
# defaults, so if we got an empty string for some
# other default type, then it's bogus.
next
unless
$abs_def
->
{
TYPE
}
=~
/char/i
;
$raw_default
=
"''"
;
}
$fix_columns
{
$table
}
||=
[]
;
push
(
@
{
$fix_columns
{
$table
}
},
$column
);
print
"$table.$column has incorrect DB default: $raw_default\n"
;
}
}
}
# foreach $column
}
# foreach $table
print
"Fixing defaults...\n"
;
foreach
my
$table
(
reverse
sort
keys
%
fix_columns
)
{
my
@alters
=
map
(
"ALTER COLUMN $_ DROP DEFAULT"
,
@
{
$fix_columns
{
$table
}
});
my
$sql
=
"ALTER TABLE $table "
.
join
(
','
,
@alters
);
$self
->
do
(
$sql
);
}
}
# There is a bug in MySQL 4.1.0 - 4.1.15 that makes certain SELECT
...
...
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