Hello, On 2018-02-20 23:59, Etienne Sanchez wrote:
Some other DBMS such as Postgres and SQL-Server implement the functions "left" and "right". SQLite does not. But why do I get confusing error messages when I (mistakenly) attempt to use them?To illustrate my point: select foo('abc', 2) Error: no such function: foo select left('abc', 2) Error: near "(": syntax error select right('abc', 2) Error: near "(": syntax error In the 2nd and 3rd cases I would expect a "no such function" error. The "syntax error" messages are slightly misleading, they lead the user to think that he has forgotten a parenthesis or a comma somewhere in the query. As for "left", it's maybe due to the ambiguity with "left join", but then what about "right"? (There is no ambiguity with "right join" since it is not supported.)
Indeed, RIGHT is considered as JOIN_KW (look at ``select.c:sqlite3JoinType()'') even if not supported. Furthermore, JOIN_KW is treated as an identifier, when in an expression: ``NATURAL'', ``LEFT'', ``OUTER'', ``RIGHT'', ``FULL'', ``INNER'', and ``CROSS'' -- all are treated as identifiers. So if you hava a column named ``left'' or ``right'', it will be treated accordingly.
``Treated'' does not mean that they are ``becoming'' identifiers, so you cannot use them as function names: id ``('' [``DISTINCT''|``ALL''] expr [, expr [...]] ``)''.
If you want to achieve a desired effect (i.e. ``no such function'' message), then copy block ``expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP. {...}'' in ``parse.y'' replacing ``id'' with ``JOIN_KW'', otherwise the parser is expecting that an expression contains the sole ``left''/``right'' or a syntax error occurs.
-- best regards Cezary H. Noweta _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

