Bug 443458 - FEAT: Match the new db schema of bz3.0 [TABLE attachments]
FEAT: Match the new db schema of bz3.0 [TABLE attachments]
Status: CLOSED CURRENTRELEASE
Product: Red Hat Hardware Certification Program
Classification: Red Hat
Component: Hardware Catalog (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: XINSUN
Yu Shao
:
Depends On:
Blocks: hwcert->BZ3_tracker
  Show dependency treegraph
 
Reported: 2008-04-21 13:24 EDT by XINSUN
Modified: 2008-08-04 13:56 EDT (History)
9 users (show)

See Also:
Fixed In Version: 3.2rh-20080801.1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-08-04 13:56:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
The patch to fix the "Add attah_data table " (8.90 KB, patch)
2008-04-22 22:20 EDT, XINSUN
no flags Details | Diff
Patch Improve: (9.80 KB, patch)
2008-04-29 10:54 EDT, XINSUN
no flags Details | Diff
Patch Improve: (11.21 KB, patch)
2008-04-30 11:31 EDT, XINSUN
no flags Details | Diff

  None (edit)
Description XINSUN 2008-04-21 13:24:39 EDT
1. Relate to TABLE attachments  need to change list below:
        1.1  Separate thedata from  the table attachemts to a new table attach_data.
      Added :       TABLE attach_data
      Removed:    FIELD attachments.thedata 
              A) File: attachment.cgi
      Line: 526
      Func: view()
      Statement: 
      my $query="SELECT mimetype, filename, thedata FROM attachments WHERE
attach_id = $::FORM{'id'}";
            
             B) File: attachment.cgi
      Line: 631
      Func: get_unified_diff()
      Statement: 
      SendSQL("SELECT bug_id, description, ispatch, thedata FROM attachments
WHERE attach_id = $id");
 
               C)  File: attachment.cgi
      Line: 764
      Func: diff()
      Statement:
      SendSQL("SELECT bug_id, description, ispatch, thedata FROM attachments
WHERE attach_id = $::FORM{'id'}");
       
              D) File: attachment.cgi
      Line: 836
      Func: viewall()
      Statement:
      SendSQL("SELECT attach_id, " . Bugzilla::DB::DateFormat('creation_ts',
'%Y.%m.%d   %H:%i') . ",
            mimetype, description, ispatch, isobsolete, isprivate, " .
            Bugzilla::DB::Length('thedata', 'base64') . "
            FROM attachments WHERE bug_id = $::FORM{'bugid'} $privacy
            ORDER BY attach_id");
  
             E) File: attachment.cgi
      Line:945
      Func: insert()
      Statement:
      my $query="INSERT INTO attachments (bug_id, creation_ts, filename,
description, mimetype, ispatch, isprivate, submitter_id, thedata)
VALUES ($::FORM{'bugid'}, now(), $sqlfilename, $description, $contenttype,
$::FORM{'ispatch'},$isprivate, $::userid, ?)";
             
              F) File: attachment.cgi
      Line:1068
      Func: edit()
      Statement:
     SendSQL("SELECT description, mimetype, filename, bug_id, ispatch,
isobsolete, isprivate, " . Bugzilla::DB::Length('thedata', 'base64') . "
           FROM attachments WHERE attach_id = $::FORM{'id'}");
          
             G) File: Bugzilla/Attachment.pm
      Line:55
      Func: query()
      Statement:
     &::SendSQL("
              SELECT attach_id, " . Bugzilla::DB::DateFormat('creation_ts',
'%Y.%m.%d %H:%i:%s') . ",
              mimetype, description, ispatch, isobsolete, isprivate,
              submitter_id, " . Bugzilla::DB::Length('thedata') . "
              FROM attachments WHERE bug_id = $bugid ORDER BY attach_id
            ");

             H) File: post.cgi
      Line:787
      Func: if ($cgi->param('md5'))
      Statement:
     SendSQL("INSERT INTO attachments (bug_id, creation_ts, filename,
description, mimetype, ispatch, isprivate, submitter_id, thedata)
           VALUES ($id, now(), $sqlfilename, $description, $contenttype,
$ispatch , $isprivate, $::userid, $thedata)");



         1.2   New “Not NULL” Field : isurl,modification_time in the attachments
