777 Commits

Author SHA1 Message Date
Johan Wikman
c11ffd91c5 MXS-1349 Access right field when picking out preparable stmt
The preparable statement is stored in two fields; in one in full
and in another at most 255 chars.
2017-08-08 15:46:01 +03:00
Johan Wikman
fdb588b866 MXS-1307 Tweak cte tests
The "parser" of compare cannot handle the following:

  prepare stmt1 from "
  with t as (select a from t1 where b >= 'c')
    select * from t2,t where t2.c=t.a;
  ";

That is, that a line *not* terminating the full statement (the
line 'select * from t2,t where t2.c=t.a;' above) ends with a ';'.
Thus, it needs to be changed into e.g.

  prepare stmt1 from "
  with t as (select a from t1 where b >= 'c')
    select * from t2,t where t2.c=t.a;";
2017-08-08 15:46:01 +03:00
Johan Wikman
a02bc3d40b MXS-1348 Treat usage differences as non-fatal
In the context of subselects and CTEs it is somewhat difficult to
make qc_sqlite and qc_mysqlembedded to agree upon in what context
a particular field is used. As that information is not used anywhere,
a usage discrepancy is for now treated as a warning.
2017-08-08 15:46:01 +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
Johan Wikman
5c68494044 MXS-1337: More functions moved into QcSqliteInfo
All callbacks called by sqlite now only access the thread specific
QcSqliteInfo and call the corresponding function on that instance.
This is the first step in making qc_sqlite exception safe from the
point of view of sqlite3.

As the diff is confusing, basically the ONLY thing that has been
done is:

BEFORE:
-------
class QcSqliteInfo
{
    ...
};

static void some_helper(...) { ... }

void mxs_someCallback(...)
{
   QC_TRACE();
   QcSqliteInfo* info = this_thread.pInfo;
   ss_dassert(info);

   info->m_status = ...;
   some_helper(info, ...);
}

AFTER:
------
class QcSqliteInfo
{
    ...
    void some_helper(...) { ... }

    void mxs_someCallback(...)
    {
        m_status = ...;
        some_helper(this, ...);
    }
};

void mxs_someCallback(...)
{
   QC_TRACE();
   QcSqliteInfo* pInfo = this_thread.pInfo;
   ss_dassert(pInfo);

   pInfo->mxs_someCallback(...);
}
2017-08-08 15:46:01 +03:00
Johan Wikman
4f4151bca9 MXS-1340 Report true table and not alias name
With this change, for a statement like

    SELECT t2.a FROM t1 t2;

the affected field is reported as t1.a and not as t2.a, as it
was before.

For a statement like

    SELECT t.f FROM d.t;

qc_mysqlembedded will now return "d.t.f" as the affected field,
while qc_sqlite will still return "t.f" as both implementations did
before. In qc_mysqlembedded's case that is a side-effect of the
alias handling. To get qc_sqlite to return the same (which would
be good), the table names would have to be collected in a smarter
way than they are now.
2017-08-08 15:46:01 +03:00
Johan Wikman
a438ff7c86 MXS-1340 is_sequence_related... functions moved to QcSqliteInfo 2017-08-07 08:31:41 +03:00
Johan Wikman
c29e8b2b9e MXS-1340 Move update_field_info to QcSqliteInfo 2017-08-07 08:31:41 +03:00
Johan Wikman
eecd7a03c5 MXS-1340 Collect alias names
Alias names for tables are now collected, so that the true
table name of a referred to field can be reported. That modification
will be made in a subsequent commit.
2017-08-07 08:31:41 +03:00
Johan Wikman
72c5d1844a MXS-1337 Add variable prefixes
Member variables of QcSqliteInfo now have m_, p, z and n prefixes
as appropriate.
2017-08-03 08:36:25 +03:00
Johan Wikman
7a5e3ede21 MXS-1339 QC: Report each table just once
If a particular table appears in a statement multiple times,
qc_get_table_names will report it as many times as it appears.
Each name should be reported just once. Same applies for
database names.
2017-08-03 08:34:22 +03:00
Markus Mäkelä
92bc3f046e Fix build failures on CentOS 6
Removed superfluous thread_local storage specifier from adminusers.cc and
fixed signed to unsigned integer comparisons in qc_sqlite.cc.
2017-08-02 15:44:45 +03:00
Markus Mäkelä
854c4a1ed3 Add support for non-glibc systems
MaxScale can now be built on systems that use an alternative libc
implementation e.g. musl.
2017-08-02 11:51:55 +03:00
Johan Wikman
542f3b69db MXS-1337 update_names(...) moved to QcSqliteInfo
The update_names() will have to be updated to take a possible alias
name as well. That needs to be tracked inside QcSqliteInfo, so that
when there is a statement like "select t2.a from t1 t2" we report
the field as t1.a and not as t2.a.
2017-08-02 09:11:35 +03:00
Johan Wikman
cfb5a315cf MXS-1337 Some variables renamed 2017-08-02 09:11:35 +03:00
Johan Wikman
19d36d425d MXS-1337 More functionality moved into QcSqliteInfo 2017-08-02 09:11:35 +03:00
Johan Wikman
cb15d90da9 MXS-1337 qc_sqlite info structure now a C++ class
The structure for storing statement information is now a C++ class.
At least initially it will not be turned into a full-fledged class
that would contain all functionality, but the code will be a mishmash
of C and C++.
2017-08-02 09:11:35 +03:00
Johan Wikman
e4f0598743 Convert qc_sqlite.c to C++
MXS-1307 requries some modifications in the query classifier and
making those changes is easier if STL collections are available.
2017-08-01 08:45:03 +03:00
Markus Mäkelä
3eb99139f5 Merge branch '2.1' into develop 2017-07-31 15:57:05 +03:00
Johan Wikman
4985bf9b6e MXS-1328 Mark regexp functions as builtin functions
Regexp functions were not listed among the builtin read-only
functions and consequently any SELECT using one of those was
routed to master.
2017-07-27 09:58:32 +03:00
Johan Wikman
2d59148a9f MXS-1307 Grant statements excluded
MaxScale does not need to fully parse grant statements. Hence
they are commented out from cte_grant.test.
2017-07-27 09:22:19 +03:00
Johan Wikman
f7bd195e9f MXS-1248: Add CTE tests
All cte tests from the server
2017-06-30 13:01:14 +02:00
Johan Wikman
d060320b36 MXS-1248: Further modifications for CTE
- Fields in CTEs are marked as being used in subselects.
- In qc_mysqlembedded all selects must be walked if CTE is present.
- In qc_sqlite unions need special handling.
2017-06-30 12:49:28 +02:00
Johan Wikman
b5d54292a4 Fix merge error 2017-06-30 11:07:00 +02:00
Johan Wikman
7297ae129c MXS-1248: Pointer value alone does not tell validity
The pointer pointing to a recursive select may be non-null even
if it is not valid. The specific boolean must be checked as well.
2017-06-30 11:05:15 +02:00
MassimilianoPinto
2c5aaeff0e Develop Merge
Develop Merge
2017-06-30 10:14:45 +02:00
Johan Wikman
f91df4617a MXS-1248: Add simple cte test 2017-06-30 08:36:19 +02:00
Johan Wikman
84c5aa9934 MXS-1248: Report fields from CTE expressions
Now field and function information of CTE expressions are
collected.
2017-06-30 08:36:19 +02:00
Johan Wikman
48a67eeef2 qc_mysqlembedded: Collect ... WHERE EXISTS ...
Information was not collected from the subselect in a situation
e.g. like

    SELECT ... WHERE NOT EXISTS (SELECT ...)
