pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rsmogura <rsmogura@softperience.eu>
To: Lukas Eder <lukas.eder@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] Fwd: Weird issues when reading UDT from stored function
Date: Tue, 25 Jan 2011 10:06:10 +0100
Message-ID: <528a0187e74bbc3a40a6659df8e67e67@mail.softperience.eu> (raw)
In-Reply-To: <AANLkTimvqQmkvG0QcruFGGxCrQ63U8srtDtMZBH8WjQU@mail.gmail.com>
References: <c63c0e3d-cd3b-4b82-b891-50f8ef43bfdb@j25g2000vbs.googlegroups.com>
	<AANLkTi=HC-C5gL29ovNqcqtfNQa6XM8oNA0a86YsYcVt@mail.gmail.com>
	<AANLkTi=pTFGV+vVFgKwB6+ZNWb+r9LrYpJXKEytL5P02@mail.gmail.com>
	<201101111946.33083.rsmogura@softperience.eu>
	<AANLkTi=UH_9qC8CmQBN7aEwsdUMYAzjRUCJmDiWFTQQH@mail.gmail.com>
	<4d7cc4033a655539995c240a6f282ab5@mail.softperience.eu>
	<AANLkTi=EAbWpOZhXUaG0OG7smtExwoE4M9dv2ykzPVcZ@mail.gmail.com>
	<4D33CD00.6000408@opencloud.com>
	<AANLkTin_UwaAjVKOqY3ZGpHtEt4WiX8f-ERJhA16JWX+@mail.gmail.com>
	<AANLkTimvqQmkvG0QcruFGGxCrQ63U8srtDtMZBH8WjQU@mail.gmail.com>

 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... 




view thread (48+ messages)  latest in thread

Message-ID: <528a0187e74bbc3a40a6659df8e67e67@mail.softperience.eu>
Permalink:  ../528a0187e74bbc3a40a6659df8e67e67@mail.softperience.eu/
Also on:    postgresql.org/message-id/528a0187e74bbc3a40a6659df8e67e67@mail.softperience.eu

 · 

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-jdbc@postgresql.org
  Cc: rsmogura@softperience.eu, lukas.eder@gmail.com, robertmhaas@gmail.com, oliver@opencloud.com, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] Fwd: Weird issues when reading UDT from stored function
  In-Reply-To: <528a0187e74bbc3a40a6659df8e67e67@mail.softperience.eu>
  References: <c63c0e3d-cd3b-4b82-b891-50f8ef43bfdb@j25g2000vbs.googlegroups.com> <AANLkTi=HC-C5gL29ovNqcqtfNQa6XM8oNA0a86YsYcVt@mail.gmail.com> <AANLkTi=pTFGV+vVFgKwB6+ZNWb+r9LrYpJXKEytL5P02@mail.gmail.com> <201101111946.33083.rsmogura@softperience.eu> <AANLkTi=UH_9qC8CmQBN7aEwsdUMYAzjRUCJmDiWFTQQH@mail.gmail.com> <4d7cc4033a655539995c240a6f282ab5@mail.softperience.eu> <AANLkTi=EAbWpOZhXUaG0OG7smtExwoE4M9dv2ykzPVcZ@mail.gmail.com> <4D33CD00.6000408@opencloud.com> <AANLkTin_UwaAjVKOqY3ZGpHtEt4WiX8f-ERJhA16JWX+@mail.gmail.com> <AANLkTimvqQmkvG0QcruFGGxCrQ63U8srtDtMZBH8WjQU@mail.gmail.com> <528a0187e74bbc3a40a6659df8e67e67@mail.softperience.eu>

* 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