> > > Very. Can you trim your test script down further? Then try other > > > drivers? (To isolate if it's a DBI or DBD::ODBC issue.) > > > > The test script is as trim as it gets. > > What I've posted is as simple as I could make it. > > I'm sure there's more room for making it smaller, but the first > priority is making it reproducable by someone else, preferably me :) > > I've attached a slightly smaller version. Could be made smaller > still by removing File::Spec (most windows APIs work fine with unix > style forward slashes). And File::Path could be dropped. Be aggressive > about removing absolutely everything you can.
Well, I whacked on it some more. > > It requires the combination of File::Copy and fetchall_hashref(). Hey, > > the problem may not be in DBI. But I can't duplicate it without both. > > Believe me, I spent some time on this before posting. > > Thanks. > > > I tried it on Linux w/mySQL. That's the only other combination to which > > I have easy access. I was unable to duplicate the behavior. > > Nor me. I tried using mysql plus perl 5.6.1 (no threads) or 5.8.3 (with > threads). > > Your test script is not self-contained. Other people can't run it > without having to more than just alter the DSN. I suggest making > it both as small as possible and more self-contained: have it > generate the data & files itself. Does there need to be a loop > around the copy() or is a single copy() enough? Etc etc. > Adding a print "DBI $DBI::VERSION\n" would also be a good idea. I removed the loop. The script now copies itself to a duplicate file name. The DSN has to be hacked. If the database is other than SQL Server the select statement has to be hacked. My strategy was to do a pull on a system table. This should work for any database, but of course databases differ in this regard. I tried it without File::Copy. The problem disappears. This is what I remembered. File::Copy is part of the issue. But so is fetchall_hashref(). Or so it seems to me. I ran it on two different configurations, the only ones available at work. Home is Linux and I can't duplicate the error at home. I believe it to be a Windows-specific problem. Perhaps even ActiveState-specific, based on one other user who used a different distribution and was also unable to duplicate the problem. My guess is that if you are not ever running Windows you won't see it. Current results. I get the problem with 5.8, but not with 5.6. Output traces (and the current script) follow: ---------------------------------5.8--------------------------------------- D:\CaseLaw>perl -v This is perl, v5.8.4 built for MSWin32-x86-multi-thread (with 3 registered patches, see perl -V for more detail) Copyright 1987-2004, Larry Wall Binary build 810 provided by ActiveState Corp. http://www.ActiveState.com ActiveState is a division of Sophos. Built Jun 1 2004 11:52:21 Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page. D:\CaseLaw>\\nas3\installation\software\unref.pl Perl: 5.008004 DBI: 1.45 File::Copy: 2.07 Step 1: Database query Using fetchrow_hashref() multiple times 16392: db_denydatareader 16393: db_denydatawriter 3: INFORMATION_SCHEMA 16384: db_owner 2: guest 16390: db_datareader 16385: db_accessadmin 16389: db_backupoperator 1: dbo 4: system_function_schema 16391: db_datawriter 0: public 16386: db_securityadmin 16387: db_ddladmin 5: servman Step 2: Copy script file D:\CaseLaw>\\nas3\installation\software\unref.pl 1 Perl: 5.008004 DBI: 1.45 File::Copy: 2.07 Step 1: Database query Using fetchall_hashref() 16392: db_denydatareader 16393: db_denydatawriter 3: INFORMATION_SCHEMA 16384: db_owner 2: guest 16390: db_datareader 16385: db_accessadmin 16389: db_backupoperator 1: dbo 4: system_function_schema 16391: db_datawriter 0: public 16386: db_securityadmin 16387: db_ddladmin 5: servman Step 2: Copy script file Attempt to free unreferenced scalar: SV 0x1c2579c at C:/Perl/lib/File/Copy.pm li ne 91. D:\CaseLaw> -------------------------5.6----------------------------------------------- This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 635 provided by ActiveState Corp. http://www.ActiveState.com Built 15:34:21 Feb 4 2003 C:\Documents and Settings\jsmith>\\nas3\installation\software\unref.pl Perl: 5.006001 DBI: 1.37 File::Copy: 2.03 Step 1: Database query Using fetchrow_hashref() multiple times 16390: db_datareader 16391: db_datawriter 0: public 1: dbo 16392: db_denydatareader 16384: db_owner 2: guest 16393: db_denydatawriter 16385: db_accessadmin 16386: db_securityadmin 3: INFORMATION_SCHEMA 16387: db_ddladmin 4: system_function_schema 5: servman 16389: db_backupoperator Step 2: Copy script file C:\Documents and Settings\jsmith>\\nas3\installation\software\unref.pl 1 Perl: 5.006001 DBI: 1.37 File::Copy: 2.03 Step 1: Database query Using fetchall_hashref() 16390: db_datareader 16391: db_datawriter 0: public 1: dbo 16392: db_denydatareader 16384: db_owner 2: guest 16393: db_denydatawriter 16385: db_accessadmin 16386: db_securityadmin 3: INFORMATION_SCHEMA 16387: db_ddladmin 4: system_function_schema 5: servman 16389: db_backupoperator Step 2: Copy script file C:\Documents and Settings\jsmith> ---------------------test script------------------------------------------- use strict; use warnings; use DBI; use File::Copy; print "Perl: $]\n"; print "DBI: $DBI::VERSION\n"; print "File::Copy: $File::Copy::VERSION\n"; print "\nStep 1: Database query\n"; # Modify this to work at your site: my $DSN = 'DBI:ODBC:' . join ';', split /\n/s, <<DSN; DRIVER=SQL Server Trusted_Connection=Yes APP=Microsoft Open Database Connectivity DATABASE=master SERVER=Tech14 DSN my $dbms = DBI->connect($DSN, undef, undef, { AutoCommit => 1, PrintError => 0, RaiseError => 1 }); # Modify this if necessary to work for your database # (should work OK for pretty much any SQL Server database): my $stmt = $dbms->prepare('select * from sysusers'); $stmt->execute; my $list = undef; if (@ARGV) { print " Using fetchall_hashref()\n"; # This causes: # Attempt to free unreferenced scalar # errors: $list = $stmt->fetchall_hashref('uid'); } else { print " Using fetchrow_hashref() multiple times\n"; # This doesn't cause the error: my %list = ( ); while (my $rec = $stmt->fetchrow_hashref) { $list{$rec->{uid}} = $rec; } $list = \%list; } $stmt->finish; printf " %8d: %s\n", $_->{uid}, $_->{name} for values %$list; print "\nStep 2: Copy script file\n"; copy $0, "$0.dup"; ---------------------------------------------------------------------------------------------- I do not have access to other drivers _and_ a Windows system at the same time. My job (where I have the Windows systems) is Windows-only under penalty of death. Well, not death. But at least one programmer has been fired for bringing a non-Windows system into work without permission. They have no other databases. They have only what they use. C'est la guerre. mma
