Re: propose: detail binding error log - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: propose: detail binding error log
Date
Msg-id CAMsr+YGQxBK31gVxo490TR9OkO6JJ5RfB7_6Bsy7DeDByMM=fg@mail.gmail.com
Whole thread Raw
In response to Re: propose: detail binding error log  (Ioseph Kim <pgsql-kr@postgresql.kr>)
List pgsql-hackers
On 15 March 2016 at 15:06, Ioseph Kim <pgsql-kr@postgresql.kr> wrote:
 
case 2: in jdbc program.
ERROR:  42804: column "a" is of type boolean but expression is of type
integer at character 25
HINT:  You will need to rewrite or cast the expression.
LOCATION:  transformAssignedExpr, parse_target.c:529
STATEMENT:  insert into test values ($1)

when this case, statement is 'insert', I think binding values already
sent to server, then server can display these.

They aren't yet sent to the server, so it cannot display them.

Sure, your code says "setInteger(1)". But that doesn't send anything to the server, it just stores it in the PreparedStatement object in Java.

PgJDBC does a Parse/Bind/Execute when you actually execute your prepared statement after setting parameters. The parse phase, which comes first, does NOT yet send the parameters your program supplied to the server.

So PgJDBC has the parameters, but the server, which is what is generating the error, does not.

 I want see that
"ERROR:  42804: column "a" is of type boolean but expression is of type
integer(input value = 24) at character 25"


You can't, and I don't see any realistic way to make that happen except for switching to client-side parameter binding (interpolation). Which is a bad idea for performance and all sorts of other reasons. If you really must do so, force the version 2 protocol in PgJDBC. 

Really, the problem is your code: you should setBool not setInteger here. That's really all there is too it.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: amcheck (B-Tree integrity checking tool)
Next
From: Amit Kapila
Date:
Subject: Re: Background Processes and reporting