SQLConnection.GetColumnNames doesn't consider selected schema

Forum related to Oracle Server

Moderators: gto, EgonHugeist, mdaems

Post Reply
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 796
Joined: 18.11.2018, 17:37
Location: Hungary

SQLConnection.GetColumnNames doesn't consider selected schema

Post by aehimself »

Hello,

I realized that by simply calling SQLConnection.GetColumnNames('MYTABLE', 'MYCOLUMN', sl) returns multiple results from different schemas. If I use the other overload and specify SQLConnection.Catalog as the first parameter (schema pattern) only one row is returned as expected, as I have a schema set on the connection.

The reason is, the first variant simply calls the other overload without a schema name. Therefore, ZDbcOracleMetadata : 1916 (TZOracleDatabaseMetadata.UncachedGetColumns) returns an empty string for OwnerCondition and therefore no filtering will be done.

There was a similar fix of mine a while ago (Merged revision(s) 7301 from trunk: By AEHimself: ZStoredProc "Cannot retrieve resultset" with multiple schemas / catalogs fix), so my question is, is this intentional, or metadata should consider the schema set on it's connection?
If it should, should I correct it on the level of TZAbstractConnection, or in TZOracleDatabaseMetadata (as there is a huge chaos in usage of terms "catalog" and "schema" across different RDBMS systems).
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: SQLConnection.GetColumnNames doesn't consider selected schema

Post by marsupilami »

*Sigh* - I dislike the way, Zeos mixes the usage of Catalog, Schema and Database. Zeos doesn't use these terms consistently.

From my POV the DBC layer does it more or less right. An Example from PostgreSQL:
* Catalog = Database
* Schema = Schema in the database - public for example, or dbo on Microsoft SQL Server

In TZConnection we do it wrong There we do:
* Database = Catalog on the DBC layer
* Catalog = Schema on the DBC layer.

I think we should change that in an upcoming version of Zeos...

Anyway - TZAbstractConnection.GetColumnNames(const TablePattern, ColumnPattern: string; List: TStrings) should use the Catalog setting from the TZConnection object. I don't know why it was introduced with spaces at all.

Opinions?
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 796
Joined: 18.11.2018, 17:37
Location: Hungary

Re: SQLConnection.GetColumnNames doesn't consider selected schema

Post by aehimself »

As for the terminology and it's modification in an upcoming release - no idea.

As for the fixing, I support it. Just say the magic word and a pull request will be on it's way.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: SQLConnection.GetColumnNames doesn't consider selected schema

Post by marsupilami »

Any pull request will be greatly apreciated :)
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 796
Joined: 18.11.2018, 17:37
Location: Hungary

Re: SQLConnection.GetColumnNames doesn't consider selected schema

Post by aehimself »

#75 fresh and ripe, ready for merging :)
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: SQLConnection.GetColumnNames doesn't consider selected schema

Post by marsupilami »

I applied the patch and synced it to Github. Thank you :)
Post Reply