[ODBC-100] Get wrong BaseTableName for first column in result with inner join Created: 2017-05-31  Updated: 2018-07-17

Status: Open
Project: MariaDB Connector/ODBC
Component/s: None
Affects Version/s: 2.0.15
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Johannes Wezel Assignee: Lawrin Novitsky
Resolution: Unresolved Votes: 0
Labels: ADO.NET, BaseTableName, INNER, JOIN, ODBC
Environment:

Windows 10


Attachments: Text File ODBC.LOG     Zip Archive ODBC_test_application.zip     PNG File VisualStudio_Screenshot.png     File testcase.sql    

 Description   

*SQL: *
SELECT d., g.
FROM device AS d
INNER JOIN group_assign AS ass ON ass.device_id = d.id
INNER JOIN group AS g ON ass.group_id = g.id;

I get the wrong BaseTableName for the first column. In this case i get for the d.id the BaseTableName "group" and if I change the order "SELECT g., d. FROM ..." I get the BaseTableName "device" for the first column g.id.

Workaround:

*SQL: *
SELECT d.id AS dummy, d., g.
FROM device AS d
INNER JOIN group_assign AS ass ON ass.device_id = d.id
INNER JOIN group AS g ON ass.group_id = g.id;

Now I get for column "dummy" the BaseTableName "group" (see attachment). I guess the first colmun in result always returns the BaseTableName of the second table of the select statement?!

I tested it with the MySQL ODBC 5.2 driver and the newest MySQL ADO.NET driver and in it works fine in both cases.



 Comments   
Comment by Lawrin Novitsky [ 2017-05-31 ]

Thank you for your bug report!

Would it be possible to provide ODBC trace for the problem you observe? Or the test case?

Comment by Johannes Wezel [ 2017-06-01 ]

I've uploaded the Windows ODBC logfile with the last 2 statements. The second block is my test case with the 'dummy' field.

I hope that's the tracefile you want. If not so please let me know.

Thank you for your efforts.

Comment by Lawrin Novitsky [ 2017-06-01 ]

Hi,
You've pasted here the trace for your workaround with dummy. That's fine, since it still shows sequence of ODBC calls your .Net application does, and presumably it's the same as with the query, that exposes the issue.
However, I could not so far repeat your problem. SQLColAttributeW(SQL_DESC_BASE_TABLE_NAME) returns 'device' for the 1st column after SQLPrepareW(your query)
Could you please try your testcase with latest 2.0 connector(2.0.15 at the moment)? 3.0 is not stable release yet, and it was released relatively long time ago, and thus it does not contain all fixes that 2.0.15 has. I could not repeat your problem with 3.0 as well, but I neither have your complete environment(e.g. table structures), nor I have your complete test-case.
And if it is repeatable with 2.0, and I guess that is the case, could you please provide me your standalone test-case with related table structures?

Comment by Johannes Wezel [ 2017-06-01 ]

I've tried it with the ODBC 2.0.13, 2.0.14, 2.0.15 and 3.0.0. I have the same issue in all versions. I use currently the 3.0.0 for development because the performance of the 2.0.15 is extremely bad. The DataReader in version 2.0.14 needs for a certain query 10 seconds and the 2.0.15 for the same query 60 seconds. That's the reason why I'm using the 3.0.0 or 2.0.14.

I've tried to rename the mawa_device.id to mawa_device.id_d and it works fine. Maybe there is a problem with the JOINs of more tables with same columnnames? Maybe the base table name become filled based on column name only?
The position of the id field doesn't matter -> same issue.

I've attached a small testcase with 3 tables and test data. The query I used is:

SELECT d., g. FROM mawa_device_group_assign as a
INNER JOIN mawa_group as g ON g.id = a.group_id
INNER JOIN mawa_device as d ON d.id = a.device_id

For mawa_device.id i get the base table name "mawa_group". I hope you can repeat the issue.

Comment by Lawrin Novitsky [ 2017-06-01 ]

I would appreciate if you reported that 2.0.15 performance regression in separate jira issue!
As for test-case - I was rather talking about short .net program that allows to repeat the issue. Because I tried restore from your ODBC trace short C program, but I could try to repeat what you see. I will try with your exact tables structure, but I doubt it will be different.
Thanks once again for your cooperation

Comment by Johannes Wezel [ 2017-06-02 ]

You will find the zip-file with the short C# .NET test-application in the attachment.

I'm using the following version of visual studio for debugging:

Microsoft Visual Studio Professional 2015
Version 14.0.25421.03 Update 3
Microsoft .NET Framework
Version 4.6.01038

My debugger is configured for "Any CPU x64".

Comment by Lawrin Novitsky [ 2017-06-02 ]

Thanks!

Comment by Lawrin Novitsky [ 2017-06-06 ]

Strange. Connector returns correct BaseTableName, but at the end it is wrong. It has smth to do with same name of columns in device and group tables(id) - if rename it in one of fields, your test passes without errors.
That all would look like a bug in ado.net, unless mysql's connector didn't show the same problem. The solution apparently is not straight forward.
May I ask one more time to file a bug about your regression problem? All 2.0.15 stuff has been merged to 3.0 branch, and most probably that regression will show up in next 3.0 release. If we don't eliminate its reason. Thanks in advance.

Generated at Thu Feb 08 03:26:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.