Commit Graph

5064 Commits

Author SHA1 Message Date
6cd6ded3d8 Merge branch '2.1-oracle-compat' into develop-new-merge-oracle 2017-06-29 09:39:55 +02:00
7f1a949198 Firewall must use its own operator codes
The firewall uses a bitmask for representing what operations a
particular rule should be applied to. Consquently it cannot use
the query classifier qc_query_op_t enumerator values as such,
as they are consecutive numbers.
2017-06-28 21:36:08 +02:00
bea551092d MXS-1278: Change modes when 'set sql_mode=' is encountered.
The initial setting of sql_mode affects how MaxScale initially
behaves with respect to autocommit.

When 'set sql_mode=[default|oracle];" is encountered, the query
classifier and autocommit modes are adjusted accordingly.
2017-06-28 21:36:08 +02:00
a14755a403 MXS-1278: Add 'sql_mode' configuration parameter
Using the 'sql_mode' configuration parameter, the initial sql mode
can be specified.
2017-06-28 21:36:08 +02:00
83f8010c4b MXS-1278: Add 'sql_mode' configuration parameter
Using the 'sql_mode' configuration parameter, the initial sql mode
can be specified.
2017-06-28 21:36:08 +02:00
a690b44919 MXS-1278: Sql mode must be specified explicitly
The default sql mode must now be provided explicitly when the query
classifier is setup. This is in preparation for "sql_mode" becoming
a global configuration parameter of MaxScale.
2017-06-28 21:36:08 +02:00
057ba4156d MXS-1278: Turn on ORCALE mode dynamically
If statement input is required for a session, we check the input
for "SET SQL_MODE..." statements and adjust the query classifier
accordingly.
2017-06-28 21:36:08 +02:00
12a291919a MXS-1275: SetSqlModeParser moved under MySQLClient
That's where it belongs as it is only the mysql client protocol that
will use it. It's a bit unfortunate that the qc test program compare
now needs to include a file from a protocol module directory, but
the fact is that the query classifier implementation and the test
programs should actually be *under* the mysql client protocol module.
2017-06-28 21:36:08 +02:00
25314b6662 MXS-1275: Add client protocol data to MXS_SESSION
The current sql mode will be tracked in that variable. Since one
thread will handle multiple sessions, we need to track the sql mode
of a session, so that the sql mode of the query classifier can be
set whenever we handle a request of a particular session.

As the sql-mode will be managed by the client protocol, the data
can be private to it as well.
2017-06-28 21:36:08 +02:00
b385e862b0 MXS-1275: Move SetSqlModeParser to .../server/core/maxscale
The parser is needed not only by mysql_client but also by the test
program of the qc-plugins, so it need to be available someplace
common.

Not that nice that both a qc-component and mysql_client will include
stuff from server/core/maxscale, but at least temporarily ok.
2017-06-28 21:36:08 +02:00
9ae0526efb MXS-1275: Extend QC-API to allow setting of sql mode
Only API changes, implementation will follow.
2017-06-28 21:36:08 +02:00
4bf2b27b3e MXS-1275: Accept @@[SESSION|GLOBAL].sql_mode = ... 2017-06-28 21:36:08 +02:00
21c1845798 MXS-1275: Accept LOCAL as a synonum for SESSION 2017-06-28 21:36:08 +02:00
2483f95be2 MXS-1275: Test comment handling 2017-06-28 21:36:08 +02:00
1c6c19d6ae MXS-1275: Inherit TrxBoundaryParser from CustomParser 2017-06-28 21:36:08 +02:00
9386143437 MXS-1275: Test also using non-contiguous statements 2017-06-28 21:33:04 +02:00
ee27efd62e MXS-1275: Add custom parser for "SET SQL_MODE=..."
SetSqlModeParser is a custom parser for detecting "SET SQL_MODE=..."
statements. It will be used in mysql_client and the result will be
used for updating the sql_mode of a session (that is to be added).

