[ODBC-370] No primary keys in Access linked tables - even if autonumber Created: 2022-08-08 Updated: 2023-06-05 Resolved: 2023-06-05 |
|
| Status: | Closed |
| Project: | MariaDB Connector/ODBC |
| Component/s: | General |
| Affects Version/s: | 3.1.16 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ray Merrill | Assignee: | Lawrin Novitsky |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Access frontend. MariaDb backend. Linked using DSN-less connections (but also happens if using regular DSN). 64b Access 16.0.15427.20194, Windows 11 (also happens Windows 10) Problem occurs on: Problem does NOT occur on: Connection string: ;SERVER=localhost;PORT=3306;DATABASE=ctu;USER=root;OPTION=67108914;Trusted_Connection=Yes; |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
After linking tables from MariaDb Access shows absolutely no primary keys ... for any table ... even if the only key is an autonumber. Although this seems likely related to the recent varchar PK reports ... this is all of them. The old driver still seems to work with the latest Access client. Although last year I had to rewrite the connection strings to use OPTION instead of the parameter names (Access seems to have stopped connecting based on parameter names and only the OPTION value). |
| Comments |
| Comment by Lawrin Novitsky [ 2022-08-09 ] | ||
|
Thank you for your report. I would imagine that could be connected to | ||
| Comment by Ray Merrill [ 2022-08-09 ] | ||
|
The database has a lot of tables, but here is a sample of a couple: – Dumping structure for table demodata.ApplicationDefaults – Dumping structure for table demodata.AccountTypes | ||
| Comment by Ray Merrill [ 2022-08-16 ] | ||
|
I decided to try a very simple table. Still no joy (as expected). The attached SQL was a database with a very simple, single table. Do you and your team have any insights into this problem? Are there settings or actions you'd like me to try? | ||
| Comment by Lawrin Novitsky [ 2022-08-16 ] | ||
|
I've removed the link as I am not sure that the issues are even connected. | ||
| Comment by Lawrin Novitsky [ 2022-08-19 ] | ||
|
Ok, I've just tried couple of your tables - those w/out foreign key constraints, and my access shows PK for all of them, and for other linked tables I have. The difference is probably in the Access version - I have 32b Microsoft® Access® 2019 MSO (Version 2207 Build 16.0.15427.20166) 32-bit. I'll get 64b to try. | ||
| Comment by Jörg [ 2022-12-10 ] | ||
|
You must define the index column as follows: This works for me when connecting to MS-Access with odbc The attached file creates a database and a table tbl_colors for testing. Does it work for you? | ||
| Comment by Ray Merrill [ 2023-03-03 ] | ||
|
I tried Jorg's suggestion of adding a unique index on the PK's (in addition to PK). Although by definition a PK has to be unique, I gave it a try. No joy. It does not resolve the problem. I wanted to just note the test result and thank Jorg for his suggestion. | ||
| Comment by Ray Merrill [ 2023-03-03 ] | ||
|
Today I finally got back to investigating this problem and I believe I've found an important clue: this problem appears to happen with recent ODBC connector version against recent MariaDb server running on Windows. I have used the latest ODBC connector (3.1.17 Win64) to successfully connect to a version of our database on LINUX server (running MariaDb 10.7.1). All PK's working. I ran the usual test against latest MariaDb 10.11.2 for Win64 and the PK's are not working. I also tested the latest ODBC connector (3.1.17 Win64) against the old, tried and true, MariaDb server for Windows 10.3.22 ... and the problem exists (no PK's read). So the latest ODBC Connector is not reading PK's the same as the older connector ... so we can't use the latest ODBC Connector either. I am about experiment with a Linux VM running a more recent mariadb server ... however, we have customers using Windows for their MariaDb server so this is still a problem even if that works. | ||
| Comment by Ray Merrill [ 2023-03-03 ] | ||
|
Also, just for reference... HeidiSQL has no problem ascertaining the keys/indexes etc ... this is an ODBC thing. Perhaps only Access via ODBC thing. | ||
| Comment by Lawrin Novitsky [ 2023-03-12 ] | ||
|
Jorg Sorry, I didn't look at the tbl_colors at the time. The problem with it is probable unique key on the `id` field. Why do you need it? Primary key is quite enough and it is unique. I linked your table, and it behaved... strange, I am looking into it as your table structure is still valid, but when I removed the UNIQUE key from it - things look normal. thrunch Search and use of primary keys was added in one of recent versions. Before the condition to identify a row was build using all columns. That can explain what you see. Anyway, I am on this ticket now. | ||
| Comment by Lawrin Novitsky [ 2023-03-12 ] | ||
|
thrunch Well, I was talking about use of primary keys in the data manipulations in Access, that is probably not related to your problem. But catalog functions returning lists of indexes were fixed recently as well. But I have a question - how do you actually check if table has primary key. I open it in design view, and primary key field has key next to it, and also the row Indexed says "Yes(No Duplicates)" Just verified that once again with aforementioned tbl_colors in both its versions. | ||
| Comment by Lawrin Novitsky [ 2023-03-13 ] | ||
|
Ok, I've obtained 64bit Access, and still no luck - all tables have primary keys, all operations are fine. | ||
| Comment by Lawrin Novitsky [ 2023-03-13 ] | ||
|
I've tried against 10.11 - all works just like with other version, i.e. fine. I'm stopping with the ticket so far. I need something more to understand/repeat the problem. | ||
| Comment by Ray Merrill [ 2023-03-29 ] | ||
|
Lawrin Novitsky: Apologies for my delayed response as we have several things going on at once. Based on your comments I decided to re-run my tests looking carefully at the results using different connectors and Maria servers. You will notice that the problem exists with Maria servers running on windows ... and notice NO primary keys are returned, regardless of type of field. In the cases where it returns the unique field instead of the actual PK ... as our actual schema is known to our application. But with no workable PK returned, the application cannot run because Access cannot operate on the table. I examined the PK results for 3 tables: 3.0.8 ODBC connector against Windows MariaDb 10.3.22 3.0.8 ODBC connector against Linux MariaDb 10.5.16 3.0.8 ODBC connector against Windows MariaDb 10.11.2 3.1.17 ODBC connector against Windows MariaDb 10.3.22 3.1.17 ODBC connector against Linux MariaDb 10.5.16 3.1.17 ODBC connector against Windows MariaDb 10.11.2 In all cases the connection settings included: Are there particular settings for the connector that you want me to try? As an aside: Access does not allow multiple statements in single query definition, although they can refer to other queries. So multi is probably not needed. | ||
| Comment by Ray Merrill [ 2023-03-29 ] | ||
|
Also also wik: I also ran a test against a Microsoft Azure MariaDb instance. I saw similar results between the 2 connectors (old 3.0.8 ok/acceptable, newer 3.1.17 gets no PK's). | ||
| Comment by Lawrin Novitsky [ 2023-03-29 ] | ||
|
Just couple of comments | ||
| Comment by Ray Merrill [ 2023-03-29 ] | ||
|
You can tell by: Our table names are case sensitive and our MariaDb servers are running with the setting "lower_case_table_names = 2". We are also running with "character-set-server=utf8" and "collation-server=utf8_general_ci" We are aware of the EOL on 10.3 and we have customers wanting us to resolve this problem so they can update. Yes, I will run a test where the name of the index is alphabetically after "PRIMARY" ... I'll post when I have the result. | ||
| Comment by Ray Merrill [ 2023-03-29 ] | ||
|
StudentAidPackages having autonumber PK and unique "QAltGUID" in varchar field. 3.0.8 ODBC connector against Windows MariaDb 10.3.22 3.0.8 ODBC connector against Linux MariaDb 10.5.16 3.0.8 ODBC connector against Windows MariaDb 10.11.2 3.1.17 ODBC connector against Windows MariaDb 10.3.22 3.1.17 ODBC connector against Linux MariaDb 10.5.16 3.1.17 ODBC connector against Windows MariaDb 10.11.2 After the above tests, I edited out the setting "lower_case_table_names=2" and restarted the Mariadb server. It did not change the results ... still no PK's against Windows MariaDb server. | ||
| Comment by Lawrin Novitsky [ 2023-03-29 ] | ||
|
So, basically we do it the same way. Thus it's a bit strange why I can see primary keys everywhere, and you can not Could you please provide one of your tables structure? Maybe of StudentAidPackageAwardResponses - as it's simplest for our case. or maybe all of them, if that is not a problem As for case sensitivity - as I said, if it was the reason, I'd expect problems with Linux servers, and not Windows. But it's other way around for you. | ||
| Comment by Lawrin Novitsky [ 2023-03-29 ] | ||
|
I don't know, why I did not ask you before. Probably because I can't repeat the issue. Could you please provide ODBC trace of linking of any of tables you see the problem with. Maybe with opening of the table, to be safe. Although I think linking is enough. Would be great along with with table "create table ..." | ||
| Comment by Ray Merrill [ 2023-03-29 ] | ||
|
This happens to every table, even the simple test table I set up and sent as attachment test1.sql. I have to hang my hat up for the day. I will run a test with ODBC trace of linking tomorrow (Thursday). But I've not had to do that before so a quick primer on setting up trace would be appreciated, even if it is just the link to documentation/page - shorten my search/read. Thanks | ||
| Comment by Lawrin Novitsky [ 2023-03-29 ] | ||
|
and here we are - for the table in test1.sql I can see the pk Tracing is easy - in ODBC Data Sources(you need the one for 64bit, since your Access and drivers are 64b afair) there is tab Tracing, you are turning it on there, you also can pick the trace file name and location. Then start Access and do linking and open table. Then you may turn tracing off, and send me the file. | ||
| Comment by Ray Merrill [ 2023-03-29 ] | ||
|
Apparently not so easy for me. I've tried and no log file seems to get written. I've run it as administrator and with machine wide tracing. No joy on any log file. Am I missing something? | ||
| Comment by Lawrin Novitsky [ 2023-03-30 ] | ||
|
Push Start Tracing Now | ||
| Comment by Ray Merrill [ 2023-03-30 ] | ||
|
I already had Access open (but not linked) when I tried it last night. I was successful in capturing your trace. I opened a blank database and linked manually (not using our code) to a Maria database which includes the test table per test1.sql ... no PK's after linking. The trace is attached. I hope this reveals the problem! Thank you for your patience and diligence. PK TEST 1.LOG | ||
| Comment by Lawrin Novitsky [ 2023-03-30 ] | ||
|
I can only thank you for your patience | ||
| Comment by Lawrin Novitsky [ 2023-06-03 ] | ||
|
thrunchThe log contains only part for table TestAccount, for which I don't have the structure | ||
| Comment by Ray Merrill [ 2023-06-03 ] | ||
|
I'm sorry, I thought I had attached a SQL file having the table. Here it is: – -------------------------------------------------------- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; – Dumping structure for table test.TestAccount – Dumping data for table test.TestAccount: ~0 rows (approximately) /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; | ||
| Comment by Lawrin Novitsky [ 2023-06-03 ] | ||
|
Sorry, my bad - found TestAccount structure. It was in the attached file, and there were few tables posted separately in comments | ||
| Comment by Lawrin Novitsky [ 2023-06-03 ] | ||
|
thrunchCould you please run following queries on your server:
and
The latter must be run having demodata_newmaria(or where is your TestAccount is located) as the current database, or you need to change in the query "TABLE_SCHEMA=DATABASE()" to "TABLE_SCHEMA=`<TestAccount's_Schema_Name>`" Aren't you or DB server on Mac btw? | ||
| Comment by Lawrin Novitsky [ 2023-06-05 ] | ||
|
I think I found the reason - at least I could re-create your problem. I opened separate ticket for it to give the better description and linked to this as the one causing this one. | ||
| Comment by Ray Merrill [ 2023-06-05 ] | ||
|
Lawrin, that is indeed the situation: lower_case_table_names set to 2 Thanks for your diligence on this. | ||
| Comment by Ray Merrill [ 2023-06-05 ] | ||
|
We can't use that workaround so we will wait for the bug fix. Thanks. |