OSX Postgres PL/Perl Problem with Finance::Quote/Options

Started by Peter Panabout 15 years ago5 messagesgeneral
Jump to latest
#1Peter Pan
ganbaru83@hotmail.com

Hi@all,

I have a weird problem on dev server (using a Mac Mini 2010 Edt., 10.6.7 OSX).

I use two Perl modules Finance::Quote and Finance::QuoteOptions in a stored PL/Perl procedure which run without problems on a standard LINUX environment (currently in production on CentOS5). Unfortunately on OSX it seems not to be able to properly connect and retrieve the data from Yahoo.

Using the same code in a local perl file (under db user) it works without problems, but fails in the stored procedure. I don't get any compilation errors during import or execution and also no exceptions while the code is executed. As mentioned, the same function works fine under Linux.

Environment:
- OSX 10.6.7
- Postgres 9.0.2 (compiled from source / config options --with-openssl --with-perl --with-libraries=/opt/local/lib --with-includes=/opt/local/include / readline was installed via ports)
- Perl 5.12.3 (compled from source under /usr/local/ linked via enviromentable variables in .profile / config options ./configure.gnu -des -Duseshrplib --prefix=/usr/local/perl5)

I guess this is some weird behaviour under OSX (one of many) and hopefully somebody stumbled over this already in the past.

Thank you in advance!

cheers,
Alex

Here is a condensed version of the function to illustrate the problem:

CREATE FUNCTION func_test() RETURNS SETOF maxpain AS $$

use strict;
#use warnings;
use Finance::Quote;
use Finance::QuoteOptions;
use Time::localtime;

elog(INFO, "Starting Yahoo data retrieval for: C;");

# YAHOO! DATA RETRIEVAL & PREPARATION
# Variables
my @work_array; # Main work array filled with final & calculated values

my $_stock_symbol = 'C';

# Get Quote Information
my $q = Finance::Quote->new();
my %data = $q->fetch('nyse', 'C');
if (!defined %data) { elog(INFO, "Quote conn. error;");
#return_next({status=>3});
return undef;
}

# Get Quote Options (Put OI, Call OI, Strike Put/Call etc.)
my $qf=Finance::QuoteOptions->new('C');
if (!$qf->retrieve) { elog(INFO, "QuoteOptions conn. errors");
return undef;
}
$$ LANGUAGE plperlu;

#2Vibhor Kumar
vibhor.kumar@enterprisedb.com
In reply to: Peter Pan (#1)
Re: OSX Postgres PL/Perl Problem with Finance::Quote/Options

On Mar 29, 2011, at 9:11 PM, Peter Pan wrote:

I use two Perl modules Finance::Quote and Finance::QuoteOptions in a stored PL/Perl procedure which run without problems on a standard LINUX environment (currently in production on CentOS5). Unfortunately on OSX it seems not to be able to properly connect and retrieve the data from Yahoo.

Using the same code in a local perl file (under db user) it works without problems, but fails in the stored procedure. I don't get any compilation errors during import or execution and also no exceptions while the code is executed. As mentioned, the same function works fine under Linux.

Environment:
- OSX 10.6.7
- Postgres 9.0.2 (compiled from source / config options --with-openssl --with-perl --with-libraries=/opt/local/lib --with-includes=/opt/local/include / readline was installed via ports)
- Perl 5.12.3 (compled from source under /usr/local/ linked via enviromentab le variables in .profile / config options ./configure.gnu -des -Duseshrplib --prefix=/usr/local/perl5)

Any Error Message?

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com

#3Peter Pan
ganbaru83@hotmail.com
In reply to: Vibhor Kumar (#2)
Re: OSX Postgres PL/Perl Problem with Finance::Quote/Options

Subject: Re: [GENERAL] OSX Postgres PL/Perl Problem with Finance::Quote/Options
From: vibhor.kumar@enterprisedb.com
Date: Wed, 30 Mar 2011 03:01:29 +0530
CC: pgsql-general@postgresql.org
To: ganbaru83@hotmail.com

On Mar 29, 2011, at 9:11 PM, Peter Pan wrote:

I use two Perl modules Finance::Quote and Finance::QuoteOptions in a stored PL/Perl procedure which run without problems on a standard LINUX environment (currently in production on CentOS5). Unfortunately on OSX it seems not to be able to properly connect and retrieve the data from Yahoo.

Using the same code in a local perl file (under db user) it works without problems, but fails in the stored procedure. I don't get any compilation errors during import or execution and also no exceptions while the code is executed. As mentioned, the same function works fine under Linux.

Environment:
- OSX 10.6.7
- Postgres 9.0.2 (compiled from source / config options --with-openssl --with-perl --with-libraries=/opt/local/lib --with-includes=/opt/local/include / readline was installed via ports)
- Perl 5.12.3 (compled from source under /usr/local/ linked via enviromentab le variables in .profile / config options ./configure.gnu -des -Duseshrplib --prefix=/usr/local/perl5)

Any Error Message?

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com

Unfortunately none at all, it just fails during the fetch and can't find any error messages anywhere. As stated, the same module works without problems in a local separate perl script.

Any ideas?

cheers,

#4Alex Hunsaker
badalex@gmail.com
In reply to: Peter Pan (#3)
Re: OSX Postgres PL/Perl Problem with Finance::Quote/Options

2011/3/30 Peter Pan <ganbaru83@hotmail.com>:
...

Unfortunately none at all, it just fails during the fetch and can't find any
error messages anywhere. As stated, the same module works without problems
in a local separate perl script.

Any ideas?

Skimming the source of Finance::Quote::Yahoo::USA (which seems to be
what Finance::Quote uses when you ->fetch('nyse')) it looks like it
makes a request to "http://finance.yahoo.com/d&quot; with LWP. Maybe you
could try using LWP directly and see if that complains?

#5Peter Pan
ganbaru83@hotmail.com
In reply to: Alex Hunsaker (#4)
Re: OSX Postgres PL/Perl Problem with Finance::Quote/Options

From: badalex@gmail.com
Date: Wed, 30 Mar 2011 09:33:50 -0600
Subject: Re: [GENERAL] OSX Postgres PL/Perl Problem with Finance::Quote/Options
To: ganbaru83@hotmail.com
CC: pgsql-general@postgresql.org

2011/3/30 Peter Pan <ganbaru83@hotmail.com>:
...

Unfortunately none at all, it just fails during the fetch and can't find any
error messages anywhere. As stated, the same module works without problems
in a local separate perl script.

Any ideas?

Skimming the source of Finance::Quote::Yahoo::USA (which seems to be
what Finance::Quote uses when you ->fetch('nyse')) it looks like it
makes a request to "http://finance.yahoo.com/d&quot; with LWP. Maybe you
could try using LWP directly and see if that complains?

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Looking through a couple of logs I finally found an indication for the error: could not lookup DNS configuration info service: (ipc/send) invalid destination port
this seems only to happen when executed with Postgres - i think its an underlying OSX problem in combination with postgres and found some entries online but no real solution for the problem.

cheers,