Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D72931337BDD for ; Tue, 11 Jan 2011 14:46:49 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 37347-10 for ; Tue, 11 Jan 2011 18:46:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from progressive.micfo.com (progressive.micfo.com [67.23.244.116]) by mail.postgresql.org (Postfix) with ESMTP id 553611337BD5 for ; Tue, 11 Jan 2011 14:46:40 -0400 (AST) Received: from 87-204-194-135.dg-net.pl ([87.204.194.135]:55019 helo=radek.localnet) by progressive.micfo.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1PcjEn-0002iL-Up; Tue, 11 Jan 2011 13:46:34 -0500 From: =?utf-8?q?Rados=C5=82aw_Smogura?= To: pgsql-jdbc@postgresql.org Subject: Re: Fwd: Weird issues when reading UDT from stored function Date: Tue, 11 Jan 2011 19:46:33 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.36-gentoo-r5; KDE/4.4.5; x86_64; ; ) Cc: Lukas Eder , oliver@opencloud.com References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201101111946.33083.rsmogura@softperience.eu> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - progressive.micfo.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - softperience.eu X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, WEIRD_QUOTING=0.001 X-Spam-Level: X-Archive-Number: 201101/27 X-Sequence-Number: 21359 I've done: test=3D# CREATE FUNCTION p_enhance_address3 (address OUT u_address_type, i1= OUT=20 int) AS $$ BEGIN SELECT t_author.address INTO address FROM t_author WHERE first_name =3D 'George'; i1 =3D 12; END; $$ LANGUAGE plpgsql; test=3D# select * =20 from p_enhance_address3(); =20 address | i1=20 =2D---------------------------------------------------+---- ("(""(""""Parliament Hill"""",77)"",NW31A9)",,,,,) | 12 (1 row) Result is ok. Because UDT is described in same way as row, it's looks like= =20 that backand do this nasty thing and instead of 1 column, it sends 6 in you= r=20 case. =46orward to hackers. Maybe they will say something, because I don;t see th= is in=20 docs. Radek Lukas Eder Tuesday 11 January 2011 16:55:52 > > Looks to me like you're getting each field of the UDT as a separate > > column. You printed only the first column i.e. the 'street' part. >=20 > Exactly, that's what I'm getting >=20 >=20 > It might be informative to run with loglevel=3D2 and see how the server is >=20 > > returning results. If the driver is reporting 6 columns, that means that > > the server is reporting 6 fields in its RowDescription message. >=20 > Here's what I get (there really is a RowDescription(6)): >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > 08:15:44.914 (1) PostgreSQL 9.0 JDBC4 (build 801) > 08:15:44.923 (1) Trying to establish a protocol version 3 connection to > localhost:5432 > 08:15:44.941 (1) FE=3D> StartupPacket(user=3Dpostgres, database=3Dpostgr= es, > client_encoding=3DUNICODE, DateStyle=3DISO, extra_float_digits=3D2) > 08:15:44.962 (1) <=3DBE AuthenticationReqMD5(salt=3D335c1a87) > 08:15:44.968 (1) FE=3D> > Password(md5digest=3Dmd5ea57d63c7d2afaed5abb3f0bb88ae7b8) > 08:15:44.970 (1) <=3DBE AuthenticationOk > 08:15:44.980 (1) <=3DBE ParameterStatus(application_name =3D ) > 08:15:44.980 (1) <=3DBE ParameterStatus(client_encoding =3D UNICODE) > 08:15:44.980 (1) <=3DBE ParameterStatus(DateStyle =3D ISO, DMY) > 08:15:44.980 (1) <=3DBE ParameterStatus(integer_datetimes =3D on) > 08:15:44.981 (1) <=3DBE ParameterStatus(IntervalStyle =3D postgres) > 08:15:44.981 (1) <=3DBE ParameterStatus(is_superuser =3D on) > 08:15:44.981 (1) <=3DBE ParameterStatus(server_encoding =3D UTF8) > 08:15:44.981 (1) <=3DBE ParameterStatus(server_version =3D 9.0.1) > 08:15:44.981 (1) <=3DBE ParameterStatus(session_authorization =3D postgr= es) > 08:15:44.981 (1) <=3DBE ParameterStatus(standard_conforming_strings =3D = off) > 08:15:44.981 (1) <=3DBE ParameterStatus(TimeZone =3D CET) > 08:15:44.981 (1) <=3DBE BackendKeyData(pid=3D2980,ckey=3D465709852) > 08:15:44.981 (1) <=3DBE ReadyForQuery(I) > 08:15:44.981 (1) compatible =3D 9.0 > 08:15:44.981 (1) loglevel =3D 2 > 08:15:44.981 (1) prepare threshold =3D 5 > getConnection returning > driver[className=3Dorg.postgresql.Driver,org.postgresql.Driver@77ce3fc5] > 08:15:45,021 DEBUG [org.jooq.impl.StoredProcedureImpl > ] - Executing query : { call public.p_enhance_address2(?) } > 08:15:45.035 (1) simple execute, > handler=3Dorg.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHand= ler@ > 2eda2cef, maxRows=3D0, fetchSize=3D0, flags=3D17 > 08:15:45.036 (1) FE=3D> Parse(stmt=3Dnull,query=3D"select * from > public.p_enhance_address2($1) as result",oids=3D{2278}) > 08:15:45.037 (1) FE=3D> Bind(stmt=3Dnull,portal=3Dnull,$1=3D<'null'>) > 08:15:45.038 (1) FE=3D> Describe(portal=3Dnull) > 08:15:45.038 (1) FE=3D> Execute(portal=3Dnull,limit=3D0) > 08:15:45.038 (1) FE=3D> Sync > 08:15:45.043 (1) <=3DBE ParseComplete [null] > 08:15:45.044 (1) <=3DBE BindComplete [null] > 08:15:45.045 (1) <=3DBE RowDescription(6) > 08:15:45.046 (1) <=3DBE DataRow > 08:15:45.046 (1) <=3DBE CommandStatus(SELECT 1) > 08:15:45.062 (1) <=3DBE ReadyForQuery(I) > org.postgresql.util.PSQLException: Ein CallableStatement wurde mit einer > falschen Anzahl Parameter ausgef=C3=BChrt. > at > org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc= 2S > tatement.java:408) at > org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statemen= t. > java:381) at > org.jooq.impl.StoredProcedureImpl.execute(StoredProcedureImpl.java:125) > at > org.jooq.test.postgres.generatedclasses.Procedures.pEnhanceAddress2(Proce= du > res.java:91) [...] > SQLException: SQLState(42601) > 08:15:45.074 (1) FE=3D> Terminate > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 >=20 > Oops, looking closer I see what you mean, that's actually 2 columns of the >=20 > > surrounding type - street + zip? >=20 > Yes, exactly. Somehow the driver stops at the second type element of the > surrounding type. This may be correlated to the fact that the inner type > has exactly 2 elements? >=20 > > What are the values of the other 5 columns reported by the driver? >=20 > The other 5 columns are reported as null (always). > In pgAdmin III, I correctly get a single column in the result set. Also, > the postgres information_schema only holds one parameter: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > select parameter_mode, parameter_name, udt_name > from information_schema.parameters > where specific_name like 'p_enhance_address2%' >=20 > yields: >=20 > "OUT";"address";"u_address_type" > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D