cockroach
cockroach copied to clipboard
sql: automatic way to ensure new sql keyword is added to `bare_label_keywords` list
Describe the solution you'd like
Adding new keyword could break user queries which use column labels without AS. We added the bare_label_keywords list to allow those keywords to be used as column labels. However, it's easy to forget to add the keyword. We need to an automatic way to validate all newly added keywords are added to this list.
We could auto generate code to validate that, for example we're already doing similar thing when generating this list. The hard part could be how do we know a keyword is newly added? One alternative is to add all keywords (including existing ones) to this list, and the automatic check just need to make sure all keywords are added.
Jira issue: CRDB-17582
I don't know which project I should add to this issue...so I just attached my team.
Thanks for the issue. What's the impact of forgetting to add the keyword to bare_label_keywords?
@rafiss adding new keyword without adding to bare_label_keywords could break user query if the query use column label without AS. Before bare_label_keyword was added, any new keyword could break user queries because it was expecting an IDENT token, but if you used a keyword as the column label, the parser would fail to get an IDENT and error out :(
I think it could be quite rare... but I encountered one case when I was adding the new keyword INPUT which broke this test.
Maybe some kind of test that automatically tries to parse SELECT 1 <keyword> with every (unreserved) keyword would suffice?