Skip site navigation (1) Skip section navigation (2)

Re: Feature request: include script file into function body

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Steve White" <swhite(at)aip(dot)de>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Feature request: include script file into function body
Date: 2011-02-01 19:31:02
Message-ID: 1075.1296588662@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2011-02-01 19:35:01
Subject: Re: Feature request: include script file into function body (better syntax)
Previous:From: Kevin GrittnerDate: 2011-02-01 19:17:35
Subject: Re: Feature request: include script file into function body

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group