sql: create common SQL parsing library to be used by mysql and postgres#11368
Conversation
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Fixed a bug in mysql testing routines which masked wrong results returned by SQL parser. Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
|
|
||
| class SQLutils { | ||
| public: | ||
| static bool setMetadata(const std::string& query, ProtobufWkt::Struct& metadata); |
There was a problem hiding this comment.
It seems like we need to add docs on this.
There was a problem hiding this comment.
I see what you mean. Actually at this moment nothing changed from metadata point of view. Documentation for mysql is still valid:https://www.envoyproxy.io/docs/envoy/v1.14.1/configuration/listeners/network_filters/mysql_proxy_filter.html?highlight=metadata#dynamic-metadata.
When I link this setMetadata to Postgres filter I will create similar docs describing what metadata is created by Postgres filter, but this will happen once this PR is merged.
There was a problem hiding this comment.
I think @dio meant doxygen style doc for this method.
| ::testing::Values( | ||
| TEST_VALUE("blahblah;", false, {}), | ||
|
|
||
| TEST_VALUE("CREATE TABLE IF NOT EXISTS table1(Usr VARCHAR(40),Count INT);", true, |
There was a problem hiding this comment.
Can we check for all lowercased queries?
create tabel if not exists table1(usr varchar(40),count int);
There was a problem hiding this comment.
Changed testing routine to convert queries to lowercase and uppercase, so all different variants are tested.
test queries. Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
|
/azp run |
|
Commenter does not have sufficient privileges for PR 11368 in repo envoyproxy/envoy |
|
|
||
| class SQLutils { | ||
| public: | ||
| static bool setMetadata(const std::string& query, ProtobufWkt::Struct& metadata); |
There was a problem hiding this comment.
I think @dio meant doxygen style doc for this method.
|
|
||
| /* | ||
| * Test query: "DROP DATABASE <DB>" | ||
| * Test is disabled because of a bug in SQL parsing library. |
There was a problem hiding this comment.
The bug was always there and this PR does not change anything. The old behaviour is preserved. The SQL parser has a bug and produces wrong output for DROP DATABASE. The old unit tests in mysql had another bug which masked SQL parser's bug. In https://github.com/envoyproxy/envoy/blob/release/v1.14/test/extensions/filters/network/mysql_proxy/mysql_command_test.cc#L205-L209 if expected_table_access_map is empty, the routine does NOT check what was parser's result, which is stored in table_access_map. In case of DROP DATABASE the table_access_map is not empty, but old unit test never checked that.
I changed how parsing results are accessed and this uncovered the bug.
There was a problem hiding this comment.
then can we either delete these tests or fix them? I don't think we want permanently disabled test live in the code base.
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
|
|
||
| /* | ||
| * Test query: "DROP DATABASE <DB>" | ||
| * Test is disabled because of a bug in SQL parsing library. |
There was a problem hiding this comment.
then can we either delete these tests or fix them? I don't think we want permanently disabled test live in the code base.
Enabled unit tests for DROP DATABASE after fix in sql-parser library. Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
|
Fixed issue with DROP DATABASE: envoyproxy/sql-parser#3. Now all tests are enabled and they pass. |
|
/retest |
|
🤷♀️ nothing to rebuild. |
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
…es (envoyproxy#11368) Description: Created _sqlutils_ library to be shared for common functionality between SQL filters. mysql and postgres filters will use that library to create filter metadata based on SQL query. mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065. Risk Level: Low: No new functionality has been added and only mysql_proxy filter is affected Testing: Added unit tests. Docs Changes: No. Release Notes: No. Fixes: envoyproxy#11320 Signed-off-by: Christoph Pakulski <christoph@tetrate.io> Signed-off-by: Arthur Yan <arthuryan@google.com>
…es (envoyproxy#11368) Description: Created _sqlutils_ library to be shared for common functionality between SQL filters. mysql and postgres filters will use that library to create filter metadata based on SQL query. mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065. Risk Level: Low: No new functionality has been added and only mysql_proxy filter is affected Testing: Added unit tests. Docs Changes: No. Release Notes: No. Fixes: envoyproxy#11320 Signed-off-by: Christoph Pakulski <christoph@tetrate.io> Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
…es (envoyproxy#11368) Description: Created _sqlutils_ library to be shared for common functionality between SQL filters. mysql and postgres filters will use that library to create filter metadata based on SQL query. mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065. Risk Level: Low: No new functionality has been added and only mysql_proxy filter is affected Testing: Added unit tests. Docs Changes: No. Release Notes: No. Fixes: envoyproxy#11320 Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
…es (envoyproxy#11368) Description: Created _sqlutils_ library to be shared for common functionality between SQL filters. mysql and postgres filters will use that library to create filter metadata based on SQL query. mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065. Risk Level: Low: No new functionality has been added and only mysql_proxy filter is affected Testing: Added unit tests. Docs Changes: No. Release Notes: No. Fixes: envoyproxy#11320 Signed-off-by: Christoph Pakulski <christoph@tetrate.io> Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
Description:
Created sqlutils library to be shared for common functionality between SQL filters.
mysql and postgres filters will use that library to create filter metadata based on SQL query.
mysql filter was already producing metadata but postges will use the new library as described in #11065.
Risk Level:
Low: No new functionality has been added and only mysql_proxy filter is affected
Testing:
Added unit tests.
Docs Changes:
No.
Release Notes:
No.
Fixes: #11320