356 Commits

Author SHA1 Message Date
Markus Mäkelä
7bd05d4581 Merge branch '2.1' into develop 2017-03-22 15:20:21 +02:00
Johan Wikman
d70dad260a Implement collecting behaviour in qc_sqlite
By default, only the essentials - the type and the operation - of
a statement will be collected and only if fields, tables, functions
and databases are explicitly asked for, will they be collected.
However, a statement will be parsed at most twice; if parsing is
needed a second time then all information will be collected.

If it is known that some particular information is needed, then
qc_parse() can be called explicitly to ensure it is collected
at first parsing.
2017-03-22 11:09:36 +02:00
Johan Wikman
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
Markus Mäkelä
1736aca7f7 Add module level static capabilities
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.
2017-03-20 11:10:08 +02:00
Johan Wikman
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
Johan Wikman
a925be4e2a Turn off error in qc_sqlite built
GCC on CentOS6 thinks there is an array-bounds error in the sqlite
code. As that code is outside our hands, it is easiest to instruct
GCC not to treat it as an error.
2017-03-08 17:18:06 +02:00
Johan Wikman
07ae37f179 Update commit/rollback rules
Now that WORK is recognized as a parser token, the BEGIN and regular
COMMIT and ROLLBACK rules should use them as well.
2017-03-07 11:49:30 +02:00
Johan Wikman
a6ae60c808 Merge branch '2.0' into 2.1 2017-03-07 11:45:49 +02:00
Markus Mäkelä
dd07feda07 MXS-1025: Parse SAVEPOINT statements
The various forms of the SAVEPOINT/RELEASE/ROLLBACK statements are now
fully parsed.
2017-03-07 08:44:21 +02:00
Johan Wikman
d834c1bbdc Compile sqlite explicitly in single thread mode
As every thread has a separate (in-memory) database, i.e. not
just a separate _connection_, sqlite can be compiled in singe-thread
mode, which means that there will be *no* locking.
2017-02-27 10:39:20 +02:00
Johan Wikman
5648f708af Update license to BSL 1.1 2017-02-14 21:42:28 +02:00
Esa Korhonen
6e38276a20 Rename files, removing "gw"-prefix
Also gwdirs.h.in -> paths.h.in
2017-01-20 12:55:52 +02:00
Esa Korhonen
eff34b91fb Move modules.h to core/maxscale
Also remove some unnecessary includes + cleanup
2017-01-19 15:53:25 +02:00
Johan Wikman
8aa76727d2 Remove explicit long indicator of size defines 2017-01-19 10:42:05 +02:00
Johan Wikman
16a76fcd28 Rename qc_get_type() to qc_get_type_mask()
To make it plain that it is a mask that is returned and not a
specific value from the enum qc_query_type_t.
2017-01-18 08:34:53 +02:00
Johan Wikman
ded9f668f1 QC: Parse statements in COM_STMT_PREPARE packets 2017-01-18 08:34:53 +02:00
Johan Wikman
20034b6fd6 QC: Exclude statement that qc_sqlite does not parse 2017-01-17 14:51:19 +02:00
Markus Mäkelä
3d92263cb3 Format query classifier modules
Formatted query classifier modules with Astyle.
2017-01-17 14:48:43 +02:00
Markus Mäkelä
5b92a1f467 Remove explicit module name from log messages
The module name doesn't need to be logged as MXS_MODULE_NAME will be
automatically added as a prefix to all messages logged by the module.
2017-01-17 12:51:08 +02:00
Johan Wikman
842e8440d4 qc_mysqlembedded: Replace '?':s with '0':s
The embedded parser is not capable of parsing preparable statements
containing ?:s as ordinary statements, so they have to be replaced
with something else. Replacing them with a dummy variable cannot be
done as that will affect the type of the statement. Replacing with
0 seems to be a good compromise.
2017-01-17 12:41:54 +02:00
Johan Wikman
a40692d81d qc_mysqlelmbedded: Handle SQLCOM_REPLACE_SELECT 2017-01-17 12:41:54 +02:00
Johan Wikman
cc6a3e629e Implement qc_get_preparable_stmt
Now returns the preparable statement as a GWBUF on which the
other qc-functions can be used.
2017-01-17 10:10:38 +02:00
Johan Wikman
8a95a0f045 Remove qc_get_prepare_operation
Since the whole preparable statement will be available, it is
superfluous to provide a function using which the operation of
the preparable statement can be obtained.
2017-01-17 10:10:38 +02:00
Johan Wikman
e349319400 Add qc_get_preparable_stmt
This function will return the preparable statement of a PREPARE
statement as a COM_QUERY GWBUF. That is, once obtained, the normal
query classifier functions can be used for obtaining information
about the preparable statement itself.
2017-01-17 10:10:38 +02:00
Johan Wikman
7fee90a399 Streamline query classifier API interface
- Only types of fixed size used in API interface
- The actual function return value specifies whether the parsing
  process succeeded, while "logical" return values are returned
  as out arguments.

The wrapper function currently ignores the function return value.
2017-01-17 10:10:38 +02:00
Johan Wikman
0ce7632f57 QC: Remove qc_is_real_query
Not used.
2017-01-16 14:17:56 +02:00
Johan Wikman
2fa12f796b Rename MYSQL_GET_PACKET_LEN to MYSQL_GET_PAYLOAD_LEN
The function returns the length of the payload, not the length of
the entire packet.
2017-01-12 14:24:14 +02:00
Johan Wikman
482fbe6400 qc: Implement qc_get_function_info for qc_mysqlembedded
MXS-1070

Now both qc_mysqlembedded and qc_sqlite return the same stuff
for the same statement, and both include also operators in
addition to pure functions. Whether that is the right approach,
is still subject to debate.

