Dear All,I am working with Red Hat Enterprise Linux ES release 4 (Nahant Update 3) Linux and
psql (PostgreSQL) 7.4.8 version and perl v5.8.5 version.
I have created my own database and tables in postgresql and my table will contains many rows and 3 columns
Database Schema is
manager=> \d activealarms
Table "public.activealarms"
Column | Type | Modifiers
----------------------+--------------------------+------------
recordid | bigint | not null
agentid | smallint | not null
additionalattributes | character varying[] |
My rows and columns in database is
recordid | agentid | additionalattributes
----------+---------+-------------------------------
186724 | 1 | {{1281,1}}
186725 | 1 |
186726 | 1 |
186727 | 1 |
186728 | 1 |
186729 | 1 |
188723 | 1 |
188724 | 1 |
189724 | 1 |
189727 | 1 |
I have written a perl script to get the rows values using DBI Modules.
While executing the perl script and I am getting Segmentation fault error.
If I change my rows order and then execute the perl script then I am
getting
output of first row data alone and then segmentation fault occurs and I
am not
able to get the output of second row onwards .
Changed rows and columns in database is
recordid | agentid | additionalattributes
----------+---------+-------------------------------
186724 | 1 |
186725 | 1 | {{1281,1}}
186726 | 1 |
186727 | 1 |
186728 | 1 |
186729 | 1 |
188723 | 1 |
188724 | 1 |
189724 | 1 |
189727 | 1 |
I think the problem is "{}"
When doing a step by step tracing I found that it is hanging in the
statement
DB<1>s
main::LoadTableDetails(test.pl:19):
19: while ( @row = $sth->fetchrow_array )
20: {
DB<1>s
main::LoadTableDetails(test.pl:21):
21: printf "@row\n";
DB<1>s
186724 1
Please find the attached test.pl and perldebug.txt file for your perusal.
Can some one throw light on this peculiar problem.
Thanks in advance.
Regards
-S.Balaji
[EMAIL PROTECTED] ~]# perl test.pl
186724 1
Segmentation fault
[EMAIL PROTECTED] ~]# perl -d test.pl
Loading DB routines from perl5db.pl version 1.27
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(test.pl:52): Init();
DB<1>n
main::(test.pl:53): LoadTableDetails();
DB<1>s
main::LoadTableDetails(test.pl:17):
17: if(ExecuteQry("db","tbl" ,"select
recordid,agentid,additionalattributes from activealarms order by agentid;") ==
$SUCCESS)
18: {
DB<1>s
main::ExecuteQry(test.pl:32): $STATUS = $SUCCESS;
DB<1>s
main::ExecuteQry(test.pl:34): $sth = $dbh->prepare("$_[2]")
main::ExecuteQry(test.pl:35): or $STATUS = $PREPARE_FAILED;
DB<1>s
DBD::Pg::db::prepare(/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi/DBD/Pg.pm:161):
161: my($dbh, $statement, @attribs)= @_;
DB<1>s
DBD::Pg::db::prepare(/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi/DBD/Pg.pm:165):
165: my $sth = DBI::_new_sth($dbh, {
166: 'Statement' => $statement,
DB<1>s
DBI::_new_sth(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1128):
1128: my ($dbh, $attr, $imp_data) = @_;
DB<1>s
DBI::_new_sth(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1129):
1129: my $imp_class = $dbh->{ImplementorClass}
1130: or Carp::croak("DBI _new_sth: $dbh has no ImplementorClass");
DB<1>s
DBI::_new_sth(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1131):
1131: substr($imp_class,-4,4) = '::st';
DB<1>s
DBI::_new_sth(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1132):
1132: my $app_class = ref $dbh;
DB<1>s
DBI::_new_sth(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1133):
1133: substr($app_class,-4,4) = '::st';
DB<1>s
DBI::_new_sth(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1134):
1134: _new_handle($app_class, $dbh, $attr, $imp_data, $imp_class);
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1042):
1042: my ($class, $parent, $attr, $imp_data, $imp_class) = @_;
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1044):
1044: Carp::croak('Usage: DBI::_new_handle'
1045: .'($class_name, parent_handle, \%attr, $imp_data)'."\n"
1046: .'got: ('.join(", ",$class, $parent, $attr,
$imp_data).")\n")
1047: unless (@_ == 5 and (!$parent or ref $parent)
1048: and ref $attr eq 'HASH'
1049: and $imp_class);
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1051):
1051: $attr->{ImplementorClass} = $imp_class
1052: or Carp::croak("_new_handle($class): 'ImplementorClass'
attribute not given");
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1054):
1054: DBI->trace_msg(" New $class (for $imp_class, parent=$parent,
id=".($imp_data||'').")\n")
1055: if $DBI::dbi_debug >= 3;
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1058):
1058: my (%hash, $i, $h);
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1059):
1059: $i = tie %hash, $class, $attr; # ref to inner hash (for driver)
DB<1>s
DBI::st::TIEHASH(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1069):
1069: sub DBI::st::TIEHASH { bless $_[1] => $_[0] };
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1060):
1060: $h = bless \%hash, $class; # ref to outer hash (for
application)
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1063):
1063: DBI::_setup_handle($h, $imp_class, $parent, $imp_data);
DB<1>s
DBI::_new_handle(/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/DBI.pm:1065):
1065: return $h unless wantarray;
DB<1>s
DBD::Pg::db::prepare(/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi/DBD/Pg.pm:169):
169: DBD::Pg::st::_prepare($sth, $statement, @attribs) or
return undef;
DB<1>s
DBD::Pg::db::prepare(/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi/DBD/Pg.pm:171):
171: $sth;
DB<1>s
main::ExecuteQry(test.pl:37): if ($STATUS == $PREPARE_FAILED)
main::ExecuteQry(test.pl:38): {
DB<1>s
main::ExecuteQry(test.pl:43): or $STATUS = $EXECUTION_FAILED;
DB<1>s
main::ExecuteQry(test.pl:45): if ($STATUS == $EXECUTION_FAILED)
main::ExecuteQry(test.pl:46): {
DB<1>s
main::ExecuteQry(test.pl:49): return $SUCCESS;
DB<1>s
main::LoadTableDetails(test.pl:19):
19: while ( @row = $sth->fetchrow_array )
20: {
DB<1>s
main::LoadTableDetails(test.pl:21):
21: printf "@row\n";
DB<1>s
186724 1
test.pl
Description: Perl program
