gpt4 book ai didi

linux - perl dbi :odbc crashing/using strange file

转载 作者:太空狗 更新时间:2023-10-29 12:36:42 25 4
gpt4 key购买 nike

我正在尝试解决一个问题,即脚本在一台服务器 (db1) 上崩溃且几乎没有错误信息,但在另一台服务器 (db2 >),尽管这两种环境在我能找到的所有方面(除了一个)都是相同的。

这是脚本,test.pl:

use strict;
use warnings;

use DBI;
use Data::Dumper;

$ENV{LD_LIBRARY_PATH} = "/var/local/odbc";
$ENV{ODBCHOME} = "/var/local/odbc";
$ENV{ODBCINI} = "/etc/odbc.ini";

my $dbh = DBI->connect( "dbi:ODBC:db", "foo", "bar" ) or die "$DBI::err\n$DBI::errstr\n$DBI::state\n";
$dbh->{RaiseError} = "0";
$dbh->{AutoCommit} = "1";
$dbh->{LongReadLen} = 1024;

#$dbh->{TraceLevel} = 10;

my $sth = $dbh->prepare( "SELECT * FROM table WHERE x='y'" ) or die "$DBI::err\n$DBI::errstr\n$DBI::state\n";
$sth->execute or die "$DBI::err\n$DBI::errstr\n$DBI::state\n";

my $data = $sth->fetchall_hashref( 'x' );
print Data::Dumper->Dump( [$data] );

这是输出(注意:死亡发生在$sth->execute):

$ ./test
DBD::ODBC::st execute failed: [DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1) at ./test line 24.
-1
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1)
HY000

TraceLevel 10 没有为我阐明:

$ ./test
DBI::db=HASH(0x1f2cc8e0) trace level set to 0x0/10 (DBI @ 0x0/0) in DBI 1.52-ithread (pid 27494)
-> prepare for DBD::ODBC::db (DBI::db=HASH(0x1f2cc510)~0x1f2cc8e0 'SELECT * FROM table WHERE x='y'') thr#1effa010
dbih_setup_handle(DBI::st=HASH(0x1f2cca60)=>DBI::st=HASH(0x1f2ccb60), DBD::ODBC::st, 1f2cca70, Null!)
dbih_make_com(DBI::db=HASH(0x1f2cc8e0), 1f2d1e30, DBD::ODBC::st, 376, 0) thr#1effa010
dbih_setup_attrib(DBI::st=HASH(0x1f2ccb60), Err, DBI::db=HASH(0x1f2cc8e0)) SCALAR(0x1f183620) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x1f2ccb60), State, DBI::db=HASH(0x1f2cc8e0)) SCALAR(0x1f1836a0) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x1f2ccb60), Errstr, DBI::db=HASH(0x1f2cc8e0)) SCALAR(0x1f183660) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x1f2ccb60), TraceLevel, DBI::db=HASH(0x1f2cc8e0)) 10 (already defined)
dbih_setup_attrib(DBI::st=HASH(0x1f2ccb60), FetchHashKeyName, DBI::db=HASH(0x1f2cc8e0)) 'NAME' (already defined)
dbih_setup_attrib(DBI::st=HASH(0x1f2ccb60), HandleSetErr, DBI::db=HASH(0x1f2cc8e0)) undef (not defined)
dbih_setup_attrib(DBI::st=HASH(0x1f2ccb60), HandleError, DBI::db=HASH(0x1f2cc8e0)) undef (not defined)
initializing sth query timeout to 0
ignore named placeholders = 0
SQLPrepare returned 0

dbd_st_prepare'd sql f523212832, ExecDirect=0
SELECT * FROM table WHERE x='y'
<- prepare= DBI::st=HASH(0x1f2cca60) at ./test line 23
-> execute for DBD::ODBC::st (DBI::st=HASH(0x1f2cca60)~0x1f2ccb60) thr#1effa010
dbd_st_execute (outparams = 0)...
dbd_st_execute (for hstmt 523212832 before)...
dbd_st_execute (for hstmt 523212832 after, rc = -1)...
dbd_error: err_rc=-1 rc=0 s/d/e: 523212832/523051280/523050880
dbd_error: SQL-HY000 (native 0): [DataDirect][ODBC SQL Server Driver] (SQL-HY000)
dbd_error: SQL-HY000 (native 0): [DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)
dbd_error: err_rc=-1 rc=0 s/d/e: 0/523051280/523050880
dbd_error: err_rc=-1 rc=0 s/d/e: 0/0/523050880
st_execute/SQLExecute error -1 recorded: [DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1)
!! ERROR: -1 '[DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1)' (err#0)
<- execute= undef at ./test line 24
DBD::ODBC::st execute failed: [DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1) at ./test line 24.
-1
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1)
HY000
-> DESTROY for DBD::ODBC::st (DBI::st=HASH(0x1f2ccb60)~INNER) thr#1effa010
SQLFreeStmt called, returned 0.
ERROR: -1 '[DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1)' (err#0)
<- DESTROY= undef
-> DESTROY for DBD::ODBC::db (DBI::db=HASH(0x1f2cc8e0)~INNER) thr#1effa010
DBD::ODBC Disconnected!
ERROR: -1 '[DataDirect][ODBC SQL Server Driver] (SQL-HY000)
[DataDirect][ODBC SQL Server Driver] (SQL-HY000)(DBD: st_execute/SQLExecute err=-1)' (err#0)
<- DESTROY= undef

straced 在两台服务器上运行,唯一的区别发生在执行结束时 db1 上的脚本试图打开和读取文件 /var/local/odbc/DDODBC.DAT 并继续崩溃。 db2 上的运行没有做任何事情,而是继续成功地完成它的工作。经过大量文件系统抓取和文件比较后,我确认两台服务器的 odbc.ini 配置文件相同,并且/var/local/odbc 的整个结构和内容也相同,除了 DDODBC .DAT 存在于 db1 上,但不存在于 db2 上。环境变量也一样。

将 DDODBC.DAT 移动到其他位置会导致脚本成功运行。该文件被重新创建、使用,然后脚本继续执行它的工作(如 strace 所示)。如果我替换原来的 DDODBC.DAT,脚本会再次崩溃。这里明显的结论是文件有错误、数据错误、损坏等。 strace on the new, successful, runs on db1 only difference to the those on db2 四行:

open("/var/local/odbc/DDODBC.DAT", O_RDONLY) = 4
lseek(4, 0, SEEK_SET) = 0
read(4, ..., 1212) = 1212
close(4) = 0

DDODBC.DAT 文件的用途是什么?创建它的原因是什么?Google 对我没有帮助。

备案:

$ perl --version
This is perl, v5.8.8 built for x86_64-linux-thread-multi
$ uname -srmo
Linux 2.6.18-141.el5 x86_64 GNU/Linux
$ odbcinst --version
unixODBC 2.2.11
$ perl -MDBD::ODBC -e 'print $DBD::ODBC::VERSION, "\n";'
1.13

最佳答案

我想您必须与您的驱动程序提供商联系,据我所知,DBD::ODBC 不使用 DDODBC.DAT 文件,从名称来看它建议使用 DataDirect。跟踪显示对 SQLExecute 错误的调用并返回没有任何错误文本的一般错误 (HY000)。

关于linux - perl dbi :odbc crashing/using strange file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9686610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com