777 Commits

Author SHA1 Message Date
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
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
bea56f40b2 MXS-1364 Disable irrelevant tests that do not pass 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
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
de9c1ef109 MXS-1364 Collect information of arguments to operators 2017-08-22 11:01:50 +03:00
Johan Wikman
597aacb313 MXS-1364 Compare should report function column usage 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
0630410bb2 Remove "unsupported" tests that are no longer unsupported 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
27ef5c3048 MXS-1247 Set the server version explicitly 2017-08-16 12:59:35 +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
9d97902899 MXS-1307 CTE tests pass
There are some issues still
- With recursive CTEs qc_mysqlembedded and qc_sqlite agree upon
  the real columns, but disagree on the CTE related "virtual"
  columns. That's largely irrelevant though.
- qc_sqlite cannot parse "SET STATEMENT var=... FOR stmt",
  but it will be classified as QUERY_TYPE_GSYSVAR_WRITE.
  This is not directly CTE related.
2017-08-10 15:23:42 +03:00
Johan Wikman
4eeff705ee MXS-1307 Catch "union all" selects 2017-08-10 14:45:27 +03:00
Johan Wikman
05bbd9676b MXS-1307 Ignore usage differences for functions
Also in the case of functions, we ignore differences in reported
usage context between qc_mysqlembedded and qc_sqlite.
2017-08-10 12:54:47 +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
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
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