248 Commits

Author SHA1 Message Date
Johan Wikman
0aaba6bc5f Use getauxval for obtaining the executable path.
It appears that reading /proc/self/exe actually can return the path
of the shared library from which the reading is made.
2016-02-12 16:32:02 +02:00
Johan Wikman
1e363b9ad7 Figure out path of plugin process executable.
The plugin process executable is assumed to be installed in the
same directory as the maxscale executable.
2016-02-12 10:41:11 +02:00
Johan Wikman
2e5bfc14f2 Introduce skeleton plugin process.
For external parsing there will be a separate process that handles
parse requests sent from MaxScale. From MaxScale's perspective there
will just be a specific query classifier plugin that upon startup
launches that external process and manages its lifetime. That is,
MaxScale proper will be completely oblivious of this arrangement.

The skeleton process introduced here does nothing; just sits in
a loop sleeping. The skeleton query classifier plugin currently
loads the MySQL embedded query classifier and performs parsing
using it. That way the external process based query classifier can
immediately be used.

Next step is to introduce process management into the picture without
actually moving the parsing anywhere.
2016-02-11 09:05:37 +02:00
Johan Wikman
d3c288abf9 Remove warning when built in release mode. 2016-02-09 15:26:41 +02:00
Johan Wikman
4a4f22c9a7 Make query_classifier part of core.
The query classifier interface is now built as an integral
part of MaxScale core.
2016-02-08 11:44:07 +02:00
Johan Wikman
0cc3db9634 Fix forgotten merge conflict. 2016-02-08 10:55:08 +02:00
Johan Wikman
c579ed7fce Merge remote-tracking branch 'origin/MXS-517' into MXS-517 2016-02-08 10:33:56 +02:00
Markus Makela
2f65c3a7b8 MariaDB Connector C is build from source if it is not found on the system
The FindMariaDBConnector.cmake file now checks if the found library actually is
the MariaDB Connector-C library. If the found library is not the MariaDB
Connector-C, it will be built from source.
2016-02-03 11:35:01 +02:00
Markus Makela
081bacdc64 Switched to MySQL client library headers for MaxScale
The include directories previously used by MaxScale were from the embedded
library. All parts of MaxScale apart from the query classifier now use
the client libraries.
2016-02-02 14:04:59 +02:00
Johan Wikman
2bbe1b068a Allow the query classifier to be specified in maxscale.cnf 2016-02-01 20:44:36 +02:00
Johan Wikman
bbfcbc18c6 Make it possible to specify query classifier name.
If none provided or if the name is empty, the default query
classifier is loaded.
2016-02-01 19:46:16 +02:00
Johan Wikman
21b415eec0 Remove MySQL arguments from qc_init.
There can be any sort of library behind qc_init. Hence the arguments
cannot be hardwired to be like the embedded library wants them.

Eventually it might make sense to allow passing arguments from
maxscale.cnf.
2016-02-01 15:53:34 +02:00
Johan Wikman
fc6f49fe8a Link against Connector-C.
Now, qc_mysqlembedded is linked against MySQL's embedded library,
and MaxScale itself against Connector-C.

So, in order to build MaxScale, Connector-C must be installed.
This has been tested with Connector-C 2.2.1.

The build variable MYSQLCLIENT_LIBRARIES is no longer used.
2016-02-01 15:43:05 +02:00
Johan Wikman
0c6e9f3def Make query_classifier a wrapper.
The query_classifier library is now only a wrapper that loads an
actual query classifier implementation. Currently it is hardwired
to load qc_mysqlembedded, which implements the query classifier
API using MySQL embedded.

This will be changed, so that the library to load is specified
when qc_init() is called. That will then allow the query classifier
to be specified in the config file.

Currently there seems to be a conflict between the mysql_library_end()
call made in qc_mysqlembedded and the mysql_library_end() call made in
gateway.c. The reason is that they both finalize a shared library.
For the time being mysql_library_end() is not called in gateway.c.
This problem is likely to go away by switching from the client
library to the connector-c library.
2016-02-01 15:43:05 +02:00
Johan Wikman
7e36e1cbb1 Link against Connector-C.
Now, qc_mysqlembedded is linked against MySQL's embedded library,
and MaxScale itself against Connector-C.

So, in order to build MaxScale, Connector-C must be installed.
This has been tested with Connector-C 2.2.1.

The build variable MYSQLCLIENT_LIBRARIES is no longer used.
2016-01-29 16:50:31 +02:00
Johan Wikman
e840f92cbb Make query_classifier a wrapper.
The query_classifier library is now only a wrapper that loads an
actual query classifier implementation. Currently it is hardwired
to load qc_mysqlembedded, which implements the query classifier
API using MySQL embedded.

This will be changed, so that the library to load is specified
when qc_init() is called. That will then allow the query classifier
to be specified in the config file.

Currently there seems to be a conflict between the mysql_library_end()
call made in qc_mysqlembedded and the mysql_library_end() call made in
gateway.c. The reason is that they both finalize a shared library.
For the time being mysql_library_end() is not called in gateway.c.
This problem is likely to go away by switching from the client
library to the connector-c library.
2016-01-29 16:35:03 +02:00
Johan Wikman
5e5a522d27 Rename EMBEDDED_LIB to MYSQL_EMBEDDED_LIB
Makes it clearer what embedded lib we are talking about.
2016-01-29 16:32:01 +02:00
Johan Wikman
5e8ba4b519 Introduce MySQL-embedded based query classifier plugin.
Currently not used, but the existing query_classifier will be
changed into being just a wrapper around a dynamically loaded
query classifier plugin, i.e. qc_mysqlembedded.
2016-01-28 08:26:32 +02:00
Johan Wikman
d6840cd16a Add query classifier plugin interface.
Added a query classifier plugin interface using which plugins
export their functionality. Cleaned up header slightly as well.

This is the first step in the process of making the loading of
the query classifier truly dynamic.
2016-01-28 08:24:32 +02:00
Johan Wikman
42b1722e49 Make query classifier self-contained.
Only the query classifier needs the functionality of the embedded
server, while the rest of MaxScale is content with the client
library or Connector/C.

This have now been rearranged so that query-classifier links with
the embedded static library and then explicitly exports its own
functions using the query_classifier.map linker script. That way
query classifier will use the embedded library, while the rest of
maxscale use the client library, and this without conflicts.

Currently, query_classifier is not linked to maxscale-common,
but executables must link to maxscale-common and query_classifier.
2016-01-25 21:43:49 +02:00
Johan Wikman
1f241a5ed1 Rearrange libraries and build files.
This is the first change in an attempt to arrange the linking so that
more errors are detected at link-time.

- All files in server/core but for gateway.c are linked to one shared
  library called maxscale-common.
- The files log_manager/log_manager.cc and utils/skygw_utils.cc are
  built into maxscale-common as well.
- MaxScale itself consists now only of gateway.c and is linked with
  maxscale-common.
- All plugins link with maxscale-common.
- All executables link in addition with {EMBEDDED_LIB}.

After this change, the change (MXS-517) where query_classifier is the
only component that uses ${EMBEDDED_LIB} and the rest mysqlclient can
be made much cleaner.

After a few additional steps, all shared libraries can be linked with
the linker flags "-Wl,-z,defs", which directs the linker to resolve
all symbols. That will require that all shared libraries list all the
libraries they need, but will at the same time ensure that any
missing symbols are detected at link-time and not at run-time.
2016-01-22 23:26:17 +02:00
Markus Makela
985543dbb2 Fixed merge conflict
One function in the query classifier used the old name which led to undefined
symbols.
2016-01-12 09:19:46 +02:00
Markus Makela
54ca1ab2de Canonicalized queries remove non-executable comments
The comments which do not alter the functionality of a query are now removed
from canonicalized queries.

Also fixed missing semicolon in the comment removal regex and added tests
for comment removal.
2016-01-11 17:14:57 +02:00
Markus Makela
8ee110efa8 Fixed canonicalization and added more tests
Fixed mistakes in the canonicalization regular expressions and altered the
functions to use a source and destination buffers. This reduces the amount
of memory allocations that take place.

