Re: DBD::Informix and SIGBUS in perl



On Tue, May 17, 2005 at 04:17:15PM -0700, Jonathan Leffler wrote:

> Also, the example code used $dbh->can()
> as if it returns some sort of subroutine reference - whereas the
> manual only says it returns true or false. Is the DBI manual
> inaccurate or just incomplete and it actually returns something
> usable?

There's fairly deep magic going on here. Returning a code-ref is
undocumented because of potential problems. And guess what...
here's a problem.

FYI: see the UNIVERSAL::can() docs for background info.

> On 5/17/05, Konstantin Solodovnikov <ks@xxxxxxxxxxxxx> wrote:
> > I'm having a problem with DBD::Informix when using it's functions via a
> > 'goto &$sub' mechanism.
>
> Que? What on earth is that? Why do you want to use it? Where did it ever work?

goto &foo

is like
return foo(@_)

but reuses the current sub's call frame and args.

It's rarely used and less rarely needed.

sub prepare_sql
{
# uncommenting the next line will avoid core dump
# return $DBH->prepare( 'select * from ');
my $sub = $DBH->can( 'prepare');
@_ = ( $DBH, 'select * from ' );
goto &$sub;
}

Messing with @_ before using goto & is just asking for trouble.

Bottom line: If it hurts then stop doing it.

Tim.
.



Relevant Pages

  • RE: DBD::Informix and SIGBUS in perl
    ... Well, it seems to me that if there are some potential problems, ... Is it a peculiarity of DBI, ... It obtains a subroutine reference by calling a blessed reference's 'can' ... it seems to me that any experiments with pure perl code ...
    (perl.dbi.users)
  • Re: ST
    ... sort {$SortC} ... It will return Sort does not return a numeric value.; ... statically set the sort strings above it works. ... a subroutine reference, not a string. ...
    (comp.lang.perl.misc)
  • Re: Humaniform robots... yea or nay?
    ... You're assuming that all sort of potential problems won't be ... "Create a brain ... Wayne Throop throopw@xxxxxxxxx http://sheol.org/throopw ...
    (rec.arts.sf.science)
  • Re: Humaniform robots... yea or nay?
    ... You're assuming that all sort of potential problems won't be ... Remember the context you yourself set. ...  "Create a brain ...
    (rec.arts.sf.science)