pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
6+ messages / 3 participants
[nested] [flat]

* A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
@ 2014-03-07 04:18 Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-10 23:21 ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Naoya Anzai @ 2014-03-07 04:18 UTC (permalink / raw)
  To: pgsql-jdbc; +Cc: Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>; Akio Iwaasa <iwaasa@mxs.nes.nec.co.jp>

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@mxu.nes.nec.co.jp
---

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Attachments:

dynamic_empty_query.patch (application/octet-stream, 717B) download diff -Naur postgresql-jdbc-9.3-1101.src/org/postgresql/core/v3/QueryExecutorImpl.java postgresql-jdbc-9.3-1101.src.new/org/postgresql/core/v3/QueryExecutorImpl.java --- postgresql-jdbc-9.3-1101.src/org/postgresql/core/v3/QueryExecutorImpl.java 2014-03-05 08:36:16.000000000 +0900 +++ postgresql-jdbc-9.3-1101.src.new/org/postgresql/core/v3/QueryExecutorImpl.java 2014-03-05 08:39:13.000000000 +0900 @@ -2260,5 +2260,5 @@ private final SimpleQuery beginTransactionQuery = new SimpleQuery(new String[] { "BEGIN" }, null); - private final static SimpleQuery EMPTY_QUERY = new SimpleQuery(new String[] { "" }, null); + private final SimpleQuery EMPTY_QUERY = new SimpleQuery(new String[] { "" }, null); }
testMain.java (application/octet-stream, 951B) download ^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
  2014-03-07 04:18 A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
@ 2014-03-10 23:21 ` Dave Cramer <pg@fastcrypt.com>
  2014-03-11 00:30   ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Cramer @ 2014-03-10 23:21 UTC (permalink / raw)
  To: Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>; +Cc: pgsql-jdbc; Akio Iwaasa <iwaasa@mxs.nes.nec.co.jp>

Naoya,

Thanks for the patch! Curious how would you ever come across this ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Thu, Mar 6, 2014 at 11:18 PM, Naoya Anzai
<anzai-naoya@mxu.nes.nec.co.jp>wrote:

> 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@mxu.nes.nec.co.jp
> ---
>
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
  2014-03-07 04:18 A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-10 23:21 ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Dave Cramer <pg@fastcrypt.com>
@ 2014-03-11 00:30   ` Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-11 01:22     ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. David Johnston <polobo@yahoo.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Naoya Anzai @ 2014-03-11 00:30 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: pgsql-jdbc; Akio Iwaasa <iwaasa@mxs.nes.nec.co.jp>

Hi Dave,

Thanks for your response.

> Thanks for the patch! Curious how would you ever come across this ?

This incident was reported by one of our customers.
So I don't know why their application executes EMPTY_QUERY frequently...

Regards,

Naoya

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


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
  2014-03-07 04:18 A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-10 23:21 ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Dave Cramer <pg@fastcrypt.com>
  2014-03-11 00:30   ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
@ 2014-03-11 01:22     ` David Johnston <polobo@yahoo.com>
  2014-03-11 16:06       ` Re: Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 6+ messages in thread

From: David Johnston @ 2014-03-11 01:22 UTC (permalink / raw)
  To: pgsql-jdbc

Naoya Anzai wrote
> Hi Dave,
> 
> Thanks for your response.
> 
>> Thanks for the patch! Curious how would you ever come across this ?
> 
> This incident was reported by one of our customers.
> So I don't know why their application executes EMPTY_QUERY frequently...
> 
> Regards,

The most obvious reason would be as a keep-alive query...I have no idea
whether that is a wise decision compared to "SELECT 1;" or something that
actually causes the server to perform work (i.e., what does the server do
when it see the empty-string as input?).

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/A-prepared-statement-ERROR-due-to-EMPTY-QUERY-is-defined-as-...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
  2014-03-07 04:18 A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-10 23:21 ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Dave Cramer <pg@fastcrypt.com>
  2014-03-11 00:30   ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-11 01:22     ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. David Johnston <polobo@yahoo.com>
