117 Commits

Author SHA1 Message Date
Markus Mäkelä
45e0e8bb59 Introduce internal protocol command enum
The enums exposed by the connector are not intended to be used by the
users of the library. The fact that the protocol, and other, modules used
it was in violation of how the library is intended to be used.

Adding an internal mapping into MaxScale also removes some of the
dependencies that the core has on the connector.
2017-09-14 15:30:43 +03:00
Johan Wikman
a2d0d24b2c Merge branch '2.1' into develop
Bringing in MXS-1406
2017-09-13 10:02:37 +03:00
Johan Wikman
49ab5797a2 MXS-1406 Report CALL operation
Basically it would be trivial to report far more operations
explicitly, but for the fact that the values in qc_query_op_t
currently, quite unnecessarily, form a bitmask.

In 2.2 that is no longer the case, so other operations will be
added there.
2017-09-12 15:38:25 +03:00
Johan Wikman
ad4e8dad94 MXS-1364 Drop the usage field
But for the most trivial statements did not really provide
useful information.

The arguments of the "function" '=' are now reported.
2017-08-24 09:58:18 +03:00
Johan Wikman
c34140abd8 MXS-1364 Improve collection of arguments to IN 2017-08-22 11:01:50 +03:00
Johan Wikman
17db8e9705 MXS-1364 Collect function column access in qc_mysqlembedded
Initial support, more updates will be needed.
2017-08-22 11:01:50 +03:00
Johan Wikman
523e7ed445 MXS-1247 Add initial support for window functions
This commit will be followed by more tests.
2017-08-16 13:04:21 +03:00
Johan Wikman
6bdc2de6fe MXS-1307 Detect field usage from all selects
In the presence of CTEs, in order to catch all field usage, we need
to iterate over all selects.
2017-08-09 13:21:24 +03:00
Johan Wikman
c11ffd91c5 MXS-1349 Access right field when picking out preparable stmt
The preparable statement is stored in two fields; in one in full
and in another at most 255 chars.
2017-08-08 15:46:01 +03:00
Johan Wikman
4f4151bca9 MXS-1340 Report true table and not alias name
With this change, for a statement like

    SELECT t2.a FROM t1 t2;

the affected field is reported as t1.a and not as t2.a, as it
was before.

For a statement like

    SELECT t.f FROM d.t;

qc_mysqlembedded will now return "d.t.f" as the affected field,
while qc_sqlite will still return "t.f" as both implementations did
before. In qc_mysqlembedded's case that is a side-effect of the
alias handling. To get qc_sqlite to return the same (which would
be good), the table names would have to be collected in a smarter
way than they are now.
2017-08-08 15:46:01 +03:00
Johan Wikman
7a5e3ede21 MXS-1339 QC: Report each table just once
If a particular table appears in a statement multiple times,
qc_get_table_names will report it as many times as it appears.
Each name should be reported just once. Same applies for
database names.
2017-08-03 08:34:22 +03:00
Johan Wikman
d060320b36 MXS-1248: Further modifications for CTE
- Fields in CTEs are marked as being used in subselects.
- In qc_mysqlembedded all selects must be walked if CTE is present.
- In qc_sqlite unions need special handling.
2017-06-30 12:49:28 +02:00
Johan Wikman
b5d54292a4 Fix merge error 2017-06-30 11:07:00 +02:00
Johan Wikman
7297ae129c MXS-1248: Pointer value alone does not tell validity
The pointer pointing to a recursive select may be non-null even
if it is not valid. The specific boolean must be checked as well.
2017-06-30 11:05:15 +02:00
MassimilianoPinto
2c5aaeff0e Develop Merge
Develop Merge
2017-06-30 10:14:45 +02:00
Johan Wikman
84c5aa9934 MXS-1248: Report fields from CTE expressions
Now field and function information of CTE expressions are
collected.
2017-06-30 08:36:19 +02:00
Johan Wikman
48a67eeef2 qc_mysqlembedded: Collect ... WHERE EXISTS ...
Information was not collected from the subselect in a situation
e.g. like

    SELECT ... WHERE NOT EXISTS (SELECT ...)
