67 Commits

Author SHA1 Message Date
Johan Wikman
7b001994b4 MXS-1978 Change qc_sqlite behaviour and update test
A statement like

  SELECT ... INTO OUTFILE|DUMPFILE ...

is now classified as a QUERY_TYPE_WRITE, instead of as
QUERY_TYPE_GSYSVAR_WRITE so that it will be sent only to the
master.
2018-11-01 11:24:44 +02:00
Markus Mäkelä
75ea1b6ea1
Fix formatting of new(std::nothrow)
The code previously formatted everything as `new( std::nothrow)`.
2018-10-04 21:50:44 +03:00
Johan Wikman
07e407945b Change ss_dassert -> mxb_assert
Caused by merge from 2.2.
2018-09-27 12:56:36 +03:00
Markus Mäkelä
66227301aa Merge branch '2.2' into develop 2018-09-27 11:47:32 +03:00
Johan Wikman
2aca6226d9 MXS-2043 Classify SELECT ... FOR UPDATE as QUERY_TYPE_WRITE
SELECT...FOR UPDATE locks the rows for update, but only if
autocommit==0 or a transaction is active, so in principle even if
it were classified as READ it'd still be sent to master when it
actually matters.

However, even if autocommit==1 and/or no transaction is active, a
slave in read only mode will reject the statement if the user is
subject to the read only restriction (a user with super privileges
is not), which might be considered a server bug. By classifying the
statement as a write, it'll be sent to master and always succeed.
2018-09-27 10:17:47 +03:00
Markus Mäkelä
71ffef5708
Partially revert 4ba011266843857bbd3201e5b925a47e88e1808f
Add back leading operator enforcement.
2018-09-20 15:57:30 +03:00
Markus Mäkelä
d11c78ad80
Format all sources with Uncrustify
Formatted all sources and manually tuned some files to make the code look
neater.
2018-09-10 13:22:49 +03:00
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +03:00
Johan Wikman
aaad63ee5e MXS-2008 Move content of maxscale/platform.h to maxbase/cdefs.h
No good reason for keeping that platform adjustments anywhere
else but in cdefs.h.
2018-08-20 11:15:14 +03:00
Johan Wikman
cf0aeed516 MXS-2014 Rename log_manager.h to log.h
There's nothing resembling a manager anymore.
2018-08-17 10:59:37 +03:00
Johan Wikman
9a8bb95be6 MXS-2014 Rename mxs_log_priority_is_enabled
- Renamed to mxs_log_is_priority_enabled
- That function instead of the macro is now consistently used
2018-08-16 09:59:43 +03:00
Markus Mäkelä
c1f930d23d
Fix query classifier initialization data race
The initialization code does some modification to the global code
(something about a page cache) and causes warnings with TSAN.
2018-08-13 10:28:02 +03:00
Johan Wikman
a044929661 MXS-1624 Allow the closing of an info object
If an info object can be dupped, it must also be possible to
close it.
2018-07-06 12:12:31 +03:00
Johan Wikman
295bae5673 MXS-1624 Implement qc_dup
Only for qc_sqlite.

