Comments (3)
Could be implemented by granting execution rights for an SQL statement that (in canonical form) hashes to a certain value. The SQL would contain placeholders for variables which would be filled in after validation. This appears to be like https://github.com/bitcoin/bips/blob/master/bip-0114.mediawiki.
from catena.
Define a template:
INSERT INTO x (y,z) VALUES(#q, 1);
The hash of this template is stored in a grants table.
Use a template:
INSERT INTO x (y,z) VALUES (#q='some value', 1);
When processing a transaction with this query in it, the engine removes all parameter values and arrives at the 'template query'. This is hashed in order to search for execution rights. When these rights are present, the original query is stripped off its parameter indicators ('#x') and executed normally.
Some thoughts:
- Any (constant) SQL value should be usable as value (e.g.
#param=(1+1)
should be legal) - The same parameter may appear multiple times in a query. In this case the values should be equal
- Unnamed parameters may be used (#='xx'), these cannot be re-used obviously in the same query.
- The definer of the query must have the rights to execute the query 'on behalf' of the invoker. A stored procedure really is a delegated query executed with rights of the delegator.
- We may want to add a variable indicating the definer of the procedure
- There needs to be a way to run multiple queries atomically in the same procedure. Procedures should execute in a transaction.
- Should it also be possible to store not the hash but the template itself? This would provide a bit more information about procedures available, otherwise needs to be done out of band.
We should also add support for some sort of IF-statement, in order to be able to validate inputs, e.g.:
CASE
WHEN #amount > 0 THEN UPDATE balance SET balance = balance - #amount
WHEN #amount = 0 THEN IGNORE
ELSE FAIL
END
Use cases:
- Expiring:
CASE WHEN $timestamp > someTime THEN FAIL ELSE [query] END
- Customizing rights:
CASE WHEN $invoker=x AND #amount<y THEN [query] ELSE FAIL END
from catena.
So there is still a use case for stored procedures, and that is to componentize (sub)statements and also publicly show them in the database. I propose the following:
- Have a special (optional)
procedures
table with structure(name TEXT PRIMARY KEY, statement TEXT)
store special statements by name. - Add a permission kind
call
with subject referring to one of the stored procedures in that table. - Add a
CALL
SQL statement that allows calling a stored procedure (if you have permissions). We do need a way to pass parameters (something likeCALL transfer(to:x, from:y, amount: z)
.
There also needs to be a recursion limit (e.g. the stack may contain at most x CALL
statements).
from catena.
Related Issues (20)
- Investigate use of CRDTs
- Show indication of database ownership in database choice list on data tab
- Add a way to search through the database list
- Add functionality for managing peers
- Detect (and show) external IP address
- Register a protocol handler that accepts transactions
- Build errors Macos , CommonCrypto error: manifest parse error(s) HOT 4
- Use bech32 address format
- What would it take to just switch this to run on Ethereum? HOT 3
- Not building in Linux other than Debian HOT 6
- Cannot POST /api/query/. HOT 2
- Cannot build with docker
- Cannot build natively on Arch Linux HOT 3
- Unable to persist block chain data HOT 3
- How to submit mutating queries programatically to catena? HOT 1
- Unable to build Database with name other than "foo". HOT 1
- Error while building the package in "swift 4.2"
- Cannot find resource: index.html HOT 1
- Issue coming while installing locally through docker
- npm WARN [email protected] No repository field
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catena.