Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B891E133616B for ; Tue, 1 Feb 2011 15:33:42 -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 58465-02 for ; Tue, 1 Feb 2011 19:33:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1B6E81337B4A for ; Tue, 1 Feb 2011 15:33:33 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p11JV22E001076; Tue, 1 Feb 2011 14:31:02 -0500 (EST) To: "Kevin Grittner" cc: "Steve White" , pgsql-bugs@postgresql.org Subject: Re: Feature request: include script file into function body In-reply-to: <4D4807EF020000250003A112@gw.wicourts.gov> References: <20110201112120.GA1327@cashmere.aip.de> <26900.1296576145@sss.pgh.pa.us> <20110201164422.GA3023@cashmere.aip.de> <4D47EB12020000250003A0EE@gw.wicourts.gov> <20110201175718.GB6707@cashmere.aip.de> <4D48023F020000250003A104@gw.wicourts.gov><4D48023F020000250003A104@gw.wicourts.gov> <590.1296587324@sss.pgh.pa.us> <4D4807EF020000250003A112@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Tue, 01 Feb 2011 13:17:35 -0600" Date: Tue, 01 Feb 2011 14:31:02 -0500 Message-ID: <1075.1296588662@sss.pgh.pa.us> From: Tom Lane 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/21 X-Sequence-Number: 29293 "Kevin Grittner" writes: > Tom Lane wrote: >> The usual procedure is to put the whole CREATE FUNCTION statement >> into a file, which you can then send with \i. I'm not quite >> seeing the point of having just the body in a file? It's not like >> the body is typically useful to run as standalone code. > The OP mentioned text highlighting, which has bothered me at times Ah, that's a fair point, particular with smarter editors. Seems like what you want here is a variant of \i that pulls in the file, escapes it as a string literal, and appends that to the query buffer. Then you write something like create function ... as \istring myfunction.pl ; A backslash command defined that way might have other applications than CREATE FUNCTION, too. regards, tom lane