From bc7607c1c4e31b9583a6a772c41567c1b1928e6d Mon Sep 17 00:00:00 2001 From: "bugreport%peshkin.net" <> Date: Sat, 27 Aug 2005 06:11:30 +0000 Subject: Bug 305333: Move attachments.thedata to its own table Patch by Joel Peshkin r=lpsolit, a=justdave --- contrib/bug_email.pl | 8 +++++--- contrib/cmdline/query.conf | 2 +- contrib/gnatsparse/gnatsparse.py | 7 +++++-- contrib/jb2bz.py | 7 +++++-- 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'contrib') diff --git a/contrib/bug_email.pl b/contrib/bug_email.pl index 1590387e6..98b8d157e 100755 --- a/contrib/bug_email.pl +++ b/contrib/bug_email.pl @@ -38,7 +38,7 @@ # # You need to work with bug_email.pl the MIME::Parser installed. # -# $Id: bug_email.pl,v 1.28 2005/07/08 02:31:43 mkanat%kerio.com Exp $ +# $Id: bug_email.pl,v 1.29 2005/08/26 23:11:32 bugreport%peshkin.net Exp $ ############################################################### # 02/12/2000 (SML) @@ -164,14 +164,16 @@ sub storeAttachments( $$ ) # Make SQL-String - my $sql = "insert into attachments (bug_id, creation_ts, description, mimetype, ispatch, filename, thedata, submitter_id) values ("; + my $sql = "insert into attachments (bug_id, creation_ts, description, mimetype, ispatch, filename, submitter_id) values ("; $sql .= "$bugid, now(), " . SqlQuote( $description ) . ", "; $sql .= SqlQuote( $mime ) . ", "; $sql .= "0, "; $sql .= SqlQuote( $decoded_file ) . ", "; - $sql .= SqlQuote( $data ) . ", "; $sql .= "$submitter_id );"; SendSQL( $sql ) unless( $test ); + $sql = "insert into attach_data (id, thedata) values (LAST_INSERT_ID(), "; + $sql .= SqlQuote( $data ) . ")"; + SendSQL( $sql ) unless( $test ); } return( $att_count ); diff --git a/contrib/cmdline/query.conf b/contrib/cmdline/query.conf index a44347b2b..87390cd3f 100644 --- a/contrib/cmdline/query.conf +++ b/contrib/cmdline/query.conf @@ -43,7 +43,7 @@ bug_file_loc substring "u","url" status_whiteboard substring "w","whiteboard" keywords substring "k","K","keywords" attachments.description substring "attachdesc" -attachments.thedata substring "attachdata" +attach_data.thedata substring "attachdata" attachments.mimetype substring "attachmime" dependson substring # bug 30823 blocked substring # bug 30823 diff --git a/contrib/gnatsparse/gnatsparse.py b/contrib/gnatsparse/gnatsparse.py index 5f7cde713..b317b240d 100755 --- a/contrib/gnatsparse/gnatsparse.py +++ b/contrib/gnatsparse/gnatsparse.py @@ -451,7 +451,7 @@ class Bugzillabug(object): print >>outfile, " %s, %s, %s, %s);" % (id, who, when, text) for name, data, who in self.attachments: print >>outfile, "\ninsert into attachments (" - print >>outfile, " bug_id, filename, description, mimetype, ispatch, submitter_id, thedata) values (" + print >>outfile, " bug_id, filename, description, mimetype, ispatch, submitter_id) values (" ftype = None # It's *magic*! if name.endswith(".ii") == 1: @@ -463,7 +463,10 @@ class Bugzillabug(object): if ftype is None: ftype = "application/octet-stream" - print >>outfile, "%s,%s,%s, %s,0, %s,%s);" %(self.bug_id, SqlQuote(name), SqlQuote(name), SqlQuote (ftype), who, SqlQuote(zlib.compress(data))) + print >>outfile, "%s,%s,%s, %s,0, %s,%s);" %(self.bug_id, SqlQuote(name), SqlQuote(name), SqlQuote (ftype), who) + print >>outfile, "\ninsert into attach_data (" + print >>outfile, "\n(id, thedata) values (last_insert_id()," + print >>outfile, "%s);" % (SqlQuote(zlib.compress(data))) for newstate, oldstate, fieldid, changedby, changedwhen in self.bug_activity: print >>outfile, "\ninsert into bugs_activity (" print >>outfile, " bug_id, who, bug_when, fieldid, added, removed) values (" diff --git a/contrib/jb2bz.py b/contrib/jb2bz.py index ed8231dfc..e2f502927 100644 --- a/contrib/jb2bz.py +++ b/contrib/jb2bz.py @@ -248,10 +248,13 @@ def process_jitterbug(filename): for a in current['attachments']: cursor.execute( "INSERT INTO attachments SET " \ "bug_id=%s, creation_ts=%s, description='', mimetype=%s," \ - "filename=%s, thedata=%s, submitter_id=%s", + "filename=%s, submitter_id=%s", [ current['number'], time.strftime("%Y-%m-%d %H:%M:%S", current['date-reported'][:9]), - a[1], a[0], a[2], reporter ]) + a[1], a[0], reporter ]) + cursor.execute( "INSERT INTO attach_data SET " \ + "id=LAST_INSERT_ID(), thedata=%s", + [ a[2] ]) cursor.close() db.close() -- cgit v1.2.3-24-g4f1b