@ 2014-03-11 16:06       ` Dave Cramer <pg@fastcrypt.com>
  2014-03-12 02:06         ` Re: Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Cramer @ 2014-03-11 16:06 UTC (permalink / raw)
  To: David Johnston <polobo@yahoo.com>; +Cc: pgsql-jdbc

I have never seen anyone use an empty query before. I doubt it saves any
bandwidth as I believe there would be a query response

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Mon, Mar 10, 2014 at 9:22 PM, David Johnston <polobo@yahoo.com> wrote:

> Naoya Anzai wrote
> > Hi Dave,
> >
> > Thanks for your response.
> >
> >> Thanks for the patch! Curious how would you ever come across this ?
> >
> > This incident was reported by one of our customers.
> > So I don't know why their application executes EMPTY_QUERY frequently...
> >
> > Regards,
>
> The most obvious reason would be as a keep-alive query...I have no idea
> whether that is a wise decision compared to "SELECT 1;" or something that
> actually causes the server to perform work (i.e., what does the server do
> when it see the empty-string as input?).
>
> David J.
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/A-prepared-statement-ERROR-due-to-EMPTY-QUERY-is-defined-as-...
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance.
  2014-03-07 04:18 A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-10 23:21 ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Dave Cramer <pg@fastcrypt.com>
  2014-03-11 00:30   ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  2014-03-11 01:22     ` Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. David Johnston <polobo@yahoo.com>
  2014-03-11 16:06       ` Re: Re: A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Dave Cramer <pg@fastcrypt.com>
@ 2014-03-12 02:06         ` Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
  0 siblings, 0 replies; 6+ messages in thread

From: Naoya Anzai @ 2014-03-12 02:06 UTC (permalink / raw)
  To: pgsql-jdbc; +Cc: Akio Iwaasa <iwaasa@mxs.nes.nec.co.jp>

Hi,

Empty Query has a query response('I') without any data.
http://www.postgresql.org/docs/current/static/protocol-message-formats.html
(see EmptyQueryResponse)

In addition, PostgreSQL curtails the execution process.
(see Postgres.c:exec_execute_message)

Regards,

Naoya

> I have never seen anyone use an empty query before. I doubt it saves any bandwidth as I believe there would be a query response
> 
> Dave Cramer
> 
> dave.cramer(at)credativ(dot)ca
> http://www.credativ.ca
> 
> 
> 
> On Mon, Mar 10, 2014 at 9:22 PM, David Johnston <polobo@yahoo.com> wrote:
> 
> 
> 	Naoya Anzai wrote
> 	
> 	> Hi Dave,
> 	>
> 	> Thanks for your response.
> 	>
> 	>> Thanks for the patch! Curious how would you ever come across this ?
> 	>
> 	> This incident was reported by one of our customers.
> 	> So I don't know why their application executes EMPTY_QUERY frequently...
> 	>
> 	> Regards,
> 	
> 	
> 	The most obvious reason would be as a keep-alive query...I have no idea
> 	whether that is a wise decision compared to "SELECT 1;" or something that
> 	actually causes the server to perform work (i.e., what does the server do
> 	when it see the empty-string as input?).
> 	
> 	David J.
> 	
> 	
> 	
> 	
> 	--
> 	View this message in context: http://postgresql.1045698.n5.nabble.com/A-prepared-statement-ERROR-due-to-EMPTY-QUERY-is-defined-as-...
> 	Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
> 	
> 
> 
> 	--
> 	Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> 	To make changes to your subscription:
> 	http://www.postgresql.org/mailpref/pgsql-jdbc
> 	
> 
> 
> 

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





-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2014-03-12 02:06 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 04:18 A prepared statement ERROR due to EMPTY_QUERY is defined as a static Instance. Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
2014-03-10 23:21 ` Dave Cramer <pg@fastcrypt.com>
2014-03-11 00:30   ` Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>
2014-03-11 01:22     ` David Johnston <polobo@yahoo.com>
2014-03-11 16:06       ` Dave Cramer <pg@fastcrypt.com>
2014-03-12 02:06         ` Naoya Anzai <anzai-naoya@mxu.nes.nec.co.jp>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox