Dne St 15.říj.2014 10:58:53, MITHALDU napsal(a):
Show quoted text> Ticketing this as per Tux' request. I'll describe it as a series of
> shell commands. Of these, the first two behaviors are misbehavior and
> only the last case is correct.
>
> In the first case it should not search in '.', but ONLY in 'test', and
> raise the error accordingly.
>
> In the second case it should not search in '.' and use the file
> 'yy.csv' found there. Instead it should search only in 'test' and
> disregard files found elsewhere.
>
> $ cd /tmp
>
> $ perl -MDBI -MDP -wE'$a=DBI-
> >connect("dbi:CSV:f_dir=./test;f_ext=.csv/r",undef,undef,{RaiseError=>1});$b=$a-
> >prepare("select distinct foo from yy");$b->execute;DDumper$b->fetch'
>
> ... Cannot open /tmp/yy.csv: No such file or directory (2) at
> /pro/lib/perl5/site_perl/5.20.0/x86_64-linux-thread-multi-
> ld/DBI/DBD/SqlEngine.pm line 1589.
>
> $ echo [useful content] > yy.csv
>
> $ perl -MDBI -MDP -wE'$a=DBI-
> >connect("dbi:CSV:f_dir=./test;f_ext=.csv/r",undef,undef,{RaiseError=>1});$b=$a-
> >prepare("select distinct foo from yy");$b->execute;DDumper$b->fetch'
>
> [ 1 ]
>
> $ mkdir test
>
> $ mv yy.csv test/
>
> $ perl -MDBI -MDP -wE'$a=DBI-
> >connect("dbi:CSV:f_dir=./test;f_ext=.csv/r",undef,undef,{RaiseError=>1});$b=$a-
> >prepare("select distinct foo from yy");$b->execute;DDumper$b->fetch'
>
> [ 1 ]
Is this fixed? Changes for DBI-1.632 mention it is fixed, but I can still see the bad behavior with DBI-1.643 and DBD-CSV-0.55:
$ touch yy.csv
[test@fedora-34 tmp]$ perl -MDBI -wE 'DBI->connect("dbi:CSV:f_dir=./test;f_ext=.csv/r",undef,undef,{RaiseError=>1})->prepare("select distinct foo from yy")->execute;'
DBD::CSV::st execute failed:
Execution ERROR: Missing first row due to EOF - End of data in parsing input stream at /usr/lib64/perl5/vendor_perl/DBI/DBD/SqlEngine.pm line 1480.
.
[...]
It opens ./yy.cvs instead of ./test/yy.csv. It should report an error because there is no ./test directory:
$ strace -e file -- perl -MDBI -wE 'DBI->connect("dbi:CSV:f_dir=./test;f_ext=.csv/r",undef,undef,{RaiseError=>1})->prepare("select distinct foo from yy")->execute;
[...]
openat(AT_FDCWD, "/usr/share/perl5/File/Basename.pm", O_RDONLY|O_CLOEXEC) = 3
getcwd("/tmp", 4096) = 5
stat("./test", 0x55cae9b864b8) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib64/perl5/5.32/SQL/Dialects/AnyData.pmc", 0x7ffd83035c80) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib64/perl5/5.32/SQL/Dialects/AnyData.pm", 0x7ffd83035c80) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/perl5/5.32/SQL/Dialects/AnyData.pmc", 0x7ffd83035c80) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/perl5/5.32/SQL/Dialects/AnyData.pm", 0x7ffd83035c80) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/perl5/vendor_perl/SQL/Dialects/AnyData.pmc", 0x7ffd83035c80) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/perl5/vendor_perl/SQL/Dialects/AnyData.pm", 0x7ffd83035c80) = -1 ENOENT (No such file or directory)
stat("/usr/share/perl5/vendor_perl/SQL/Dialects/AnyData.pmc", 0x7ffd83035c80) = -1 ENOENT (No such file or directory)
stat("/usr/share/perl5/vendor_perl/SQL/Dialects/AnyData.pm", {st_mode=S_IFREG|0644, st_size=2092, ...}) = 0
openat(AT_FDCWD, "/usr/share/perl5/vendor_perl/SQL/Dialects/AnyData.pm", O_RDONLY|O_CLOEXEC) = 3
stat("/usr/local/lib64/perl5/5.32/SQL/Dialects/Role.pmc", 0x7ffd83035580) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib64/perl5/5.32/SQL/Dialects/Role.pm", 0x7ffd83035580) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/perl5/5.32/SQL/Dialects/Role.pmc", 0x7ffd83035580) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/perl5/5.32/SQL/Dialects/Role.pm", 0x7ffd83035580) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/perl5/vendor_perl/SQL/Dialects/Role.pmc", 0x7ffd83035580) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/perl5/vendor_perl/SQL/Dialects/Role.pm", 0x7ffd83035580) = -1 ENOENT (No such file or directory)
stat("/usr/share/perl5/vendor_perl/SQL/Dialects/Role.pmc", 0x7ffd83035580) = -1 ENOENT (No such file or directory)
stat("/usr/share/perl5/vendor_perl/SQL/Dialects/Role.pm", {st_mode=S_IFREG|0644, st_size=2560, ...}) = 0
openat(AT_FDCWD, "/usr/share/perl5/vendor_perl/SQL/Dialects/Role.pm", O_RDONLY|O_CLOEXEC) = 4
lstat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=220, ...}) = 0
stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=220, ...}) = 0
openat(AT_FDCWD, "/tmp", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/tmp/yy.csv", O_RDONLY|O_CLOEXEC) = 3
DBD::CSV::st execute failed:
Execution ERROR: Missing first row due to EOF - End of data in parsing input stream at /usr/lib64/perl5/vendor_perl/DBI/DBD/SqlEngine.pm line 1480.
.
[...]
But when I create the missing directory:
$ mkdir test
[test@fedora-34 tmp]$ perl -MDBI -wE 'DBI->connect("dbi:CSV:f_dir=./test;f_ext=.csv/r",undef,undef,{RaiseError=>1})->prepare("select distinct foo from yy")->execute;'
DBD::CSV::st execute failed:
Execution ERROR: Cannot open /tmp/test/yy.csv: No such file or directory (2) at /usr/lib64/perl5/vendor_perl/DBI/DBD/SqlEngine.pm line 1624.
It behaves correctly.
Is looks like it falls back to a current directory, if the f_dir directory does not exist.