Commit Graph

207 Commits

Author SHA1 Message Date
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
94b0b082e4 MXS-1275: Make sql_mode a property of the current context
The sql mode is now a property of the info object used for storing
parsing related information. It is initialized with the value of the
sql mode qc_sqlite was initialized with.

This will be further changed so that the mode can be adjusted at
runtime so that the sql mode can be the property of a session. That
is, once set it will affect all future parsing for that session.
2017-06-28 21:33:04 +02:00
9431aded48 MXS-1196: Do not translate keywords that arrive first 2017-06-28 21:33:04 +02:00
e9ad1ea7bb MXS-1196: Recognize SQL%ROWCOUNT
Special handling is needed as otherwise "SQL%ROWCOUNT" does not
appear as a function but as the function "%" and the fields "SQL"
and "ROWCOUNT".
2017-06-28 21:33:04 +02:00
8b6fc49dc1 MXS-1196: Turn certain keywords into ids 2017-06-28 21:33:04 +02:00
77f05b49d0 MXS-1196: Handle top-level FOR loops
The content is ignored and the type is QUERY_TYPE_WRITE.
2017-06-28 21:33:04 +02:00
f9eef5ee3b MXS-1196: Classify SHOW as QUERY_TYPE_READ 2017-06-28 21:33:04 +02:00
49c9c60c63 MXS-1196: Parse arguments to CALL. 2017-06-28 21:33:04 +02:00
2a89a4de45 MXS-1196: Handle DECLARE
DECLARE can also begin an anonymous block in PL/SQL.
2017-06-28 21:33:04 +02:00
bf54a9bf9f MXS-1196: Handle anonymous blocks
In PL/SQL BEGIN starts a block (i.e. not a transaction). Whenever we
see that, we assume it is such a block, consume all input and set the
type to QUERY_TYPE_WRITE to ensure it goes to master.
2017-06-28 21:33:04 +02:00
573a2c6160 MXS-1196: Accept ".tbl.col" columns names 2017-06-28 21:33:04 +02:00
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
61b265467b MXS-1196: Add support for DROP SEQUENCE 2017-06-28 21:33:04 +02:00
6645a0581f MXS-1196: Add support for [SHOW] CREATE SEQUENCE 2017-06-28 21:33:04 +02:00
116e2cd974 MXS-1196: Handle Oracle EXECUTE and PREPARE statements
- EXECUTE IMMEDIATE ...
- PREPARE stmt FROM dynamic string
2017-06-28 21:33:04 +02:00
66e027febd MXS-1196: Accept EXECUTE ... USING <INTEGER> 2017-06-28 21:33:04 +02:00
471fa01f40 MXS-1196: A single '?' is not a user variable 2017-06-28 21:33:04 +02:00
a5637a311c MXS-1196: Recognize builtin Oracle functions 2017-06-28 21:33:04 +02:00
1d2ca5cde7 MXS-1196: Translate NVL into IFNULL 2017-06-28 21:33:04 +02:00
c46f16041e MXS-1196: Ignore the DUAL table
The embedded parser ignores the DUAL table so it's better if
qc_sqlite does that as well.
2017-06-28 21:33:04 +02:00
e6f8432e33 MXS-1196: Accept :'a' as placeholder variables
Oracle SQL accepts statements like

  PREPARE stmt FROM 'INSERT INTO t1 VALUES (:a,:b)';
  PREPARE stmt FROM 'INSERT INTO t1 VALUES (:"a",:"b")';

That is, the variable may be surrounded by quotes.
2017-06-28 21:33:04 +02:00
e80a378213 MXS-1196: Add 'sql_mode' argument to qc_sqlite 2017-06-28 21:33:04 +02:00
8c1d53192c MXS-1196: Handle REPLACE explicitly
Allowing REPLACE to implicitly decay into an identifier does not
work.
2017-06-28 21:33:04 +02:00
e7ef6c855f MXS-1196: Register if variables are used in function calls 2017-06-28 21:33:04 +02:00
593070b865 MXS-1196: Tentative commit 2017-06-28 21:33:04 +02:00
0de99dc686 MXS-1196: Use a syntactically correct stmt for init 2017-06-28 21:33:04 +02:00
422ea7f912 MXS-1196: In 10.3 a unary minus is not a function 2017-06-28 21:33:04 +02:00
0c51dd75fe MXS-1196: Pre 10.3 or 10.3 mode selected with option
The embedded parser of 10.3 parses things slightly differently than
how the embedded parser of earlier releases does. When comparing the
output of different query classifiers you need to be able to specify
with what qc_sqlite should be compatible with.
2017-06-28 21:33:04 +02:00
62a64cba31 MXS-1196: Report user var read when prepared statements 2017-06-28 21:33:04 +02:00
da0900786a MXS-1196: Accept UNIQUE as synonym for DISTINCT 2017-06-28 21:33:04 +02:00
298d5642f6 MXS-1196: Accept top-level variable assignments
In Oracle you can write

    set autocommit=1
or
    autocommit:=1
2017-06-28 21:33:04 +02:00
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
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
43895b6f28 MXS-1249: Add json functions
The json function are treated as read-only when the server version
is >= 10.2.3.
https://mariadb.com/kb/en/mariadb/json-functions/
2017-06-21 13:28:59 +03:00
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
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
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
7bd05d4581 Merge branch '2.1' into develop 2017-03-22 15:20:21 +02:00
d70dad260a Implement collecting behaviour in qc_sqlite
By default, only the essentials - the type and the operation - of
a statement will be collected and only if fields, tables, functions
and databases are explicitly asked for, will they be collected.
However, a statement will be parsed at most twice; if parsing is
needed a second time then all information will be collected.

If it is known that some particular information is needed, then
qc_parse() can be called explicitly to ensure it is collected
at first parsing.
2017-03-22 11:09:36 +02:00
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
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
a925be4e2a Turn off error in qc_sqlite built
GCC on CentOS6 thinks there is an array-bounds error in the sqlite
code. As that code is outside our hands, it is easiest to instruct
GCC not to treat it as an error.
2017-03-08 17:18:06 +02:00
07ae37f179 Update commit/rollback rules
Now that WORK is recognized as a parser token, the BEGIN and regular
COMMIT and ROLLBACK rules should use them as well.
2017-03-07 11:49:30 +02:00
a6ae60c808 Merge branch '2.0' into 2.1 2017-03-07 11:45:49 +02:00
dd07feda07 MXS-1025: Parse SAVEPOINT statements
The various forms of the SAVEPOINT/RELEASE/ROLLBACK statements are now
fully parsed.
2017-03-07 08:44:21 +02:00
d834c1bbdc Compile sqlite explicitly in single thread mode
As every thread has a separate (in-memory) database, i.e. not
just a separate _connection_, sqlite can be compiled in singe-thread
mode, which means that there will be *no* locking.
2017-02-27 10:39:20 +02:00
5648f708af Update license to BSL 1.1 2017-02-14 21:42:28 +02:00
8aa76727d2 Remove explicit long indicator of size defines 2017-01-19 10:42:05 +02:00
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
ded9f668f1 QC: Parse statements in COM_STMT_PREPARE packets 2017-01-18 08:34:53 +02:00