566 Commits

Author SHA1 Message Date
Johan Wikman
e64b034334 MXS-2248 Add change that fixes the problem
Any kind of expression is legal after INTERVAL.
2019-01-09 09:11:49 +02:00
Johan Wikman
a456168fd0 MXS-2248 Add test that reveals problem 2019-01-09 09:11:49 +02:00
Johan Wikman
2895f361d9 MXS-2242 Add change that fixes the problem
A whole slew of missing builtin functions were added, not just the
ones directly relevant for MXS-2242.
2019-01-08 15:55:41 +02:00
Johan Wikman
f94ddadc18 MXS-2242 Add test that reveals problem 2019-01-08 15:55:41 +02:00
Johan Wikman
87d2a45b20 MXS-2207 Fix the problem in qc_mysqlembedded 2018-12-03 16:03:51 +02:00
Johan Wikman
964180804c MXS-2207 Add test that reveals problem
With qc_mysqlembedded statements like

    SET STATEMENT ... FOR stmt;

are always classified as READ, although their type should be
that of stmt.
2018-12-03 15:59:43 +02: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
Johan Wikman
743daa5755 MXS-2043 Create test that exposes problem
A statement like

    SELECT a FROM tbl FOR UPDATE;

should be classified like QUERY_TYPE_WRITE so as to be sent
to master.
2018-09-27 10:17:47 +03:00
Johan Wikman
254084fc5e MXS-1935 Accept "PREPARE name FROM @var" 2018-06-21 12:51:47 +03:00
Johan Wikman
457d74f6b4 MXS-1935 Add test that exposes problem
"PREPARE a FROM @var" is not classified.
2018-06-21 12:51:47 +03:00
Johan Wikman
45bda0f72e MXS-1936 Make qc_mysqlembedded compatible with qc_sqlite
qc_mysqlembedded must also be updated to handle the new type
QUERY_TYPE_DEALLOC_PREPARE. Some adjustements were also needed
elsewhere.
2018-06-21 12:51:47 +03:00
Johan Wikman
d9100278b0 MXS-1719 Update qc test parser
The recent change to the qc_sqlite parser also requires some
modifications to the parser used for reading .test-files.
2018-06-12 17:35:49 +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
001ae8e29a MXS-1874 Handle SET STATEMENT ... FOR ...
The SET STATEMENT ... FOR part can be ignored and the type
of the statement be whatever the type of the part following
FOR is.
2018-05-18 12:35:44 +03:00
Johan Wikman
b12f037b24 MXS-1874 Fix leak in qc_mysqlembedded 2018-05-18 12:35:44 +03:00
Johan Wikman
f665125f1c MXS-1874 Add test that reveals problem 2018-05-18 12:35:44 +03:00
Johan Wikman
9cf44b3092 MXS-1829 Recognise PREVIOUS in addition to NEXT
Earlier only "SELECT NEXT VALUE FOR SEQ" was parsed
properly, while "SELECT PREVIOUS VALUE FOR SEQ" was not.
Now the latter statement is also parsed properly.
2018-04-26 13:14:23 +03:00
Johan Wikman
b2cc9e5107 MXS-1829 Add test that reveals problem 2018-04-26 12:44:30 +03:00
Markus Mäkelä
d67320e06a
Fix more GCC 8 build failures
Fixed string truncation warnings by reducing max parameter lengths by one
where applicable. The binlogrouter filename lengths are slightly different
so using memcpy to work around the warnings is an adequate "solution"
until the root of the problem is solved.

