dbTalk Databases Forums  

[SQL] very frustrating feature-bug

mailing.database.pgsql-sql mailing.database.pgsql-sql


Discuss [SQL] very frustrating feature-bug in the mailing.database.pgsql-sql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
silly sad
 
Posts: n/a

Default [SQL] very frustrating feature-bug - 02-17-2010 , 01:20 AM






acc=>

CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT)
RETURNS usr AS $$
INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4)
RETURNING usr.*;
$$ LANGUAGE sql SECURITY DEFINER;

acc=>

ERROR: return type mismatch in function declared to return usr
DETAIL: Function's final statement must be a SELECT.
CONTEXT: SQL function "add_user"

SURPRISE :-) SURPRISE :-)

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #2  
Old   
Jasen Betts
 
Posts: n/a

Default Re: [SQL] very frustrating feature-bug - 02-17-2010 , 04:51 AM






On 2010-02-17, silly sad <sad (AT) bankir (DOT) ru> wrote:
Quote:
acc=

CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT)
RETURNS usr AS $$
INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4)
RETURNING usr.*;
$$ LANGUAGE sql SECURITY DEFINER;

acc=

ERROR: return type mismatch in function declared to return usr
DETAIL: Function's final statement must be a SELECT.
CONTEXT: SQL function "add_user"

SURPRISE :-) SURPRISE :-)
SQL functions are inlined when invoked, and so must be valid subselects.

rewrite it in plpgsql.

CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT)
RETURNS usr AS $$
DECLARE
retval usr;
BEGIN
INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4)
RETURNING usr.* INTO retval;
RETURN retval;
END;
$$ LANGUAGE PLPGSQL SECURITY DEFINER;


--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #3  
Old   
silly sad
 
Posts: n/a

Default Re: [SQL] very frustrating feature-bug - 02-17-2010 , 05:34 AM



On 02/17/10 13:51, Jasen Betts wrote:
Quote:
On 2010-02-17, silly sad<sad (AT) bankir (DOT) ru> wrote:

acc=

CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT)
RETURNS usr AS $$
INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4)
RETURNING usr.*;
$$ LANGUAGE sql SECURITY DEFINER;

acc=

ERROR: return type mismatch in function declared to return usr
DETAIL: Function's final statement must be a SELECT.
CONTEXT: SQL function "add_user"

SURPRISE :-) SURPRISE :-)

SQL functions are inlined when invoked, and so must be valid subselects.

rewrite it in plpgsql.
thanx for advice.

may i ask? when this feature will be fixed?
(now i am using 8.3.9)


--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #4  
Old   
Pavel Stehule
 
Posts: n/a

Default Re: [SQL] very frustrating feature-bug - 02-17-2010 , 05:37 AM



2010/2/17 silly sad <sad (AT) bankir (DOT) ru>:
Quote:
On 02/17/10 13:51, Jasen Betts wrote:

On 2010-02-17, silly sad<sad (AT) bankir (DOT) ru> Â*wrote:

acc=

CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT)
RETURNS usr AS $$
Â* Â*INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4)
Â* Â*RETURNING usr.*;
$$ LANGUAGE sql SECURITY DEFINER;

acc=

ERROR: Â*return type mismatch in function declared to return usr
DETAIL: Â*Function's final statement must be a SELECT.
CONTEXT: Â*SQL function "add_user"

SURPRISE :-) SURPRISE :-)

SQL functions are inlined when invoked, and so must be valid subselects.

rewrite it in plpgsql.

thanx for advice.

may i ask? when this feature will be fixed?
(now i am using 8.3.9)

please, report it as bug to pgsql-bugs

Regards
Pavel Stehule

Quote:
--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #5  
Old   
Tom Lane
 
Posts: n/a

Default Re: [SQL] very frustrating feature-bug - 02-17-2010 , 09:27 AM



silly sad <sad (AT) bankir (DOT) ru> writes:
Quote:
may i ask? when this feature will be fixed?
(now i am using 8.3.9)
The example works fine for me in 8.4.

regards, tom lane

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #6  
Old   
Achilleas Mantzios
 
Posts: n/a

Default Re: [SQL] very frustrating feature-bug - 02-17-2010 , 09:33 AM



Óôéò Wednesday 17 February 2010 17:27:11 ï/ç Tom Lane Ýãñáøå:
Quote:
silly sad <sad (AT) bankir (DOT) ru> writes:
may i ask? when this feature will be fixed?
(now i am using 8.3.9)

The example works fine for me in 8.4.
Same for me,
postgres@smadevnew:~>
postgres@smadevnew:~> psql
psql (8.4.1)
Type "help" for help.

dynacom=# CREATE OR REPLACE FUNCTION add_user (TEXT, TEXT, TEXT, TEXT)
dynacom-# RETURNS usr AS $$
dynacom$# INSERT INTO usr (login,pass,name,email) VALUES ($1,$2,$3,$4)
dynacom$# RETURNING usr.*;
dynacom$# $$ LANGUAGE sql SECURITY DEFINER;
CREATE FUNCTION
dynacom=#
dynacom=#


Quote:
regards, tom lane



--
Achilleas Mantzios

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.