Patch for DBD::mysql 2.9002

Patch for DBD::mysql 2.9002

am 20.10.2003 19:01:16 von Aaron Ross

--=-Nc4xb6DlUDf0M4RY5lfm
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,

This is a simple patch to fully qualify constant subs from DBI that
define the SQL datatypes. Without the patch, column_info and table_info
will not work. Also included is a simple test in t/40listfields.t

Thanks, Aaron and Chuck

--=-Nc4xb6DlUDf0M4RY5lfm
Content-Disposition: attachment; filename=dbd-mysql.patch
Content-Type: text/x-patch; name=dbd-mysql.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -rc DBD-mysql-2.9002/lib/DBD/mysql.pm DBD-mysql-2.9002.patched/lib/DBD/mysql.pm
*** DBD-mysql-2.9002/lib/DBD/mysql.pm 2003-06-23 20:25:19.000000000 -0400
--- DBD-mysql-2.9002.patched/lib/DBD/mysql.pm 2003-10-20 12:52:54.000000000 -0400
***************
*** 334,342 ****
my @type_attr = split / /, $3||'';
#warn "$type: $basetype [@type_params] [@type_attr]\n";

! $info->{DATA_TYPE} = SQL_VARCHAR();
if ($basetype =~ /char|text|blob/) {
! $info->{DATA_TYPE} = SQL_CHAR() if $basetype eq 'char';
if ($type_params[0]) {
$info->{COLUMN_SIZE} = $type_params[0];
}
--- 334,342 ----
my @type_attr = split / /, $3||'';
#warn "$type: $basetype [@type_params] [@type_attr]\n";

! $info->{DATA_TYPE} = DBI::SQL_VARCHAR();
if ($basetype =~ /char|text|blob/) {
! $info->{DATA_TYPE} = DBI::SQL_CHAR() if $basetype eq 'char';
if ($type_params[0]) {
$info->{COLUMN_SIZE} = $type_params[0];
}
***************
*** 359,387 ****
$info->{"mysql_values"} = \@type_params;
}
elsif ($basetype =~ /int/) {
! $info->{DATA_TYPE} = SQL_INTEGER();
$info->{NUM_PREC_RADIX} = 10;
$info->{COLUMN_SIZE} = $type_params[0];
}
elsif ($basetype =~ /decimal/) {
! $info->{DATA_TYPE} = SQL_DECIMAL();
$info->{NUM_PREC_RADIX} = 10;
$info->{COLUMN_SIZE} = $type_params[0];
$info->{DECIMAL_DIGITS} = $type_params[1];
}
elsif ($basetype =~ /float|double/) {
! $info->{DATA_TYPE} = ($basetype eq 'float') ? SQL_FLOAT() : SQL_DOUBLE();
$info->{NUM_PREC_RADIX} = 2;
$info->{COLUMN_SIZE} = ($basetype eq 'float') ? 32 : 64;
}
elsif ($basetype =~ /date|time/) { # date/datetime/time/timestamp
if ($basetype eq 'time' or $basetype eq 'date') {
! $info->{DATA_TYPE} = ($basetype eq 'time') ? SQL_TYPE_TIME() : SQL_TYPE_DATE();
$info->{COLUMN_SIZE} = ($basetype eq 'time') ? 8 : 10;
}
else { # datetime/timestamp
! $info->{DATA_TYPE} = SQL_TYPE_TIMESTAMP();
! $info->{SQL_DATA_TYPE} = SQL_DATETIME();
$info->{SQL_DATETIME_SUB} = $info->{DATA_TYPE} - ($info->{SQL_DATA_TYPE} * 10);
$info->{COLUMN_SIZE} = ($basetype eq 'datetime') ? 19 : $type_params[0] || 14;
}
--- 359,387 ----
$info->{"mysql_values"} = \@type_params;
}
elsif ($basetype =~ /int/) {
! $info->{DATA_TYPE} = DBI::SQL_INTEGER();
$info->{NUM_PREC_RADIX} = 10;
$info->{COLUMN_SIZE} = $type_params[0];
}
elsif ($basetype =~ /decimal/) {
! $info->{DATA_TYPE} = DBI::SQL_DECIMAL();
$info->{NUM_PREC_RADIX} = 10;
$info->{COLUMN_SIZE} = $type_params[0];
$info->{DECIMAL_DIGITS} = $type_params[1];
}
elsif ($basetype =~ /float|double/) {
! $info->{DATA_TYPE} = ($basetype eq 'float') ? DBI::SQL_FLOAT() : DBI::SQL_DOUBLE();
$info->{NUM_PREC_RADIX} = 2;
$info->{COLUMN_SIZE} = ($basetype eq 'float') ? 32 : 64;
}
elsif ($basetype =~ /date|time/) { # date/datetime/time/timestamp
if ($basetype eq 'time' or $basetype eq 'date') {
! $info->{DATA_TYPE} = ($basetype eq 'time') ? DBI::SQL_TYPE_TIME() : DBI::SQL_TYPE_DATE();
$info->{COLUMN_SIZE} = ($basetype eq 'time') ? 8 : 10;
}
else { # datetime/timestamp
! $info->{DATA_TYPE} = DBI::SQL_TYPE_TIMESTAMP();
! $info->{SQL_DATA_TYPE} = DBI::SQL_DATETIME();
$info->{SQL_DATETIME_SUB} = $info->{DATA_TYPE} - ($info->{SQL_DATA_TYPE} * 10);
$info->{COLUMN_SIZE} = ($basetype eq 'datetime') ? 19 : $type_params[0] || 14;
}
diff -rc DBD-mysql-2.9002/t/40listfields.t DBD-mysql-2.9002.patched/t/40listfields.t
*** DBD-mysql-2.9002/t/40listfields.t 2003-05-27 21:58:51.000000000 -0400
--- DBD-mysql-2.9002.patched/t/40listfields.t 2003-10-20 12:52:39.000000000 -0400
***************
*** 70,75 ****
--- 70,77 ----
$dbh->do($def)))
or DbiError($dbh->err, $dbh->errstr);

+ Test($state or $dbh->table_info(undef,undef,$table));
+ Test($state or $dbh->column_info(undef,undef,$table,'%'));

Test($state or $cursor = $dbh->prepare("SELECT * FROM $table"))
or DbiError($dbh->err, $dbh->errstr);


--=-Nc4xb6DlUDf0M4RY5lfm
Content-Type: text/plain; charset=us-ascii

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org
--=-Nc4xb6DlUDf0M4RY5lfm--