Added more canonical query tests to the internal test suite.
2016-01-11 17:14:44 +02:00
Markus Makela
e0c84e0fe3 Added removal of MySQL style comments to query canonicalization.
Also fixed minor issues with the canonicalization regular expressions.
2016-01-11 17:13:14 +02:00
Markus Makela
c067bbe34a Formatted the canonical query test.
The file is now formatted according to the style guide.
2016-01-11 17:13:01 +02:00
Markus Makela
9c9e30fa08 Fixed value replacement and added more tests for canonicalization of queries
The value replacement was not taking session or system variables into notice.
2016-01-11 17:09:40 +02:00
Markus Makela
995ed8c9d2 Improved query canonicalization
The query does not need to be parsed for it to be canonicalized and the parsing
uses the PCRE2 library. The regular expressions were changed so that only one
call to the function which replaces literal unquoted values is made.
2016-01-11 17:08:03 +02:00
Johan Wikman
f57df4b967 Hide unused public functions
parse_query and query_is_parsed are not used outside query classifier
anymore. Consequently, they can be made internal.
2016-01-11 15:28:00 +02:00
Johan Wikman
4d155f70b0 Remove call to parse_query.
Not needed anymore.
2016-01-11 15:14:27 +02:00
Johan Wikman
20bc6a4ab7 Reindent canonizer.c
- Untabify
- Remove trailing whitespace.
- Allman braces.
2016-01-11 15:08:27 +02:00
Johan Wikman
79fa226000 Move private type to implementation.
parsing_info_t is only used by the query_classifier implementation.
No need to keep it public.
2016-01-11 14:58:15 +02:00
Johan Wikman
23a7562d3a Replace skygw_ type prefix with qc_.
- skygw_query_type_t renamed to qc_query_type_t.
- skygw_query_op_t renamed to qc_query_op_t.
2016-01-11 12:06:21 +02:00
Johan Wikman
2f42246880 Rename query classifier functions consistently.
All public query classifier functions now have the prefix qc_.
2016-01-11 12:04:52 +02:00
Johan Wikman
6e6ad67504 Parse query if it has not been parsed already.
Now consistently all functions parse the query if it has not
been parsed already.
2016-01-11 10:02:27 +02:00
Markus Makela
40cfe1a864 Merge branch 'release-1.3.0' into develop 2016-01-08 11:14:02 +02:00
Johan Wikman
4b21154066 Make private query_classifier functions static.
parsing_info_init and parsing_info_done are only used by
query_classifier. Hence they should not be public and extern.
2016-01-07 22:36:15 +02:00
Markus Makela
080a9ebc9d PCRE2 is now statically linked
Since the PCRE2 library was always going to be a part of MaxScale, there was
no real reason to have it as a shared library apart from smaller binaries.
2015-12-29 10:09:38 +02:00
Markus Makela
93f10fdb7b Formatted query_classifier
Query_classifier formatted according to the style guide.
2015-12-02 13:36:51 +02:00
Markus Makela
a829b38873 Fix to MXS-363: Added soname versions to libraries
The soname version numbers were missing from all the library targets
properties which caused ldconfig to warn about non-symlink libraries
being installed.
2015-11-30 10:46:08 +02:00
Johan Wikman
a8535f42af Remove all traces of logfile_t
The earlier log file based approach for enabling and disabling
messages has now been completely replaced with the syslog priority
based approach.

Similarly as with log files before it is now possible to enable
and disable a log priority for a particular session, even though
it apparently has not been used much.

The local test-programs of the logging has got minimal attention
only to make them compile. They should get an overhaul as they did
not work before either.
2015-11-23 19:10:53 +02:00
Markus Makela
23b2ce004b Added support for MariaDB 10.1 embedded library
The code used in the query classifier was not compatible with 10.1 version
of MariaDB and needed to be fine tuned in order for it to work with all
supported versions of MariaDB.
2015-11-23 11:41:05 +02:00
Johan Wikman
1bd16db593 query_classifier: LOGIF and skygw_log_write replaced.
The use of LOgIF and skygw_log_write replaced with the equivalent
MXS_[ERROR|WARNING|NOTICE|INFO|DEBUG] macros.
2015-11-16 13:42:37 +02:00
Johan Wikman
a355e1beef Printf format checking added to logging function.
Printf format checking added to logging function and all
issues that were revealed by that fixed.
2015-11-16 12:40:49 +02:00
counterpoint
dee20fe077 Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111
# Conflicts:
#	server/core/CMakeLists.txt
#	server/core/buffer.c
#	server/core/service.c
#	server/modules/filter/tee.c
#	server/modules/monitor/mysql_mon.c
#	server/modules/routing/binlog/blr.c
#	server/modules/routing/binlog/blr_slave.c
#	server/modules/routing/debugcmd.c
#	server/modules/routing/readwritesplit/readwritesplit.c
#	utils/skygw_utils.cc

- resolved.
2015-11-11 11:08:02 +00:00
Johan Wikman
834a88aeda Log variables moved to log_manager.h
The log manager variables lm_enabled_log_files_bitmask, log_ses_count
and tls_log_info that earlier were declared separately in every
c-file are now declared in the log_manager.h header.
2015-11-04 14:26:53 +02:00
Markus Makela
0accf869de Fix to MXS-365: https://mariadb.atlassian.net/browse/MXS-365 Added tracking of LOAD DATA LOCAL INFILE
While a LOAD DATA LOCAL INFILE query is being executed, all queries will be sent to the master
and they will not be processed as normal packets.
2015-11-04 12:47:55 +02:00
Markus Makela
9064212353 Fixed queries without assignment operators failing to be properly canonized. 2015-10-27 14:20:43 +02:00
Markus Makela
c1194a5ee8 Fixed test build failures. 2015-09-10 18:07:24 +03:00
Johan Wikman
160bbb70ee MXS-251: strerror
Replaces all calls to strerror with calls to strerror_r. The former
is non-thread safe while the latter is.
2015-09-05 15:52:13 +03:00