22.03.2021 11:14, Mark Rotteveel wrote:

It turns out that RETURNING is not a reserved word, which allows statements like:

```
SQL> create table returning (returning boolean);
SQL> insert into returning (returning) values (true) returning returning returning;

RETURNING
=========
<true>

SQL> update returning set returning = not returning where returning returning returning returning;

RETURNING
=========
<false>
```

I had hoped to make a very simple parser to detect the presence of a RETURNING clause, but the possibility of having columns and expressions containing RETURNING makes that a lot harder :(. Alternatively, I will just need to ignore this, and for example detect a `UPDATE ... WHERE RETURNING` as having a RETURNING clause.

For context, this would be used in Jaybird to replace a slightly more complicated parser with a third-party dependency I want to get rid of.

Why is RETURNING not a reserved word?

Because it's non-standard. We usually don't introduce new reserved words unless they're standard or cause conflicts in the parser (*).

(*) the second rule was not strictly followed in the past, as btyacc resolves many conflicts automagically


Dmitry


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to