View Issue Details

IDProjectCategoryView StatusLast Update
0029819FPCDatabasepublic2016-03-14 14:35
ReporterRik van KekemAssigned ToLacaK 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionProduct Build 
Target VersionFixed in Version3.1.1 
Summary0029819: TSQLConnector.GetTableNames fails on MySQL
DescriptionTSQLConnector has an internal FProxy which gets the correct TXXXConnection for the specified database. It's used for the connection.

However calling TSQLConnector.GetTableNames doesn't call the GetTableNames of that underlying object. Instead it call the inherited TSQLConnection.GetTableNames which only works for SQLite but not for other databases.

SQLConnector1.GetTableNames(Sl, false); // user tables
gives this as error on a MySQL database
 : Field not found : "table_name".

SQLConnector1.GetTableNames(Sl, true); // system tables
gives this as error on a MySQL database
The metadata is not available for this type of database.

This could be fixed by creating an override as TSQLConnector.GetTableNames which calls FProxy.GetTableNames() (if FPoxy is assigned) just like the other procedures in TSQLConnector do.
Additional InformationSolution could be something like this:
--------------
type
  TSQLConnector = class(TSQLConnection)
  public
    procedure GetTableNames(List: TStrings; SystemTables: boolean = False); override;
  end;

procedure TSQLConnector.GetTableNames(List: TStrings; SystemTables: boolean);
begin
  if Assigned(FProxy) then
    FProxy.GetTableNames(List, SystemTables)
  else
    inherited;
end;
TagsNo tags attached.
Fixed in Revision33254
FPCOldBugId
FPCTarget
Attached Files

Activities

Rik van Kekem

2016-03-12 16:26

reporter   ~0090937

It seems like the error for the systemtable is correct (because you can't do that with MySQL) so the error "The metadata is not available for this type of database." is correct in that case.

But the error for the user-tables shouldn't be there. The GetSchemaInfoSQL from the FProxy-connection is called correctly but that's not enough for the GetDBInfo()-function to get the tables. GetDBInfo() also receives a "Return-field" parameter which is different in SQLite from MySQL. In SQLite it is "table_name" and in MySQL it is "tables_in_databasename".

Because GetDBInfo() doesn't get back to FProxy-connection, there is no way for the TSQLConnector to know what that return-field is called. So there is still a need to either override GetTableNames or include return-field in the meta-data-information somehow.

Oh, AND ADDITIONAL:
Same as above also goes for TSQLConnector.GetFieldNames(TableName, TStrings)
 : Field not found : "column_name".

LacaK

2016-03-14 14:35

developer   ~0091019

Fixed for MySQL 5+. I have used standard INFORMATION_SCHEMA queries so there is no more need override GetDBInfo()

Issue History

Date Modified Username Field Change
2016-03-12 14:20 Rik van Kekem New Issue
2016-03-12 15:01 LacaK Assigned To => LacaK
2016-03-12 15:01 LacaK Status new => assigned
2016-03-12 16:26 Rik van Kekem Note Added: 0090937
2016-03-14 14:35 LacaK Fixed in Revision => 33254
2016-03-14 14:35 LacaK Note Added: 0091019
2016-03-14 14:35 LacaK Status assigned => resolved
2016-03-14 14:35 LacaK Fixed in Version => 3.1.1
2016-03-14 14:35 LacaK Resolution open => fixed