[rtg] Bug in targetmaker [WAS: RTG 9]
Brian T. O'Neill
btoneill at misplaced.net
Mon Mar 24 15:58:33 EDT 2008
I'll try to get these incorporated in the next day or two. I jsut
got a new job and things have been crazy for the whole process, so been
out of town alot.
So, things aren't being ignored :)
Brian
Quoting Brandon Ewing (nicotine at warningg.com) from :
> On Fri, Mar 21, 2008 at 04:34:24PM -0500, Brandon Ewing wrote:
> > On Sun, Mar 02, 2008 at 07:19:45AM -0600, Brian T. O'Neill wrote:
> > > Let me know what issue's you're seeing please, I'll get them taken care
> > > of ASAP.
> > >
> > > Brian
> >
> > There appears to be a bug in the CVS version of targetmaker, but I'm no perl
> > guru, so I'm having trouble figuring out how to fix it.
> >
> > Every time I run targetmaker, it always inserts additional rows into
> > options_table. From looking at the code, it appears that it is trying to
> > check to see if a row exists, inserting it if it doesn't, and only updating
> > if necessary.
> >
> > Unfortunately, something appears to be going horribly wrong.
> >
> > Wouldn't it make more sense to replace the whole check, INSERT/UPDATE thing
> > with just a REPLACE statement, since it appears there's already a key
> > composed of the 3 columns?
> >
>
> Attached patch changes options_table.graphname into a primary key, removes
> the select / insert / update check with a simple REPLACE.
>
> --
> Brandon Ewing (nicotine at warningg.com)
> --- targetmaker/etc/targetmaker.orig 2008-03-24 14:30:37.000000000 -0500
> +++ targetmaker/etc/targetmaker 2008-03-24 14:36:55.000000000 -0500
> @@ -748,7 +748,7 @@
> (graphname VARCHAR(64) NOT NULL, options VARCHAR(128) NOT NULL, \
> class VARCHAR(32) NOT NULL )";
> &sql_insert($sql);
> - $sql = "CREATE INDEX options_graphname_idx on options_table(graphname)";
> + $sql = "CREATE UNIQUE INDEX options_graphname_idx on options_table(graphname)";
> &sql_insert($sql);
> $sql = "CREATE INDEX options_options_idx on options_table(options)";
> &sql_insert($sql);
> @@ -760,31 +760,8 @@
> $sql = "DELETE FROM mapping_table WHERE graphname='$graph'";
> &sql_insert($sql);
>
> - if($DB_TYPE =~ /mysql/i) {
> - $sql = "SELECT * FROM options_table where graphname='$graph'";
> - debug("SQL: $sql");
> - $sth = $dbh->prepare($sql)
> - or die "Can't prepare $sql: $dbh->errstr\n";
> - } elsif($DB_TYPE =~ /oracle/i) {
> - $sql = "SELECT * FROM options_table where graphname=:graph";
> - debug("SQL: $sql");
> - $sth = $dbh->prepare($sql)
> - or die "Can't prepare $sql: $dbh->errstr\n";
> - $sth->bind_param(":graph",$graph);
> - }
> - my $rv = $sth->execute
> - or die "can't execute the query: $sth->errstr\n";
> - my @row = $sth->fetchrow_array();
> - unless ( $#row == 0 ) {
> - $sql = "INSERT INTO options_table VALUES ('$graph','@{$table_options{$graph}}','$table_class{$graph}')";
> - &sql_insert($sql);
> - }
> - else {
> - if($row[1] ne join(@{$table_options{$graph}}) || $row[2] ne $table_class{$graph}) {
> - $sql = "UPDATE options_table SET options='".join(" ",@{$table_options{$graph}})."',class='$table_class{$graph}' WHERE graphname='$graph'";
> - &sql_insert($sql);
> - }
> - }
> + $sql = "REPLACE INTO options_table VALUES ('$graph','@{$table_options{$graph}}','$table_class{$graph}')";
> + &sql_insert($sql);
>
> foreach $table (@{$table_map{$graph}}) {
> $sql = "SELECT * FROM mapping_table WHERE graphname='$graph' AND tablename='$table'";
> _______________________________________________
> RTG mailing list
> RTG at lists.grdata.com
> http://lists.grdata.com/mailman/listinfo/rtg
--
btoneill at misplaced.net
****************************************************************************
UNIX is simple and coherent, but it takes a genius (or at any rate a
programmer) to understand and appreciate the simplicity." - Dennis Ritchie
****************************************************************************
More information about the RTG
mailing list