Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 90A2A1337B94 for ; Tue, 25 Jan 2011 05:06:19 -0400 (AST) 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 31174-05; Tue, 25 Jan 2011 09:06:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.intergenia.de [217.118.26.141]) by mail.postgresql.org (Postfix) with ESMTP id 055EB133798E; Tue, 25 Jan 2011 05:06:10 -0400 (AST) Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.intergenia.de [217.118.26.141]) by mail.softperience.eu (Postfix) with ESMTPA id CFA68C000A0; Tue, 25 Jan 2011 10:06:10 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 25 Jan 2011 10:06:10 +0100 From: rsmogura To: Lukas Eder Cc: Robert Haas , Oliver Jowett , , Subject: Re: [HACKERS] Fwd: Weird issues when reading UDT from stored function In-Reply-To: References: <201101111946.33083.rsmogura@softperience.eu> <4d7cc4033a655539995c240a6f282ab5@mail.softperience.eu> <4D33CD00.6000408@opencloud.com> Message-ID: <528a0187e74bbc3a40a6659df8e67e67@mail.softperience.eu> X-Sender: rsmogura@softperience.eu User-Agent: Roundcube Webmail/0.5-rc X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.889 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_FILL_THIS_FORM_SHORT=0.01, WEIRD_QUOTING=0.001 X-Spam-Level: X-Archive-Number: 201101/64 X-Sequence-Number: 21396 Hi, I don't know if this is a bug, but at least I haven't found any clear statement in documentation about; this should be wrote with big and bold letters. In any way I think this is bug or big inconsistency, because of, as was stated in previous mail test=# CREATE FUNCTION p_enhance_address3 (address OUT u_address_type, i1 OUT int) AS $$ BEGIN SELECT t_author.address INTO address FROM t_author WHERE first_name = 'George'; i1 = 12; END; $$ LANGUAGE plpgsql; test=# select * from p_enhance_address3(); address | i1 ----------------------------------------------------+---- ("(""(""""Parliament Hill"""",77)"",NW31A9)",,,,,) | 12 (1 row), but if you will create above function without last, i1 parameter (SELECT * FROM p_enhance_address2();) then result will be street | zip | city | country | since | code -------------------------------------+-----+------+---------+-------+------ ("(""Parliament Hill"",77)",NW31A9) | | | | | In last case, I think, result should be "packed" in one column, because of it clearly "unpacked" record. On Tue, 25 Jan 2011 14:39:51 +0700, Lukas Eder wrote: >>> Here, we've somehow got the first two fields of u_address_type - >> street and > >>> zip - squashed together into one column named 'street', and all >> the other >>> columns nulled out. >>   >> I think this is the old problem of PL/pgsql having two forms of >> SELECT >> INTO.  You can either say: >>   >> SELECT col1, col2, col3, ... INTO recordvar FROM ... >>   >> Or you can say: >>   >> SELECT col1, col2, col3, ... INTO nonrecordvar1, nonrecordvar2, >> nonrecordvar3, ... FROM ... >>   >> In this case, since address is a recordvar, it's expecting the first >> >> form - thus the first select-list item gets matched to the first >> column of the address, rather than to address as a whole.  It's not >> >> smart enough to consider the types of the items involved - only >> whether they are records.  :-( > >   > So what you're suggesting is that the plpgsql code is causing the > issues? Are there any indications about how I could re-write this > code? The important thing for me is to have the aforementioned > signature of the plpgsql function with one UDT OUT parameter. Even > if this is a bit awkward in general, in this case, I don't mind > rewriting the plpgsql function content to create a workaround for > this problem...