Page 1 of 1

MySQL Metadata for keys

Posted: 06.08.2022, 14:40
by MJFShark
It looks like the MySQL metadata calls:
UncachedGetImportedKeys
UncachedGetExportedKeys
UncachedGetCrossReference

All currently don't work on MySQL 5.7 and MySQL 8.0 (those are the only two versions I have access to.)
They all seem to rely on the command:
SHOW TABLE STATUS FROM %s LIKE ''%s''
which as far as I can tell does not show any real key information. I've gone back through the file history to see if something changed at some point, but didn't find anything.

The easiest solution I can see would be to use the information_schema to get the information. The MySQL metadata stuff is currently a mix of using the informaton_schema and the "show" commands and I know there's been some concern about using the information_schema, but in this case since I don't think the current functions work at all it doesn't seem like using the informaton_schema would be an issue.

I'm happy to do a pr with updated functions but wanted to check if others think it's the way to go, of if perhaps someone knows how to use the show command to get the key information those calls need.

-Mark

Re: MySQL Metadata for keys

Posted: 08.08.2022, 06:42
by marsupilami
Hello Mark,

generally speaking there is no problem in using the information_schema. I suggest to check the server version so we don't get an exception on older servers. Something like:

Code: Select all

  if MySQLServerVersion >=WorkingVersion then begin
    // get information fom information schema here
  end else begin
    // do nothing here and return an empty result set.
  end;
As far as I know the information schema was buggy at times and doesn't exist on old servers.