After a second look qc_mysqlembedded will not support dupping
the statement information. Without additional changes, simply stashing
an info object away, parsing another new GWBUF, deleting that and
then using the stashed away info object will not work; the THD object
will be corrupted. As qc_mysqlembedded is _only_ used for verifying the
sqlite-based parser this is not important anyway.
2018-07-06 12:12:31 +03:00
Johan Wikman
4e168f36f7 MXS-1624 Make the QC info object explicit
The query classifier stores information about the statement carried
by a GWBUF in the GWBUF itself. We need to be able to store that
object out side the lifetime of the GWBUF. So, we require that a
query classifier is capable of duplicating references to that object.
2018-07-06 12:12:31 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Johan Wikman
254084fc5e MXS-1935 Accept "PREPARE name FROM @var" 2018-06-21 12:51:47 +03:00
Johan Wikman
776f199d01 MXS-1719 Treat # comments the same way as -- comments
sqlite does not treat # as the start of a to-end-of-line
comment. It cannot trivially be treated as such because at
startup sqlite parses statements containing the #-character.
Thus, only after sqlite has been initialized can it be treated
the same way as --.
2018-06-12 17:35:49 +03:00
dapeng huang
cd136b11a7 MXS-1891: dealloc named prepare should route to all (#174)
* dealloc named prepare route to all

* add newline

* erase from ps manager too

* little refactor
2018-06-12 10:45:11 +03:00
Markus Mäkelä
cddcc6d7d5
MXS-1896: Distinct LOAD DATA LOCAL INFILE from LOAD DATA INFILE
The two operations return different types of results and need to be
treated differently in order for them to be handled correctly in 2.2.

This fixes the unexpected internal state errors that happened in all 2.2
versions due to a wrong assumption made by readwritesplit. This fix is not
necessary for newer versions as the LOAD DATA LOCAL INFILE processing is
done with a simpler, and more robust, method.
2018-06-04 15:17:48 +03:00
Johan Wikman
3d8d2beaaa MXS-1787 Provide alias map when parsing an expression list
A statement like "CALL p1((SELECT f1()), ?);" needs an collection
for storing aliases when being parsed.
2018-04-13 13:50:28 +03:00
Johan Wikman
9b36ba5e0a MXS-1677: Don't assume all queries are in text form
After a temporary table is created, readwritesplit will check whether a
query drops or targets that temporary table. The check for query type was
missing from the table dropping part of the code. The temporary table read
part was checking that the query is a text form query.

Added a debug assertion to the query parsing function in qc_sqlite to
catch this type of interface misuse.
2018-02-24 17:02:51 +02:00
Markus Mäkelä
bce5627ee3
Fix out-of-bounds read on invalid query message
When the parsing of a query failed, the message would treat the parameter
as a string as the printf format was `%*s` instead of `%.*s`.

The manpage of printf states the following about the precision specifier:

    ... or the maximum number of characters to be printed from a string
        for `s` and `S` conversions.

This means that the field length specifier is somewhat meaningless for
strings.
2018-02-16 20:49:27 +02:00
Johan Wikman
5c10d0ae92 Merge branch '2.1' into 2.2 2018-02-12 14:00:08 +02:00
Markus Mäkelä
4089b6b6fd
MXS-1647: Detect API version mismatch
If the API versions do not match, MaxScale will treat this as an
error. The API versioning would allow backwards compatible changes but the
functionality to handle that is not implemented in MaxScale.

Updated API versions based on changes done to module APIs in 2.2.
2018-02-06 14:51:07 +02:00
Johan Wikman
c31881914b MXS-1584 Correctly classify "SELECT NEXT VALUE FOR seq" 2018-01-04 10:11:19 +02:00
Johan Wikman
dfc7b1713a Merge branch '2.1' into 2.2 2017-12-27 11:31:27 +02:00
Johan Wikman
1c58df8307 qc_sqlite: Copy database if tables are copied
To be able to correctly report the fullname of a table we must
copy the database, if it is available.
2017-11-20 15:15:58 +02:00
Johan Wikman
a51d23ded0 Bail out earlier when walking parse tree
No point walking the parse tree, if no information will be
collected.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
eab7b7e2a3 Remove call to qc_sqlite_thread_end in qc_sqlite_process_end
Since the thread initialization was removed from the process
initialization function, the thread finish function should not be called
in the process finish function.
2017-09-17 11:55:12 +03:00
Markus Mäkelä
d00c5b2838 Move thread initialization into Worker::run
By moving the initialization into Worker::run, all threads, including the
main thread, are properly initialized. This was not noticed before as
qc_sqlite initialized the main thread in the process initialization
callback.
2017-09-15 18:08:49 +03:00
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
Markus Mäkelä
3676dcebb1 MXS-1398: Clean up mysql.h header
Cleaned up the MaxScale version of the mysql.h header by removing all
unused includes. This revealed a large amount of dependencies on these
removed includes in other files which needed to be fixed.

Also sorted all includes in changed files by type and alphabetical
order. Removed explicit revision history from modified files.
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
19407a09f8 Remove unnecessary assert
We are only interested in asterisks and column names. Everything
else - integers, floating point numbers, strings, etc. - is of
no interest and not an error.
2017-09-07 13:46:44 +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
83ae19cd68 MXS-1364 Collect field usage of CASE and BETWEEN 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
de9c1ef109 MXS-1364 Collect information of arguments to operators 2017-08-22 11:01:50 +03:00
Johan Wikman
feebc85d98 MXS-1364 Report true name and not alias name
With this change, in the case of a statement like

  select a as b from t where length(b) = 1

it will be reported that length accesses a and not b.
2017-08-22 11:01:50 +03:00
Johan Wikman
6812ae51fc MXS-1364 Collect function field usage
In qc_sqlite the fields that a particular function refers to are now
collected and reported. Qc_mysqlembedded needs to be updated accordingly
and also the compare utility. For subsequent commits.
2017-08-22 11:01:50 +03:00
Johan Wikman
65bf471bd7 MXS-1364 Factor out field name extraction
Will be used when function field usage is collected.
2017-08-22 11:01:50 +03:00
Johan Wikman
8bd234a442 MXS-1337 Manual array manipulation replaced with std::vector 2017-08-17 09:21:52 +03:00
Johan Wikman
de7004cb95 Merge branch '2.1' into develop 2017-08-15 10:31:30 +03:00
Johan Wikman
c662bea983 MXS-1359 Turn recursion into iteration
In case of very large compound selects or an INSERT with many
values, qc_sqlite could run out of stack space. To deal with
that, the critical recursion is turned into an iteration.
2017-08-14 13:29:19 +03:00
Johan Wikman
4dc41509af MXS-1337 Move more functions to QcSqliteInfo 2017-08-10 16:09:58 +03:00
Johan Wikman
8ce5147d39 MXS-1337 Moved functions to QcSqliteInfo 2017-08-10 15:57:48 +03:00
Johan Wikman
54a75a1752 MXS-1337 Move update_field_infos_from[sub]select to QcSqliteInfo 2017-08-10 15:45:25 +03:00
Johan Wikman
4eeff705ee MXS-1307 Catch "union all" selects 2017-08-10 14:45:27 +03:00
Johan Wikman
878bbe4a98 MXS-1307 Aliases must be stored hierarchically
Alias handling must be made so that in a subselect, aliases created
in an outer select are available, but aliases created in another
subselect are not.
2017-08-10 11:43:09 +03:00