Bug 443458

Summary: FEAT: Match the new db schema of bz3.0 [TABLE attachments]
Product: [Retired] Red Hat Hardware Certification Program Reporter: XINSUN <xisun>
Component: Hardware CatalogAssignee: XINSUN <xisun>
Status: CLOSED CURRENTRELEASE QA Contact: Yu Shao <yshao>
Severity: medium Docs Contact:
Priority: medium    
Version: 5CC: bxu, dkl, efeng, kbaker, nelhawar, rlandry, tfu, xiqin, ykun
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 3.2rh-20080801.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-08-04 17:56:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 443456    
Attachments:
Description Flags
The patch to fix the "Add attah_data table "
none
Patch Improve:
none
Patch Improve: none

Description XINSUN 2008-04-21 17:24:39 UTC
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-23 02:20:27 UTC
Created attachment 303412 [details]
The patch to fix the "Add attah_data table "

Comment 2 Noura El hawary 2008-04-28 04:19:14 UTC
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 04:20:14 UTC
> 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 15:15:07 UTC
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 14:54:59 UTC
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 14:57:03 UTC
./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 21:40:48 UTC
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 15:31:48 UTC
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-05-01 01:48:53 UTC
The patch looks good to me nicho :)

Thanks,
Noura

Comment 10 Rob Landry 2008-07-17 20:45:56 UTC
Please commit this change to CVS and set the status to MODIFIED.

Comment 11 eric_liu 2008-08-01 11:16:23 UTC
tested and run good