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.
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
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.txthttps://www.rfc-editor.org/std/std66.txt
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.
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.
The static module capabilities are now used to query the capabilities of
filters and routers. The new RCAP_TYPE_NOAUTH capability is also taken
into use. These changes removes the need for the `is_internal_service`
function.
The static capabilities declared in getCapabilities allows certain
capabilities to be queried before instances are created. The intended use
of this capability is to remove the need for the `is_internal_service`
function.
The filter now checks what types of parameters it has been given and
only accepts the old style (match, server) XOR new style (match01,
target01 etc).
Adds support for special targets ->master and ->slave.
Code cleanup.
- 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.
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.
Move most of the functions under the filter or session-classes.
Class definitions moved to a header file. General cleanup. Some features
are still incoming.
The filter now accepts (in addition to the old "match" and "server")
parameters of the form "matchN" and "serverN", where N is a decimal
number with two digits, i.e 01, 02, 03 .. 20. When routing queries,
the regural expressions will be tested one by one, and the servers
from the first match will be added as hints. Also, a single "server"-
setting may contain multiple servers separated by ','. The server
names are not verified to be actual servers, this is up to the user.
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.
The core now provides a simple function to close a session. This removes
the need for the modules to directly call the API entry points when the
session should be closed. It is also in line with the style that other
objects, namely the DCBs, use. This makes the new session_close very
similar to dcb_close.
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.
Change to modutil_extract_SQL(), add pcre2_data to filter session.
The pattern is now jit-compiled for maximum speed. Move general
pcre2 error printing to a function and macro. Add instance-level
statistics so the filter always prints diagnostic info. Add a mention
of PCRE2 to release notes.
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/
If user or system variables are used in a SELECT statement, then
the result will not be cached. That ensures that the wrong result
will not be returned.
maxrows returns empty resultset instead of OK.
The response with coulmndefs is sent then an EOF without flags is added.
Limitations: in case of MULTI_RESULT sets only the first one coulmndefs
is sent with EOF
As before, the cache will be used if there is no ongoing transaction
(includes autocommit being on), or if there is an explicitly read-
only transaction.
In addition, the cache will be used and populated during any other
transaction as long as only pure read statements are executed. After
first non-read statement, the use of the cache is disabled.
The autocommit state is now included in the result returned
from session_trx_is_active(), so it need not be checked separately.
This is preparatory work for MXS-1136 that will change the approach
so that the cache is used and populated in a non readonly transaction
*until* the first non-read statement is encountered.