344 Commits

Author SHA1 Message Date
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
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
Johan Wikman
ecb6680e71 MXS-976: qc_sqlite: Force initialization of sqlite3
Sqlite3 performs some lazy initialization, during which it internally
parses some SQL statements of its own. Earlier there was detection code
for noticing that, but it was costly and errorprone.

Now, sqlite3 is forced to perform the initialization at startup so that
we no longer need any detection code.
2016-11-18 16:04:26 +02:00
Johan Wikman
d640291023 Add crashing test-case
With 2.0.1 or earlier, if a statement contains a trailing NULL,
the statement will inside qc_sqlite.c incorrectly be assumed not
to be the one to be classified with a crash being indirectly the
result.
2016-11-18 16:00:57 +02:00
Johan Wikman
59ee5a78c9 MXS-969: Report user var modifications properly
User variable modifications are now reported as QUERY_TYPE_USERVAR_WRITE
and not as QUERY_TYPE_GSYSVAR_WRITE as earlier.
2016-11-16 15:26:06 +02:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00
Johan Wikman
15e9652c46 qc: Provide information about field usage
Together with the field names, now qc_get_field_info also returns
field usage information, that is, in what context a field is used.
This allows, for instance, the cache to take action if a a particular
field is selected (SELECT a FROM ...), but not if it is used in a
GROUP BY clause (...GROUP BY a).

This caused a significant modifications of qc_mysqlembedded that
earlier did not walk the parse-tree, but instead looped over of a
list of st_select_lex instances that, the name notwithstanding,
also contain information about other things but SELECTs. The former
approach lost all contextual information, so it was not possible
to know where a particular field was used.

Now the parse tree is walked, which means that the contextual
information is known, and thus the field usage can be updated.
2016-11-14 09:35:16 +02:00
Johan Wikman
bf62f8950a Remove qc_get_affected_fields
Function is no longer used and it was quite unoptimal, so now
removed.

qc_get_prepare_name, qc_get_prepare_operation and qc_get_field_info
that were missing from qc_dummy added at the same time.
2016-11-07 12:28:58 +02:00
Johan Wikman
568153efb9 Fix buflen calculation in classify
qc_sqlite.c is now strict as far as buffers and payloads goes.
2016-11-07 10:10:26 +02:00
Johan Wikman
add7577f08 MXS-884: Update exclusion code 2016-11-07 10:10:26 +02:00
Johan Wikman
ac4999ec76 qc_sqlite: Only exclude exact match
When checking whether a name should be excluded, there may be a match
only if the name checked against is not a qualified name.
2016-11-07 10:10:26 +02:00
Johan Wikman
75509a67d4 qc: Do not collect HAVING names
A HAVING clause can only refer to names that already have been mentioned
or if "SELECT *" is used. Either way, the HAVING names need not be separately
collected.
2016-11-07 10:10:26 +02:00
Johan Wikman
0aaeda0ef1 qc_mysqlembedded: qc_get_affected_fields uses qc_get_field_info 2016-11-07 10:10:26 +02:00
Johan Wikman
c71acecce3 MXS-884: qc_mysqlembedded now supports qc_get_field_info
Initial implementation, one failure in the tests still to be
sorted out. Plus some cleanup.
2016-11-07 10:10:26 +02:00