Skip Menu |

This queue is for tickets about the DBD-CSV CPAN distribution.

Report information
The Basics
Id: 58039
Status: resolved
Priority: 0/
Queue: DBD-CSV

People
Owner: Nobody in particular
Requestors: matthaeuskiem [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: f_ext
Date: Wed, 2 Jun 2010 08:14:10 +0200
To: bug-DBD-CSV [...] rt.cpan.org
From: Matthäus Kiem <matthaeuskiem [...] gmail.com>
Hello, I did'nt manage to generate different behavior with the two f_ext-options ".csv/r" and ".csv". Could it be a bug?
Subject: Re: [rt.cpan.org #58039] f_ext
Date: Wed, 2 Jun 2010 08:42:38 +0200
To: bug-DBD-CSV [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Wed, 2 Jun 2010 02:14:28 -0400, "Matthäus Kiem via RT" <bug-DBD-CSV@rt.cpan.org> wrote: Show quoted text
> I did'nt manage to generate different behavior with the two f_ext-options > ".csv/r" and ".csv". Could it be a bug?
I don't think so. You will only see a difference if you have *both* table and table.csv: $ ls $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:")->tables' $ touch foo.csv $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:")->tables' "merijn".foo.csv $ touch foo.txt $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:")->tables' "merijn".foo.txt "merijn".foo.csv $ touch foo $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:f_ext=.csv")->tables' "merijn".foo.txt "merijn".foo $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:f_ext=.csv/r")->tables' "merijn".foo $ -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Subject: Re: [rt.cpan.org #58039] f_ext
Date: Wed, 2 Jun 2010 18:39:41 +0200
To: bug-DBD-CSV [...] rt.cpan.org
From: Matthäus Kiem <matthaeuskiem [...] gmail.com>
Thx, I tried know with a simpler example and it worked as expected. But with the example which I used in the first place I don't find the error. Could you say me where the error is? #!/usr/bin/env perl use warnings; use 5.012; use File::Spec::Functions; use DBI; my $dir = '/home/mm/test_folder'; mkdir $dir or die if ! -e $dir; my $file1 = catfile( $dir, 'test_1' ); # with test_1.csv and test_2.csv it works my $file2 = catfile( $dir, 'test_2' ); open my $fh, '>', $file1 or die $!; say $fh 'id,name'; say $fh '1,Brown'; say $fh '2,Smith'; say $fh '5,Green'; close $fh; open $fh, '>', $file2 or die $!; say $fh 'id,city'; say $fh '1,Greenville'; say $fh '2,Watertown'; say $fh '8,Springville'; close $fh; my $dbh = DBI->connect("DBI:CSV:", '', '', { RaiseError => 1, f_dir => $dir, f_ext => ".csv", } ); my $table_1 = 'test_1'; my $table_2 = 'test_2'; eval { my $sth_old = $dbh->prepare( "SELECT a.id, a.name, b.city FROM $table_1 AS a NATURAL JOIN $table_2 AS b" ); $sth_old->execute(); my $table = 'new'; $dbh->do( "DROP TABLE IF EXISTS $table" ); $dbh->do( "CREATE TABLE $table ( id INT, name CHAR(64), city CHAR(64) )" ); my $sth_new = $dbh->prepare( "INSERT INTO $table( id, name, city ) VALUES ( ?, ?, ? )" ); say "id,name,city"; while ( my $hash_ref = $sth_old->fetchrow_hashref() ) { state $count = 1; say $count++, ',', $hash_ref->{'a.name'}, ',', $hash_ref->{'b.city'}; $sth_new->execute( $count++, $hash_ref->{'a.name'}, $hash_ref->{'b.city'} ); } }; $@ and warn $@; $dbh->disconnect(); Am Mittwoch, 2. Juni 2010 08:42:51 schrieben Sie: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=58039 > > > On Wed, 2 Jun 2010 02:14:28 -0400, "Matthäus Kiem via RT" > > <bug-DBD-CSV@rt.cpan.org> wrote:
> > I did'nt manage to generate different behavior with the two f_ext-options > > ".csv/r" and ".csv". Could it be a bug?
> > I don't think so. You will only see a difference if you have *both* > table and table.csv: > > $ ls > $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:")->tables' > $ touch foo.csv > $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:")->tables' > "merijn".foo.csv > $ touch foo.txt > $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:")->tables' > "merijn".foo.txt > "merijn".foo.csv > $ touch foo > $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:f_ext=.csv")->tables' > "merijn".foo.txt > "merijn".foo > $ perl -MDBI -wle'print for DBI->connect ("dbi:CSV:f_ext=.csv/r")->tables' > "merijn".foo > $ >

Message body is not shown because sender requested not to inline it.

CC: Jens Rehsack <rehsack [...] googlemail.com>
Subject: Re: [rt.cpan.org #58039] f_ext
Date: Thu, 3 Jun 2010 07:53:03 +0200
To: bug-DBD-CSV [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Wed, 2 Jun 2010 12:40:11 -0400, "Matthäus Kiem via RT" <bug-DBD-CSV@rt.cpan.org> wrote: Show quoted text
> Thx, I tried know with a simpler example and it worked as expected. > But with the example which I used in the first place I don't find the error. > Could you say me where the error is?
DBD::CSV's supported SQL language is implemented in SQL::Statement That obviously does not support all you are using. --8<--- rt58039.pl #!/pro/bin/perl use strict; use warnings; use autodie; use 5.012; use Cwd; use File::Spec::Functions; use DBI; my $dir = "rt58039"; -d $dir or mkdir $dir, 0777; my @leftovers = glob "$dir/*"; @leftovers and unlink @leftovers; my $file1 = catfile ($dir, "test_1"); # with test_1.csv and test_2.csv it my $file2 = catfile ($dir, "test_2"); open my $fh, ">", $file1 or die $!; say $fh "id,name"; say $fh "1,Brown"; say $fh "2,Smith"; say $fh "5,Green"; close $fh; open $fh, ">", $file2 or die $!; say $fh "id,city"; say $fh "1,Greenville"; say $fh "2,Watertown"; say $fh "8,Springville"; close $fh; my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { RaiseError => 1, PrintError => 1, f_dir => $dir, f_ext => ".csv", }); my $table_1 = "test_1"; my $table_2 = "test_2"; eval { my $sth_old = $dbh->prepare ( "SELECT a.id, a.name, b.city" . "FROM $table_1 AS a NATURAL JOIN $table_2 AS b" ); $sth_old->execute (); my $table = "new"; $dbh->do ("DROP TABLE IF EXISTS $table"); $dbh->do ("CREATE TABLE $table (id INT, name CHAR (64), city CHAR (64))"); my $sth_new = $dbh->prepare ( "INSERT INTO $table (id, name, city) VALUES (?, ?, ?)"); say "id,name,city"; while (my $hash_ref = $sth_old->fetchrow_hashref ()) { state $count = 1; say $count++, ",", $hash_ref->{"a.name"}, ",", $hash_ref->{"b.city"}; $sth_new->execute ($count++, $hash_ref->{"a.name"}, $hash_ref->{"b.city"}); } }; $@ and warn $@; $dbh->disconnect (); -->8--- => $ perl rt58039.pl Table 'a' referenced but not found in FROM list ()! at /pro/lib/perl5/site_perl/5.12.0/SQL/Statement.pm line 77 DBD::CSV::db prepare failed: Table 'a' referenced but not found in FROM list ()! at /pro/lib/perl5/site_perl/5.12.0/SQL/Statement.pm line 77 [for Statement "SELECT a.id, a.name, b.cityFROM test_1 AS a NATURAL JOIN test_2 AS b"] at rt58039.pl line 43. DBD::CSV::db prepare failed: Table 'a' referenced but not found in FROM list ()! at /pro/lib/perl5/site_perl/5.12.0/SQL/Statement.pm line 77 [for Statement "SELECT a.id, a.name, b.cityFROM test_1 AS a NATURAL JOIN test_2 AS b"] at rt58039.pl line 43. -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
CC: Jens Rehsack <rehsack [...] googlemail.com>
Subject: Re: [rt.cpan.org #58039] f_ext
Date: Thu, 3 Jun 2010 08:28:06 +0200
To: bug-DBD-CSV [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Wed, 2 Jun 2010 12:40:11 -0400, "Matthäus Kiem via RT" <bug-DBD-CSV@rt.cpan.org> wrote: Show quoted text
> Thx, I tried know with a simpler example and it worked as expected. > But with the example which I used in the first place I don't find the error. > Could you say me where the error is?
Take back that last reply. I lost a space. If you *create* your files with *open* instead of "create table", and do not add the ".csv" extension" yourself, it looks as if it cannot find the table. If you do add the csv extension on file creation, all works fine (and a space was lost in the previous code) --8<--- rt58039.pl #!/pro/bin/perl use strict; use warnings; use autodie; use 5.012; use Cwd; use File::Spec::Functions; use DBI; my $dir = "rt58039"; -d $dir or mkdir $dir, 0777; my @leftovers = glob "$dir/*"; @leftovers and unlink @leftovers; my $file1 = catfile ($dir, "test_1.csv"); # with test_1.csv and test_2.csv it my $file2 = catfile ($dir, "test_2.csv"); open my $fh, ">", $file1 or die $!; say $fh "id,name"; say $fh "1,Brown"; say $fh "2,Smith"; say $fh "5,Green"; close $fh; open $fh, ">", $file2 or die $!; say $fh "id,city"; say $fh "1,Greenville"; say $fh "2,Watertown"; say $fh "8,Springville"; close $fh; my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { RaiseError => 1, PrintError => 1, f_dir => $dir, f_ext => ".csv", }); my $table_1 = "test_1"; my $table_2 = "test_2"; eval { my $sth_old = $dbh->prepare ( "SELECT a.id, a.name, b.city " . "FROM $table_1 AS a NATURAL JOIN $table_2 AS b" ); $sth_old->execute (); my $table = "new"; $dbh->do ("DROP TABLE IF EXISTS $table"); $dbh->do ("CREATE TABLE $table (id INT, name CHAR (64), city CHAR (64))"); my $sth_new = $dbh->prepare ( "INSERT INTO $table (id, name, city) VALUES (?, ?, ?)"); say "id,name,city"; while (my $hash_ref = $sth_old->fetchrow_hashref ()) { state $count = 1; say $count++, ",", $hash_ref->{"a.name"}, ",", $hash_ref->{"b.city"}; $sth_new->execute ($count++, $hash_ref->{"a.name"}, $hash_ref->{"b.city"}); } }; $@ and warn $@; $dbh->disconnect (); -->8--- => $ perl rt58039.pl id,name,city 1,Brown,Greenville 3,Smith,Watertown It might be a problem in DBD::File from DBI. We'll look into that and add some tests to verify. Meanwhile I will close this bug somewhere this week, as it is neither a DBD::CSV nor a SQL::Statement bug. Thanks for sending the original report though. I'll mould it into something simpler (not involving joins and as). -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
The "bug" was in DBD::File - I've fixed that thank Tux good test case.