Re: [HACKERS] JPA + enum == Exception

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Tom Dunstan <pgsql(at)tomd(dot)cc>, "Hudson, Derrick" <dhudson(at)redcom(dot)com>, "Marc G(dot) Fournier" <scrappy(at)hub(dot)org>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] JPA + enum == Exception
Date: 2013-02-12 15:50:44
Message-ID: 22027.1360684244@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Craig Ringer <craig(at)2ndquadrant(dot)com> writes:
> On 02/08/2013 12:55 PM, Tom Lane wrote:
>> AFAIK this is just business as usual with JDBC: setString() implies that
>> the parameter is of a string type.

> Well, it means that it's a type compatible with a java.lang.String .
> JDBC doesn't say much about the database-side type.

> It's my strong view that we should accept setString(...) for any
> string-like type, like xml, json, domains of text, and so on - or at
> least provide an easy, no-superuser-required way to tell Pg to do so.

The difficulty I've got with that is that there are only two kinds of
literal in SQL, namely numbers and strings, so that "it looks like a
string" applies to absolutely every non-numeric type. If we go down
this road we'll end up allowing implicit casts from text to (at least)
every non-numeric type, which will be pretty much fatal for type
checking purposes.

IIRC, there's already a hack to tell the JDBC driver to mark setString
parameters as "unknown" rather than "text", which seems to me to be
a much less dangerous way of getting the lenient behavior when you want
it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Rijkers 2013-02-12 15:52:32 Re: pgsql: Create libpgcommon, and move pg_malloc et al to it
Previous Message Tom Lane 2013-02-12 15:45:28 Re: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]

Browse pgsql-jdbc by date

  From Date Subject
Next Message Bryan Varner 2013-02-12 16:01:31 Re: PostgreSQL XAResource & GlassFish 3.1.2.2
Previous Message 3rd Party Components Updates Notifications 2013-02-12 14:27:58