Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client. - Mailing list pgsql-hackers

From Jonah H. Harris
Subject Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.
Date
Msg-id 36e682920903160926w1dbaa73bpb36487397af6c2d1@mail.gmail.com
Whole thread Raw
In response to Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.  (Tomasz Olszak <tolszak@o2.pl>)
Responses Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.  (Magnus Hagander <magnus@hagander.net>)
Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.  (Tomasz Olszak <tolszak@o2.pl>)
Re: Problem with accesing Oracle from plperlu functionwhen using remote pg client.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, Mar 16, 2009 at 11:09 AM, Tomasz Olszak <tolszak@o2.pl> wrote:
So it looks like that plperlu function is executing from remote and local clients with the same set of environment variable.

It has nothing to do with the environment variables.
 
So I don't have a clue how can I iron out this issue.

Finally, my low-level Oracle knowledge does benefit Postgres :)

It's a TNS parsing error due to a combination of Oracle's use of a Lispish s-expression-like name-value pair format and Postgres' process listing format for remote connections. 

On connection, the Oracle client sends the current application name to the Oracle server (which is listed in the V$SESSION view); in the case of Postgres, the program name is the current backend process name text.  Because Oracle picks up Postgres' backend text, "postgres: www postgres 192.168.1.1(13243)", the (13243) screws up Oracle's TNS parser which prevents it from resolving the connection.  This doesn't happen when you're connected to PG locally, because the backend text is, "postgres: www postgres [local]".

The solution to this is to change the following line in src/backend/postmaster/postmaster.c:

remote_port[0] == '\0' ? "%s" : "%s(%s)"

TO

remote_port[0] == '\0' ? "%s" : "%s[%s]"
OR
remote_port[0] == '\0' ? "%s" : "%s:%s"

Which I would prefer as a nice change to make overall.

--
Jonah H. Harris, Senior DBA
myYearbook.com

pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: small but useful patches for text search
Next
From: Gregory Stark
Date:
Subject: Re: small but useful patches for text search