Bug 60217 - error message limited to a dot when mysql native connector is used
Summary: error message limited to a dot when mysql native connector is used
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
3.5.4 release
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Database-Connectivity
  Show dependency treegraph
 
Reported: 2013-02-03 10:37 UTC by t.bazin
Modified: 2021-08-19 13:47 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Macro fot testing executeQuery on a trivial database (444 bytes, text/plain)
2013-02-11 15:36 UTC, t.bazin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description t.bazin 2013-02-03 10:37:08 UTC
When using executeQuery macro instead of executeUpdate when the SQL string manipulates data, the error message is not explicit (limited to a dot).
This error message should be "cannot issue data manipulation statements with executequery" as it is when using JDBC connector for example.

The exact version of libreoffice is the LibreOffice 3.5.4.2 
Version ID : 350m1(Build:2) on UBUNTU 12.04 generic.
Comment 1 Robert Großkopf 2013-02-10 10:57:52 UTC
1. Could you add a database with the macro-code you use?
2. Who has confirmed this bug. Status is "New" and nobody else but the reporter has written any comment. Nothing could be seen in the histry. I will change it to "Needinfo"
Comment 2 t.bazin 2013-02-11 15:36:28 UTC
Created attachment 74623 [details]
Macro fot testing executeQuery on a trivial database

See comment #2
Comment 3 t.bazin 2013-02-11 15:42:52 UTC
It is easy to reproduce the bug from scratch with a single mysql test database which has a test table with a test column.

The attached macro can be executed with the native mySQL connector, the error message is :

Erreur d’exécution BASIC.
Une exception s'est produite :
Type: com.sun.star.sdbc.SQLException
Message:.

With the same database connected with the JDBC connector, I have the following error message

Erreur d’exécution BASIC.
Une exception s'est produite :
Type: com.sun.star.sdbc.SQLException
Message:can not issue data manipulation statement with executeQuery()

Yon can also note that the executeQuery statement works even if you manipulate data if you are using a native hsql libreoffice database.
Comment 4 t.bazin 2013-02-11 15:46:24 UTC
In comment #2, read "see comment #3" instead "see comment #2"
Comment 5 Robert Großkopf 2013-02-11 19:01:46 UTC
Have tried it with the macro. Same problem with the dot. Seems to be no error-message available in the connector. Now we have to look, which connector we are using. Could you please write down the exact connector?
I have tested with aoo-my-sdbc 1.1.0 - other connectors doesn't work with OpenSuSE and LO 3.5 or 3.6. Remember, that there is no connector at this moment working with LO 4.0.
The oracle-mysql-connector shows all databases. But when I try to run the macro in LO 3.3.4 base crashed immediately.

One hint to the macro:
oStatement.executeQuery(strSQL)
is used for queries, where you should get feedback from the database (See some content of the tables ...)
oStatement.executeUpdate(strSQL)
is used for actions, which doesn't give back any content. With executeUpdate the macro works.
Comment 6 t.bazin 2013-02-11 21:53:50 UTC
I use the folowing ubuntu version of the connector :

1.0.1+LibO3.5.4-0ubuntu1.1

