Hi, According to the documentation (Sqlite + standard Ansi), queries that should be supported like : SELECT * FROM A JOIN (B JOIN C ON B.ID = C.ID) ON A.ID = B.ID are still not supported whereas badly formed queries like : SELECT * FROM A JOIN (B JOIN C ON B.ID = C.ID) AS D ON A.ID = D.ID work !
anyone to fix this ? Mathieu -----Message d'origine----- De : sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] De la part de Mathieu TAUZIN Envoyé : lundi 26 mars 2012 15:53 À : sqlite-users@sqlite.org Objet : [sqlite] Parser bug on sub joins when on right side of the join operator Hi, According to their definition (http://sqlite.org/syntaxdiagrams.html#single-source) , Join sources (named single-source) are either : * a table or view with an optional alias and/or with an optional index * a sub query with an optional alias * a sub join (with no alias) In SQLite parser.y source code we can find on line 496 the grammar rule handling those three cases (in the same order) <snippet line='496'> ... seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) indexed_opt(I) on_opt(N) using_opt(U). { A = sqlite3SrcListAppendFromTerm(pParse,X,&Y,&D,&Z,0,N,U); sqlite3SrcListIndexedBy(pParse, A, &I); } seltablist(A) ::= stl_prefix(X) LP select(S) RP as(Z) on_opt(N) using_opt(U). { A = sqlite3SrcListAppendFromTerm(pParse,X,0,0,&Z,S,N,U); } seltablist(A) ::= stl_prefix(X) LP seltablist(F) RP as(Z) on_opt(N) using_opt(U). { if( X==0 && Z.n==0 && N==0 && U==0 ){ A = F; }else{ Select *pSubquery; sqlite3SrcListShiftJoinType(F); pSubquery = sqlite3SelectNew(pParse,0,F,0,0,0,0,0,0,0); A = sqlite3SrcListAppendFromTerm(pParse,X,0,0,&Z,pSubquery,N,U); } } ... </snippet> Case 1 and 2 are handled properly but as you can see the third definition (wich should deal with sub joins) contains mistakes : #1 : It allows an as clause after the parenthesis #2 : on the right of a join operator (else { ... }) it generates a subquery instead of merging F (which is a seltabList, not a sub query) with X into A. I wish I could propose a fix but I have no skills in C/yacc. Hope this will help anyway. Thanks _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users