table.
        Added :       FIELD attachments.isurl, attachment.modification_time
                     Removed :   N/A

             A) File: attachment.cgi
      Line:945
      Func: insert()
      Statement:
      my $query="INSERT INTO attachments (bug_id, creation_ts, filename,
description, mimetype, ispatch, isprivate, submitter_id, thedata)
VALUES ($::FORM{'bugid'}, now(), $sqlfilename, $description, $contenttype,
$::FORM{'ispatch'},$isprivate, $::userid, ?)";

              B)File: Bugzilla/Attachment.pm
      Line:787
      Func: if ($cgi->param('md5'))
      Statement:
     SendSQL("INSERT INTO attachments (bug_id, creation_ts, filename,
description, mimetype, ispatch, isprivate, submitter_id, thedata)
           VALUES ($id, now(), $sqlfilename, $description, $contenttype,
$ispatch , $isprivate, $::userid, $thedata)");
Comment 1 XINSUN 2008-04-22 22:20:27 EDT
Created attachment 303412 [details]
The patch to fix the "Add attah_data table "
Comment 2 Noura El hawary 2008-04-28 00:19:14 EDT
Hi nicho,

maybe other places where thedata also need to be changed to belong to the table
attach_data and not attachments are:

./quicksearchhack.html:236:  <td>Attachment Data <i>("attachments.thedata")</i></td>

./post.cgi:778:  my $thedata = SqlQuote($data);

./post.cgi:787:  SendSQL("INSERT INTO attachments (bug_id, creation_ts,
filename, description, mimetype, ispatch, isprivate, submitter_id, thedata)

./post.cgi:788:           VALUES ($id, now(), $sqlfilename, $description,
$contenttype, $ispatch , $isprivate, $::userid, $thedata)");

./quicksearch.js:154:add_mapping("attachmentdata",     "attachments.thedata");

./quicksearch.js:155:add_mapping("attachdata",         "attachments.thedata");

./importResultRPMS_direct.pl:50:                "mimetype, ispatch, isprivate,
submitter_id, thedata, it_id) " .

./importResultRPMS_direct.pl:54:    $bugs_dbh->do($query, undef, $thedata);


please note that the above info includes the file number in the file where the
code needs to be changed.

Cheers,
Noura
Comment 3 Noura El hawary 2008-04-28 00:20:14 EDT
> please note that the above info includes the file number in the file where the
> code needs to be changed.
> 

s/file number/line number :)

Comment 4 Rob Landry 2008-04-28 11:15:07 EDT
importResultRPMS_direct.pl should probably be deprecated now; IIRC it's only use
was the one time migration from flat files to bugzilla attachments for the
results rpms.
Comment 5 XINSUN 2008-04-29 10:54:59 EDT
Created attachment 304124 [details]
Patch Improve:

Add the post.cgi which is leaked to put into patch last time.
Thanks a lot, Noura,
Comment 6 XINSUN 2008-04-29 10:57:03 EDT
./quicksearch.js and ./quicksearchhack.html are not used in the hwcert
catalog,So we can leave it alone. 

Noura : Thanks a lot! 
Comment 7 Rob Landry 2008-04-29 17:40:48 EDT
if they exist in the hwcert tree we should go ahead and update them.  It's ok
with me to either update them with the schema changes or to remove the
functionality which references the schema changes or to deprecate the files from
the repo.
Comment 8 XINSUN 2008-04-30 11:31:48 EDT
Created attachment 304248 [details]
Patch Improve:

Add the new update (changes) in the quicksearch.js and quicksearchhack.html
which Noura has motioned. :)

Pls review.
Comment 9 Noura El hawary 2008-04-30 21:48:53 EDT
The patch looks good to me nicho :)

Thanks,
Noura
Comment 10 Rob Landry 2008-07-17 16:45:56 EDT
Please commit this change to CVS and set the status to MODIFIED.
Comment 11 eric_liu 2008-08-01 07:16:23 EDT
tested and run good

Note You need to log in before you can comment on or make changes to this bug.