problem in query result # table_name header string when schema name contains a dot character #7493
Labels
Client interfaces
Design
The issue involves a design choice
enhancement
New feature or request
JDBC
The issue is in the JDBC driver
ODBC
The issue is in the ODBC driver
Describe the bug
the query result
# table_name
header string contains both the schema name and table name of each result column.The names are separated by the dot character, so '.'.
However when the schema name contains a dot character, the
# table_name
header string will contain multiple dot characters.This makes it impossible to extract the correct schema and table names metadata information.
This is a problem for the ODBC and JDBC drivers which need to return separate schema and table name metadata information.
To Reproduce
This last query returns incorrect resultset schema and table name metadata in ODBC and JDBC.
They return 'sch' as the schema name and '..tabl' as the table name which is incorrect.
In mclient you can inspect this
# table_name
header information by using the\X
mode before sending the last query:You can see line:
% sch...tabl # table_name
contains the fully qualified table_name. It is a concatenation of
sch.
, a dot character and.tabl
, all without the double quotes.This header line is what is send by the server to the client.
The client libraries have to figure out from the received header line, what the schema name part is and what the table name part is.
In ODBC and JDBC driver this is done by searching for the first dot character. If it is found it splits the string into two substrings, the first is the schema name, the second the table name.
This goes wrong in the case the schema name contains a dot character.
In ODBC and JDBC it will return 'sch' as the schema name and '..tabl' as the table name which is incorrect.
Expected behavior
This problem cannot be fixed in the ODBC or JDBC driver code, as it is not possible to correctly decide which of the dot characters in
'sch...tabl'
is the real separator. Is it the first, second or third dot character?This problem should be fixed in the mapi protocol.
Suggestion: extend the header information with an additional # schema_name line, so:
This makes parsing the header lines for schema and table name possible without problems.
Also it is adaptive for new ODBC and JDBC driver as the client can inform the server to enable sending the
# schema_name
header line dynamically (like is done for the# typesizes
header info) when the server and mapi supports it.I also considered to add double quotes to the schema and table name parts when it contains a dot character.
So the
# table_name
header would become:`% "sch.".".tabl" # table_name
Technically this would allow new versions of the ODBC and JDBC drivers to detect that the string between the double quotes need to be treated specially.
However old ODBC and JDBC drivers would then return wrong information: '"sch' as the schema name and '".".tabl"' as the table name. So I do not recommend this option.
When the mapi header changes also the client libraries (ODBC and JDBC) need to be adapted for this new behavior. Note that the ODBC and JDBC drivers also need to keep supporting older server versions, so be dynamic.
Software versions
The text was updated successfully, but these errors were encountered: