SQLite Forum

Bug In EXPLAIN Syntax Diagram
Login

Bug In EXPLAIN Syntax Diagram

(1) By Lawrence D'Oliveiro (ldo289) on 2021-04-16 00:24:08 [link] [source]

There is an ambiguity in the syntax diagram for EXPLAIN: it shows the EXPLAIN keyword as optional. But if you leave this out, then the syntax becomes indistinguishable from the syntax for the various statements being EXPLAINed.

The fix is to remove the line bypassing the EXPLAIN keyword, and make it mandatory.

(2.1) By Larry Brasfield (larrybr) on 2021-04-16 01:59:16 edited from 2.0 in reply to 1 [source]

I can understand your position on this, but I cannot agree that you have identified a bug or even a nit, and I see no need for a fix. This is because I consider that syntax diagram to represent "the set of ways that one can use the EXPLAIN keyword". Among those ways is "not use it at all". The presence of the bypass makes very clear that its syntax is nothing more than prefixing EXPLAIN onto other legitimate SQL statements not already so prefixed.

I think you must want a syntax diagram for "the set of SQL statements that may be called 'EXPLAIN'-prefixed statements." For that, the bypass should vanish.

(Amended to add:)

If you look at the link, "sql-stmt:", or click it, you will see that the railroad chart is depicting a high-level syntactic element, one which can become a member of a "sql-stmt-list". The "EXPLAIN" page is simply focusing on the effect of EXPLAIN and EXPLAIN QUERY PLAN. There is no need to create a separate syntactic element, (which might be called "unexplained-sql-stmt"), merely to aid conceptualization of the grammar or its meanings.

The argument for eliminating the separate and redundant sql-stmt page is, I think, stronger than the argument for introducing (new) unexplained-sql-stmt and explained-sql-stmt grammar non-terminals.