1043 Commits

Author SHA1 Message Date
Markus Mäkelä
75eded4b89
Merge branch '2.2' into develop 2018-05-14 11:24:09 +03:00
Johan Wikman
5eb6718b75 MXS-1861 Detect and handle multistatement responses
Multi-statement SELECTs were properly detected and handled,
but e.g. multi-statement UPDATESs were not, with the result
that erronous warnings were logged.

Now the responses are detected and handled properly.
2018-05-14 10:15:36 +03:00
Johan Wikman
aa1c956aa7 MXS-1841 Compile all filters as C++
Minimal changes to make the files compile with a C++ compiler.
2018-05-03 10:04:44 +03:00
Niclas Antti
02b6cd7004 MXS-173 Initial version of throttle filter 2018-04-30 08:51:50 +03:00
Esa Korhonen
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +03:00
Johan Wikman
5f7257f432 MXS-1401 Add test cases
Test that an array of rules is parsed and used properly.
2018-04-27 09:22:17 +03:00
Johan Wikman
a3a8b5523e MXS-1401 Support multiple cache rules
The possibility to have multiple cache rules in a cache
configuration file is now handled throughout the cache
filter.

The major difference is that while you earlier directly
queried the Cache whether data should be stored to the
cache and whether data in the cache should be used, you
now query the Cache whether data should be stored to the
cache and, if so, get a CacheRules object from which you
subsequently query whether data from the cache should
be used.
2018-04-27 09:22:17 +03:00
Johan Wikman
605f771518 MXS-1401 Extend rule parsing to handle array of rule objects
It's now possible to have a rules file with an array of rule
objects, e.g.

  [
    {
      store: [ ... ],
      use: [ ... ]
    },
    {
      store: [ ... ],
      use: [ ... ]
    }
  ]

This commit only contains the low-level modifications for
supporting that; the upper-level modifications are made in
another commit.
2018-04-27 09:22:17 +03:00
Johan Wikman
5c534acf6b MXS-1830 Remove erroneous free
The libdir is set elsewhere as well, which causes the set
buffer to be freed. Consequently it cannot be freed.
2018-04-26 15:46:51 +03:00
Johan Wikman
08230ef24c MXS-1830 Remove erroneous free
The libdir is set elsewhere as well, which causes the set
buffer to be freed. Consequently it cannot be freed.
2018-04-26 15:21:16 +03:00
Johan Wikman
fb5a856cea MXS-1725 Use normal routing route when mocking
As results provided directly by filters are now delivered
properly, the functionality of the session must be used
also when mocking.
2018-04-25 10:58:45 +03:00
Markus Mäkelä
cc793b2151
MXS-1506: Remove unused MXS_UPSTREAM variables
The `error` variable was never used. Also added a more convenient typedef
for both the downstream and upstream functions and updated filter API
version.
2018-04-10 15:29:30 +03:00
Markus Mäkelä
c70216390f
MXS-1506: Combine housekeeper task types
The tasks themselves now control whether they are executed again. To
compare it to the old system, oneshot tasks now return `false` and
repeating tasks return `true`.

Letting the housekeeper remove the tasks makes the code simpler and
removes the possibility of the task being removed while it is being
executed. It does introduce a deadlock possibility if a housekeeper
function is called inside a housekeeper task.
2018-04-10 15:29:30 +03:00
Markus Mäkelä
46ebf19223
Fix luafilter build failure
The pointer passed to was of the wrong type.
2018-03-27 21:49:35 +03:00
Johan Wikman
3b26db8e01 MXS-1725 Update luafilter to use session_set_response 2018-03-26 12:17:36 +03:00
Johan Wikman
e631f64458 MXS-1725 Update DbFWFilter to use session_set_response 2018-03-26 12:17:36 +03:00
Johan Wikman
c08fe079bf MXS-1725 Use session_set_response() in Cache
- session_set_response() made const correct
- set_response() function added to mxs::FilterSession; calls
  session_set_response().
- Cache uses set_response() for delivering the cache result
  to the client.
2018-03-26 12:17:36 +03:00
Johan Wikman
cf547b9532 Merge branch '2.2' into develop 2018-03-26 10:03:20 +03:00
Johan Wikman
033ef59c01 MXS-1733 Match empty values
If a table/database rule has been provided then if the resultset
does not contain table/database names, then we consider it a match
(subject to the column obviously).

Otherwise a rule like

        {
            "replace": {
                "table": "info",
                "column": "email"
            },
            "with": {
                "fill": "*"
            }
        }

could be bypassed with a statement like

    SELECT * FROM info UNION SELECT * from info

as the resultset in that case will not indicate that the column emain
is from info, which it will if the statement is

    SELECT * FROM info;
