Commit Graph

784 Commits

Author SHA1 Message Date
b46c52d65c MXS-1684 Match space+linefeed as linefeed
A linefeed is whitespace, so given the rules

  "\n"+    return '\n'
  {SPACE}  ;

a line consisting of space followed by a linefeed, will be matched
as space and not as a linefeed and hence will cause the parser to
barf.
2018-03-01 17:57:07 +02:00
95983ddaf4 Fix unit test failures
When the unit tests were run without installing the libraries in their
final locations, the loading of the modules would fail. Using locations
relative to the build directory allows unit testing without having to
install the libraries.
2017-12-29 10:09:16 +02:00
23fb0bf928 MXS-1449 Firewall: Allow 'USE <db>'
When the database firewall filter is used in white-list mode,
'USE <db>' should be allowed. When connecting, it is always
possible to specify the database anyway so restricting
'USE <db>' serves no purpose.
2017-09-27 12:59:20 +03:00
c1a7008479 MXS-1449 Sort case statements
Faster to later check for something specific.
2017-09-27 12:59:20 +03:00
aaa60d37e6 Add missing parameter documentation to maxrows
Documented new parameters.
2017-09-18 22:03:30 +03:00
d72375ebb5 Reset resultset offset when discarding response
The offset into the resultset buffer needs to be reset before each
processed packet if the resultset is being discarded.
2017-09-18 20:51:52 +03:00
d168493ddf Fix maxrows offset calculation
The code that handles the resultset rows added the extra offset given as a
parameter into the total offset when it should've be ignored.
2017-09-18 20:32:28 +03:00
d1b742eaa5 Log details if cache received unexpected packet from server 2017-09-15 17:14:21 +03:00
fb12e4c0aa MXS-1411: additional fix to error message
MXS-1411: additional fix to error message
2017-09-15 15:30:39 +02:00
9dd7f2174c MXS-1412: while discarding a result set don't buffer any data.
MXS-1412: while discarding a result set don't buffer any data: this
avoids to store useless data.

