180 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
02b9e0a01d Merge branch '2.1.7' into develop-2.1-merge 2017-09-12 11:08:02 +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
19cc3e67e1 MXS-1395 Allow NAMES to be used as keyword/id
NAMES is a keyword but not a reserved one. So it must be possible
to use it as an identifier as well.
2017-09-07 10:17:04 +03:00
Johan Wikman
7cb3c68d1e MXS-1380 Parse UNIONs completely
Before this change, only db2.t2 was reported as table name for a
select like

    select * from db1.t1 union select * from db2.t2

With this change, db1.t1 and db2.t2 are reported.
2017-08-31 13:27:02 +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
4c100a305e MXS-1364 Simplify grammar rules 2017-08-24 09:58:18 +03:00
Johan Wikman
2d6ac6c682 MXS-1364 Collect columns referred to by group_concat 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
384633fc69 MXS-1247 Add all server window function tests 2017-08-17 09:21:52 +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
4034931013 MXS-1247 Update mkopcodeh.tcl of sqlite3
With sqlite3 3110100, which is used in MaxScale, the the generation
of the used op-codes could sometime generate code that did not define
all opcodes. That resulted then in a compilation error like:

.../sqlite-bld-3110100/sqlite3.c: In function 'sqlite3VdbeExec':
.../sqlite-bld-3110100/sqlite3.c:75427:6: error: 'OP_Real' undeclared
                                          (first use in this function)
 case OP_Real: {            /* same as TK_FLOAT, out2 */
      ^

The reason seems to be that if a particular op-code was not used, the
generation stopped at that point:

    #define OP_Explain       160
    #define OP_NotUsed_161   161

With mkopcodeh.tcl from sqlite3 version 3200000, the generated code
looks like

    #define OP_NotUsed_161   161
    #define OP_Real          162 /* same as TK_FLOAT,
                                    synopsis: r[P2]=P4       */

and the code compiles.

Thus, mkopcodeh.tsl is updated from the newer sqlite3 version.
2017-08-16 10:17:27 +03:00
Johan Wikman
de7004cb95 Merge branch '2.1' into develop 2017-08-15 10:31:30 +03:00
geaaru
3485a32731 Fix compilation errors/warning with gcc-5.4.0 (#137)
Warning are like this:
 error: ‘delimiter’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2017-08-15 09:56:22 +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
Johan Wikman
aeb881afea MXS-1337 Better sqlite3 initialization
The sqlite3 initialization is done a bit more properly now.
It is also ensured that issues are logged at most once, even
if a statement is parsed twice.
2017-08-09 13:21:24 +03:00
Johan Wikman
1d693640c7 MXS-1337 All callbacks now exception safe
No exceptions can now ever escape from the C++ side of qc_sqlite
to sqlite3 (where they would cause havoc).
2017-08-08 15:46:01 +03:00
Johan Wikman
e084c0a464 MXS-1337 Thread initialization is checked by explicit callbacks
When any of the QcSqliteInfo member functions are called, they
can assume that thread initialization has been performed.
2017-08-08 15:46:01 +03:00
Johan Wikman
83a5614d2a MXS-1337 Initialization status moved to thread specific data
The initialization state is thread specific, not QcSqliteInfo
instance specific.
2017-08-08 15:46:01 +03:00