Re: a possible bug in postgresql jdbc driver
От | Kris Jurka |
---|---|
Тема | Re: a possible bug in postgresql jdbc driver |
Дата | |
Msg-id | 49B6A4EA.5060905@ejurka.com обсуждение исходный текст |
Список | pgsql-jdbc |
Pawel Pastula wrote: > Hi Kris > Please send general questions to the pgsql-jdbc@postgresql.org mailing list rather than to individual developers. > I think I've found a bug in jdbc driver. > I need to execute a query which is actually a list of queries and some > of them drop tables, other update tables and one of them queries data > with select. > Imagine the following query (report): > > drop table if exists test_table; > select * into test_table from other_table; > select * from test_table; > > Of course it looks very simple but it's only for testing purposes. My > queries are more demanding with lots of select * into temp table etc. > I figured out that in order to get data from test_table I need to > actually call getResultSet() 3 times. Therefore I wrote some simple > 'result set walker' to get the latest result set returned by the query. > And it's fine. > > However in case of this report stmt.executeQuery() would be more > convenient since we expect to receive some data. > And this is the place where the problem is. It throws exception just > because after the query is executed there is a check whether result set > is not null. > And the problem is, that only the first result set is taken into > account. The rest is ignored. And in my case the first query has no > result set, it only has update count, the same with the second query. > Only the third one has a result set. > Therefore the check shouldn't be done whether there is a result set and > whether it's not null for the first subquery but whether there is a > result set for any subquery in this query. See the javadoc for Statement.executeQuery, it says it should throw a SQLException if, "the given SQL statement produces anything other than a single ResultSet object." As you've noted it has produced other results (update counts) and therefore it must throw the exception. Kris Jurka
В списке pgsql-jdbc по дате отправления: