Re: propose: detail binding error log

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Ioseph Kim <pgsql-kr(at)postgresql(dot)kr>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: propose: detail binding error log
Date: 2016-03-15 07:13:17
Message-ID: CAMsr+YGQxBK31gVxo490TR9OkO6JJ5RfB7_6Bsy7DeDByMM=fg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15 March 2016 at 15:06, Ioseph Kim <pgsql-kr(at)postgresql(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2016-03-15 07:25:04 Re: Background Processes and reporting
Previous Message Peter Geoghegan 2016-03-15 07:11:01 Re: amcheck (B-Tree integrity checking tool)