Bug #92966 ROW_COUNT() returns 0 on insert when using ODBC connector 8.0+
Submitted: 26 Oct 2018 14:03 Modified: 28 May 2019 16:34
Reporter: Ben Lu Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:8.0.12 OS:Windows (10)
Assigned to: CPU Architecture:Any

[26 Oct 2018 14:03] Ben Lu
Description:
I recently switched my C++ application to use the latest MySQL ODBC connector 8.0.12 from ODBC 3.51. After the switch, I found out that ROW_COUNT() always return 0 on inserts/updates. For example, in my application, it inserted a new row to a table (I verified that the row was inserted), then using the same db connection object, it immediately did a "select ROW_COUNT()". The query returned 0 instead of 1. If I switched back to ODBC 3.51 and tried the same thing, it would return 1.

How to repeat:
You'd need to run these queries using C++ API via ODBC connector 8.0.12 or 8.0.13 -

create table test (bug varchar(255))

insert into test select 'odbc bug';

select row_count();

Suggested fix:
I am suspecting that ODBC implementation might be doing a ping or something like that to MySQL before it executes a new query, causing the affected row count from the previous query to be reset.
[26 Oct 2018 16:42] MySQL Verification Team
Thank you for the bug report. Could you please provide the test code client file which presents this issue (attach it using the Files tab). Thanks.
[27 Nov 2018 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".
[27 May 2019 18:43] Johnny C.L.
No solution for this?
[27 May 2019 18:46] Johnny C.L.
by the way he provieded how to duplicate.

create table test (bug varchar(255))
insert into test select 'odbc bug';
select row_count();

Using ODBC 8.0 (any verison from 8.)
[28 May 2019 16:32] MySQL Verification Team
Test case

Attachment: myodbc1.c (text/plain), 1.40 KiB.

[28 May 2019 16:34] MySQL Verification Team
I couldn't repeat with version 8.0.16:

C:\code\myodbc1\x64\Debug>myodbc1.exe
select row_count(): 1

C:\code\myodbc1\x64\Debug>