Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eP8JM-0006UM-Te for pgsql-admin@arkaria.postgresql.org; Wed, 13 Dec 2017 14:47:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eP8JM-0005eY-C3 for pgsql-admin@arkaria.postgresql.org; Wed, 13 Dec 2017 14:47:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eP8JM-0005eO-5A for pgsql-admin@lists.postgresql.org; Wed, 13 Dec 2017 14:47:04 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eP8JA-0000x4-Fx for pgsql-admin@postgresql.org; Wed, 13 Dec 2017 14:47:03 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id B3D764D1EC; Wed, 13 Dec 2017 15:46:49 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id 0j9bBfFAD4-y; Wed, 13 Dec 2017 15:46:48 +0100 (CET) Message-ID: <1513176406.5128.36.camel@cybertec.at> Subject: Re: WG: Extension using the current connection handle From: Laurenz Albe To: "Brandl, Wolfgang" , "pgsql-admin@postgresql.org" Date: Wed, 13 Dec 2017 15:46:46 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Wolfgang Brandl wrote: > I have written a extension in postgres to call a Oracle Stored procedure. > We have a Postgres table holding the usernames and password related to the Oracle SID. > > In my extension I wanted to select the username and password out of this table. > Do I have to make a new Postgres connection or can I somehow use the current connection handel from the session Where the extension will be called? You would use the SPI interface to query database tables from a C function: https://www.postgresql.org/docs/current/static/spi.html If you don't feel like reinventing the wheel, there are tricks how to do that with oracle_fdw. You could create an Oracle table with a BEFORE INSERT trigger that executes the procedure. See https://stackoverflow.com/a/46360383/6464308 Yours, Laurenz Albe