Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6A9E8636A2C for ; Thu, 11 Mar 2010 19:33:49 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 89713-01-6 for ; Thu, 11 Mar 2010 23:33:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iw0-f187.google.com (mail-iw0-f187.google.com [209.85.223.187]) by mail.postgresql.org (Postfix) with ESMTP id 5431D640175 for ; Thu, 11 Mar 2010 18:42:41 -0400 (AST) Received: by iwn17 with SMTP id 17so588081iwn.19 for ; Thu, 11 Mar 2010 14:42:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=5P2AWirZe9Unv5zpM+jOBmx8phhrPDe+tqSJ3nlJLmI=; b=HdnREwkHegjqicjeSeHhRuy5ADVpVcpBSKrU3kQpB/FRB5kyuWAB3pIFPkVs5i9LR6 1VtWx5cCLGv+2CVnWhHc45wc9Y4g71WXAWzavUfcZCsP4DYc/6YAkTTDzZOrSqUirMjF xczLdeZIFtMJCHUd84OjU4MuMloKeLWfO0vGU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=LvrbsR872RzRNBKvSmkorDGUXm+e7VrpVSe2Jipbf5UQiG4/aIkvOXQAY72y41cx5x ke8WLNK/mrnKPqQ59rw+DGTfZVW+Rnqo+I57uCSvdyicpp10BBK4rbG8npHx7JgDYQwL IjvrKc81ezjOxk8XhGbdrGLIeF5c6rTdLuxco= MIME-Version: 1.0 Received: by 10.231.158.205 with SMTP id g13mr442677ibx.30.1268347359800; Thu, 11 Mar 2010 14:42:39 -0800 (PST) In-Reply-To: <98bbb46a1003111439y5a83f3fdqf7089a37091adf11@mail.gmail.com> References: <98bbb46a1003101807m475f3812gac5b381685d6498a@mail.gmail.com> <98bbb46a1003101820h2ef41b09w45ce304fa8c01469@mail.gmail.com> <98bbb46a1003111439y5a83f3fdqf7089a37091adf11@mail.gmail.com> Date: Thu, 11 Mar 2010 17:42:39 -0500 Message-ID: <98bbb46a1003111442o4c6e9180y9daf01ac6363dace@mail.gmail.com> Subject: Re: Multiple Functions and Tables in different Schemas with COmposite Types From: Jason Tesser To: pgsql-jdbc Content-Type: multipart/alternative; boundary=00504501416dd52f6b04818e21fb X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.878 tagged_above=-10 required=5 tests=AWL=0.720, BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201003/47 X-Sequence-Number: 20387 --00504501416dd52f6b04818e21fb Content-Type: text/plain; charset=ISO-8859-1 Sorry one more thing you need to create your table as a type extending PG_Object like so public class PGPerson extends PGobject implements Serializable, Cloneable{ /** * */ private static final long serialVersionUID = 2347713583412585369L; private Person person; public PGPerson() { setType("person"); } public PGPerson(Person person){ this(); this.person = person; } @Override public String getValue() { return "(" + PGHelper.escapeObjectForPostgres(person.getId() + "") + "," + PGHelper.escapeObjectForPostgres(person.getFirstName()) + "," + PGHelper.escapeObjectForPostgres(person.getLastName()) + "," + PGHelper.escapeObjectForPostgres(person.getMiddleName()) + ")"; } } On Thu, Mar 11, 2010 at 5:39 PM, Jason Tesser wrote: > Any ideas here? I am pretty sure this is a bug. > > It is easy to reproduce. > > 1. Create 2 schemas with tables of the same name > 2. Create the same function in each schema each taking as an IN param the > table > 3. From Java use a Stored proc to call the function setting the search_path > accordingly. > 4. Use a prepared statement to set the IN param > > When it tries to set the parameter on the Prepared Statement one schema > will work and the other will not. > > On Wed, Mar 10, 2010 at 9:20 PM, Jason Tesser wrote: > >> I guess my issues here is that the driver doesn't seem to provide me a way >> of handling tablenamespace when types of the same name live in 2 different >> schemas. >> >> Can I control this at all? >> >> >> On Wed, Mar 10, 2010 at 9:07 PM, Jason Tesser wrote: >> >>> I am getting this error function person_save(testclient.person, unknown, >>> testclient.email[], unknown) does not exist when using a prepared >>> statement. >>> >>> the reason for this is SELECT oid FROM pg_catalog.pg_type WHERE typname = >>> $1 >>> is called and $1 is person >>> it gets the wrong oid, multiple OID are returned >>> >>> I tried to make my type be schema.person but that doesn't work >>> This IN parameters are composite types so I had to create objects that >>> extended PGObject to make it work >>> >>> My procs all work as I can call from pgadmin by setting searchpath. But >>> from java with a prepared statement and ? as the IN parameters it fails even >>> with the searchpath set. >>> >>> >> > --00504501416dd52f6b04818e21fb Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sorry one more thing you need to create your table as a type extending PG_O= bject

like so

public class PGPerson extends PGobject impleme= nts Serializable, Cloneable{

=A0=A0=A0 /**
=A0=A0=A0 =A0*
=A0= =A0=A0 =A0*/
=A0=A0=A0 private static final long serialVersionUID =3D 23= 47713583412585369L;
=A0=A0=A0 private Person person;
=A0=A0=A0 public PGPerson() {
=A0=A0= =A0 =A0=A0=A0 setType("person");
=A0=A0=A0 }
=A0=A0=A0
= =A0=A0=A0 public PGPerson(Person person){
=A0=A0=A0 =A0=A0=A0 this();=A0=A0=A0 =A0=A0=A0 this.person =3D person;
=A0=A0=A0 }
=A0=A0=A0 =A0=A0=A0 @Override
=A0=A0=A0 public String getValue() {
=A0=A0=A0 = =A0=A0=A0 return=A0 "(" + PGHelper.escapeObjectForPostgres(person= .getId() + "") + "," + PGHelper.escapeObjectForPostgres= (person.getFirstName()) + "," + PGHelper.escapeObjectForPostgres(= person.getLastName()) + "," + PGHelper.escapeObjectForPostgres(pe= rson.getMiddleName()) + ")";
=A0=A0=A0 }
=A0=A0=A0
}


On Thu= , Mar 11, 2010 at 5:39 PM, Jason Tesser <jasontesser@gmail.com> wrote:
=
Any ideas here?=A0 I am pretty sure this is a bug.

It is easy to re= produce.

1. Create 2 schemas with tables of the same name
2. Cre= ate the same function in each schema each taking as an IN param the table 3. From Java use a Stored proc to call the function setting the search_path= accordingly.
4. Use a prepared statement to set the IN param

Wh= en it tries to set the parameter on the Prepared Statement one schema will = work and the other will not.=A0

--00504501416dd52f6b04818e21fb--