Thereafter, whenever a statement arrives, the value of that sql_mode
will be used for setting the mode of the query_classifier.
2017-06-28 21:33:04 +02:00
cd1e3f26cf MXS-1275: Compile mysql_client as C++
A custom parser for detecting "set sql_mode=ORACLE" is needed
and writing that is C++ is more convenient than writing it in
C. Consequently, so as to be able to use that parser, mysql_client
must be compiled as C++.
2017-06-28 21:33:04 +02:00
43ab0f036e MXS-1196: Do not parse EXPLAIN statements
EXPLAIN statements are no longer parsed completely as doing so makes
it hard to modify the grammar for the needs or Oracle SQL.

Consequently, for an EXPLAIN statement you now bascially only get the
type and the operation (the newly added QUERY_OP_EXPLAIN and QUERY_OP_SHOW).
The other information is not interesting and is related to
information_schema and similar tables.
2017-06-28 21:33:04 +02:00
14bb6cf99b Add convenience functions for common tasks with regular expressions
Several filters use a match-or-ignore logic with two regular
expressions when filtering queries. This commit adds a convenience
function for this task. Also adds a convenience function for reading
several regular expression parameters at once, compiling them and
saving the code while checking for errors.

Also, use the new functions in QLA and CCR filters.
2017-06-28 13:26:52 +03:00
2bc5188dae MXS-1304: Don't null-terminate buffers in gw_str_xor
The gw_str_xor function is used only for doing XOR operations on binary
buffers.
2017-06-28 11:36:17 +03:00
40b1739249 MXS-1299: Fix CREATE TABLE t1 LIKE t2 processing
The creation of tables from other tables was not working even though the
information was available inside the avrorouter.
2017-06-28 11:25:57 +03:00
84925b3f10 Merge branch '2.0' into 2.1 2017-06-28 10:59:06 +03:00
9b0631f30b MXS-1289: Fix crash on TABLE_MAP with ID > 1024
The active table map was acquired with a modulo operation on the size of
the array instead of the number of elements.
2017-06-28 08:49:57 +03:00
5fd690eb1f MXS-1220: Limit /sessions/ to client sessions
The /sessions/ resource should only contain client sessions as the
information is about the sessions, not the connections themselves.
2017-06-27 21:45:00 +03:00
27d8212c51 Fix typo in server resource
The 'statistics' was mistakenly written as 'statictics'.
2017-06-27 21:45:00 +03:00
dc849d1c0f MXS-1291: Attempt to bind on 0.0.0.0 when :: fails
If binding on the IPv6 all interfaces address fails, MaxScale will attempt
to bind on the IPv4 address.
2017-06-27 21:27:20 +03:00
1df8fda93f Merge branch '2.0' into 2.1 2017-06-27 20:52:58 +03:00
be28bf1e23 Fix internal DCB test
The test created a DCB of an unexpected type in an unexpected state with
an invalid file descriptor. This caused the test to fail due to a debug
assertion where the the validity of the file descriptor was asserted in
relation to the internal state of the DCB.
2017-06-26 21:06:05 +03:00
cd09e65714 MXS-1296: Always use a case-insensitive parser
The two cases where the case-sensitive parser functions were used don't
appear to hold any special meaning. The case-insensitive function should
be used as it implements a superset of functionality compared to the
case-sensitive version.
2017-06-26 21:05:42 +03:00
b83538d011 Merge branch '2.1' into develop 2017-06-26 12:29:46 +02:00
500f79a150 MXS-1296: Test that lc statements are parsed correctly
The transaction boundary parser - TrxBoundaryParser - must handle
upper and lowercase statements correctly.
2017-06-26 10:57:27 +03:00
bd1da82c96 Fix cdc_schema.py
There's no need to use Python 3 for the script and using it introduces
problems due to the poor availability of MySQL Connector/Python for
Python3.

