- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试解决一个问题,即脚本在一台服务器 (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
我 strace
d 在两台服务器上运行,唯一的区别发生在执行结束时 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/
这个问题在这里已经有了答案: How do I compare strings in Java? (23 个回答) 关闭 9 年前。 所以我运行了这段代码 String line =
此代码适用于我的网站: $(function(){ $('.link-follow-stop').on('click', function(event){ console.lo
private synchronized Map calculateStanding() { System.out.println("Calculate standing for
下面的程序 (prog1) 抛出 OutOfMemoryError 错误。确实如此。但如果我在第 5 行(prog2)下方添加 sysout,它不会抛出错误。这种奇怪的行为有什么原因吗? 程序1: p
class Foo(object): def __init__(self,x): self.x = x self.is_bar = False def
好的,我有一个设置了高度和宽度的简单 div。前后也设置了高度和宽度。它们都设置为显示为 block ,伪元素的内容为“”。 :before 在内容里面,而不是在它之前。:after 之前有一大堆奇怪
我无法解释 Scala 集合的这种行为。 让我们从一些定义开始。 import scala.collection.mutable.Set case class Item(name: String, c
在阅读我遇到的代码时,结构的以下定义和初始化: // header file struct foo{ char* name; int value; }; //Implementation file s
我正在尝试用 c 操作二进制数。我用下面的最小代码发现了一个奇怪的事情。谁能告诉我“+”和“|”有什么区别这里?谢谢! char next_byte1 = 0b11111111; char next_
我是德尔福的新手。在 TStrem 类的文档中,我读到它是一个抽象类。所以我认为当我尝试使用 创建它时编译器会出错 stream := TStream.Create(); 为什么不呢? 最佳答案 De
我有 2 个简单的表单,Form1 和 Form2 (Delphi 7)。 Form1 打开 Form2,我在那里等待特定的组合键 (Ctrl + F2)。一旦我关闭 Form2 并返回到 Form1
我有很多建立TCP网络的类-使用boost::asio,使用Packet进行传输。 (Packet的基类是std::vector) 我以为我已经解决了所有可能的内存泄漏,但是后来我在关闭客户端之前只是
我对以下声明有一些疑问: SELECT 1 FROM dual WHERE DECODE(1, 0, (SELECT COUNT(*) from tbl
我已经在 symfony 2.1 上安装了最新的 Sonata 管理包,但遇到了以下问题: 配置文件: services: app.geo.admin.city: class: App
我必须输出一系列先前保存在数据库中的随机图像。在输出的那一刻,而不是打印一张图片,代码打印一个奇怪的字符串(meaby dumpfile?): (¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(
我刚刚在从 Code Project 下载的项目中看到了这个: base.DialogResult = this.Result != null; 我不认为自己是 C# 新手,但这个对我来说是新手。谁能
看看这个...今天晚上我试图将一些 primiteves 转换到 wrapper 上时发现: Integer i = (Integer)4; Integer i = (Integer)4f; // D
我很少使用 Python,所以我不清楚为什么允许这样的行为:没有 w 对象,因此它没有 s 属性,那为什么 f 允许进行 w.s 赋值? >>> def f(): w.s="ads" #al
在 Jsfiddle 上:http://jsfiddle.net/jhzux/ 我在这个简单的脚本上浪费了很多时间。我想做的是在 jQuery 中启用克隆表单,然后使它们正常工作。 首先,当我在 Js
这是我的代码: .specific_tag_cases a:after{ position: absolute; font-family: Arial; background-
我是一名优秀的程序员,十分优秀!