Skip Menu |
 

This queue is for tickets about the DBD-ADO CPAN distribution.

Report information
The Basics
Id: 96558
Status: open
Priority: 0/
Queue: DBD-ADO

People
Owner: sgoeldner [...] cpan.org
Requestors: ASB [...] cpan.org
Cc: dbi-users-help [...] perl.org
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.99
Fixed in: (no value)



CC: dbi-users-help [...] perl.org
Subject: Error restoring database - although everything works fine
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
Message-ID: <rt-4.0.18-22037-1403174629-1476.0-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1403174629-22037-1"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
Content-Length: 1857
Download (untitled) / with headers
text/plain 1.8k
Hi! When I restore a database, an error is reported although everything works fine. The databae is restored. Is this a problem of DBD::ADO or do I have to investigate somewhere else? I attached a script for reproduction. It restores a test.bak file and throws an error. The result is the following output to the command line: Name "Win32::OLE=HASH(0x3aae8cc)::LastError" used only once: possible typo at /< D:\error-on-restore.exe>DBD/ADO/Const.pm line 31. DBD::ADO::db do warning: Can't Execute 'RESTORE DATABASE [test] FROM DISK = N'D: \test.bak' WITH FILE = 1, MOVE N'test' TO N'D:\data\test.mdf', MOVE N'test_log' TO N'D:\logs\test_log.ldf', REPLACE' Package : DBD::ADO::db Filename : /<D:\error-on-restore.exe>DBD/ADO.pm Line : 983 Description : 328 Seiten wurden f³r die test-Datenbank, Datei 'test' f³r Datei 1, verarbeitet. HelpContext : HelpFile : NativeError : 4035 Number : Source : Microsoft OLE DB Provider for SQL Server SQLState : 01000 at error-on-restore.pl line 45. Error restoring database: Can't Execute 'RESTORE DATABASE [test] FROM DISK = N'D :\test.bak' WITH FILE = 1, MOVE N'test' TO N'D:\data\test.mdf', MOVE N'test_log' TO N'D:\logs\test_log.ldf', REPLACE' Package : DBD::ADO::db Filename : /<D:\error-on-restore.exe>DBD/ADO.pm Line : 983 Description : 328 Seiten wurden f³r die test-Datenbank, Datei 'test' f³r Datei 1, verarbeitet. HelpContext : HelpFile : NativeError : 4035 Number : Source : Microsoft OLE DB Provider for SQL Server SQLState : 01000 at error-on-restore.pl line 45. Sorry for the German, it's a German OS. Here is some details: OS: Windows Server 2012 DB: MS SQL Server 2012 Perl: 5.16.3 x86m from ActiveState
Subject: error-on-restore.txt
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"; name="error-on-restore.txt"
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline; filename="error-on-restore.txt"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: ascii
Content-Length: 1369
#!perl use strict; use warnings; use DBI; use DBD::ADO; use Data::Dumper qw/Dumper/; =comment Reproduction program. Triggers an error message when a backup is restored using an SQL command. The error occurres in the line startig with $dbh->do($restore_sql) Database: MS SQL Server 2012 =cut my $host = '192.168.0.48'; my $user = 'your-username'; my $auth = 'your-secret-password'; my $database = 'master'; # dropping requires using master db # build DSN in a somewhat ugly way my $dsn = "Provider=sqloledb;Trusted Connection=yes;"; $dsn .= "Server=$host;Database=$database"; # connect my $dbh = DBI->connect( "dbi:ADO:$dsn", $user, $auth, { PrintError => 0, RaiseError => 0, AutoCommit => 1}, ) or die "Database connection not made: $DBI::errstr"; # drop the database if it already exists my $drop_sql = q~IF EXISTS (SELECT name FROM sys.databases WHERE name = N'test') DROP DATABASE [test]~; $dbh->do($drop_sql) or die "Error dropping database: " . $dbh->errstr; # restore the database from a backup my $restore_sql = q~RESTORE DATABASE [test] FROM DISK = N'D:\test.bak' WITH FILE = 1, MOVE N'test' TO N'D:\data\test.mdf', MOVE N'test_log' TO N'D:\logs\test_log.ldf', REPLACE~; $dbh->do($restore_sql) or die "Error restoring database: " . $dbh->errstr; # Close the connection $dbh->disconnect(); exit(0);
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-22037-1403174629-1476.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-22037-1403174629-1476.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-31935-1403694560-957.96558-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 359
Download (untitled) / with headers
text/plain 359b
This is a warning, not an error. Both are mixed in DBI (similar to SUCCESS_WITH_INFO in SQL). You can check $dbh->err for real errors. But I wouldn't use $dbh->do(...) or die ... IMHO, exception handling is much easier to use. You can control the behavior with RaiseError, PrintError, PrintWarn in a declarative way and omit all (or most) error handling code.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.