From: | Steve White <swhite(at)aip(dot)de> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: Feature request: include script file into function body |
Date: | 2011-02-02 11:18:08 |
Message-ID: | 20110202111808.GA21282@cashmere.aip.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
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...
if only I could get it to work.
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'
====================================================================
So far, so good.
But the :'yadda'; produces an error--it seems the variable yadda isn't
expanded in the presence of the quotes.
====================================================================
d=# CREATE FUNCTION yadda_yadda() returns text language plpythonu AS
:'yadda';
ERROR: syntax error at or near ":"
LINE 2: :'yadda';
====================================================================
Without the quotes, the colon expands the variable, but not into a
string function body:
====================================================================
d=# CREATE FUNCTION yadda_yadda() returns text language plpythonu AS
:yadda;
ERROR: syntax error at or near "print"
LINE 2: print 'hello world';
====================================================================
Just for completeness and blind optimism let's try putting string
delimiters on the outside. The command succeeds but with the wrong
effect.
====================================================================
d=# CREATE OR REPLACE FUNCTION yadda_yadda() returns text language plpythonu AS
$$:yadda$$;
CREATE FUNCTION
cepheids=# \df+ yadda_yadda
List of functions
Schema | Name | Result data type | Argument data types | Type | Volatility | Owner | Language | Source code | Description
-----------+-------------+------------------+---------------------+--------+------------+----------+-----------+-------------+-------------
astronomy | yadda_yadda | text | | normal | volatile | cepheids | plpythonu | :yadda |
====================================================================
Please explain.
--
| - - - - - - - - - - - - - - - - - - - - - - - - -
| 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
| - - - - - - - - - - - - - - - - - - - - - - - - -
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2011-02-02 11:41:24 | Re: Feature request: include script file into function body |
Previous Message | Pankaj Singh | 2011-02-02 06:54:22 | BUG #5861: lo_import and lo_export methods not working from the client side if database is at remote |