However, if we want to make it possible to disable e.g. the
use of concat as in "select concat(a) from t", where a is a string,
to prevent the bypassing of the masking filter, then conceptually
it should be possible to prevent "select a+0 from t", where a is an
int, as well.
2017-01-09 09:17:38 +02:00
Johan Wikman
0d561df880 QC: Implement qc_get_function_info for qc_sqlite 2017-01-09 09:17:38 +02:00
Johan Wikman
d078f56dc5 qc: Reveal function usage
MXS-1070

Just interface changes. Implementation follow in separate changes.
2017-01-09 09:17:38 +02:00
Johan Wikman
8fc5bdc2f1 Perform query classifier initialization implicitly
The setting up and the initialization of the query classifier has
now been separated. The gateway explicitly sets up the query
classifier (i.e. chooses which one to use and what arguments to
provide), but the actual initialization is performed as part of
the general module initialization.
2017-01-09 09:16:35 +02:00
Johan Wikman
530c0e9617 QC: Setup and initialization separated
This is in preparation for using the general process/thread
initialization mechanism.
2017-01-09 09:16:35 +02:00
Johan Wikman
a2a38f952a Add [process|thread] [init|finish] functions to modules
The MXS_MODULDE object now contains optinal pointers for functions
to be called att process and thread startup and shutdown. Since the
functions were added to the end, strictly speaking, all structures
would not have needed to have been modified, but better to be
explicit. In a subsequent change, these will be called.

C++ does not support flexible arrays, so for the time being C++
modules are restricted to 10 parameters. Better approach is to
factor out the parameters to a separate array and then just store
a pointer to that array in MXS_MODULE.
2017-01-05 14:44:02 +02:00
Markus Mäkelä
2a4714500f Fix the symbols exported by query classifiers
The query classifiers only export the needed symbols and these weren't
adjusted to the changes in the entry point names.
2017-01-03 19:16:56 +02:00
Markus Mäkelä
c96bd64aa8 Rename MODULE_INFO to MXS_MODULE
The MODULE_INFO is now the main object which is used by modules to convey
information to the MaxScale core. The MXS_MODULE name is more apt as it
now contains the actual module definition.

The old MODULES structure was moved into load_utils.c as an internal
implementation and was renamed so that it is not confused with the new
MODULE structure.
2017-01-03 18:01:14 +02:00
Markus Mäkelä
b00e0328d5 Create a macro for module declarations
The modules are now declared with a common macro. This allows future
additions to the module loading process while also making the loaded
symbol name a constant.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
ae0577c695 Move module object inside MODULE_INFO
This allows modules to only expose one entry point with a consistent
signature. In the future, this could be used to implement declarations of
module parameters.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
6c53999c97 Combine ModuleInit and GetModuleObject
The two functions can be combined into one as both are called only
once. This removes the need for the explicit ModuleInit function.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
7df29aa1ec Move version entry point into MODULE_INFO
The MODULE_INFO can easily hold the version information of the
module. This removes the need for a explicit version entry point.
2017-01-03 18:01:13 +02:00
Johan Wikman
aa2de52054 Factor out .test-reading capability
The capability for reading MySQL/MariaDB .test-files has now been
factored out from the compare.cc test program. That way, the
functionality can be used from other test programs as well.
2016-12-13 12:15:57 +02:00
Johan Wikman
ebca707335 QC: Always set number of returned items
qc_get_table_names() and qc_get_database_names() now always set
the number items, also in case of error. That is, it is now always
safe to start iterating using the number of items without first
checking the returned pointer.
2016-12-09 13:06:26 +02:00
Johan Wikman
994299b4f1 MXS-1043: Handle @@identity like @@last_insert_id
The type of @@identity, @@last_insert_id and last_insert_id() is
now the same, that is, QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ.
2016-12-02 11:38:27 +02:00
Johan Wikman
0218ac9e9c MXS-1043: Handle @@identity like @@last_insert_id
The type of @@identity, @@last_insert_id and last_insert_id() is
now the same, that is, QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ.
2016-12-02 11:35:50 +02:00
Markus Makela
3ba8525063 Remove old .gitignore files
The files were used to deal with old Makefile builds.
2016-11-28 14:37:26 +02:00
Johan Wikman
d9642dd5ae MXS-1025: All logging now behing the log_level
Earlier a successful parsing but failure to classify was always
logged.
2016-11-23 14:47:24 +02:00
Johan Wikman
35620f8dae Build compare using embedded library
For whatever reason compare fails to load qc_mysqlembedded if
it has not been built with the embedded library. Needs to be
sorted out at some point.
2016-11-23 14:35:46 +02:00
Johan Wikman
83ffdcf4ed Change defines into inline functions
To prevent bugs caused by pointers having the wrong type (e.g. uint32_t
instead of uint8_t), some macros are changed into inline functions so that
the normal type-checking is performed.

The macros MYSQL_GET_ERRCODE, MYSQL_GET_STMTOK_NPARAM, MYSQL_GET_STMTOK_NATTR,
and MYSQL_GET_NATTR were not changed, because they may be too specific to
be present in a general purpose header in the first place.
2016-11-23 10:14:50 +02:00
Johan Wikman
dcd98900ea Remove dependency on embedded library
The test programs of the query classifier do not need the
embedded library headers.
2016-11-23 10:14:50 +02:00
Johan Wikman
8572eb34a0 qc_sqlite: Dequote more properly
When a backslash is encountered, the backslash should not be
copied but only the character after that.

For the sake of completeness, a few more characters would have
to be handled explicitly, but as the content of a string will not
affect the statement's classification there is not much point in
doing that.
2016-11-22 19:11:21 +02:00
Johan Wikman
9e4ee0323d Merge branch '2.0' into develop 2016-11-21 12:23:30 +02:00