2018-03-26 10:02:57 +03:00
Johan Wikman
a5012c6a80 Fix signed/unsigned compilation error 2018-03-22 16:49:36 +02:00
Markus Mäkelä
65033313a7
MXS-1701: Fix build instructions
Corrected the documentation on building from source and fixed a missing
variable check for the luafilter.
2018-03-22 13:29:28 +02:00
Johan Wikman
98aa9c8d5b MXS-1475 Fix unit-test program 2018-03-21 15:58:12 +02:00
Markus Mäkelä
436c563da7 MXS-1729: Allow global routeQuery to return values
The `lua_pcall` parameters were incorrect, the second number signifies the
number of parameters the function can return.
2018-03-21 14:58:09 +02:00
Markus Mäkelä
61b93185c5
Remove useless session spinlock
The session level spinlock was useless given the threading model changes
done for 2.1.
2018-03-21 14:15:13 +02:00
Markus Mäkelä
8a397f574f
Expose modutil_get_canonical in luafilter
Exposing the canonicalization code in the luafilter allows it to be used
on the Lua side of things. This should enable some pretty cool stuff to be
done with it.
2018-03-21 14:15:13 +02:00
Markus Mäkelä
7359774ae1
MXS-1729: Allow global routeQuery to return values
The `lua_pcall` parameters were incorrect, the second number signifies the
number of parameters the function can return.
2018-03-21 14:14:04 +02:00
Johan Wikman
ad05019445 Avoid clashes with TRUE/FALSE
TRUE/FALSE may be visible as defines. Consequently better
not to use them as names.
2018-03-20 13:10:31 +02:00
Johan Wikman
3331eb9eb6 MXS-1475 Fix typos 2018-03-16 14:34:04 +02:00
Johan Wikman
51251fd9f3 MXS-1475 Introduce @maxscale.cache.[soft_ttl|hard_ttl]
Now it is possible to control the soft and hard ttl of the
cache on a session basis. That is, it is possible to use
different TTLs for different SELECTs.
2018-03-16 14:34:04 +02:00
Johan Wikman
2c49f90bc4 MXS-1475 Allow caller to specify (soft|hard) TTL
As the TTL is checked at lookup time, it need not be hardwired
when the storage instance is created. With this changed it is
possible to introduce @maxscale.cache.(soft|hard)_ttl user
variables using which a client can control what TTL should be
applied for a particular kind of data, which is requested by
MXS-1475.
2018-03-16 14:34:04 +02:00
Johan Wikman
0ef902621d MXS-1475 Update cache entry if originally present
In case the entry in the cache can not be used because the hard
TTL has kicked in, we fetch the data and update the cache
irrespected of the value if @maxscale.cache.populate. That way
an entry that once was put in the cache, will remain in the cache
(as long as there is space).
2018-03-16 14:34:04 +02:00
Johan Wikman
4ce894d24d MXS-1475 Report if hard TTL has hit in
If an entry is not returned because the hard TTL had hit in,
we tell about it so that the caller can act differently in that
case.
2018-03-16 14:34:04 +02:00
Johan Wikman
38d20c1575 MXS-1475 Remove all traces of RocsDB cache storage
Some API changes are needed and it's not time well spent to
update the RocksDB storage implementation.
2018-03-16 14:34:04 +02:00
Johan Wikman
2ec19e2358 MXS-1475 Add test case for @maxscale.cache.[use|populate]
Also extend logging.
2018-03-16 14:34:04 +02:00
Johan Wikman
82b55ff362 MXS-1475 Add @maxscale.cache.[populate|use]
The earlier @maxscale.cache.enabled has now been replaced with
@maxscale.cache.populate and @maxscale.cache.use that provide
for more flexibility.

With the former it is possible to control in what circumstances
the cache is populated and with the latter one when it is used.
Together they can be used for having a completely client driven
caching.
2018-03-16 14:34:04 +02:00
Johan Wikman
2d20a19f12 MXS-1475 Act accordingly if cache disabled
If caching is dynamically disabled, then CACHE_USE_AND_POPULATE is
turned into CACHE_POPULATE leading to the cache being refreshed but
not used.
2018-03-16 14:34:04 +02:00
Johan Wikman
090892db4c MXS-1475 Add 'enabled' parameter to Cache filter
With 'enabled' it can be specified whether the cache should initially
be enabled or disabled. Useful as it is now possible to enable/disable
the cache dynamically.
2018-03-16 14:34:04 +02:00
Johan Wikman
71c8a327b2 MXS-1475 Introduce variable @maxscale.cache.enabled
With the variable @maxscale.cache.enabled the caching can be
enabled/disabled at runtime.

In a subsequent commit, the variable will actually be used.
2018-03-16 14:34:04 +02:00
Johan Wikman
ea83420620 Merge branch '2.2' into develop 2018-03-01 18:08:45 +02:00
Johan Wikman
544e0eb60b Merge branch '2.1' into 2.2 2018-03-01 17:57:40 +02:00
Johan Wikman
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
Johan Wikman
5326c8db5c Merge branch '2.2' into develop 2018-02-08 12:48:06 +02:00
Johan Wikman
b15a460416 MXS-1659 Do not include C++ headers from C header 2018-02-08 12:45:18 +02:00
Markus Mäkelä
771716e9db
Merge branch '2.2' into develop 2018-02-05 10:22:43 +02:00
Markus Mäkelä
ea58b16a7a Add missing include for vector
The vector header was not included in dbfwfilter.hh.
2018-01-30 19:14:28 +02:00
Esa Korhonen
c7474e439e Print new parameters during diagnostics
Also, copy using strdup instead since config_copy_string()
returns null for empty strings.
2018-01-30 18:40:33 +02:00
Johan Wikman
0db538db9a MXS-1583 Treat independent 'users' line in OR-fashion
If there are several 'users' lines in a rule file, for a particular
user, the rules each matching line will be checked independently
until a rule match is found.

That is, the rules of each 'users' line are treated in an OR-fashion
with respect to each other.
2018-01-29 15:25:21 +02:00
Esa Korhonen
1222d2a400 Use C-string as parameter to fix compile error 2018-01-23 12:28:15 +02:00
Esa Korhonen
0bcae6117d Fix compilation errors by using defines in mysql.h 2018-01-23 12:18:52 +02:00
Esa Korhonen
459d4bb002 Turn QLA filter to C++, part1 2018-01-19 16:58:06 +02:00