Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 1C41A1337B34 for ; Tue, 1 Feb 2011 07:21:29 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 11987-01 for ; Tue, 1 Feb 2011 11:21:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail0.aip.de (maigret.aip.de [141.33.160.2]) by mail.postgresql.org (Postfix) with SMTP id 1F4A513364DE for ; Tue, 1 Feb 2011 07:21:20 -0400 (AST) Received: (qmail 5629 invoked from network); 1 Feb 2011 10:15:47 -0000 Received: from cashmere.aip.de (141.33.4.98) by mailout.aip.de with SMTP; 1 Feb 2011 10:15:47 -0000 Received: from cashmere.aip.de (localhost.localdomain [127.0.0.1]) by cashmere.aip.de (8.13.8/8.13.8) with ESMTP id p11BLKek001470 for ; Tue, 1 Feb 2011 12:21:20 +0100 Received: (from swhite@localhost) by cashmere.aip.de (8.13.8/8.13.8/Submit) id p11BLKAl001469 for pgsql-bugs@postgresql.org; Tue, 1 Feb 2011 12:21:20 +0100 X-Authentication-Warning: cashmere.aip.de: swhite set sender to swhite@aip.de using -f Date: Tue, 1 Feb 2011 12:21:20 +0100 From: Steve White To: pgsql-bugs@postgresql.org Subject: Feature request: include script file into function body Message-ID: <20110201112120.GA1327@cashmere.aip.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i "Organization: Astrophysikalisches Institut Potsdam" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/2 X-Sequence-Number: 29274 Hi I asked on pgsql-general 31 Jan 2011 if there were a way to do this, and got no response, so let's make it a feature request. It would be really nice to have a way to load script (especially Python and Perl) from a separate file into a function body. Some advantages would be: to run a code checker outside of Postgresql, and to make things easier for source code colorizers. I have in mind syntax something like ================================================ CREATE OR REPLACE FUNCTION myfunc( ... ) RETURNS VOID FROM 'ScriptFile.py' LANGUAGE PLPYTHONU; ================================================ I think the FROM keyword fits here, and serves to distinguish behavior from AS. This is just a suggestion though. The file name ought to work in the usual way: without a leading slash to be interpreted as a path relative to the current directory (in case the command is inside an .sql file, that would be the directory containing the .sql file). With a leading slash, it would be taken as an absolute path. For distribution purposes, it would also be nice to have some portable means of indicating the installation directory of the running PostgreSQL, perhaps with an environment variable replacement (e.g. $LIBDIR). Cheers! -- | - - - - - - - - - - - - - - - - - - - - - - - - - | Steve White +49(331)7499-202 | E-Science Zi. 27 Villa Turbulenz | - - - - - - - - - - - - - - - - - - - - - - - - - | Astrophysikalisches Institut Potsdam (AIP) | An der Sternwarte 16, D-14482 Potsdam | | Vorstand: Prof. Dr. Matthias Steinmetz, Peter A. Stolz | | Stiftung privaten Rechts, Stiftungsverzeichnis Brandenburg: III/7-71-026 | - - - - - - - - - - - - - - - - - - - - - - - - -