#
# This file contains statements qc_sqlite is known not to parse.
#

(SELECT a, b AS c FROM t1) ORDER BY c+1;
# Problem: SELECT in parenthesis.

SELECT 1 FROM t2 WHERE pk > ANY (SELECT 1 FROM t2);
# Problem: The second SELECT.

SELECT table3 .`date_key` field1
  FROM
    B table1 LEFT JOIN B table3 JOIN
      (BB table6 JOIN A table7 ON table6 .`varchar_nokey`)
       ON table6 .`int_nokey` ON table6 .`date_key`
  WHERE  NOT ( table1 .`varchar_key`  AND table7 .`pk`) GROUP  BY field1;
# Problem: Fails to parse some ON.

SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7));
# REMOVE: expr(A) ::= LP(B) expr(X) RP(E). {A.pExpr = X.pExpr; spanSet(&A,&B,&E);}
# REMOVE: expr(A) ::= LP expr(X) COMMA(OP) expr(Y) RP. {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
# ADD   : expr(A) ::= LP exprlist RP. { ... }

insert into t1 values (2, 2) on duplicate key update data= data + 10;
# Problem: warning: [qc_sqlite] Statement was only partially parsed (Sqlite3 error: SQL logic error
#          or missing database, near "on": syntax error): "insert into t1 values (2, 2) on duplicate
#          key update data= data + 10;"

SET @`a b`='hello';
# warning: qc_sqlite: Statement was classified only based on keywords
# (Sqlite3 error: SQL logic error or missing database, unrecognized token: "@"): "set @=4"
#
# sqlite3GetToken needs to be modified to accept a quoted variable name.

INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
# warning: [qc_sqlite] Statement was only partially parsed
# (Sqlite3 error: SQL logic error or missing database, near "ON": syntax error):
# "INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a)"

PREPARE stmt FROM 'UPDATE t2 AS A NATURAL JOIN v1 B SET B.f1 = 1';
# warning: [qc_sqlite] Statement was classified only based on keywords
# (Sqlite3 error: SQL logic error or missing database, near "SET": syntax error):
# "UPDATE t2 AS A NATURAL JOIN v1 B SET B.f1 = 1"

SELECT LENGTH(_utf8 0xC39F), LENGTH(CHAR(14844588 USING utf8));
# warning: [qc_sqlite] Statement was classified only based on keywords
# (Sqlite3 error: SQL logic error or missing database, near "0xC39F": syntax error):
# "SELECT LENGTH(_utf8 0xC39F), LENGTH(CHAR(14844588 USING utf8));"

SELECT t.f FROM d.t;
# qc_get_field_info        : ERR: d.t.f(QC_USED_IN_SELECT) != t.f(QC_USED_IN_SELECT)
# Table names need to be collected in a more intelligent fashion to be able
# to do that.
select t.c,t1.b from t,mysqltest.t1 where t.c=t1.a;
with t as (select c from mysqltest.t2 where c < 2) select t.c,t1.b from t,mysqltest.t1 where t.c=t1.a;

#MXS qc_sqlite cannot parse this
#MXS qc_parse                 : INF: QC_QUERY_PARSED != QC_QUERY_TOKENIZED
set statement standard_compliant_cte=0 for select 1;

#MXS qc_sqlite cannot parse this
#MXS qc_parse                 : INF: QC_QUERY_PARSED != QC_QUERY_PARTIALLY_PARSED
create table my_ancestors
(
with recursive
ancestor_ids (id)
as
(
  select father from folks where name = 'Me'
  union
  select mother from folks where name = 'Me'
  union
  select father from folks, ancestor_ids a  where folks.id = a.id
  union
  select mother from folks, ancestor_ids a  where folks.id = a.id
)
select p.* from folks as p, ancestor_ids as a where p.id = a.id
);

#MXS qc_sqlite cannot parse this
#MXS qc_parse                 : INF: QC_QUERY_PARSED != QC_QUERY_INVALID
analyze format=json 
with recursive src(counter) as 
(select 1 
 union 
 select counter+1 from src where counter<10
) select * from src;

#MXS qc_sqlite
#MXS Statement was classified only based on keywords (Sqlite3 error: SQL logic
#MXS error or missing database, near "(": syntax error): "create view win_view
#MXS as (select a, min(a) over () from t1 where a = 1);"
create view win_view
as (select a, min(a) over () from t1 where a = 1);

select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
# qc_get_function_info     : ERR: =()[QC_USED_IN_WHERE] like(t2.fld3)[QC_USED_IN_WHERE] != =()[QC_USED_IN_WHERE] like(fld3)[QC_USED_IN_WHERE]
# qc_sqlite is not capable of amending a field name with the table name, in cases
# where there is only table. However, neither is qc_mysqlembedded always either.
# E.g. "select a from t where length(a) = 5" results in just a.

#MXS qc_sqlite
#MXS qc_get_function_info     : ERR: >(a, b)[QC_USED_IN_WHERE] avg(a)[QC_USED_IN_SUBSELECT|QC_USED_IN_WHERE] != >(a)[QC_USED_IN_WHERE] avg(a)[QC_USED_IN_SUBSELECT|QC_USED_IN_WHERE]
CREATE VIEW v1 AS SELECT a,1 as b FROM t1 WHERE a>(SELECT AVG(a) FROM t1) AND b>(SELECT 1);

#MXS qc_sqlite
#MXS qc_get_function_info     : ERR: =(t2.fld3) != =(fld3)
select t2.fld3 from t2 where fld3 = 'honeysuckle';
