After moving to a new server after executing a SELECT query, if the requested column value is NULL , Perl DBI::fetchrow_array()returns what appears to be an empty string: defined()returns 1 and length()returns 0.
Everything I read tells me that I should get undef from NULL , and indeed that is how it works on my old server. There is a copy of the MySQL database on the new server that I migrated using the Export SQL and Import SQL functions for Sequel Pro, the MySQL gui that I run on my Mac. For both databases, the indicated values ββare clearly marked as gray NULL in Sequel Pro and as NULL if I run mysqlinteractively. For example, see namethis decryption:
mysql> SELECT * from trials WHERE id = 26069 ;
+-------+----------+-----------+---------+--------+ ...
| id | language | numTrials | name | status | ...
+-------+----------+-----------+---------+--------+ ...
| 26069 | en | 3 | NULL | Done | ...
+-------+----------+-----------+---------+--------+ ...
1 row in set (0.00 sec)
My old server works with older packages:
- Perl 5.10.1 vs 5.22.1
- DBI 1.634 vs 1.636
- DBD :: mysql 4.022 vs 4.033
Here is my code around fetchrow_array:
@result = $statementHandle->fetchrow_array ;
for my $value (@result) {
if (! utf8::is_utf8($value)) {
utf8::decode($value) ;
my $aValue = $value ;
my $len = length($aValue) ;
if (!defined($value)) {
$aValue = "<unnndefined>" ;
}
print {*::STDLOG} info => "daValue l=$len : $daValue\n" ;
}
}
Many thanks to everyone who can offer what can be here!