This connector is proposed in the Ubuntu distribution 12.04
Comment 7 Alex Thurgood 2015-01-03 17:38:47 UTC Comment hidden (no-value)
Comment 8 QA Administrators 2016-01-17 20:03:34 UTC Comment hidden (obsolete)
Comment 9 Robert Großkopf 2016-01-28 19:27:27 UTC
Bug still exists with LO 5.1.0.2, OpenSUSE 42.1 Leap, 64bit rpm Linux.
Comment 10 QA Administrators 2017-03-06 14:10:24 UTC Comment hidden (obsolete)
Comment 11 Julien Nabet 2017-09-24 17:53:45 UTC
On pc Debian x86-64 with master sources updated 2 days ago, I tried to reproduce this but got stuck at line:
oDB = oDBContext.getbyName("db.table") (
I had the error message:
BASIC runtime error.
An exception occurred 
Type: com.sun.star.container.NoSuchElementException
Message: db.table.

what to put in arg for getbyName?
Comment 12 Julien Nabet 2017-09-24 18:06:25 UTC
Forget my last message, I could reproduce this.
I registered a Mysql database with "test" then it was ok.
Comment 13 Julien Nabet 2017-09-24 18:12:51 UTC
I reproduced exactly what Robert indicated:
executeQuery with delete sql -> error message with just .
executeUpdate with delete sql -> no message and the table is empty
Comment 14 Julien Nabet 2018-06-23 22:58:32 UTC
Here's part of the bt of the root cause:
#0  0x00007fffc0031145 in sql::SQLString::SQLString(char const*) (this=0x7fffffff0aa0, other=0x55555892c0a7 "")
    at /home/julien/lo/libreoffice/workdir/UnpackedTarball/mysql-connector-cpp/cppconn/sqlstring.h:57
#1  0x00007fffc009b1ae in sql::mysql::NativeAPI::MySQL_NativeConnectionWrapper::error() (this=0x55555892bfc0)
    at /home/julien/lo/libreoffice/workdir/UnpackedTarball/mysql-connector-cpp/driver/nativeapi/mysql_native_connection_wrapper.cpp:149
#2  0x00007fffc0096986 in sql::mysql::util::throwSQLException(sql::mysql::NativeAPI::NativeConnectionWrapper&) (proxy=...)
    at /home/julien/lo/libreoffice/workdir/UnpackedTarball/mysql-connector-cpp/driver/mysql_util.cpp:51
#3  0x00007fffc0093e0f in sql::mysql::MySQL_Statement::get_resultset() (this=0x555558a189c0)
    at /home/julien/lo/libreoffice/workdir/UnpackedTarball/mysql-connector-cpp/driver/mysql_statement.cpp:113
#4  0x00007fffc009423a in sql::mysql::MySQL_Statement::executeQuery(sql::SQLString const&) (this=0x555558a189c0, sql=...)
    at /home/julien/lo/libreoffice/workdir/UnpackedTarball/mysql-connector-cpp/driver/mysql_statement.cpp:166
#5  0x00007fffc059afd5 in connectivity::mysqlc::OCommonStatement::executeQuery(rtl::OUString const&) (this=0x5555581b6810, sql="DELETE FROM test")
    at /home/julien/lo/libreoffice/mysqlc/source/mysqlc_statement.cxx:151
#6  0x00007fffca9d5572 in OStatement::executeQuery(rtl::OUString const&) (this=0x555558a21de0, _rSQL="DELETE FROM test")
    at /home/julien/lo/libreoffice/dbaccess/source/core/api/statement.cxx:453


Since Mysql connector doesn't indicate an error, I wonder if we shouldn't test the query in mysqlc_statement.cxx to check if it contains a "select type" only
(or perhaps it'd be simpler to check it doesn't contain update or delete).
I suppose since these keywords may be included in some table names, we should use a parser.(I don't know how to do it but hope there may be something simpler).
May https://gerrit.libreoffice.org/#/c/55960/ change things here?
Comment 15 QA Administrators 2019-08-19 06:59:51 UTC Comment hidden (obsolete)
Comment 16 QA Administrators 2021-08-19 03:45:01 UTC Comment hidden (obsolete)
Comment 17 Robert Großkopf 2021-08-19 13:47:21 UTC
Have tested it with LO 7.1.5.2 and MariaDB/direct connection integrated in LO.
Gives now:

BASIC runtime error.
An exception occurred 
Type: com.sun.star.sdbc.SQLException
Message: executeQuery called on SQL command that does not return a ResultSet /home/buildslave/source/libo-core/connectivity/source/drivers/mysqlc/mysqlc_general.cxx:119.

So I will close this one as worksforme. Feel free to reopen if the buggy behavior still exists in a newer version.