Re: streaming result sets: progress - Mailing list pgsql-jdbc

From nferrier@tapsellferrier.co.uk
Subject Re: streaming result sets: progress
Date
Msg-id ur8doi06k.fsf@tapsellferrier.co.uk
Whole thread Raw
In response to Re: streaming result sets: progress  (snpe <snpe@snpe.co.yu>)
Responses Re: streaming result sets: progress  (snpe <snpe@snpe.co.yu>)
List pgsql-jdbc
snpe <snpe@snpe.co.yu> writes:

> I add AbstractJdbc3Statement missing method from AbstractJdbc2Statement and
> it work.I don't test complete, but simple command on table with 1 mil. rows
> work fine.

Ok.

> > > 2) method nic_execute create query like :
> > > BEGIN; DECLARE JDBC_CURS_1 CURSOR FOR select * from tab FETCH FORWARD 100
> > > FROM JDBC_CURS_1;
> > > I add ";" before FETCH
> >
> > Hmmm... that's odd. Does the statement you supply have a ";" on the
> > end of it? My patch only works if it does.
>
> You send this :
> BEGIN; DECLARE JDBC_CURS_1 CURSOR FOR select * from tab FETCH FORWARD 100
> FROM JDBC_CURS_1;
> I change and send :
> BEGIN; DECLARE JDBC_CURS_1 CURSOR FOR select * from tab; FETCH FORWARD 100
> FROM JDBC_CURS_1;

Yes. But the reason I send:

DECLARE JDBC_CURS_1 CURSOR FOR select * from tab FETCH FORWARD 100 FROM JDBC_CURS_1;

is because the SQL statement you supply is _supposed_ to end with a
";". The code for the above is actually doing:

   DECLARE JDBC_CURS_1 CURSOR FOR $userquery  FETCH FORWARD 100 FROM JDBC_CURS_1;

where $userquery is what comes in from the client code, eg:

   Statement st = con.createStatement();
   ResultSet rs = con.executeQuery("select * from tab;");

then "select * from tab;" is inserted as $userquery. It must always
end with ";" because that's how PGSQL's normal query processing works.

So if your code does this:

   Statement st = con.createStatement();
   ResultSet rs = con.executeQuery("select * from tab");

it won't work. AFAIK it won't work with unpatched PGSQL JDBC either
(please correct me if I'm wrong).


Nic

pgsql-jdbc by date:

Previous
From: snpe
Date:
Subject: Re: streaming result sets: progress
Next
From: snpe
Date:
Subject: Re: streaming result sets: progress