Re: [BUGS] Feature request: include script file into function body

2011-02-03 Thread Jasen Betts
On 2011-02-02, Steve White wrote: > Hi, Robert, > > I made a file 'yadda_yadda.py' containing only the line: > print 'hello world' > > > d=# \set yadda `cat yadda_yadda.py` > d=# \echo :yadda > print 'hello world' >==

Re: [BUGS] Feature request: include script file into function body

2011-02-03 Thread Jasen Betts
On 2011-02-01, Steve White wrote: > 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 bo

Re: [BUGS] Feature request: include script file into function body

2011-02-02 Thread Pavel Stehule
2011/2/2 Tom Lane : > Pavel Stehule writes: >> probably you need a third form of expansion - not implemented yet >> ":$$var$$ > > Seems quite useless.  A string literal is a string literal. > I don't propose this form now. I saying so this form can be usefull for Steve. It appends a started and

Re: [BUGS] Feature request: include script file into function body

2011-02-02 Thread Tom Lane
Pavel Stehule writes: > probably you need a third form of expansion - not implemented yet > ":$$var$$ Seems quite useless. A string literal is a string literal. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your su

Re: [BUGS] Feature request: include script file into function body

2011-02-02 Thread Tom Lane
Steve White writes: > But the :'yadda'; produces an error--it seems the variable yadda isn't > expanded in the presence of the quotes. Apparently you're using a pre-9.0 psql. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make chang

Re: [BUGS] Feature request: include script file into function body

2011-02-02 Thread Pavel Stehule
Hello probably you need a third form of expansion - not implemented yet ":$$var$$ escaping :'xxx' is designed for SQL language, not for Python :( Regards Pavel 2011/2/2 Steve White : > Hi, Robert, > > On  1.02.11, Robert Haas wrote: >> >> Can't you already do it this way: >> >> \set yadda `ca

Re: [BUGS] Feature request: include script file into function body

2011-02-02 Thread Steve White
Hi, Robert, On 1.02.11, Robert Haas wrote: > > Can't you already do it this way: > > \set yadda `cat yadda_yadda.py` > CREATE FUNCTION yadda_yadda() returns text language plpythonu AS > :'yadda'; > > I guess it probably won't work on Windows... > This would also satisfy my immediate needs...

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Tom Lane
"Kevin Grittner" writes: > Robert Haas wrote: >> Can't you already do it this way: >> >> \set yadda `cat yadda_yadda.py` >> CREATE FUNCTION yadda_yadda() returns text language plpythonu AS >> :'yadda'; > Clever, but not pretty. Yeah. So the question is whether this is useful enough to justif

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Kevin Grittner
Robert Haas wrote: > Can't you already do it this way: > > \set yadda `cat yadda_yadda.py` > CREATE FUNCTION yadda_yadda() returns text language plpythonu AS > :'yadda'; OK, that works. It sure ain't pretty, though. Clever, but not pretty. -Kevin -- Sent via pgsql-bugs mailing list (pg

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Robert Haas
On Tue, Feb 1, 2011 at 3:09 PM, Kevin Grittner wrote: > Steve White wrote: >> On  1.02.11, Tom Lane wrote: >>> "Kevin Grittner" writes: Maybe some option for the \i command?  \iq (for input quoted) with automatic $$ quoting around what is read? >>> That way you could do something

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Kevin Grittner
Steve White wrote: > On 1.02.11, Tom Lane wrote: >> "Kevin Grittner" writes: >>> Maybe some option for the \i command? \iq (for input quoted) >>> with automatic $$ quoting around what is read? >> >>> That way you could do something like: >> >>> CREATE FUNCTION yadda_yadda() returns text langu

Re: [BUGS] Feature request: include script file into function body (better syntax)

2011-02-01 Thread Kevin Grittner
Steve White wrote: > I said that the script interpreter might do this... The script interpreter runs on the server. -Kevin -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs

Re: [BUGS] Feature request: include script file into function body (better syntax)

2011-02-01 Thread Steve White
Hi Tom, I already agreed to Kevin's proposed syntax, and it is better than my suggestion, but mine isn't quite as crazy as you make out. On 1.02.11, Tom Lane wrote: > Steve White writes: > > Try this instead: > > > > > CREATE OR REPLACE FUNCTION

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Steve White
Hi guys, On 1.02.11, Tom Lane wrote: > "Kevin Grittner" writes: > > Maybe some option for the \i command? \iq (for input quoted) with > > automatic $$ quoting around what is read? > > > That way you could do something like: > > > CREATE FUNCTION yadda_yadda() returns text language plpython

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Tom Lane
"Kevin Grittner" writes: > Maybe some option for the \i command? \iq (for input quoted) with > automatic $$ quoting around what is read? > That way you could do something like: > CREATE FUNCTION yadda_yadda() returns text language plpythonu as > \iq yadda_yadda.py > ; Just got this --- looks

Re: [BUGS] Feature request: include script file into function body (better syntax)

2011-02-01 Thread Tom Lane
Steve White writes: > Try this instead: > > CREATE OR REPLACE FUNCTION > myfunc( ... ) > RETURNS VOID AS '#PGSQL_IMPORT filename' LANGUAGE PLPYTHONU; > I think having psql decide that string

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Tom Lane
"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 standalon

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Kevin Grittner
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 tex

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Tom Lane
"Kevin Grittner" writes: > It seems to me that something which let you pull the body of a > script file into the statement on the *client* side of the > connection, before sending the CREATE FUNCTION statement to the > server would not only be a lot more secure (you could only read > files that th

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Gary Doades
On 01/02/2011 6:50 PM, Steve White wrote: Hi again, all, OK I think I now know what the misunderstanding is. [Please don't top-post. Rearranged for clarity.] Steve White wrote: On 1.02.11, Tom Lane wrote: Steve White writes: It would be really nice to have a way to load script (especia

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Kevin Grittner
Steve White wrote: > I *DO NOT MEAN* that a query should run about grabbing files off > the server, or wherever. > > I meant something like the replacement that happens with the \i > command in loading SQL, and under similar circumstances, except > that somehow non-SQL code is loadad in a funct

Re: [BUGS] Feature request: include script file into function body (better syntax)

2011-02-01 Thread Steve White
Hi again, Now that I know what got you all riled, I can propose something that might be more satisfactory. See below. On 1.02.11, Steve White wrote: > Hi again, all, > > OK I think I now know what the misunderstanding is. > > > [Please don't top-post. Rearranged for clarity.] > > > > Steve

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Kevin Grittner
Steve White wrote: > On 1.02.11, Kevin Grittner wrote: >> Steve White wrote: >>> Isn't the \i command a similar security hole? >> >> That is run by a client program on a client machine. > > Sorry I don't understand this remark. The CREATE FUNCTION statement is parsed and executed on the

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Steve White
Hi again, all, OK I think I now know what the misunderstanding is. > [Please don't top-post. Rearranged for clarity.] > > Steve White wrote: > > On 1.02.11, Tom Lane wrote: > >> Steve White writes: > >>> It would be really nice to have a way to load script (especially > >>> Python and Perl)

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Bruce Momjian
Steve White wrote: > Hi Kevin, > > On 1.02.11, Kevin Grittner wrote: > > [Please don't top-post. Rearranged for clarity.] > > > As you like. > > > Steve White wrote: > > > On 1.02.11, Tom Lane wrote: > > >> Steve White writes: > > >>> It would be really nice to have a way to load script (e

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Steve White
Hi Kevin, On 1.02.11, Kevin Grittner wrote: > [Please don't top-post. Rearranged for clarity.] > As you like. > Steve White wrote: > > On 1.02.11, Tom Lane wrote: > >> Steve White writes: > >>> It would be really nice to have a way to load script (especially > >>> Python and Perl) from a s

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Steve White
Hi Pavel, On 1.02.11, Pavel Stehule wrote: > Hello > > 2011/2/1 Steve White : > > Hi Tom, > > > > This seems like a detail that is beside the point I'm making. > > But security is important, so let's think about it. > > > > PostgreSQL has an \i command, which loads the text from any readable fil

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Kevin Grittner
[Please don't top-post. Rearranged for clarity.] Steve White wrote: > On 1.02.11, Tom Lane wrote: >> Steve White writes: >>> It would be really nice to have a way to load script (especially >>> Python and Perl) from a separate file into a function body. >> >> This seems like a security hole,

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Pavel Stehule
Hello 2011/2/1 Steve White : > Hi Tom, > > This seems like a detail that is beside the point I'm making. > But security is important, so let's think about it. > > PostgreSQL has an \i command, which loads the text from any readable file > interpretes and executes it as further PostgreSQL commands.

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Steve White
Hi Tom, This seems like a detail that is beside the point I'm making. But security is important, so let's think about it. PostgreSQL has an \i command, which loads the text from any readable file interpretes and executes it as further PostgreSQL commands. I'm proposing a similar mechanism that w

Re: [BUGS] Feature request: include script file into function body

2011-02-01 Thread Tom Lane
Steve White writes: > It would be really nice to have a way to load script (especially Python > and Perl) from a separate file into a function body. This seems like a security hole, ie, you could use it to read any file the backend has access to. regards, tom lane -- Se