2017-06-30 08:36:19 +02:00
MassimilianoPinto
cb57e10761 Develop merge
Develop merge
2017-06-29 15:34:22 +02:00
Johan Wikman
6cd6ded3d8 Merge branch '2.1-oracle-compat' into develop-new-merge-oracle 2017-06-29 09:39:55 +02:00
Johan Wikman
f0ddbc5c8f MXS-1258: Remove non-critical failing test-cases
"SELECT LENGTH(_utf8 0xC39F), LENGTH(CHAR(14844588 USING utf8));"

Type and operation collected correctly, but function names are not
2017-06-28 21:36:08 +02:00
Johan Wikman
8128c74341 MXS-1196: Update Oracle tests 2017-06-28 21:36:08 +02:00
Johan Wikman
a690b44919 MXS-1278: Sql mode must be specified explicitly
The default sql mode must now be provided explicitly when the query
classifier is setup. This is in preparation for "sql_mode" becoming
a global configuration parameter of MaxScale.
2017-06-28 21:36:08 +02:00
Johan Wikman
12a291919a MXS-1275: SetSqlModeParser moved under MySQLClient
That's where it belongs as it is only the mysql client protocol that
will use it. It's a bit unfortunate that the qc test program compare
now needs to include a file from a protocol module directory, but
the fact is that the query classifier implementation and the test
programs should actually be *under* the mysql client protocol module.
2017-06-28 21:36:08 +02:00
Johan Wikman
51452ecb3b MXS-1275: No need to be explicit about the sql mode
As statements as "set sql_mode=oracle" are recognized and the
behaviour of the classifiers is configured accordingly, the mode
need not the hardwired.
2017-06-28 21:36:08 +02:00
Johan Wikman
d9448e1550 MXS-1275: Function name mappings need to follow sql_mode 2017-06-28 21:36:08 +02:00
Johan Wikman
a60b6473ed MXS-1275: Check for "set sql_mode=ORACLE" and act accordingly 2017-06-28 21:36:08 +02:00
Johan Wikman
021fe09edb MXS-1275: qc_mysqlembedded, add support for qc_[get|set]_sql_mode 2017-06-28 21:36:08 +02:00
Johan Wikman
368ae65779 MXS-1275: // is not an mysql comment token 2017-06-28 21:36:08 +02:00
Johan Wikman
3084e95772 MXS-1275: Implement qc_[get|set]_sql_mode for qc_sqlite 2017-06-28 21:36:08 +02:00
Johan Wikman
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
Johan Wikman
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
Johan Wikman
cc0c193d2e MXS-1196: Run Oracle test only when built against 10.3 2017-06-28 21:33:04 +02:00
Johan Wikman
d9b4013b69 MXS-1196: Add Oracle tests 2017-06-28 21:33:04 +02:00
Johan Wikman
9431aded48 MXS-1196: Do not translate keywords that arrive first 2017-06-28 21:33:04 +02:00
Johan Wikman
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
Johan Wikman
8b6fc49dc1 MXS-1196: Turn certain keywords into ids 2017-06-28 21:33:04 +02:00