diff options
author | mkanat%bugzilla.org <> | 2009-08-17 21:31:02 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2009-08-17 21:31:02 +0000 |
commit | ef1a85038621e7e13ff850e9b1c33b504ebcde35 (patch) | |
tree | 6ce13d8993729c4af32732ec5caa562a5d41cda9 /Bugzilla/Install | |
parent | c023c92ea3bd7cf256d51557be29cfea1c055b01 (diff) | |
download | bugs-ef1a85038621e7e13ff850e9b1c33b504ebcde35.tar bugs-ef1a85038621e7e13ff850e9b1c33b504ebcde35.tar.gz bugs-ef1a85038621e7e13ff850e9b1c33b504ebcde35.tar.bz2 bugs-ef1a85038621e7e13ff850e9b1c33b504ebcde35.tar.xz bugs-ef1a85038621e7e13ff850e9b1c33b504ebcde35.zip |
Bug 509497: Implement sql_group_concat for all databases
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
Patch by Xiaoou Wu <xiaoou.wu@oracle.com> r=mkanat, a=mkanat
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 62 |
1 files changed, 16 insertions, 46 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 48fc06630..697e2fdcc 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -3133,52 +3133,22 @@ sub _populate_bugs_fulltext { my $bug_ids = $dbh->selectcol_arrayref('SELECT bug_id FROM bugs'); return if !@$bug_ids; - # Populating bugs_fulltext can be very slow for large installs, - # so we special-case any DB that supports GROUP_CONCAT, which is - # a much faster way to do things. - if (UNIVERSAL::can($dbh, 'sql_group_concat')) { - print "Populating bugs_fulltext..."; - print " (this can take a long time.)\n"; - $dbh->do( - q{INSERT INTO bugs_fulltext (bug_id, short_desc, comments, - comments_noprivate) - SELECT bugs.bug_id, bugs.short_desc, } - . $dbh->sql_group_concat('longdescs.thetext', '\'\n\'') - . ', ' . $dbh->sql_group_concat('nopriv.thetext', '\'\n\'') . - q{ FROM bugs - LEFT JOIN longdescs - ON bugs.bug_id = longdescs.bug_id - LEFT JOIN longdescs AS nopriv - ON longdescs.comment_id = nopriv.comment_id - AND nopriv.isprivate = 0 } - . $dbh->sql_group_by('bugs.bug_id', 'bugs.short_desc')); - } - # The slow way, without group_concat. - else { - print "Populating bugs_fulltext.short_desc...\n"; - $dbh->do('INSERT INTO bugs_fulltext (bug_id, short_desc) - SELECT bug_id, short_desc FROM bugs'); - - my $count = 1; - my $sth_all = $dbh->prepare('SELECT thetext FROM longdescs - WHERE bug_id = ?'); - my $sth_nopriv = $dbh->prepare( - 'SELECT thetext FROM longdescs - WHERE bug_id = ? AND isprivate = 0'); - my $sth_update = $dbh->prepare( - 'UPDATE bugs_fulltext SET comments = ?, comments_noprivate = ? - WHERE bug_id = ?'); - - print "Populating bugs_fulltext comment fields...\n"; - foreach my $id (@$bug_ids) { - my $all = $dbh->selectcol_arrayref($sth_all, undef, $id); - my $nopriv = $dbh->selectcol_arrayref($sth_nopriv, undef, $id); - $sth_update->execute(join("\n", @$all), join("\n", @$nopriv), $id); - indicate_progress({ total => scalar @$bug_ids, every => 100, - current => $count++ }); - } - print "\n"; - } + print "Populating bugs_fulltext..."; + print " (this can take a long time.)\n"; + my $newline = $dbh->quote("\n"); + $dbh->do( + q{INSERT INTO bugs_fulltext (bug_id, short_desc, comments, + comments_noprivate) + SELECT bugs.bug_id, bugs.short_desc, } + . $dbh->sql_group_concat('longdescs.thetext', $newline) + . ', ' . $dbh->sql_group_concat('nopriv.thetext', $newline) . + q{ FROM bugs + LEFT JOIN longdescs + ON bugs.bug_id = longdescs.bug_id + LEFT JOIN longdescs AS nopriv + ON longdescs.comment_id = nopriv.comment_id + AND nopriv.isprivate = 0 } + . $dbh->sql_group_by('bugs.bug_id', 'bugs.short_desc')); } } |