ricomariani / CG-SQL-author

CG-SQL Author's Cut: CG/SQL is a compiler that converts a SQL Stored Procedure like language into C for SQLite. SQLite has no stored procedures of its own. CG/CQL can also generate other useful artifacts for testing and schema maintenance.
https://ricomariani.github.io/CG-SQL-author/
Other
11 stars 3 forks source link

No way to support databases with tables that have exotic names #52

Closed ricomariani closed 1 year ago

ricomariani commented 1 year ago

e.g. a database with a table named [x y]and a column named [a b] is fundamentally not usable by CQL today.

The idea here to add basic support for this:

These names leak into the algebra... these areas have to be enlightened.

ricomariani commented 1 year ago

`abc def` is escaped to X_abcX20def for use in C/Lua. This transformation is reversable. In principle it can collide with user names but this is not a new thing for CQL. Note that `abc` will map to just abc. This means if you are doing this just to avoid reserved word collisions then output quality does not suffer. In short anything that isn't an alphanumeric is hex encoded in the C/Lua. This really only happens for fields in cursors. The C code doesn't include table names that are not in strings.

ricomariani commented 1 year ago

To see progress on this item check out https://github.com/ricomariani/CG-SQL-author/pull/53

This is not going to be a five-minute fix by any means...

ricomariani commented 1 year ago

Further progress: https://github.com/ricomariani/CG-SQL-author/commit/dba95f4717320faf31d19b004812f1f05b16d809

What's left is a lot more fringe at this point. With query plan, upgrade, and JSON plus the main codegen supporting these it's quite usable.

Test helpers should be very straightforward, that will be next.

ricomariani commented 1 year ago

Test helpers are done and it was less straightforward than I expected because test helpers force the issue of:

There are not that many things left that can't have an exotic name.

ricomariani commented 1 year ago

I'm not aware of any missing cases now. I may do another exploration pass just to make sure but I think everything that needs to be done is done at this point. I will open separate issues for anything non-trivial that I discover while I play with it.