pixelspark / catena

Catena is a distributed database based on a blockchain, accessible using SQL.
MIT License
302 stars 23 forks source link

Support GRANT TEMPLATE statement with the actual template instead of a hash #115

Open pixelspark opened 6 years ago

pixelspark commented 6 years ago

Currently the system requires the following syntax:

GRANT template X'123123' TO X'456456';

The following would be a bit more user-friendly (but may interfere with parameter binding?):

GRANT template (INSERT INTO foo VALUES ($invoker, ?a, ?b)) TO X'456456';

This interferes with parameter binding as ?a is intended as a parameter for the template, but needs to be bound in the GRANT statement (or we should ignore them here). Another solution would be to use string literals:

GRANT template 'INSERT INTO foo VALUES ($invoker, ?a, ?b);' TO X'456456';

This may lead to issues with escaping.

A better solution would be to support calculating a template hash using a macro, e.g. the front-end query looks like GRANT template (INSERT INTO foo VALUES ($invoker, ?a, ?b)) TO X'456456'; for which the actual on-chain query becomes GRANT template X'123123' TO X'456456';.