https://bugs.documentfoundation.org/show_bug.cgi?id=103685

--- Comment #13 from Lionel Elie Mamane <lio...@mamane.lu> ---
(In reply to Julien Nabet from comment #8)
> The call to getResultSet() is really just to update the status, not for
> using a rs.

I thought from memory that calling getResultSet twice in a row would implicitly
retrieve the second result  of the query. That is indeed wrong. To advance to
the next result, one must call getMoreResults(). However, MySQL C++ connector
implements (part of) the JDBC API in C++. So looking at the JDBC documentation
https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#getResultSet()
I see:

 This method should be called only once per result.

So unless MySQL C++ connector declares it made that safe in its documentation,
we should avoid calling it and throwing away the result; we will not
necessarily get it back correctly when calling getResultSet() the next time.

> In executeQuery, we retrieve a rs that we can release, it's not the case for
> execute.

Yes, because in executeQuery, there is necessarily a ResultSet to be retrieved.
It is an error to call executeQuery on a query that does not return results
(such as a basic UPDATE / DELETE query). The query can be a query that returns
a result containing zero rows, but it must return a result.

It is allowed to call execute() on any kind of query: returning a single result
(of zero, one or more rows) or not returning any result, or returning several
results. It is then the caller's job to call getResultSet() and
getMoreResults() to retrieve the results.

There is example code on how to use execute() correctly there:

https://blogs.msdn.microsoft.com/jdbcteam/2008/08/01/use-execute-and-getmoreresults-methods-for-those-pesky-complex-sql-queries/

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to