On Fri, 26 Jul 2013 14:33:10 +0200, "H.Merijn Brand"
<h.m.br...@xs4all.nl> wrote:

> DBD::File supports locking of files used as tables. That flag is stored
> as f_lock: 0 no locking, 1: shared lock, 2: exclusive lock
> 
> When a io handle is opened as ScalarIO
> 
>     open my $fh, "<", \$data;
> 
> locking will hang the operation, so we have to disable locking or die
> or croak or whatever, but not try to lock.
> 
> Is below change sane?
> 
> DBI test suite still passes, and a test I added in DBD::CSV now passes.

Ignore. This is wrong. It fights delayed problems. "perlio" is ok,
"scalar" is not, but it doesn't even get that far. The correct code
here would be

> diff --git a/lib/DBD/File.pm b/lib/DBD/File.pm
> index 590a351..7f67730 100644
> --- a/lib/DBD/File.pm
> +++ b/lib/DBD/File.pm
> @@ -475,6 +475,11 @@ sub open_data
>      $flags->{dropMode} and croak "Can't drop a table in stream";
>      my $fn = "file handle " . fileno ($meta->{f_file});

       !defined $fileno || $fileno < 0 ||
           grep { $_ eq "scalar" } PerlIO::get_layers ($meta->{f_file}) and
               $flags->{f_lock} = 0;

>      if ($flags->{createMode} || $flags->{lockMode}) {
>         $meta->{fh} = IO::Handle->new_from_fd (fileno ($meta->{f_file}), 
> "w+") or
>             croak "Cannot open $fn for writing: $! (" . ($!+0) . ")";

/me gets a shovel to dig deeper

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.19   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/
  • Sanity check H.Merijn Brand
    • Re: Sanity check H.Merijn Brand

Reply via email to