From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Steve White <swhite@aip.de>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Feature request: include script file into function body
Date: Tue, 01 Feb 2011 14:31:02 -0500
Message-ID: <1075.1296588662@sss.pgh.pa.us> (raw)
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>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Tom Lane <tgl@sss.pgh.pa.us> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, Kevin.Grittner@wicourts.gov, swhite@aip.de
Subject: Re: Feature request: include script file into function body
In-Reply-To: <1075.1296588662@sss.pgh.pa.us>
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> <590.1296587324@sss.pgh.pa.us> <4D4807EF020000250003A112@gw.wicourts.gov> <1075.1296588662@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox