Add compatibility with misbehaving client applications#7438
Add compatibility with misbehaving client applications#7438findepi merged 4 commits intotrinodb:masterfrom
Conversation
There was a problem hiding this comment.
given fact we have no test for new functionality we will only notice this verify fails on deployed Trino, if constant value changes. A simple unit test for this method would help.
kokosing
left a comment
There was a problem hiding this comment.
Please add some tests when this property is set it is expected that table_name won't match tableXname.
It is dangerous flag and it has to be well documented that it is due buggy BI tools, and it may cause incorrect results. I think that property name has to be more scary: workaroudNonEscapedLiteralsInMetadataCalls?
i agree we need a good name for this property. @losipiuk @electrum @martint @alexjo2144 thoughts? |
|
Buggy -> NonConforming |
|
Let's have an agreement for the general approach, and the name (in comments) and will update the code for merge separately. |
|
Thanks for the work @findepi ! We've encountered a significant amount of pain due to improper escaping over the years. Its unfortunate that Trino has to compensate for improper behavior by clients, but the current situation has not been particularly effective at incentivizing Tableau, et al., to change their behavior. |
There was a problem hiding this comment.
Probably deserves a comment describing what the intent is.
There was a problem hiding this comment.
The regex replace needs some unit testing too, be wary of this from the docs:
"Note that backslashes () and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences as described above, and backslashes are used to escape literal characters in the replacement string"
|
Maybe something like |
|
@losipiuk @kokosing @electrum what do you think about the approach in general? for the name, i see these proposals
the |
losipiuk
left a comment
There was a problem hiding this comment.
LGMT % naming decision and test nice to have
|
As for the naming from options above I think |
|
|
|
Seems like we have agreement. I am changing to |
Before the change, each invocation of `assertMetadataCalls` opened a new connection, even though the test setup provides one.
e9578a2 to
7bdb0b2
Compare
|
Renamed the flag, added tests, both unit for escaping and end-to-end, fixing the bug spotted by @alexjo2144 . |
There was a problem hiding this comment.
// no matches in getTables call as table name pattern treated as literal
There was a problem hiding this comment.
would this return something else if assumeLiteralNamesInMetadataCallsForNonConformingClients was not passed?
Or in other words. Is there some other schema which matches test_schema1 (e.g testXschema1)
There was a problem hiding this comment.
no, but it would result in a different number of metadata calls.
note however the test_schema_ test case which seems what you're looking for.
Number of `DatabaseMetaData` methods accept name patterns (e.g. `schemaPattern`, `tableNamePattern`, `columnNamePattern`, etc.). Values provided, if ought to be treated as literals, should have underscores `_` and percent signs `%` escaped with `DatabaseMetaData.getSearchStringEscape()`. Sadly, many client applications do not do that, which results in metadata queries which cannot be answered efficiently by the server. This commit adds `assumeLiteralNamesInMetadataCallsForNonConformingClients`, a compatibility flag as a workaround for such misbehaving client applications.
7bdb0b2 to
69778e1
Compare
Number of
DatabaseMetaDatamethods accept name patterns (e.g.schemaPattern,tableNamePattern,columnNamePattern, etc.). Valuesprovided, if ought to be treated as literals, should have underscores
_and percent signs%escaped withDatabaseMetaData.getSearchStringEscape(). Sadly, many clientapplications do not do that, which results in metadata queries which
cannot be answered efficiently by the server.
This commit adds a compatibility flag as a workaround for such
misbehaving client applications.
Closes #7424