Giter Site home page Giter Site logo

dbd-csv's Issues

Attempt to free unreferenced scalar during global destruction

This was raised and reproduced on dbi-users, thanks @ronsavage.

I've written a further test for this which is more simple and passes far less options to connect() to aid in identification of the cause and could possibly be made subject of a pull request.

observations

  • In the monkey patched DBD::CSV::Table::DESTROY uncommenting this stops the warnings.
  • Specifying csv_tables is a sure way to trigger the warning, however I have seen multiple warnings from this code, from the test_with_options() for (1 .. 100); calls, so I doubt this is the full story.
  • The SV that is unreferenced is always the Text::CSV_XS object, so I don't know if the bug lies there - csv_tables is not an option to new() there though.

Can't call method "print" on an undefined value

Hi everyone,
I've taken the example from the SYNOPSIS and added a line with the content of csv_class => 'Text::CSV_XS' to it:

use strict;
use warnings;
use DBI;

# See "Creating database handle" below
my $dbh = DBI->connect("dbi:CSV:", undef, undef, {
    f_ext => ".csv/r",  RaiseError => 1,
    csv_class => 'Text::CSV_XS'
}) or die "Cannot connect: $DBI::errstr";
$dbh->do ("CREATE TABLE foo (id INTEGER, name CHAR (10))");

Though I expected to change nothing, because Text::CSV_XS should be the default value, my programm now fails. With the help of Carp::Always I got this error stacktrace:

DBD::CSV::db do failed: Can't call method "print" on an undefined value at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/DBD/CSV.pm line 410.
	DBD::CSV::Table::push_row(DBD::CSV::Table=HASH(0x5587daf78350), DBI::st=HASH(0x5587da2cb1d0), ARRAY(0x5587da36b3d0)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/SQL/Statement.pm line 232
	SQL::Statement::CREATE(DBD::CSV::Statement=HASH(0x5587da2cb230), DBI::st=HASH(0x5587da2cb1d0), ARRAY(0x5587daff92d8)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/SQL/Statement.pm line 157
	SQL::Statement::execute(DBD::CSV::Statement=HASH(0x5587da2cb230), DBI::st=HASH(0x5587da2cb1d0), ARRAY(0x5587daff92d8)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/x86_64-linux-thread-multi/DBI/DBD/SqlEngine.pm line 1271
	eval {...} called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/x86_64-linux-thread-multi/DBI/DBD/SqlEngine.pm line 1269
	DBI::DBD::SqlEngine::st::execute(DBI::st=HASH(0x5587da2cb1d0)) called at /home/ba01m/perl5/perlbrew/perls/perl-5.32.0-threads/lib/site_perl/5.32.0/x86_64-linux-thread-multi/DBI.pm line 1635
	DBD::_::db::do(DBI::db=HASH(0x5587daf77c38), "CREATE TABLE foo (id INTEGER, name CHAR (10))") called at wtf2.pl line 11

Can someone help, please?

csv_ prefix is mandatory for eol attribute in csv_tables hash ref

Although I could not figure out why the csv_ prefix seems to be mandatory for the eol attribute, if used inside the csv_tables hash ref.

Does not work. Uses the default "\r\n" instead of "\n" only.

csv_tables       => {
  my_table => {
    eol => "\n"
  }
}      

Works

csv_tables       => {
  my_table => {
    csv_eol => "\n"
  }
}      

Trailing semi-colon in SQL statements should be discarded

Forwarding an issue mailed in private:

Most SQL bases either requires or permits ; following a statement. Not so for DBD::CSV.

That seems like a bug, because that makes it harder to switch to DBD::CSV.

Works:
$dbh->do ("CREATE TABLE foo (id INTEGER, name CHAR (10))");

Fails:
$dbh->do ("CREATE TABLE foo (id INTEGER, name CHAR (10));");

The second works fine for SQLite, MySQL and PostgreSQL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.