Commit Graph

321 Commits

Author SHA1 Message Date
82826f2de5 MXS-2733 Add fix that fixes the problem
UTC_TIMESTAMP() was missing from the list of builtin functions.
2019-10-29 09:26:41 +02:00
840b771283 Merge branch '2.3' into 2.4 2019-10-28 09:16:53 +02:00
d2996e1ba6 MXS-2733 Add fix that fixes the problem
UTC_TIMESTAMP() was missing from the list of builtin functions.
2019-10-28 08:34:39 +02:00
312469dca2 Merge branch '2.3' into 2.4 2019-10-07 16:17:53 +03:00
e7e40b0179 MXS-2713 Classify SET PASSWORD as QUERY_TYPE_WRITE
A change of the password is replicated to the slaves, so it
must only be sent to the master.
2019-10-07 14:33:53 +03:00
0dce20e5e7 Merge branch '2.3' into 2.4 2019-09-27 12:30:58 +03:00
a9f07844b3 MXS-2699 Accept '_[character_set] hex' as string
The purpose is to recognize e.g. /_utf8mb4 0xD091D092D093/ as
a valid string. The rule actually accepts /id integer/, but in
case the statement is something else but an '_' immediately
followed by a character set, followed by a hex number, it will
be rejected by the server so no harm done.
2019-09-27 12:23:04 +03:00
5bbb2e239d MXS-2699 Add rule for (expr [, expr]*)
Sofar at most (expr, expr) was accepted.
2019-09-27 12:23:04 +03:00
19487d2bfb Merge branch '2.3' into 2.4 2019-09-20 09:36:23 +03:00
aa7be1447d MXS-2688 Handle SET [ROLE|NAMES|PASSWORD|CHARACTER] explicitly
It's not correct to claim that they would modify a system variable,
so they are purely classified as QUERY_TYPE_SESSION_WRITE.
2019-09-20 09:27:38 +03:00
f587ec191d MXS-2688 Add QC operator QUERY_OP_SET
Allows RWS to unconditionally send all SET-statements to
all servers.
2019-09-20 09:27:38 +03:00
5e2d9f599b Merge branch '2.3' into 2.4 2019-09-16 09:50:05 +03:00
01ab0c8736 MXS-2553 Allow parenthesis around SELECT
With this change, a parenthesized top-level SELECT, such as
"(SELECT f FROM t)" will be fully parsed. Before this change,
the statement was classified as invalid and would thus have
been sent to the master.

With this change also statements like

    (SELECT f FROM t1) UNION (SELECT f FROM t2)

will be correctly classified, although only partially parsed.
2019-09-13 15:45:16 +03:00
7531515259 MXS-2674 Fix query classification
With these changes

  SET @saved_cs_client= @@character_set_client;

will be classified as QUERY_TYPE_USERVAR_WRITE and

  SELECT 1 AS c1 FROM t1 ORDER BY ( SELECT 1 AS c2 FROM
    t1 GROUP BY GREATEST(LAST_INSERT_ID(), t1.a) ORDER BY
      GREATEST(LAST_INSERT_ID(), t1.a) LIMIT 1);

will be classified as QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ
2019-09-13 15:43:57 +03:00
c079d1312e MXS-2674 Recognize timediff as builtin function 2019-09-12 12:38:57 +03:00
0ba779d5a2 Update 2.4.0 Change Date 2019-06-25 10:11:55 +03:00
d03e025046 MXS-2553 Allow parenthesis around SELECT
With this change, a parenthesized top-level SELECT, such as
"(SELECT f FROM t)" will be fully parsed. Before this change,
the statement was classified as invalid and would thus have
been sent to the master.

With this change also statements like

    (SELECT f FROM t1) UNION (SELECT f FROM t2)

will be correctly classified, although only partially parsed.
2019-06-13 10:42:46 +03:00
a0fcf67993 Merge branch '2.3' into develop 2019-06-12 11:29:03 +03:00
b98ff222f0 Merge branch '2.3.8' into 2.3 2019-06-12 11:26:33 +03:00
814ae196e9 qc_sqlite: Replace strncpy with memcpy
On RHEL8 the former may give rise to incorrect

    error: 'char* strncpy(char*, const char*, size_t)' destination
    unchanged after copying no bytes [-Werror=stringop-truncation]
2019-06-11 20:14:58 +03:00
1e3da20409 Merge branch '2.3' into develop 2019-06-11 13:54:51 +03:00
acc5863fe2 MXS-2442 ':N' accepted as pos. parameter in Oracle mode 2019-06-11 13:53:09 +03:00
4efa9dbeea Remove maxscale/alloc.h
The remaining contents were moved to maxbase/alloc.h.
2019-06-10 14:11:25 +03:00
ba60b92612 Merge branch '2.3' into develop 2019-06-05 14:48:43 +03:00
b8d601aab2 MXS-2250 Reveal table information for 'DESCRIBE tbl'
When a statement like 'DESCRIBE tbl' is classified, the table
name will now be available so that a router can check whether the
table is a temporary one. In that case, the statement must be sent
to the master.
2019-06-05 14:28:45 +03:00
b635cc92ab MXS-1783 Add 10.4 support
qc_mysqlembedded can now be built using the embedded library from
MariaDB 10.4.
2019-05-31 15:12:57 +03:00
de95fcc9d6 Format rest of the sources 2019-05-10 10:31:12 +03:00
fb0745e3de Merge branch '2.3' into develop 2019-05-03 13:48:57 +03:00
4aa8eac799 MXS-2457 Allow strings to be treated as fields
Before this change, if the firewall was configured to block the use
of certain columns, it could be be bypassed simply by

        > set @@sql_mode='ANSI_QUOTES';
        > select "ssn" from person;

The reason is that as the query classifier is not aware of whether
'ANSI_QUOTES' is on or not, it will not know that what above appears
to be the string "ssn", actually is the field name `ssn`. Consequently,
the select will not be blocked and the result returned in cleartext.

It's now possible to instruct the query classifier to report all strings
as fields, which will prevent the above. However, it will also mean that
there may be false positives.
2019-05-03 13:38:12 +03:00
f09d46c8e6 MXS-2457 Allow string arguments to be treated as fields
Before this change, the masking could be bypassed simply by

    > set @@sql_mode='ANSI_QUOTES';
    > select concat("ssn") from person;

The reason is that as the query classifier is not aware of whether
'ANSI_QUOTES' is on or not, it will not know that what above appears
to be the string "ssn", actually is the field name `ssn`. Consequently,
the select will not be blocked and the result returned in cleartext.

It's now possible to instruct the query classifier to report all string
arguments of functions as fields, which will prevent the above. However,
it will also mean that there may be false positives.
2019-05-03 13:38:12 +03:00
524a083203 MXS-2439 Do not classify implicit commits as commits
The type mask of CREATE, ALTER, etc. that cause an implicit commit
will no longer contain the bit QUERY_TYPE_COMMIT.

As an implicit commit does not change the transaction state as seen
by MaxScale, it does not make sense to claim that the statement is
a commit.
2019-04-18 11:19:23 +03:00
d2c71472b0 MXS-2432 Recognize RESET
RESET QUERY CACHE is reported to be a session command, which will
cause it to be sent to all servers. RESET [MASTER|SLAVE] are
classified as write, which will cause them to be sent to the master.

It could be argued that RESET [MASTER|SLAVE] should cause an error
to be sent to the client.
2019-04-12 14:51:01 +03:00
c643f9bc8d Merge branch '2.3' into develop 2019-04-12 13:23:49 +03:00
4131f09c16 MXS-2431 Recognize the XA keyword
Recognize the XA keyword and classify the statement as write.
Needs to be dealt with explicitly as sqlite3 assumes there are
no keywords starting with the letter X.
2019-04-12 11:05:15 +03:00
e659c6cc73 Merge branch '2.3' into develop 2019-04-01 13:24:30 +03:00
5f5d2ef183 MXS-2363 Implement /v1/maxscale/query_classifier/cache
That URL will now return information about the statements in
the query classifier cache. The information is collected using
the same map in a serial manner from all routing workers (that
each have their own cache). Since all caches will contains the
same statements, collecting the information in a serial manner
means that the overall memory consumption will be lower than
what it would be if the information was collected in parallel.
2019-03-29 11:31:35 +02:00
514dd96301 MXS-2413 Parse 'DROP DATABASE [IF EXISTS] db' completely 2019-03-29 10:09:38 +02:00
6bc2c54081 Merge commit 'a78f0fbe2537542dc7f3f0dd8b19b93ac8d9d7f8' into develop 2019-03-28 13:53:40 +02:00
fe359593ba MXS-2407 Report database for SHOW TABLES FROM db
The database used in 'SHOW TABLES FROM db' is now available via
qc_get_database_names().
2019-03-25 17:02:36 +02:00
f37340e9fd MXS-2397 Provide context information for fields
The query classifier now returns contextual information for a fields;
does it appear in the (right hand side) of a UNION or in a SUBQUERY.
2019-03-25 15:24:35 +02:00
bf2d6673bc Merge branch '2.3' into develop 2019-03-21 18:23:27 +02:00
559b786533 MXS-2398 Handle MariaDB specific comments
Same approach as with regular comments:
- /*M! STMT */ are always parsed.
- /*M!###### STMT */ are never parsed.
2019-03-21 14:57:24 +02:00
2ba7e63e7e Merge branch '2.3' into develop 2019-03-21 09:26:06 +02:00
65b4ac7c1b MXS-2389 Handle MariaDB comment correctly
A non version specific executable comment, such as "/*! SELECT 1; */"
is during classification handled as if it would not be a comment. That
is, the contained statement will *always* be parsed.

A version specific executable comment, such as "/*!99999 CREATE PROCEDURE
 bypass BEGIN */ SELECT ... " is during classification handled as it would
be a general comment. That is, the contained statement will *never* be
parsed.

In addition, in the latter case the parse result will never be better than
QC_QUERY_PARTIALLY_PARSED. The rationale is that since the comment is version
specific, we cannot know how the server will actually interpret the statement.

This will have an impact on the masking filter and the database firewall that
now will reject statements containing _version specific_ executable comments.
2019-03-20 16:17:50 +02:00
a51f156372 Merge branch '2.3' into develop 2019-02-22 12:22:11 +02:00
675971bd3c MXS-2345 Query classifier collects db of USE stmt
qc_get_database_names() will now return the database used
in a USE statement.
2019-02-22 11:22:32 +02:00
42b5c39f43 Merge branch '2.3' into develop 2019-02-07 10:50:27 +02:00
b560a67e54 Merge branch '2.2' into 2.3 2019-02-07 10:45:57 +02:00
994bfcd285 MXS-2268: Fix undefined behavior
Using a void return value as an integer results in undefined behavior.
apparently in this case it doesn't translate into a crash and instead only
manifests itself when all the planets align.
2019-02-07 10:38:38 +02:00
d4674faa7d Convert maxscale/query_classifier.h to .hh
The header was not merged with queryclassifier.hh since the latter
does not include the former.
2019-01-15 18:18:39 +02:00