A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.

From: Naoya Anzai <anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Cc: Naoya Anzai <anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp>, Akio Iwaasa <iwaasa(at)mxs(dot)nes(dot)nec(dot)co(dot)jp>
Subject: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
Date: 2014-03-07 04:18:56
Message-ID: 116262CF971C844FB6E793F8809B51C6B7D6BF@BPXM02GP.gisp.nec.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi All,

I have found an odd movement when using multiple connections with prepareStatement("").

The following ERROR message appeared.

org.postgresql.util.PSQLException: ERROR: prepared statement "S_1" does not exist

In org/postgresql/core/v3/QueryExecutorImpl.java,
EMPTY_QUERY instance is defined as a static instance.

---
private final static SimpleQuery EMPTY_QUERY = new SimpleQuery(new String[] { "" }, null);
---

For that reason,
After CONNECTION-A has prepared EMPTY_QUERY already,
If CONNECTION-B tries to execute EMPTY_QUERY for the first time,
then CONNECTION-B sends a bind message to PostgreSQL without prepare.

I attached a sample source and a patch.

Please confirm it.

Best Regards,

Naoya

---
Naoya Anzai
Engineering Department
NEC Soft, Ltd.
E-Mail: anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp
---

Attachment Content-Type Size
dynamic_empty_query.patch application/octet-stream 717 bytes
testMain.java application/octet-stream 951 bytes

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2014-03-10 23:21:15 Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
Previous Message Artem Pronchakov 2014-03-06 12:32:54 Re: insert daterange field value