diff --git a/maxscale-system-test/masking_auto_firewall.cpp b/maxscale-system-test/masking_auto_firewall.cpp index fcbb50bfa..f8672211d 100644 --- a/maxscale-system-test/masking_auto_firewall.cpp +++ b/maxscale-system-test/masking_auto_firewall.cpp @@ -87,6 +87,9 @@ void run(TestConnections& test) // This should NOT go through as a function is used with a masked column (that happens to be uppercase). test_one(test, "SELECT LENGTH(A), b FROM masking_auto_firewall", Expect::FAILURE); + // This should NOT go through as a function is used with a masked column. + test_one(test, "SELECT CAST(A as CHAR), b FROM masking_auto_firewall", Expect::FAILURE); + // This SHOULD go through as a function is NOT used with a masked column // in a prepared statement. test_one(test, "PREPARE ps1 FROM 'SELECT a, LENGTH(b) FROM masking_auto_firewall'", Expect::SUCCESS); @@ -118,6 +121,9 @@ void run(TestConnections& test) // This should NOT succeed as a masked column is used in the statment. test_one(test, "select 1 UNION select a FROM masking_auto_firewall", Expect::FAILURE); + // This should NOT succeed as a masked column is used in the statment. + test_one(test, "select 1 UNION ALL select a FROM masking_auto_firewall", Expect::FAILURE); + // This should NOT succeed as '*' is used in the statment. test_one(test, "select 1 UNION select * FROM masking_auto_firewall", Expect::FAILURE); diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index b5364732c..a1f256694 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -928,6 +928,7 @@ public: case TK_BITAND: case TK_BITOR: case TK_CASE: + case TK_CAST: case TK_IN: case TK_ISNULL: case TK_MINUS: @@ -1258,6 +1259,11 @@ public: IGNORE_COMPOUND_SELECTS }; + bool is_significant_union(const Select* pSelect) + { + return ((pSelect->op == TK_UNION) || (pSelect->op == TK_ALL)) && pSelect->pPrior; + } + void update_field_infos_from_select(QcAliases& aliases, uint32_t context, const Select* pSelect, @@ -1357,7 +1363,7 @@ public: if (compound_approach == ANALYZE_COMPOUND_SELECTS) { - if (((pSelect->op == TK_UNION) || (pSelect->op == TK_ALL)) && pSelect->pPrior) + if (is_significant_union(pSelect)) { const Select* pPrior = pSelect->pPrior; @@ -2139,7 +2145,7 @@ public: } QcAliases aliases; - uint32_t context = (pSelect->op == TK_UNION && pSelect->pPrior) ? QC_FIELD_UNION : 0; + uint32_t context = is_significant_union(pSelect) ? QC_FIELD_UNION : 0; update_field_infos_from_select(aliases, context, pSelect, NULL); } @@ -4002,6 +4008,9 @@ static const char* get_token_symbol(int token) case TK_CASE: return "case"; + case TK_CAST: + return "cast"; + case TK_IN: return "in";