Removed unnecessary CMake policy settings from qc_sqlite. Adding a
self-dependency on the source file of an external project has no effect
and only caused warnings to be logged.
2018-04-23 14:02:54 +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
94af85b948 MXS-1787 Add test that exposes problem 2018-04-13 13:50:28 +03:00
Johan Wikman
0e3874781f Fix merge breakage 2018-03-21 14:20:54 +02:00
Johan Wikman
a996ea58ef Merge branch '2.1' into 2.2 2018-03-21 13:27:51 +02:00
Johan Wikman
041b775150 MXS-1730 Add change that fixes the problem
ENGINE is a keyword but not a reserved word, so it must
silently convert into an identifier if it is used in a
context where it cannot be used as a keyword.
2018-03-21 13:25:06 +02:00
Johan Wikman
5be9a8d7f8 MXS-1730 Add test-case that reveals the problem 2018-03-21 13:25:06 +02:00
Johan Wikman
39d3c42c94 Merge branch '2.1' into 2.2 2018-03-01 17:52:42 +02:00
Johan Wikman
0c206ff428 MXS-1688 Handle ...INTERVAL N <unit>
"INTERVAL N <unit>" is now handled as an expression in itself and
as asuch will cause both statements such as

  "SELECT '2008-12-31 23:59:59' + INTERVAL 1 SECOND;"

and

  "select id from db2.t1 where DATE_ADD("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";"

to be handled correctly. The compare test program contains some
heuristic checking, as the the embedded parser will in all cases
report date manipulation as the use of the add_date_interval()
function.
2018-03-01 17:39:03 +02:00
Johan Wikman
b7cc793c40 MXS-1688 Add test that reveals DATE_ADD problem 2018-03-01 17:39:03 +02: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
Johan Wikman
cd1604f915 Merge branch '2.0' into 2.1 2018-02-12 13:44:51 +02:00
Johan Wikman
9b03cf46d1 qc_sqlite and qc_mysqlembedded marked as GA 2018-02-12 13:40:26 +02:00
Johan Wikman
7f045beb59 Fix include conflict in qc_mysqlembedded
qc_mysqlembedded must include the headers from the embedded
library and not from Connector-C.

So, it must be ensured the embedded library include directories
are first.
2018-02-08 12:44:30 +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
ef1ec2e524 MXS-1591 Mark GET_LOCK(...) et.al. as WRITE
The follwing statements

    SELECT GET_LOCK('lock1',10);
    SELECT IS_FREE_LOCK('lock1');
    SELECT IS_USED_LOCK('lock1');
    SELECT RELEASE_LOCK('lock1');

are now classified as QUERY_TYPE_READ|QUERY_TYPE_WRITE. That will
make cooperative locking work if these functions are used inside
non-read-only transactions and outside transanctions.
2018-01-29 15:25:21 +02:00
Johan Wikman
f129dd56be MXS-1595 Rename mysqlclient to mariadbclient
Documentation update will follow.
2018-01-05 10:01:50 +02:00
Johan Wikman
c31881914b MXS-1584 Correctly classify "SELECT NEXT VALUE FOR seq" 2018-01-04 10:11:19 +02:00
Markus Mäkelä
8b2aa52384 Merge branch '2.1' into 2.2 2017-12-29 08:42:49 +02:00
Johan Wikman
c6e0d1f33c Fix canonizer test programs 2017-12-27 15:34:18 +02:00
Johan Wikman
1908faf150 MXS-1527 Add test case 2017-12-27 14:14:51 +02:00
Johan Wikman
dfc7b1713a Merge branch '2.1' into 2.2 2017-12-27 11:31:27 +02:00
Johan Wikman
ba9b4a3bf6 MXS-1527 Do not consider sysvars to be updated in SELECT
A statement like

    select if(@@hostname='box02','prod_mariadb02','n');

does not modify @@hostname. Hence the type mask should be
QUERY_TYPE_READ|QUERY_TYPE_SYSVAR_READ and NOT
QUERY_TYPE_READ|QUERY_TYPE_GSYSVAR_WRITE.
2017-12-27 11:09:36 +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
Johan Wikman
8ef8343f5c MXS-1391 Parse CREATE OR REPLACE 2017-09-25 14:24:42 +03:00
Johan Wikman
621b66ab13 Thread initialization added
Also the main thread must now explicitly be initialized.
2017-09-25 14:04:03 +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