ENUM, SET and DECIMAL values should have a length of -1 as the length is
meaningless for these types.
2017-06-23 11:10:41 +03:00
8825f89670 Perform cleanup of rwsplit_route_stmt.cc
Adjusted comments and variable declarations.
2017-06-22 10:40:19 +03:00
705d29ea41 MXS-852: Fix prepared statement collection
If a prepared statement response was collected into one buffer, it doesn't
need to be processed again. By jumping directly to the routing of the
collected result, we prevent the unnecessary splitting of buffers that
appears to happend with continuous preparations of prepared statements.
2017-06-22 10:40:19 +03:00
33a0f8be88 MXS-852: Add support for text protocol prepared statements
When a statement is being prepared, the type and name of the statement is
stored in the router session. If the name of a statement to be executed is
found in the map, the query type that stored in the map is used.
2017-06-22 10:40:18 +03:00
1ac37d6a50 Change rwsplit comparison function types
The comparison functions now take a const reference to a Backend type
class.
2017-06-22 10:40:18 +03:00
c7520a2156 Add name and uri helpers to Backend
Providing helper functions for the commonly used parts of the server makes
code easier to read. It also removes any possibility for formatting
problems by moving the URI and name string handling inside the Backend
class.
2017-06-22 10:40:18 +03:00
d7543988ee Add server state helper functions
Added helper functions that check various server states. This makes the
readwritesplit code easier to read as the function names convey the
intention better than the macro invokations.
2017-06-22 10:40:18 +03:00
37b6cf250d Rename readwritesplit variables
Renamed variables to better represent the types of variables they
represent. Reordered some of the functions so that the functions don't
need to be declared before they are used.
2017-06-22 10:40:18 +03:00
aa61c8a30b Clean up backend comparison function
Renamed and reorganized the function that compares the backend servers.
2017-06-22 10:40:18 +03:00
ae1cdea802 Clean up functions that use SRWBackend
Return values instead of objects. This removes the need to handle cases
where a reference to a "debug value" is returned.

Return SRWBackend values instead of passing output references. This
doubles as a false boolan return value when an empty reference is
returned.
2017-06-22 10:40:18 +03:00
e5f6d00fda Fix debug assertion in backend.cc
The Backend should be closed in the destructor if it was in use but was
not closed.
2017-06-22 10:40:17 +03:00
7a98e6d050 Remove redundant states
The closed state is not required as a separate boolean is used to track
it.
2017-06-22 10:40:17 +03:00
0c8e68fd05 Rename and overload adding of session commands
As the session commands are always appended to the end of the list, the
name should reflect that action. For this reason, the function was renamed
to append_session_command.

Readwritesplit supports replacement of slave servers by storing all
executed session commands in a list. To make the copying of this list a
bit cleaner, an overload for a list of session commands was added. This
will allow relatively smooth addition of server replacement to all router
modules that use the Backend class.
2017-06-22 10:40:17 +03:00
869325e00a Make execute_session_command virtual
Making the function allows higher level checking to be done by the derived
class.

The readwritesplit does some of the reply bookkeeping for session commands
in the function. This makes their execution less prone for errors as the
states are always updated correctly whenever a session command is
executed.
2017-06-22 10:40:17 +03:00
0c45eb5d17 Take SessionCommand into use in readwritesplit
Readwritesplit now uses the SessionCommand class as a "master list" of
executed session commands. This allows the session commands to be easily
copied over to slaves that are taken into use after session commands have
already been executed.

Currently, the code doesn't execute the session command history when a
mid-session reconnection occurs. A method to cleanly copy the session
commands needs to be exposed by the Backend class.
2017-06-22 10:40:17 +03:00
b48bb4fc5e Refactor auxiliary routing functions
Refactored some of the functions used to calculate servers. Removed
redundant checks and moved the ack_write() call to the right place.
2017-06-22 10:40:17 +03:00
1f31cfdfd7 Add more session command related functions to Backend
The class now allows simpler construction of session commands by
overloading the add_session_command with a version that accepts a const
reference to a shared pointer. This removes the need to copy the
references to the source buffer by calling gwbuf_clone.

Exposed the first session command as a const reference to allow
interaction with it. Currently, it is planned to be used to get the
session command position of each backend.
2017-06-22 10:40:17 +03:00
15ef274178 Refactor routing code to use the Backend class
The Backend class is now used to handle the interaction with the backend
servers in the code that decides where each query is routed.
2017-06-22 10:40:17 +03:00