[ic] Redundant code in DBI.pm?

Jon Jensen jon at endpoint.com
Fri Mar 13 03:27:57 UTC 2015


On Fri, 13 Mar 2015, Peter wrote:

> IRT this block of code in the create_sql function in DBI.pm:
>
>    for (my $i = 0;  $i < @$columns;  $i++) {
>        $cols[$i] = $$columns[$i];
> #::logDebug("checking column '$cols[$i]'");
>                if(defined $key) {
>                        $keycol = $i if $cols[$i] eq $key;
>                }
>                if(defined $config->{COLUMN_DEF}->{$cols[$i]}) {
>                        $cols[$i] .= " " .
> $config->{COLUMN_DEF}->{$cols[$i]};
>                }
>                else {
>                        $cols[$i] .= " $def_type";
>                }
>                $$columns[$i] = $cols[$i];
>                $$columns[$i] =~ s/\s+.*//;
>    }
>
> The last two lines of the loop look to be redundant to me.
> $$columns[$i] already contains the column name, and $cols[$i] contain
> the column definition which is the column name, followed by a space and
> other stuff, so the last two names write $cols[$i] back to $$columns[$i]
> then strip the space + other stuff off the end leaving just the column
> name ... which is what was in $$columns[$i] to begin with?
>
> Can we scrap those two lines or is there something I'm missing?

I read it that way too.

However, to avoid getting caught by anything "tricky, tricky" I think you 
would want to put some heavy debugging in there before & after and test 
pretty extensively.

It would also be good to hear from Mike whether he remembers any obscure 
reason for this.

Jon


-- 
Jon Jensen
End Point Corporation
https://www.endpoint.com/



More information about the interchange-users mailing list