Additionally the colum definitions buffer is used instead of the offset
value.
2017-09-15 12:05:28 +02:00
8905c3aa34 MXS-1411: fix error message and log priority
MXS-1411: fix error message and log priority
2017-09-14 15:33:39 +02:00
7e48941a04 MXS-1412: Process response buffers individually
By processing each buffer individually, the need to iterate over the whole
resultset is removed. Profiling showed that most of the time was spent
navigating the linked list of buffers when an offset into the whole
resultset was used instead of an offset to the individual response buffer.
2017-09-14 09:50:05 +03:00
3485a32731 Fix compilation errors/warning with gcc-5.4.0 (#137)
Warning are like this:
 error: ‘delimiter’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2017-08-15 09:56:22 +03:00
e26ec4f8b9 MXS-1329: Only parse text protocol statements
The query classifier should only be used to parse text protocol
statements. The insertstream filter exploited the fact that any statements
that the filter did not expect would be classified as an unknown
commands. This led to repetitive error messages with binary protocol
statements.
2017-07-27 09:26:27 +03:00
d47e32966f MXS-1312: Make the permission rule the default type
If a rule is defined with only an optional part, it should be of the
permission type. This type is used to signal that the rule matches if the
optional constraints are fulfilled.

Due to refactoring, the default type was changed from RT_PERMISSION to
RT_UNDEFINED.
2017-07-07 15:44:37 +03:00
9c4711aac8 MXS-1311: Allow backtick quoted values for function rules
The function rules can now take keywords as arguments if they are quoted
by backticks.
2017-07-07 15:17:57 +03:00
b7a6e4b7b0 Fix HintParser line break detection
The HintParser wrongly ignored linebreaks, causing parsing faults
e.g. parsing too far or accepting invalid comments. Now, the parser
detects a line break and terminates comments unless they started with
'/*'. Also, fixed a memory leak when parsing parameter-value-combinations.
2017-06-19 10:49:47 +03:00
7e59254454 Change modutil_get_SQL() to modutil_extract_SQL() + length limit
The modutil_get_SQL()-function allocates storage, while
modutil_extract_SQL() does not. The strings given by the latter
are not 0-terminated so require a length limit when matched using
regexec().

This commit changes the used function in those cases where the
sql-string is not modified nor is the pointer saved for later use.
2017-06-16 10:07:27 +03:00
539474a28d Disable RocksDB tests in 2.1
The RocksDB based cache storage is not built by default so the tests
should be disabled.
2017-06-05 13:20:15 +03:00
9124de86df Add default value to MaskingFilter "fill" setting
MXS-1261. If "fill" is not defined, an "X" is used as default.
Setting an empty string as "fill" or "value" is disallowed.
2017-06-05 11:30:06 +03:00
8e2c7fd952 Merge branch '2.0' into 2.1 2017-05-10 09:12:42 +03:00
e8b14dd8b0 Remove debug output 2017-05-08 14:54:23 +03:00
33b809eec1 Do not build storage_rocksdb by default 2017-04-20 13:12:46 +03:00
d03b059107 Cache length of buffered data
If a complete response is delivered in many buffers, then calling
gwbuf_length() whenever you need the complete size starts to hurt.
By caching the length of the data received sofar and by updating
the length in clientReply(), gwbuf_length() will be called exactly
once for each buffer(chain) delivered to routeQuery().
2017-04-19 18:15:56 +03:00
f4a5134a83 MXS-1212: use res.length for buffer length instead of computing the size of the whole buffer chain
This reduces CPU usage and decreases the response time for result sets
with many rows.
2017-04-07 12:16:50 +02:00
e0a98f6539 Fix calls of pcre2_substitute
If the output buffer given to pcre2_substitute is too small, an error
value is written to the last parameter (output length). That value
should not be used for calculations. This patch gives a copy as
parameter instead.

Coincidentally, this commit fixes the crashes of query classifier tests.

Also, increase buffer growth rate in utils.c.
2017-04-04 16:19:21 +03:00
0c3f9ffa2e Maxrows: documentation update and use of MXS_MODULE_PARAM_SIZE for max_resultset_size parameter
max_resultset_size parameter now uses MXS_MODULE_PARAM_SIZE and
config_get_size

Documentation change follows the change.
2017-04-04 08:43:55 +02:00
815780aa4a In cache testrules.c ensure there seems to be at least one thread 2017-04-03 14:20:54 +03:00
e6d2c96f5b MXS-1211: maxrows should be configurable to return error when limit has been exceeded
New parameter added to maxsrows filter:
max_resultset_return=empty|error|ok
Default, 'empty' is to return an empty set, as the current
implementation.
'err' will return an ERR reply with the input SQL statement
'ok' will return an OK packet
2017-03-31 14:26:44 +02:00
cbc1e864d9 Use RFC 3986 compliant addresses in log messages
When log messages are written with both address and port information, IPv6
addresses can cause confusion if the normal address:port formatting is
used. The RFC 3986 suggests that all IPv6 addresses are expressed as a
bracket enclosed address optionally followed by the port that is separate
from the address by a colon.

In practice, the "all interfaces" address and port number 3306 can be
written in IPv4 numbers-and-dots notation as 0.0.0.0:3306 and in IPv6
notation as [::]:3306. Using the latter format in log messages keeps the
output consistent with all types of addresses.

The details of the standard can be found at the following addresses:

     https://www.ietf.org/rfc/rfc3986.txt

     https://www.rfc-editor.org/std/std66.txt
2017-03-31 14:12:58 +03:00
4b2d94d0f8 When a transaction has been started, no other checks are needed
If we do check then we will end up turning off the read only flag
that just was set on.
2017-03-28 16:17:13 +03:00
f2734f895e Revert "Update dbfwfilter build configuration"
This reverts commit 09ef292283311483354e6cd628318a5cafd96b2c. The old
syntax is still required on SLES 11.
2017-03-27 10:01:54 +03:00
d0a9571da0 Introduce new qc_parse() prototype
It is now possible to specify what information the caller is interested
in. With this the cost for collecting information during the query parsing
that nobody is interested in can be avoided.
2017-03-22 11:09:36 +02:00
15a22ec295 Do not use shared PCRE2 match data
The match data needs to be unique for each thread, so for the time
being it is created whenever it is needed. A more performant (although
possibly to a negigible amount) solution would be to have a separate
match data for each thread, but that will have to wait for 2.2.
2017-03-21 15:21:13 +02:00
117534d288 Use JIT in regex matching if available 2017-03-21 15:21:13 +02:00
17057ef340 Use thread specific pcre2 match data
For 2.2 a worker/thread object need to be passed around so that
not everyone need to create their own thread id mechanism.
2017-03-21 15:21:13 +02:00
b81c86f228 A rules object may be empty 2017-03-21 10:35:30 +02:00
ed06b6a331 The cache storage storage_inmemory is now the default 2017-03-17 13:45:55 +02:00
9c3aaddda1 Improve cache performance
- Selects are picked out using custom parsing, so if a statement is
  anything else but a SELECT, the cache will never cause the statement
  to be parsed.
- The setting of of the cache parameter `selects` is taken into account.
  If it is `assume_cacheable` then the statement will also not be parsed
  even if it is a SELECT.
2017-03-17 12:22:00 +02:00
6db3cc380b Add cache parameter 'selects' 2017-03-17 09:06:27 +02:00
987a52b398 Further simplify key generation
The original approach was made for RocksDB where it is beneficial
to keep keys of stuff related to each other close to each other.
However, as RocksDB is no longer the primary focus, it just causes
additional cost to dig out the table names.

The key is a 64-bit integer, but crc32 only gives us a 32-bit one.
We create an other 32-bit value by running crc32 over the same SQL,
using the first crc value as adler.

I think that further reduces the chance for clashes:

    uint32_t crc0 = crc32(0, Z_NULL, 0);
    uint32_t crc1;
    uint32_t crc2;

    crc1 = crc32(crc0, "codding", 7) => 1774765869
    crc2 = crc32(crc1, "codding", 7) => 1409592046

    crc1 = crc32(crc0, "gnu", 3)     => 1774765869
    crc2 = crc32(crc1, "gnu", 3)     => 1213798908

Note that the first value is the same, but the second is not.
2017-03-16 18:39:10 +02:00
daf3774329 Use simpler function for calculating hash
Now the key is a 64-bit integer and it is created by the cache
component and can not be unique for the storage.
2017-03-16 16:47:15 +02:00
c235e181ce Null filter no long requires 'capabilities' argument
- If no capabilities are provided, then the filter will have none.
- Now logs its capabilities as startup (useful for debugging).
2017-03-15 10:26:31 +02:00
a58f944f23 Allow query classifier to initialize itself
The process and thread initialization/finalization of the query
classifier plugins is handled using the process and thread
initialization/finalization functions in the module object.

However, the top-level query classifier will also need to perform
process and thread initialization when transaction boundaries are
detected using regular expressions.
2017-03-15 09:35:15 +02:00
d88d02ee95 Fix namedserverfilter source parameter
The `source` parameter was broken by the IPv6 change. Now the filter no
longer uses functions from the core to resolve the network addresses.
2017-03-13 10:45:55 +02:00
37dd561470 Add support for IPv6
Both the listeners and servers now support IPv6 addresses.

The namedserverfilter does not yet use the new structures and needs to be
fixed in a following commit.
2017-03-13 10:45:55 +02:00
20d89717c7 Remove unused headers
The my_config.h headers are not used.
2017-03-09 13:02:23 +02:00
b1521e0545 Log the use of prepared statements
If cache decisions should be logged, we log the presence of
prepared statements as they currently are the primary source
for the cache not caching.
2017-03-07 15:45:29 +02:00
09ef292283 Update dbfwfilter build configuration
The filter now uses a more recent syntax to declare the function name
prefixes. This removes a build warning.
2017-03-03 18:44:58 +02:00
da5edadcda MXS-1150: Do not cache non-cachable functions
The resultset of SELECTs that use functions whose result will
always vary or whose result depend upon the user executing the
query should not be cached. The list of functions is the same
as that specified for the query cache of MariaDB:
https://mariadb.com/kb/en/mariadb/query-cache/
2017-03-02 13:13:31 +02:00