Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TPmSS-0008L7-48 for pgsql-jdbc@postgresql.org; Sun, 21 Oct 2012 03:44:12 +0000 Received: from nm20-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.165]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TPmSK-0005Pw-8T for pgsql-jdbc@postgresql.org; Sun, 21 Oct 2012 03:44:11 +0000 Received: from [98.139.212.145] by nm20.bullet.mail.bf1.yahoo.com with NNFMP; 21 Oct 2012 03:44:03 -0000 Received: from [98.139.212.234] by tm2.bullet.mail.bf1.yahoo.com with NNFMP; 21 Oct 2012 03:44:03 -0000 Received: from [127.0.0.1] by omp1043.mail.bf1.yahoo.com with NNFMP; 21 Oct 2012 03:44:02 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 993914.42243.bm@omp1043.mail.bf1.yahoo.com Received: (qmail 27030 invoked by uid 60001); 21 Oct 2012 03:44:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1350791042; bh=Bye29UC5WSvxEgFcI1VGJLNE3oszLPeGIxIg+LxWmGA=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type; b=T58tDaF+kEueHAeCanxbgMI0IlUaI35mxaEhkgkl/54Hzqp6Dvm5vNdOagqeOV2iwUH5c8Mr/Ljx+ox+L50X9/FrdansnnEfXB9WB1QXL6FsPJbRJcHNgXDXzV5gWLFbBezgfbxnRGyqRQZgKi5QZSOp4iiqGYBMcg8mPPGUmak= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type; b=4m1FSKhc90xqAEL5/6gjFtMaeUhova0jvHGpx4TmFr++DGo4D8VIUssFls/m+9HJ+dcahsI5nNyRYYMVpfsj0NilTVHNIA4NV5XtQNTws9hSstG80nuW+DAclx4c+pIyNZ+du0s/39Dx198PUnM7d0TihxTYbJGFeyblo+NRemY=; X-YMail-OSG: 8Vqv3M4VM1lkuPLryEZ15opSfovb9z4d9U2YGTmT6kCGs0n qde6cE_KmnxGJvfueJLnDqoipXRLwZrUJvX6eR8IyvzhAHqTVzMLFYT6I1HR 4LluQD46r5OfD_teWYC_o3jdBV52oHmwb9HQOa93btN45dkpdFq0nS9SUPpT E_tjqD9ENXHoMAp_3sRUWucE03ackS1JuojtBPdbW3ILdbelzyywQU72N3io 9.vIVL2N.Z.yXYex7IrLWsM6u5d93EJ0RJKjiAfyRcqcSKvOIDr8X2EpEEFl IB_X5qVubxh1R5MuTpdXGUEyq6O_8bAqlaUSshiiSHtCeZR56Yno3GwLNM9X zea83izU6svuSfQBpwbSsDXyqFaXQY8NZPkVjofvY6q3eBiCX_HPWQqjqLd. TEW7jbXAknRxOPN7n.XsWeFqUBxdFVKIj2rXG_bpYO2PGLNZIaGH.1iaRxEG ZEyrqxlhuLPAbE5qYYtNLfMoMEOoqwovmO3TIuRVOtJH0Scvt9YmTQPICVVl m_WP5iwKrkAFb5oGSVA5nfsRZTXPiEOTrUd.Pg23HhlzqddUf0Z2t_8ZA9UU CMA-- Received: from [110.175.18.253] by web161806.mail.bf1.yahoo.com via HTTP; Sat, 20 Oct 2012 20:44:02 PDT X-Rocket-MIMEInfo: 001.001, SGkgRGF2ZSwKwqBJIGFtIGluIHByb2Nlc3Mgb2YgaW1wbGVtZW50aW5nIGphdmEuc3FsLlN0cnVjdCB0byBzdXBwb3J0IGNvbXBvc2l0ZSB0eXBlcyBhcyBPVVQvSU4gcGFyYW1ldGVycyBpbiBwb3N0Z3JlcyBKREJDIERyaXZlci4gSSBhbSBhbG1vc3QgZG9uZSB3aXRoIHRoYXQsIGJ1dCB3aGlsZSB3cml0aW5nIHRlc3QgY2FzZXMsIEkgY2FtZSBhY3Jvc3MgYW4gaXNzdWUgd2l0aCByZXR1cm4gdmFsdWVzLiBUaGUgU3RydWN0IHBhcmFtZXRlcnMgYXJlIHN1Y2Nlc3NmdWxseSBiZWluZyBwYXNzZWQgYW5kIHIBMAEBAQE- X-Mailer: YahooMailWebService/0.8.123.450 Message-ID: <1350791042.11899.YahooMailNeo@web161806.mail.bf1.yahoo.com> Date: Sat, 20 Oct 2012 20:44:02 -0700 (PDT) From: Muhammad Altaf Reply-To: Muhammad Altaf Subject: Struct Support To: "dave.cramer@credativ.ca" Cc: "pgsql-jdbc@postgresql.org" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="1665047788-1853561614-1350791042=:11899" X-Pg-Spam-Score: 0.3 (/) X-Archive-Number: 201210/92 X-Sequence-Number: 23416 --1665047788-1853561614-1350791042=:11899 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Dave,=0A=A0I am in process of implementing java.sql.Struct to support co= mposite types as OUT/IN parameters in postgres JDBC Driver. I am almost don= e with that, but while writing test cases, I came across an issue with retu= rn values. The Struct parameters are successfully being passed and returned= as OUT parameters (I have tested that with multiple out and in parameters = of type Struct as well). But when it comes to returning a struct value, ser= ver returns two fields in RowDescription which makes driver believe that th= ese are actually two parameters. Initially I thought I am doing something w= rong at the Driver level, but pgAdminIII showed the same behavior. I'll sho= w both behaviors in pgAdminIII.=0A=0ASQL Script:=0Acreate type city as (cit= y_id int4, city_name text);=0Acreate type address as (street_address text, = city city);=0Acreate or replace function udt_f1(a in varchar, b out city, c= out address) returns RECORD AS $$=0A=A0DECLARE =0A=A0=A0=A0 c_city city;= =0A=A0=A0=A0 BEGIN =0A=A0=A0=A0 select 1,a into b;=0A=A0=A0=A0 select 2, 'C= ity Name' into c_city; =0A=A0=A0=A0 select 'Street address',c_city into c;= =0A=A0=A0=A0 END;$$ language 'plpgsql';=0A=A0=A0=A0 =0Acreate or replace fu= nction udt_f2(a in int4, b in city) returns city AS $$ =0Adeclare =0A=A0=A0= =A0 c_city city; =0ABEGIN =0A=A0=A0=A0 select a,b.city_name into c_city; = =0A=A0=A0=A0 return c_city; =0AEND;$$ language 'plpgsql';=0A=0A=0A=A0Now, i= n pgAdmin, call udt_f1=0A=A0=A0=A0 select * from udt_f1('Test City');=0AThi= s will display two columns with appropriate city and address details.=0A=0A= Now call udt_f2=0A=A0=A0=A0 select * from udt_f2(100, '(4, "Washington")');= =0AInstead of displaying a single city column, it displays two columns. The= first as integer (city_id) and the second being text (city_name).=0A=0ACan= you please confirm I am not correct and something needs to be done while c= alling this function to get it working?=0A=0A=0AThanks,=0AAltaf Malik=0A --1665047788-1853561614-1350791042=:11899 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Dave,
 I am in process of implementing java.sql.Struct= to support composite types as OUT/IN parameters in postgres JDBC Driver. I= am almost done with that, but while writing test cases, I came across an i= ssue with return values. The Struct parameters are successfully being passe= d and returned as OUT parameters (I have tested that with multiple out and = in parameters of type Struct as well). But when it comes to returning a str= uct value, server returns two fields in RowDescription which makes driver b= elieve that these are actually two parameters. Initially I thought I am doi= ng something wrong at the Driver level, but pgAdminIII showed the same behavior. I'll show both behaviors in pgAdminIII.

<= span>
SQL Script:
create type city as (city_id int4, city_name text)= ;
create type address as (street_address text, city city);
create or = replace function udt_f1(a in varchar, b out city, c out address) returns RE= CORD AS $$
 DECLARE
    c_city city;
    BEGIN
    select 1,a into b= ;
    select 2, 'City Name' into c_city;
  =   select 'Street address',c_city into c;
    END;$$ = language 'plpgsql';
   
create or replace function ud= t_f2(a in int4, b in city) returns city AS $$
declare
  &= nbsp; c_city city;
BEGIN
    select a,b.city_name in= to c_city;
    return c_city;
END;$$ language 'plpgs= ql';


 N= ow, in pgAdmin, call udt_f1
    select * from udt_f1('Test City');
This will display two columns with appropriate ci= ty and address details.

Now call udt_f2
 = ;   select * from udt_= f2(100, '(4, "Washington")');
Instead of displaying a sing= le city column, it displays two columns. The first as integer (city_id) and= the second being text (city_name).

Can you please confirm I am not = correct and something needs to be done while calling this function to get i= t working?

Thanks,
Altaf Malik
--1665047788-1853561614-1350791042=:11899--