felipebz / zpa

Parser and static code analysis tool for PL/SQL and Oracle SQL.
https://zpa.felipebz.com
GNU Lesser General Public License v3.0
211 stars 77 forks source link

COMPLETE and few other keywords are not a reserved #157

Closed mcpiroman closed 2 years ago

mcpiroman commented 2 years ago

It is marked as reserved in PlSqlKeyword.kt but, at least on 19c, it is not:

image

Therefore parser throws at this valid code:

DECLARE
     PROCEDURE COMPLETE(x NUMBER) IS
     BEGIN
            NULL;
     END;

BEGIN
     COMPLETE(1);
END;

Edit: I have found this is also the case for these keywords: PCTUSED, INCREMENT, TABLESPACE, SOME, INITRANS

felipebz commented 2 years ago

Thanks, @mcpiroman.

I reclassified the list of keywords using the v$reserved_words from 21c and the keywords you mentioned will be accepted as valid identifiers.

mcpiroman commented 2 years ago

Thanks!

So actually, I took the list of keywords that were marked as reserved and intersected them with v$reserved_words that are RESERVED = 'N', which theoretically gives the list of keywords that should be undeclared as reserved. However, as I tested, only some of them (i.e. COMPLETE , PCTUSED, INCREMENT, TABLESPACE, SOME, INITRANS) can be used to name a procedure - although v$reserved_words shows no distinction between them and the others.

So I suggest that, unless investigated, using v$reserved_words alone may not be fully correct. Prominently, it reports many keywords like IF or DECLARE as completely not reserved, while you can't use them as identifiers (unless I miss something).