KonnexionsGmbH / sqlparse

LALR grammar based SQL Parser
Other
43 stars 15 forks source link

support for @ in sqlparse #176

Open stoch opened 5 years ago

stoch commented 5 years ago

@walter-weinmann

Would this query not be similar to a DB-Link select?

image

Just for curiosity (for now), I'm trying to read a csv file on another cluster node like this.

Not sure it would work in the engine if the parser supported that.

Thanks for having a look (no priority!)

walter-weinmann commented 5 years ago

The problem is in the lexer. With this definition we allow the character '@' in the token 'NAME':

% names
[A-Za-z][A-Za-z0-9_\$@~]*                           : match_any(TokenChars, TokenLen, TokenLine, ?TOKENPATTERNS).

But according to Oracle this character is only allowed in the database link name. I think the correction - no '@' allowed in names - doesn't pose a problem.

c-bik commented 5 years ago

Imem node sharded table has @ in name. @walter-weinmann your proposal would mean some imem changes too.

But IMHO it is the correct approach.

walter-weinmann commented 5 years ago

I think we've had that discussion before. That's why we introduced the restriction that database links must be enclosed in double quotes. So actually the SQL statement is wrong.

stoch commented 5 years ago

I agree that imem_meta should treat @ similarly to Oracle. This would mean that @ is only supported within double quoted name pieces and as a separator between the table/view/object name and the database link (node shard string). This seems to be possible but needs another round of imem work from my side. The parser consequently cannot change until this is done. Will re-raise the question in a few weeks.

walter-weinmann commented 5 years ago

image

https://docs.oracle.com/database/121/SQLRF/sql_elements008.htm#SQLRF00223

This is taken from the Oracle documentation (12.2). If you consider this, then you should also allow database link names without double quotes and additionally allow the character '@' only in the database link name.