pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6043: Compilation PLpgsql Succesful but execution bad
6+ messages / 4 participants
[nested] [flat]
* BUG #6043: Compilation PLpgsql Succesful but execution bad
@ 2011-05-27 14:05 Emanuel <postgres.arg@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Emanuel @ 2011-05-27 14:05 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged online:
Bug reference: 6043
Logged by: Emanuel
Email address: postgres.arg@gmail.com
PostgreSQL version: 9.1 beta
Operating system: Ubuntu 10.04 2.6.31
Description: Compilation PLpgsql Succesful but execution bad
Details:
postgres=# CREATE OR REPLACE FUNCTION p_() RETURNS TABLE (i int) AS $$
DECLARE
BEGIN
SELECT * FROM p; --<<<-- here must ne RETURN QUERY ..
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION
postgres=# select p_();
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "p_" line 4 at SQL statement
I don't know if it's really a bug or a feature request. But seems that the
function compiles well without checking the existence of a RETURN QUERY. I
think the best in this cases is raise an error during compilation.
Thougths?
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6043: Compilation PLpgsql Succesful but execution bad
@ 2011-05-27 14:18 Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
parent: Emanuel <postgres.arg@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Heikki Linnakangas @ 2011-05-27 14:18 UTC (permalink / raw)
To: Emanuel <postgres.arg@gmail.com>; +Cc: pgsql-bugs
On 27.05.2011 17:05, Emanuel wrote:
> postgres=# CREATE OR REPLACE FUNCTION p_() RETURNS TABLE (i int) AS $$
> DECLARE
> BEGIN
> SELECT * FROM p; --<<<-- here must ne RETURN QUERY ..
> END;
> $$ LANGUAGE plpgsql;
> CREATE FUNCTION
> postgres=# select p_();
> ERROR: query has no destination for result data
> HINT: If you want to discard the results of a SELECT, use PERFORM instead.
> CONTEXT: PL/pgSQL function "p_" line 4 at SQL statement
>
> I don't know if it's really a bug or a feature request. But seems that the
> function compiles well without checking the existence of a RETURN QUERY. I
> think the best in this cases is raise an error during compilation.
Yeah, the PL/pgSQL compiler isn't smart enough to catch that at
compilation time. It's easy to see that there's a RETURN missing from a
simple function like that, but not so easy in general. For example:
CREATE FUNCTION AS foo() RETURNS text $$
declare
i int4;
begin
i := 0;
loop
IF i = 100 THEN
RETURN 'done';
END IF
end
end;
$$ LANGUAGE plpgsql;
The compiler would have to determine that the loop never ends, or it
would complain that there's no RETURN at the end.
Many compilers for other languages do that kind of analysis, but it
usually only results in a warning, and compilers sometimes get that
wrong. I don't think it's worthwhile to do that, but of course, patches
are welcome.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6043: Compilation PLpgsql Succesful but execution bad
@ 2011-05-28 09:53 Emanuel Calvo <postgres.arg@gmail.com>
parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Calvo @ 2011-05-28 09:53 UTC (permalink / raw)
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; +Cc: pgsql-bugs
El 27/05/2011 16:18, "Heikki Linnakangas" <
heikki.linnakangas@enterprisedb.com> escribió:
> On 27.05.2011 17:05, Emanuel wrote:
>> postgres=# CREATE OR REPLACE FUNCTION p_() RETURNS TABLE (i int) AS $$
>> DECLARE
>> BEGIN
>> SELECT * FROM p; --<<<-- here must ne RETURN QUERY ..
>> END;
>> $$ LANGUAGE plpgsql;
>> CREATE FUNCTION
>> postgres=# select p_();
>> ERROR: query has no destination for result data
>> HINT: If you want to discard the results of a SELECT, use PERFORM
instead.
>> CONTEXT: PL/pgSQL function "p_" line 4 at SQL statement
>>
>> I don't know if it's really a bug or a feature request. But seems that
the
>> function compiles well without checking the existence of a RETURN QUERY.
I
>> think the best in this cases is raise an error during compilation.
Thanks Heikki for your fast response! ^^
> The compiler would have to determine that the loop never ends, or it
> would complain that there's no RETURN at the end.
>
> Many compilers for other languages do that kind of analysis, but it
> usually only results in a warning, and compilers sometimes get that
> wrong. I don't think it's worthwhile to do that, but of course, patches
> are welcome.
>
Yeah, it's not a very big concern, althougth cold be taken for future
improvements
in plpgsql. I very far for submit a patch :P
Regards,
E
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6043: Compilation PLpgsql Succesful but execution bad
@ 2011-05-28 11:53 Pavel Stehule <pavel.stehule@gmail.com>
parent: Emanuel Calvo <postgres.arg@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Pavel Stehule @ 2011-05-28 11:53 UTC (permalink / raw)
To: Emanuel Calvo <postgres.arg@gmail.com>; +Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs
2011/5/28 Emanuel Calvo <postgres.arg@gmail.com>:
> El 27/05/2011 16:18, "Heikki Linnakangas"
> <heikki.linnakangas@enterprisedb.com> escribió:
>> On 27.05.2011 17:05, Emanuel wrote:
>>> postgres=# CREATE OR REPLACE FUNCTION p_() RETURNS TABLE (i int) AS $$
>>> DECLARE
>>> BEGIN
>>> SELECT * FROM p; --<<<-- here must ne RETURN QUERY ..
>>> END;
>>> $$ LANGUAGE plpgsql;
>>> CREATE FUNCTION
>>> postgres=# select p_();
>>> ERROR: query has no destination for result data
>>> HINT: If you want to discard the results of a SELECT, use PERFORM
>>> instead.
>>> CONTEXT: PL/pgSQL function "p_" line 4 at SQL statement
>>>
>>> I don't know if it's really a bug or a feature request. But seems that
>>> the
>>> function compiles well without checking the existence of a RETURN QUERY.
>>> I
>>> think the best in this cases is raise an error during compilation.
>
> Thanks Heikki for your fast response! ^^
>
>
>> The compiler would have to determine that the loop never ends, or it
>> would complain that there's no RETURN at the end.
>>
>> Many compilers for other languages do that kind of analysis, but it
>> usually only results in a warning, and compilers sometimes get that
>> wrong. I don't think it's worthwhile to do that, but of course, patches
>> are welcome.
>>
>
> Yeah, it's not a very big concern, althougth cold be taken for future
> improvements
> in plpgsql. I very far for submit a patch :P
>
The deep check of embedded SQL is not possible in PL/pgSQL - this
remove dependency between PL/pgSQL and database objects. Deeper checks
mean a broken compatibility :(.
PL/PSM has different philosophy where full check is implemented now.
Regards
Pavel Stehule
> Regards,
> E
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6043: Compilation PLpgsql Succesful but execution bad
@ 2011-05-28 14:23 Emanuel Calvo <postgres.arg@gmail.com>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Calvo @ 2011-05-28 14:23 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs
>>
>> Thanks Heikki for your fast response! ^^
>>
>>
>>> The compiler would have to determine that the loop never ends, or it
>>> would complain that there's no RETURN at the end.
>>>
>>> Many compilers for other languages do that kind of analysis, but it
>>> usually only results in a warning, and compilers sometimes get that
>>> wrong. I don't think it's worthwhile to do that, but of course, patches
>>> are welcome.
>>>
>>
>> Yeah, it's not a very big concern, althougth cold be taken for future
>> improvements
>> in plpgsql. I very far for submit a patch :P
>>
>
> The deep check of embedded SQL is not possible in PL/pgSQL - this
> remove dependency between PL/pgSQL and database objects. Deeper checks
> mean a broken compatibility :(.
>
Good point.
> PL/PSM has different philosophy where full check is implemented now.
>
Do you think that make some test in 9.1 worthwhile for this
language? I see that the last contrib was submitted years ago.
Regards,
--
--
Emanuel Calvo
Helpame.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6043: Compilation PLpgsql Succesful but execution bad
@ 2011-05-28 14:36 Pavel Stehule <pavel.stehule@gmail.com>
parent: Emanuel Calvo <postgres.arg@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Pavel Stehule @ 2011-05-28 14:36 UTC (permalink / raw)
To: Emanuel Calvo <postgres.arg@gmail.com>; +Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs
2011/5/28 Emanuel Calvo <postgres.arg@gmail.com>:
>>>
>>> Thanks Heikki for your fast response! ^^
>>>
>>>
>>>> The compiler would have to determine that the loop never ends, or it
>>>> would complain that there's no RETURN at the end.
>>>>
>>>> Many compilers for other languages do that kind of analysis, but it
>>>> usually only results in a warning, and compilers sometimes get that
>>>> wrong. I don't think it's worthwhile to do that, but of course, patches
>>>> are welcome.
>>>>
>>>
>>> Yeah, it's not a very big concern, althougth cold be taken for future
>>> improvements
>>> in plpgsql. I very far for submit a patch :P
>>>
>>
>> The deep check of embedded SQL is not possible in PL/pgSQL - this
>> remove dependency between PL/pgSQL and database objects. Deeper checks
>> mean a broken compatibility :(.
>>
>
> Good point.
>
>> PL/PSM has different philosophy where full check is implemented now.
>>
>
> Do you think that make some test in 9.1 worthwhile for this
> language? I see that the last contrib was submitted years ago.
>
I worked on new implementation called PL/PSM - but it is not mature.
It should to work with 9.1.
https://github.com/okbob/plpsm0
all features https://github.com/okbob/plpsm0/blob/master/test.sql are
supported, but there are no real project that is based on this
language now.
Regards
Pavel Stehule
> Regards,
>
>
> --
> --
> Emanuel Calvo
> Helpame.com
>
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2011-05-28 14:36 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27 14:05 BUG #6043: Compilation PLpgsql Succesful but execution bad Emanuel <postgres.arg@gmail.com>
2011-05-27 14:18 ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-05-28 09:53 ` Emanuel Calvo <postgres.arg@gmail.com>
2011-05-28 11:53 ` Pavel Stehule <pavel.stehule@gmail.com>
2011-05-28 14:23 ` Emanuel Calvo <postgres.arg@gmail.com>
2011-05-28 14:36 ` Pavel Stehule <pavel.stehule@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox