629 Commits

Author SHA1 Message Date
Johan Wikman
b98ff222f0 Merge branch '2.3.8' into 2.3 2019-06-12 11:26:33 +03:00
Johan Wikman
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
Johan Wikman
acc5863fe2 MXS-2442 ':N' accepted as pos. parameter in Oracle mode 2019-06-11 13:53:09 +03:00
Johan Wikman
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
Johan Wikman
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
Johan Wikman
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
Johan Wikman
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
Johan Wikman
62f2a86a5f MXS-2431 Add test that reveals the problem 2019-04-12 10:30:36 +03:00
Johan Wikman
514dd96301 MXS-2413 Parse 'DROP DATABASE [IF EXISTS] db' completely 2019-03-29 10:09:38 +02:00
Johan Wikman
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
Johan Wikman
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
Johan Wikman
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
Johan Wikman
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
Johan Wikman
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
Markus Mäkelä
b560a67e54
Merge branch '2.2' into 2.3 2019-02-07 10:45:57 +02:00
Markus Mäkelä
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
Markus Mäkelä
cc6665c732
Add solo mode to compare
In this mode the compare program does a sanity check where it compares the
output of a classifier when a statement is classified multiple times. The
main use-case for this is to get the verbose output generated when the -v3
option is added, not the sanity check itself.
2019-02-06 13:55:41 +02:00
Markus Mäkelä
f335dba2c0
Fix stack buffer overflow in compare
The buffer was three characters short.
2019-01-28 17:35:27 +02:00
Johan Wikman
78ea12b4c1 Merge branch '2.2' into 2.3 2019-01-09 09:13:59 +02:00
Johan Wikman
e64b034334 MXS-2248 Add change that fixes the problem
Any kind of expression is legal after INTERVAL.
2019-01-09 09:11:49 +02:00
Johan Wikman
a456168fd0 MXS-2248 Add test that reveals problem 2019-01-09 09:11:49 +02:00
Johan Wikman
7a7545f8f7 Merge branch '2.2' into 2.3 2019-01-08 15:59:03 +02:00
Johan Wikman
2895f361d9 MXS-2242 Add change that fixes the problem
A whole slew of missing builtin functions were added, not just the
ones directly relevant for MXS-2242.
2019-01-08 15:55:41 +02:00
Johan Wikman
f94ddadc18 MXS-2242 Add test that reveals problem 2019-01-08 15:55:41 +02:00
Johan Wikman
1a78f2ffbb Merge branch '2.2' into 2.3 2018-12-04 11:23:31 +02:00
Johan Wikman
87d2a45b20 MXS-2207 Fix the problem in qc_mysqlembedded 2018-12-03 16:03:51 +02:00
Johan Wikman
964180804c MXS-2207 Add test that reveals problem
With qc_mysqlembedded statements like

    SET STATEMENT ... FOR stmt;

are always classified as READ, although their type should be
that of stmt.
2018-12-03 15:59:43 +02:00
Johan Wikman
470e4d440e MXS-1978 Fix qc_mysqlembedded behaviour
Now qc_mysqlembedded also treats SELECT ... INTO DUMPFILE|OUTFILE
as a write.
2018-11-01 11:24:44 +02:00
Johan Wikman
7b001994b4 MXS-1978 Change qc_sqlite behaviour and update test
A statement like

  SELECT ... INTO OUTFILE|DUMPFILE ...

is now classified as a QUERY_TYPE_WRITE, instead of as
QUERY_TYPE_GSYSVAR_WRITE so that it will be sent only to the
master.
2018-11-01 11:24:44 +02:00
Johan Wikman
9d8a49af5d MXS-1978 Add test that tests current behaviour 2018-11-01 11:24:44 +02:00
Markus Mäkelä
75ea1b6ea1
Fix formatting of new(std::nothrow)
The code previously formatted everything as `new( std::nothrow)`.
2018-10-04 21:50:44 +03:00
Johan Wikman
07e407945b Change ss_dassert -> mxb_assert
Caused by merge from 2.2.
2018-09-27 12:56:36 +03:00
Markus Mäkelä
66227301aa Merge branch '2.2' into develop 2018-09-27 11:47:32 +03:00
Johan Wikman
2aca6226d9 MXS-2043 Classify SELECT ... FOR UPDATE as QUERY_TYPE_WRITE
SELECT...FOR UPDATE locks the rows for update, but only if
autocommit==0 or a transaction is active, so in principle even if
it were classified as READ it'd still be sent to master when it
actually matters.

However, even if autocommit==1 and/or no transaction is active, a
slave in read only mode will reject the statement if the user is
subject to the read only restriction (a user with super privileges
is not), which might be considered a server bug. By classifying the
statement as a write, it'll be sent to master and always succeed.
2018-09-27 10:17:47 +03:00
Johan Wikman
743daa5755 MXS-2043 Create test that exposes problem
A statement like

    SELECT a FROM tbl FOR UPDATE;

should be classified like QUERY_TYPE_WRITE so as to be sent
to master.
2018-09-27 10:17:47 +03:00
Markus Mäkelä
71ffef5708
Partially revert 4ba011266843857bbd3201e5b925a47e88e1808f
Add back leading operator enforcement.
2018-09-20 15:57:30 +03:00
Markus Mäkelä
d11c78ad80
Format all sources with Uncrustify
Formatted all sources and manually tuned some files to make the code look
neater.
2018-09-10 13:22:49 +03:00
Niclas Antti
c447e5cf15 Uncrustify maxscale
See script directory for method. The script to run in the top level
MaxScale directory is called maxscale-uncrustify.sh, which uses
another script, list-src, from the same directory (so you need to set
your PATH). The uncrustify version was 0.66.
2018-09-09 22:26:19 +03:00
Johan Wikman
a29851a42c MXS-2026 Use qc_init(...)/qc_end()
Use qc_init(...)/qc_end() for initializing QC in test-programs.
2018-08-29 09:47:13 +03:00
Johan Wikman
5c1a1c2700 MXS-2026 Separate QC process and thread initialization
qc_thread_init() must now explicitly be called in every thread
and not just in other threads but the one where qc_process_init()
is called.

This change was caused by QC_INIT_SELF initialization actually
being performed in query_classifier.cc. Before this change, there
actually was a leak in the routing worker running in the main
thread, the query classification cache was created twice.
2018-08-29 09:47:13 +03:00
Johan Wikman
ab9a9f92cb MXS-2020 Remove maxscale/debug.h
- Removed from all files.
- maxbase/assert.h included where necessary.
2018-08-22 11:35:35 +03:00
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +03:00
Johan Wikman
b1e405442f MXS-2020 Replace ss_debug with MXB_AT_DEBUG 2018-08-22 11:34:06 +03:00
Niclas Antti
24ab3c099c Move top of the file "#pragma once" to after the following comment (swap them). If the comment is a BPL update it to the latest one 2018-08-21 13:13:15 +03:00
Johan Wikman
3576780f78 MXS-2008 Update gateway and tests to initialize maxbase
Update gateway and tests to initialize maxbase using

  maxbase::init();

instead of initializing individual components.
2018-08-21 10:02:39 +03:00
Johan Wikman
aaad63ee5e MXS-2008 Move content of maxscale/platform.h to maxbase/cdefs.h
No good reason for keeping that platform adjustments anywhere
else but in cdefs.h.
2018-08-20 11:15:14 +03:00
Johan Wikman
cf0aeed516 MXS-2014 Rename log_manager.h to log.h
There's nothing resembling a manager anymore.
2018-08-17 10:59:37 +03:00
Johan Wikman
9a8bb95be6 MXS-2014 Rename mxs_log_priority_is_enabled
- Renamed to mxs_log_is_priority_enabled
- That function instead of the macro is now consistently used
2018-08-16 09:59:43 +03:00
Johan Wikman
ae43e4f0f2 MXS-2013 Remove all CHK_-macros 2018-08-15 09:28:04 +03:00
Johan Wikman
8fd1648217 MXS-2013 Remove skygw_chk_t 2018-08-15 09:28:04 +03:00