Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > proposal: table...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 9398 of 10966
Post > Topic >>

proposal: table functions and plpgsql

by pavel.stehule@[EMAIL PROTECTED] ("Pavel Stehule") May 21, 2008 at 06:12 PM

Hello

I am returning back to my patch and older proposal
http://archives.postgresql.org/pgsql-hackers/2007-02/msg00318.php
.

Some work did Neil Conway
http://archives.postgresql.org/pgsql-hackers/2007-07/msg00501.php
and
he commited half of this patch - RETURN QUERY part.

Problematic part of my patch is implementation. Tom Lane proposal
implenation RETURNS TABLE only as syntactic sugar for RETURNS SETOF
RECORD. This is not comaptible with potential implementation, because
it adds some default variables. My solution was special argmode, so I
was able don't create default variables for output. My solution wasn't
best too. It was ugly for current plpgsql where is often used RETURN
NEXT statement (PSM doesn't know similar statement). I unlike default
variables - it simply way to variables and column names collision.

I propose following syntax for plpgsql:

CREATE OR REPLACE FUNCTION foo(m integer)
RETURNS TABLE (a integer, b integer) AS $$
DECLARE r foo; -- same name as function, this type has local visibility
BEGIN
  FOR i IN 1..m LOOP
    r.a := i; r.b := i + 1;
    RETURN NEXT r;
  END LOOP;
  RETURN;
END;
$$ LANGUAGE plpgsql;

In my proposal I don't create any default variables. Result type is
only virtual - I don't need write it to system directory. I thing it's
better than using some specific predeclared type as RESULTTYPE OR
RESULTSET.

What do you thing about?

Regards
Pavel Stehule

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
 




 9 Posts in Topic:
proposal: table functions and plpgsql
pavel.stehule@[EMAIL PROT  2008-05-21 18:12:27 
Re: proposal: table functions and plpgsql
hannu@[EMAIL PROTECTED]   2008-05-21 20:28:12 
Re: proposal: table functions and plpgsql
mmoncure@[EMAIL PROTECTED  2008-05-21 13:31:01 
Re: proposal: table functions and plpgsql
hannu@[EMAIL PROTECTED]   2008-05-21 21:14:47 
Re: proposal: table functions and plpgsql
pavel.stehule@[EMAIL PROT  2008-05-21 23:01:10 
Re: proposal: table functions and plpgsql
pavel.stehule@[EMAIL PROT  2008-05-21 23:03:53 
Re: proposal: table functions and plpgsql
hannu@[EMAIL PROTECTED]   2008-05-22 16:01:55 
Re: proposal: table functions and plpgsql
pavel.stehule@[EMAIL PROT  2008-05-22 15:36:37 
Re: proposal: table functions and plpgsql
pavel.stehule@[EMAIL PROT  2008-06-01 20:53:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 12:14:08 CST 2008.