Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A639DB5DBD1 for ; Sat, 28 May 2011 08:54:37 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 03267-02 for ; Sat, 28 May 2011 11:54:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iy0-f174.google.com (mail-iy0-f174.google.com [209.85.210.174]) by mail.postgresql.org (Postfix) with ESMTP id 54642B5D80A for ; Sat, 28 May 2011 08:54:30 -0300 (ADT) Received: by iyb14 with SMTP id 14so1938861iyb.19 for ; Sat, 28 May 2011 04:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=1jxUosTyc132Z6sdcDSbvYTf2RsM1hp7vYGJEGD/yXI=; b=efCJjUxnl/eK7XR7G2WwtjtSGkycv85gsFJ+zT8Wv4APR7/HTO+pNrHuiodfuGW4bC 1E0QRtVkLICwmTQId9I/00YTA+kl1u7zXjFjWX5d5RtChJdzpxlzmt9NyiihVhAnyNbE qZgEbjpHmM68Oli7KvPg9FqvTRUKAviGJEj34= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=saCU8KxBKATCCXLZ7LEB9MxyaQ2dg/F7bmqa+v2OhksVGomnXw0b9nsvXJ9lsW3ofK Adtrt/dawRiEnhpCWHomoIOSHL86hyEa16lnkVvq2ufA9YugQOwXa/rE+drirnu0TRcn /kBipnXs1nbmrnBnFi5dyAudZK0i9MEd6B9ZI= Received: by 10.42.161.70 with SMTP id s6mr5673923icx.374.1306583670047; Sat, 28 May 2011 04:54:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.172.196 with HTTP; Sat, 28 May 2011 04:53:50 -0700 (PDT) In-Reply-To: References: <201105271405.p4RE5Tid050879@wwwmaster.postgresql.org> <4DDFB2A3.7080900@enterprisedb.com> From: Pavel Stehule Date: Sat, 28 May 2011 13:53:50 +0200 Message-ID: Subject: Re: BUG #6043: Compilation PLpgsql Succesful but execution bad To: Emanuel Calvo Cc: Heikki Linnakangas , pgsql-bugs@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/208 X-Sequence-Number: 30347 2011/5/28 Emanuel Calvo : > El 27/05/2011 16:18, "Heikki Linnakangas" > escribi=C3=B3: >> On 27.05.2011 17:05, Emanuel wrote: >>> postgres=3D# 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=3D# 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 >