Bug #70006 getString()
Submitted: 13 Aug 2013 3:10 Modified: 24 Oct 2013 2:29
Reporter: Aluísio Macedo Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:1.1.3 OS:Windows (Visual Studio 2010)
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: crash, debug, getString()

[13 Aug 2013 3:10] Aluísio Macedo
Description:
Version 1.1.3 worked fine with almost all tested the 'getX()' member functions of ResultSet class, like getInt, getDouble, getBoolean, etc.

But I really can not extract any char field, it seems that SQLString object is being destroyed before been forwarded to the left side of expression. Unfortunatelly I do not know how to get around this issue, if it is possible.

std::cout<<res->getInt("some_Int_field")<<std::endl;
std::cout<<res->getString("some_char(N)_field")<<std::endl;//-> Always crash.

In general member-functions that return SQLString typeid have this problem, I experienced same errors in other cases like ResultSet::getMetaData::getColumnName(int).

Please let me know if I'm using the member-function (getString) in a wrong way. Or if there is some technique to avoid the lost (destruction) of object before its use.

Thanks in advance

How to repeat:
Every time I tested.
[13 Aug 2013 9:26] Aluísio Macedo
Call Stack

Attachment: tmp_Connect001Bug.jpg (image/jpeg, text), 147.21 KiB.

[13 Aug 2013 9:34] Aluísio Macedo
The problem occours under Debug mode, I still have not try to run under release mode.
[13 Aug 2013 10:39] Aluísio Macedo
Code

Attachment: Statement_and_query.cpp (text/plain), 4.18 KiB.

[13 Aug 2013 16:37] Aluísio Macedo
Same error when runs in Release mode (MTDLL);
[14 Aug 2013 4:38] Bogdan Degtyariov
Hi Aluísio,

Thank you very much for your interest in MySQL and for reporting a problem in our software along with providing the C++ test case.

Unfortunately, I was not able to repeat the crash using the code you provided.
Here is the output I see:
-----------------------------------------------------------------
Testando uma conexao...
Connector 1.1.3:
Sucesso!

Inserindo statement...
Criada a tabela...
Linhas inseridas...
Preparando-se para listar os inteiros:

Total de fields: 4
Tipo de res                             : bool
Tipo de res->getMetaData()              : class sql::SQLString
Quantidade de fields (espero 2) res->getMetaData()->getColumnCount()
: 4

Verificando <<cout para SQLString::tmp01: Qualquer coisa aqui dentro...

Final dos tipos!4
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 14
perc
id = 1  perc: 0.93       completo : 1
.
..
...
Terminado!
-----------------------------------------------------------------

I consider the above results as successful program run.
Therefore, I want to ask a few questions:

 1. Did you link the static or the dynamic version of Connector/C++?
    (I used mysqlcppconn-static.lib)

 2. Which version of mysqlclient.lib you are using?
    (I tried linking against versions 5.5.33 and 5.6.13)
[14 Aug 2013 12:42] Aluísio Macedo
Hi, Bogdan,

Thanks for your prompt response, it’s always good when the other’s questions and observations shed some light on hard tasks.

Unfortunately I’ve forgot to uncomment the problematic line, I’m sending other code with less garbage outputs.

About the Connector, I only have success when using the dll (mysqlcppconn.lib), it was not possible to perform a static link. About other programs, I’ve took a look on how they are organized under PATH system variable, and it’s a good time to comment what I have here on my Win_Vista, besides MS Visual C++ 2010 Express and my day-by-day apps, I have:

 .MySQL Server Version 5.6.12-log; (obtained with “SELECT VERSION();” - intended to be only client)
 .MySQL Connetor ODBC 5.2.5 (used with MS-Excel/MS-Query to access multiple databases);
 .Connector C++ 1.0.5;
 .Connector C++ 1.1.3;
 .XAMPP with PHP 5.3.9, Apache 2 and Apache 2.2 (used to perform some local WebPages tests);

The PATH has, among others, these lines are present:

 C:\Arquivos de Programas Compilers\MinGW 10.0\MinGW\bin;
 C:\Program Files\MySQL\Connector C++ 1.1.3\lib\opt;
 C:\Program Files\MySQL\Connector C++ 1.0.5\lib\opt;
 C:\Program Files\MySQL\MySQL Server 5.6\lib;
 C:\Program Files\CMake 2.8\bin

MySQL Server, against what I’m doing the tests, is on another machine that runs XUbuntu 10.04 LTS, and it’s current version is the 5.1.70-0ubuntu0.10.04.1.
My goal is to set a complete test handling the database on XUbuntu, from C++ Windows based applications and the next step, reusing part of code written in C++, is to develop some routines to C++ Linux based that will run on the XUbuntu machine as services (daemons).

Hugs

Aluísio
[14 Aug 2013 12:46] Aluísio Macedo
Forum_Sample_001.cpp

Attachment: Forum_Sample_001.cpp (text/plain), 2.63 KiB.

[14 Aug 2013 12:46] Aluísio Macedo
Another sshot of problem.

Attachment: tmp_Connect002Bug.jpg (image/jpeg, text), 116.73 KiB.

[16 Aug 2013 7:30] Bogdan Degtyariov
Hi Aluísio

I tried the new version of your C++ test case without any crashes.
Also, I linked the dll-version of Connector/C++ library instead of the static one. The result is the same, no crash:

------------------------------------------------------------------
Connection test using Connector/C++ 1.1.3:
Success!

Inserting statement...
Table done...
Table populated...

Total fields on table: 4
Type of *res                            : bool
Type *res->getMetaData()                : class sql::SQLString

Listing non-char fields:
id = 1  perc: 0.93      completo : 1
id = 1  perc: 0.93      completo : 1
id = 1  perc: 0.93      completo : 1

Now trying to list the char field label01;
Here, in my case, code compiles but crashes at the runtime
(cursor blinks after first value output):
label01 = Ajkjk
label01 = Ajkjk
label01 = Ajkjk
.
..
...
Passed the try/catch block!!!
Enter to terminate
------------------------------------------------------------------

Any other ideas of what I should try?
[16 Aug 2013 23:39] Aluísio Macedo
Hi, Bogdan,

I finally had success running the code, but before had it done I decided to capitulate in my effort using MSI Installer distro.

I followed the general advice and did the compilation using CMake, having success after some few tries.

The problem is that going through this way, I feel myself a bit hostage of others job...

The solution opened by CMake into MS Visual C++ Express 2010 is astonishing huge, and I think it'll take me some time to get the overall comprehension of the dependencies btw headers, sources and compiling options.

To get more controll, last night I read something about Property Manager and related "props" files and hope have more control of process on next few days.

Anyway I'd like to thank your attention and help.

Hughs

Aluísio
[19 Aug 2013 5:24] Bogdan Degtyariov
Hi Aluísio,

Sorry, I am not sure I understand what exactly you wanted to say.
If your message was about non-working Connector/C++ libraries installed by MSI installer then I would like to mention that I used the MSI-installed Connector/C++ when trying to repeat the problem.

What exactly was the solution? Was it only to re-build the Connector/C++ libraries from the sources or you did something else?
Thanks.
[20 Sep 2013 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[24 Sep 2013 2:29] Bogdan Degtyariov
Hi Aluísio,

Please note that the current bug report is waiting on your feedback.
Do you have any updates for me?
The report will be automatically closed if we have no replies from you for next 15 days.
Thanks.
[25 Oct 2013 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".