[rt-users] Followup: trouble with creating a new ticket

Piet Honkoop piet at wirehub.net
Fri Nov 9 13:07:46 EST 2001


On Fri, 9 Nov 2001, Jesse Vincent wrote:

>
> What rev of DBD::mysql do you have installed? there was a bug in some earlier
> versions that caused it to fail sort of badly when asked for insert_id.
>

DBD-mysql-2.1003

> Also, I'd love to see your patch presented as a unified diff. It would be much
> easier for me to eyeball ;)
>

Mwah ;) it doesn't deserve the term patch I'm afraid... But:

--- /usr/local/share/cpan/build/DBIx-SearchBuilder-0.47/SearchBuilder/Handle/mysql.pm   Fri Nov  9 19:01:41 2001
+++ /usr/local/lib/perl5/site_perl/5.005/DBIx/SearchBuilder/Handle/mysql.pm    Fri Nov  9 10:59:16 2001
@@ -44,17 +44,18 @@
                die "Error with Insert: ". $self->dbh->errstr;
       }
        else {
-           return (undef);
+               warn "Error with Insert: ". $self->dbh->errstr;
+           #return (undef);
        }
      }

-    $self->{'id'}=$self->dbh->{'mysql_insertid'};
+    #$self->{'id'}=$self->dbh->{'mysql_insertid'};
     # Yay. we get to work around mysql_insertid being null some of the time :/

-    unless ($self->{'id'}) {
+    # unless ($self->{'id'}) {
        $self->{'id'} =  $self->FetchResult('SELECT LAST_INSERT_ID()');
-    }
-    warn "$self no row id returned on row creation" unless ($self->{'id'});
+    #}
+    warn "$self no row id returned on row creation" unless ($self->{'id'}) ;
     return( $self->{'id'}); #Add Succeded. return the id
   }



As you can see, no coding, just chopping away; too many tests before we
get to the point. The id returned originally went negative (unsigned near
the limit). Now I don't know whether this is a problem in mysql or in the
DBD/DBIx combination, but still. It cost me a good few days to get to the
point where I could fix it and start testing ...


Thanks & good luck!

Piet


>
> 	Thanks very much,
> 	Jesse
>
>
> On Fri, Nov 09, 2001 at 01:22:35PM +0100, Piet Honkoop wrote:
> >
> > As reported earlier, I had problems with setting up rt 2.0.8_02
> >
> > Relevant software:
> > FreeBSD 4.4-stable
> > Mysql: 3.23.43
> > RT: 2.0.8_02
> > DBIx::SearchBuilder 0.47
> > mod_perl 1.26
> >
> > What I found out in the end was that for some reason the id field was not
> > treated correctly. Below is an excerpt from the mysql log where it tries
> > to insert a ticket. The ticket gets created all right but the
> > last_insert_id from mysql is never picked up.
> >
> > Coming from the mysql log:
> >
> >                      34 Query       INSERT INTO Tickets (Starts, Type,
> > Priority, Status, Queue, Owner, InitialPriority, FinalPriority, Subject,
> > Creator, LastUpdatedBy, Created, TimeLeft, TimeWorked, LastUpdated, Due)
> > VALUES ('2001-11-09 09:41:53', 'ticket', '0', 'new', '1', '2', '0', '0',
> > 'g1', '3', '3', '2001-11-09 09:41:53', '', '', '2001-11-09 09:41:53',
> > '2001-11-09 09:41:53')
> >                      34 Query       SELECT  * FROM Tickets WHERE id =
> > '4294967330'
> >                      34 Query       UPDATE Tickets SET
> > EffectiveId='4294967330' WHERE id=NULL
> >
> >
> > After an extensive search (I can find my way around in perl code, but
> > that's about it...), I found:
> >
> > DBIx/SearchBuilder/Handle/mysql.pm
> >
> > The following changes made:
> >
> > 47c47,48
> > <           return (undef);
> > ---
> > >               warn "Error with Insert: ". $self->dbh->errstr;
> > >           #return (undef);
> > 51c52
> > <     $self->{'id'}=$self->dbh->{'mysql_insertid'};
> > ---
> > >     #$self->{'id'}=$self->dbh->{'mysql_insertid'};
> > 54c55
> > <     unless ($self->{'id'}) {
> > ---
> > >     # unless ($self->{'id'}) {
> > 56,57c57,58
> > <     }
> > <     warn "$self no row id returned on row creation" unless
> > ($self->{'id'});
> > ---
> > >     #}
> > >     warn "$self no row id returned on row creation" unless
> > ($self->{'id'}) ;
> >
> > (admitted, this is the crude way). suppress the warning/return undef and
> > force the darn thing to get the last_insert_id() after an insert...
> >
> > But once that was in place, I got the following result:
> >
> >              50 Query       INSERT INTO Tickets (Starts, Type, Priority,
> > Status,
> >  Queue, Owner, FinalPriority, InitialPriority, Subject, Creator,
> > LastUpdatedBy,
> > Created, TimeLeft, TimeWorked, LastUpdated, Due) VALUES ('2001-11-09
> > 09:59:59',
> > 'ticket', '0', 'new', '1', '2', '0', '0', 'blabla', '3', '3', '2001-11-09
> > 09:59:
> > 59', '', '', '2001-11-09 09:59:59', '2001-11-09 09:59:59')
> >              50 Query       SELECT LAST_INSERT_ID()
> >              50 Query       SELECT  * FROM Tickets WHERE id = '2'
> >              50 Query       UPDATE Tickets SET EffectiveId='2' WHERE
> > id='2'
> >
> > Now everything is working, but of course the origin of trouble lies
> > elsewhere (otherwise nothing would have worked once it uses
> > DBIx::SearchBuilder).
> >
> > Where should I start looking where to find the true origin of this
> > problem?
> >
> > P.
> >
> >
> > --
> >
> > =========================================================================
> > Wirehub! Internet BV                                  tel. +31 10 2448344
> > Westzeedijk 487                                       fax. +31 10 2448300
> > 3024 EL Rotterdam                                  http://www.wirehub.net
> >
> >
> >
> >
> > _______________________________________________
> > rt-users mailing list
> > rt-users at lists.fsck.com
> > http://lists.fsck.com/mailman/listinfo/rt-users
> >
>
>

-- 

=========================================================================
Wirehub! Internet BV                                  tel. +31 10 2448344
Westzeedijk 487                                       fax. +31 10 2448300
3024 EL Rotterdam                                  http://www.wirehub.net






More information about the rt-users mailing list