2017-06-30 08:36:19 +02:00
MassimilianoPinto
cb57e10761 Develop merge
Develop merge
2017-06-29 15:34:22 +02:00
Johan Wikman
6cd6ded3d8 Merge branch '2.1-oracle-compat' into develop-new-merge-oracle 2017-06-29 09:39:55 +02:00
Johan Wikman
a690b44919 MXS-1278: Sql mode must be specified explicitly
The default sql mode must now be provided explicitly when the query
classifier is setup. This is in preparation for "sql_mode" becoming
a global configuration parameter of MaxScale.
2017-06-28 21:36:08 +02:00
Johan Wikman
d9448e1550 MXS-1275: Function name mappings need to follow sql_mode 2017-06-28 21:36:08 +02:00
Johan Wikman
021fe09edb MXS-1275: qc_mysqlembedded, add support for qc_[get|set]_sql_mode 2017-06-28 21:36:08 +02:00
Johan Wikman
9ae0526efb MXS-1275: Extend QC-API to allow setting of sql mode
Only API changes, implementation will follow.
2017-06-28 21:36:08 +02:00
Johan Wikman
f9eef5ee3b MXS-1196: Classify SHOW as QUERY_TYPE_READ 2017-06-28 21:33:04 +02:00
Johan Wikman
9ecd5da255 MXS-1196: Handle sequence related fields/functions
Both 10.3 and Oracle support sequence pseudo colums and corresponding
functions. Getting the next number in the sequence is in both cases
obtained using nextval/nextval() but the current number is in Oracle
obtained using currval/currval() and in 10.3 using lastval/lastval().

These fields/functions are now ignored, in the sense that they will
not show up in the field/function infos. However, they will cause the
type mask of the statement to contain the bit QUERY_TYPE_WRITE so that
statements accessing the sequence will always be sent to the master.
2017-06-28 21:33:04 +02:00
Johan Wikman
61b265467b MXS-1196: Add support for DROP SEQUENCE 2017-06-28 21:33:04 +02:00
Johan Wikman
6645a0581f MXS-1196: Add support for [SHOW] CREATE SEQUENCE 2017-06-28 21:33:04 +02:00
Johan Wikman
7c1afe5d2c MXS-1196: Not all preparable stmts can be parsed
But the out arguments of ...get_[field|function]_infos must
be sensible and the functions must not crash.
2017-06-28 21:33:04 +02:00
Johan Wikman
ee54f3ac61 MXS-1196: Hide implicit translations
The embedded library, when used in Oracle mode, reports the use of
"concat" as "concat_operator_oracle" and the use of "decode" as "case.
2017-06-28 21:33:04 +02:00
Johan Wikman
32d4a6a8c7 MXS-1196: Oracle mode needs to be turned on repeatedly
Seems it not sufficient to turn it on when the qc module is loaded.
2017-06-28 21:33:04 +02:00
Johan Wikman
e0c78d4242 MXS-1196: Qc arguments are separated by ",", not by ";" 2017-06-28 21:33:04 +02:00
Johan Wikman
53dfa818e3 MXS-1196: Make MODE_ORACLE optional
Turned on by providing an argument when loading the query classifier.
2017-06-28 21:33:04 +02:00
Johan Wikman
518f7e81ca MXS-1196: Handle preparable statements when db is 10.3 2017-06-28 21:33:04 +02:00
Johan Wikman
9ae3ab522d MXS-1196: Turn on Oracle compatibility 2017-06-28 21:33:04 +02:00
Johan Wikman
13fad9933c MXS-1196: Make qc_mysqlembedded 10.3 compatible.
- Strings no longer null-terminated but pointer + length.
- Preparable statements NOT yet handled.
2017-06-28 21:33:04 +02:00
Johan Wikman
b191e6ecda MXS-1196: qc_mysqlembedded will not always claim a stmt was parsed
When developing the oracle related parser extensions, it makes
things simpler if also qc_mysqlembedded properly reports when
it cannot parse a statement.

Note, although this change is marked for 2.1, it will not be
merged into the first 2.1 GA release.
2017-06-28 21:33:04 +02:00
Johan Wikman
43ab0f036e MXS-1196: Do not parse EXPLAIN statements
EXPLAIN statements are no longer parsed completely as doing so makes
it hard to modify the grammar for the needs or Oracle SQL.

Consequently, for an EXPLAIN statement you now bascially only get the
type and the operation (the newly added QUERY_OP_EXPLAIN and QUERY_OP_SHOW).
The other information is not interesting and is related to
information_schema and similar tables.
2017-06-28 21:33:04 +02:00
Markus Mäkelä
65df87d801 Update query operation enum and add EXECUTE
Changed the query operation enum to contain implicit enum values instead
of providing. The operation was never used as a bitmask so it is pointless
to declare them as such.

Added the EXECUTE type to the enum and used it in qc_sqlite and
qc_mysqlembedded.
2017-06-22 10:40:18 +03:00
Johan Wikman
dcfe118457 MXS-1249: Qc, the server version is passed as a single integer
To be compatible with how the version is managed elsewhere.
2017-06-21 13:28:59 +03:00
Johan Wikman
1034cc51be MXS-1249: Qc, allow setting the server version
In the case of qc_sqlite, the server version may affect how statements
are parsed.
2017-06-21 13:28:59 +03:00
Markus Mäkelä
7bd05d4581 Merge branch '2.1' into develop 2017-03-22 15:20:21 +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
Esa Korhonen
6e38276a20 Rename files, removing "gw"-prefix
Also gwdirs.h.in -> paths.h.in
2017-01-20 12:55:52 +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
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