pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Emanuel Calvo <postgres.arg@gmail.com>
Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6043: Compilation PLpgsql Succesful but execution bad
Date: Sat, 28 May 2011 13:53:50 +0200
Message-ID: <BANLkTim_d0ZwLiqssaWd9NZz5Smk5Tq5NQ@mail.gmail.com> (raw)
In-Reply-To: <BANLkTiksk+sNoPKzJV573FycQnUQ31_EQg@mail.gmail.com>
References: <201105271405.p4RE5Tid050879@wwwmaster.postgresql.org>
	<4DDFB2A3.7080900@enterprisedb.com>
	<BANLkTiksk+sNoPKzJV573FycQnUQ31_EQg@mail.gmail.com>

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
>



view thread (6+ messages)  latest in thread

Message-ID: <BANLkTim_d0ZwLiqssaWd9NZz5Smk5Tq5NQ@mail.gmail.com>
Permalink:  ../BANLkTim_d0ZwLiqssaWd9NZz5Smk5Tq5NQ@mail.gmail.com/
Also on:    postgresql.org/message-id/BANLkTim_d0ZwLiqssaWd9NZz5Smk5Tq5NQ@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: pavel.stehule@gmail.com, postgres.arg@gmail.com, heikki.linnakangas@enterprisedb.com
  Subject: Re: BUG #6043: Compilation PLpgsql Succesful but execution bad
  In-Reply-To: <BANLkTim_d0ZwLiqssaWd9NZz5Smk5Tq5NQ@mail.gmail.com>
  References: <201105271405.p4RE5Tid050879@wwwmaster.postgresql.org> <4DDFB2A3.7080900@enterprisedb.com> <BANLkTiksk+sNoPKzJV573FycQnUQ31_EQg@mail.gmail.com> <BANLkTim_d0ZwLiqssaWd9NZz5Smk5Tq5NQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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