Bug#354421: libdbd-sqlite3-perl: fails to add columns using SQL commands

Krzysztof Krzyzaniak eloy at kofeina.net
Sun Feb 26 11:37:31 UTC 2006


Christoph Biedl wrote:
> Package: libdbd-sqlite3-perl
> Version: 1.08-1
> Severity: normal
> 
> To my big surprise I cannot issue an "ALTER TABLE table ADD" command
> using the Perl library.
> 
> The sqlite3 command line tool works fine:
> 
> $ sqlite3 test2.db
> SQLite version 3.2.1
> Enter ".help" for instructions
> sqlite> CREATE TABLE data (foo INTEGER);
> sqlite> ALTER TABLE data ADD bar INTEGER;
> sqlite> .schema data
> CREATE TABLE data (foo INTEGER, bar INTEGER);
> 
> Now the same in a perl script using libdbd-sqlite3-perl:
> ---------------------------------------------------------------
> #!/usr/bin/perl -w
> 
> use DBI;
> 
> use strict;
> 
> sub docmd ($);
> 
> my $dbh = DBI -> connect('dbi:SQLite:dbname=test.db', '', '') or die;
> 
> docmd ('CREATE TABLE data (foo INTEGER)');
> docmd ("ALTER TABLE data ADD bar INTEGER");
> 
> sub docmd ($) {
>     my $q = $_[0];
>     my $sth;
>     ($sth  = $dbh -> prepare ($q)) ||
>         die "cannot prepare $q: $DBI::errstr";
>     ($sth -> execute ()) ||
>         die "cannot execute $q: $DBI::errstr";
> }
> ---------------------------------------------------------------
> This results in:
> 
> $ perl -w /tmp/test_sqlite 
> DBD::SQLite::db prepare failed: near "ADD": syntax error(1) at dbdimp.c
> line 268 at /tmp/test_sqlite line 17.
> cannot prepare ALTER TABLE data ADD bar INTEGER: near "ADD": syntax
> error(1) at dbdimp.c line 268 at /tmp/test_sqlite line 17.
> 
> Please assist. I need the ability to add columns add a later time.


Cannot confirm. Your example:


eloy at ws143:/tmp$ perl ./test.pl
eloy at ws143:/tmp$ sqlite3 test.db
SQLite version 3.2.8
Enter ".help" for instructions
sqlite> .schema data
CREATE TABLE data (foo INTEGER, bar INTEGER);

Please check if DBD::SQLite came from libdbd-sqlite3-perl

   eloy
-- 
-------e-l-o-y-----------e-l-o-y- at -t-r-a-n-s-i-l-v-a-n-i-a-.-e-u-.-o-r-g------

        jak to dobrze, że są oceany - bez nich byłoby jeszcze smutniej




More information about the pkg-perl-maintainers mailing list