11/*
2- Copyright 2019-2020 vChain, Inc.
3-
2+ Copyright 2021 CodeNotary, Inc. All rights reserved.
43Licensed under the Apache License, Version 2.0 (the "License");
54you may not use this file except in compliance with the License.
65You may obtain a copy of the License at
7-
86 http://www.apache.org/licenses/LICENSE-2.0
9-
107Unless required by applicable law or agreed to in writing, software
118distributed under the License is distributed on an "AS IS" BASIS,
129WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +14,7 @@ limitations under the License.
1714syntax = "proto3" ;
1815
1916import "google/protobuf/empty.proto" ;
17+ import "google/protobuf/struct.proto" ;
2018
2119package immudb.schema ;
2220
@@ -109,6 +107,7 @@ message Op {
109107
110108message ExecAllRequest {
111109 repeated Op Operations = 1 ;
110+ bool noWait = 2 ;
112111}
113112
114113message Entries {
@@ -214,6 +213,7 @@ message InclusionProof {
214213
215214message SetRequest {
216215 repeated KeyValue KVs = 1 ;
216+ bool noWait = 2 ;
217217}
218218
219219message KeyRequest {
@@ -254,6 +254,7 @@ message ReferenceRequest {
254254 bytes referencedKey = 2 ;
255255 uint64 atTx = 3 ;
256256 bool boundRef = 4 ;
257+ bool noWait = 5 ;
257258}
258259
259260message VerifiableReferenceRequest {
@@ -267,6 +268,7 @@ message ZAddRequest {
267268 bytes key = 3 ;
268269 uint64 atTx = 4 ;
269270 bool boundRef = 5 ;
271+ bool noWait = 6 ;
270272}
271273
272274message Score {
@@ -320,7 +322,41 @@ message TxList {
320322}
321323
322324message Database {
323- string databasename = 1 ;
325+ string databaseName = 1 ;
326+ }
327+
328+ message Table {
329+ string tableName = 1 ;
330+ }
331+
332+ message SQLGetRequest {
333+ string table = 1 ;
334+ SQLValue pkValue = 2 ;
335+ uint64 atTx = 3 ;
336+ uint64 sinceTx = 4 ;
337+ }
338+
339+ message VerifiableSQLGetRequest {
340+ SQLGetRequest sqlGetRequest = 1 ;
341+ uint64 proveSinceTx = 2 ;
342+ }
343+
344+ message SQLEntry {
345+ uint64 tx = 1 ;
346+ bytes key = 2 ;
347+ bytes value = 3 ;
348+ }
349+
350+ message VerifiableSQLEntry {
351+ SQLEntry sqlEntry = 1 ;
352+ VerifiableTx verifiableTx = 2 ;
353+ InclusionProof inclusionProof = 3 ;
354+ uint64 DatabaseId = 4 ;
355+ uint64 TableId = 5 ;
356+ string PKName = 6 ;
357+ map <uint64 , string > ColIdsById = 8 ;
358+ map <string , uint64 > ColIdsByName = 9 ;
359+ map <uint64 , string > ColTypesById = 10 ;
324360}
325361
326362message UseDatabaseReply {
@@ -348,71 +384,113 @@ message DatabaseListResponse{
348384 repeated Database databases = 1 ;
349385}
350386
351- // immudb gRPC & REST service
352- // IMPORTANT: All get and safeget functions return base64-encoded keys and values, while all set and safeset functions expect base64-encoded inputs.
353- service ImmuService {
354- rpc ListUsers (google .protobuf .Empty ) returns (UserList ){};
355-
356- rpc CreateUser (CreateUserRequest ) returns (google .protobuf .Empty ){};
357-
358- rpc ChangePassword (ChangePasswordRequest ) returns (google .protobuf .Empty ){};
359-
360- rpc UpdateAuthConfig (AuthConfig ) returns (google .protobuf .Empty ){}
361- rpc UpdateMTLSConfig (MTLSConfig ) returns (google .protobuf .Empty ){}
362-
363- rpc Login (LoginRequest ) returns (LoginResponse ){};
364-
365- rpc Logout (google .protobuf .Empty ) returns (google .protobuf .Empty ){};
366-
367- rpc Set (SetRequest ) returns (TxMetadata ){};
368-
369- rpc VerifiableSet (VerifiableSetRequest ) returns (VerifiableTx ){};
370-
371- rpc Get (KeyRequest ) returns (Entry ){};
372-
373- rpc VerifiableGet (VerifiableGetRequest ) returns (VerifiableEntry ){};
374-
375- rpc GetAll (KeyListRequest ) returns (Entries ){};
376-
377- rpc ExecAll (ExecAllRequest ) returns (TxMetadata ) {};
378-
379- rpc Scan (ScanRequest ) returns (Entries ){};
380-
381- rpc Count (KeyPrefix ) returns (EntryCount ){};
382-
383- rpc CountAll (google .protobuf .Empty ) returns (EntryCount ){};
384-
385- rpc TxById (TxRequest ) returns (Tx ){};
386-
387- rpc VerifiableTxById (VerifiableTxRequest ) returns (VerifiableTx ){};
388-
389- rpc TxScan (TxScanRequest ) returns (TxList ) {}
390-
391- rpc History (HistoryRequest ) returns (Entries ){};
392-
393- rpc Health (google .protobuf .Empty ) returns (HealthResponse ){};
394-
395- rpc CurrentState (google .protobuf .Empty ) returns (ImmutableState ){};
396-
397- rpc SetReference (ReferenceRequest ) returns (TxMetadata ){};
398-
399- rpc VerifiableSetReference (VerifiableReferenceRequest ) returns (VerifiableTx ){};
387+ message Chunk {
388+ bytes content = 1 ;
389+ }
400390
401- rpc ZAdd (ZAddRequest ) returns (TxMetadata ){};
391+ message UseSnapshotRequest {
392+ uint64 sinceTx = 1 ;
393+ uint64 asBeforeTx = 2 ;
394+ }
402395
403- rpc VerifiableZAdd (VerifiableZAddRequest ) returns (VerifiableTx ){};
396+ message SQLExecRequest {
397+ string sql = 1 ;
398+ repeated NamedParam params = 2 ;
399+ bool noWait = 3 ;
400+ }
404401
405- rpc ZScan (ZScanRequest ) returns (ZEntries ){};
402+ message SQLQueryRequest {
403+ string sql = 1 ;
404+ repeated NamedParam params = 2 ;
405+ bool reuseSnapshot = 3 ;
406+ }
406407
407- rpc CreateDatabase (Database ) returns (google .protobuf .Empty ) {}
408+ message NamedParam {
409+ string name = 1 ;
410+ SQLValue value = 2 ;
411+ }
408412
409- rpc DatabaseList (google .protobuf .Empty ) returns (DatabaseListResponse ){};
413+ message SQLExecResult {
414+ repeated TxMetadata ctxs = 1 ;
415+ repeated TxMetadata dtxs = 2 ;
416+ }
410417
411- rpc UseDatabase (Database ) returns (UseDatabaseReply ) {}
418+ message SQLQueryResult {
419+ repeated Column columns = 2 ;
420+ repeated Row rows = 1 ;
421+ }
412422
413- rpc CleanIndex (google .protobuf .Empty ) returns (google .protobuf .Empty ) {}
423+ message Column {
424+ string name = 1 ;
425+ string type = 2 ;
426+ }
414427
415- rpc ChangePermission (ChangePermissionRequest ) returns (google .protobuf .Empty ) {}
428+ message Row {
429+ repeated string columns = 1 ;
430+ repeated SQLValue values = 2 ;
431+ }
416432
417- rpc SetActiveUser (SetActiveUserRequest ) returns (google .protobuf .Empty ){};
433+ message SQLValue {
434+ oneof value {
435+ google.protobuf.NullValue null = 1 ;
436+ uint64 n = 2 ;
437+ string s = 3 ;
438+ bool b = 4 ;
439+ bytes bs = 5 ;
440+ }
418441}
442+
443+ // immudb gRPC & REST service
444+ // IMPORTANT: All get and safeget functions return base64-encoded keys and values, while all set and safeset functions expect base64-encoded inputs.
445+ service ImmuService {
446+ rpc ListUsers (google .protobuf .Empty ) returns (UserList );
447+ rpc CreateUser (CreateUserRequest ) returns (google .protobuf .Empty );
448+ rpc ChangePassword (ChangePasswordRequest ) returns (google .protobuf .Empty );
449+ rpc UpdateAuthConfig (AuthConfig ) returns (google .protobuf .Empty );
450+ rpc UpdateMTLSConfig (MTLSConfig ) returns (google .protobuf .Empty );
451+ rpc Login (LoginRequest ) returns (LoginResponse );
452+ rpc Logout (google .protobuf .Empty ) returns (google .protobuf .Empty );
453+ rpc Set (SetRequest ) returns (TxMetadata );
454+ rpc VerifiableSet (VerifiableSetRequest ) returns (VerifiableTx );
455+ rpc Get (KeyRequest ) returns (Entry );
456+ rpc VerifiableGet (VerifiableGetRequest ) returns (VerifiableEntry );
457+ rpc GetAll (KeyListRequest ) returns (Entries );
458+ rpc ExecAll (ExecAllRequest ) returns (TxMetadata );
459+ rpc Scan (ScanRequest ) returns (Entries );
460+ rpc Count (KeyPrefix ) returns (EntryCount );
461+ rpc CountAll (google .protobuf .Empty ) returns (EntryCount );
462+ rpc TxById (TxRequest ) returns (Tx );
463+ rpc VerifiableTxById (VerifiableTxRequest ) returns (VerifiableTx );
464+ rpc TxScan (TxScanRequest ) returns (TxList );
465+ rpc History (HistoryRequest ) returns (Entries );
466+ rpc Health (google .protobuf .Empty ) returns (HealthResponse );
467+ rpc CurrentState (google .protobuf .Empty ) returns (ImmutableState );
468+ rpc SetReference (ReferenceRequest ) returns (TxMetadata );
469+ rpc VerifiableSetReference (VerifiableReferenceRequest ) returns (VerifiableTx );
470+ rpc ZAdd (ZAddRequest ) returns (TxMetadata );
471+ rpc VerifiableZAdd (VerifiableZAddRequest ) returns (VerifiableTx );
472+ rpc ZScan (ZScanRequest ) returns (ZEntries );
473+ rpc CreateDatabase (Database ) returns (google .protobuf .Empty );
474+ rpc DatabaseList (google .protobuf .Empty ) returns (DatabaseListResponse );
475+ rpc UseDatabase (Database ) returns (UseDatabaseReply );
476+ rpc CleanIndex (google .protobuf .Empty ) returns (google .protobuf .Empty );
477+ rpc ChangePermission (ChangePermissionRequest ) returns (google .protobuf .Empty );
478+ rpc SetActiveUser (SetActiveUserRequest ) returns (google .protobuf .Empty );
479+ // Streams
480+ rpc streamGet (KeyRequest ) returns (stream Chunk );
481+ rpc streamSet (stream Chunk ) returns (TxMetadata );
482+ rpc streamVerifiableGet (VerifiableGetRequest ) returns (stream Chunk );
483+ rpc streamVerifiableSet (stream Chunk ) returns (VerifiableTx );
484+ rpc streamScan (ScanRequest ) returns (stream Chunk );
485+ rpc streamZScan (ZScanRequest ) returns (stream Chunk );
486+ rpc streamHistory (HistoryRequest ) returns (stream Chunk );
487+ rpc streamExecAll (stream Chunk ) returns (TxMetadata );
488+
489+ // SQL
490+ rpc UseSnapshot (UseSnapshotRequest ) returns (google .protobuf .Empty );
491+ rpc SQLExec (SQLExecRequest ) returns (SQLExecResult );
492+ rpc SQLQuery (SQLQueryRequest ) returns (SQLQueryResult );
493+ rpc ListTables (google .protobuf .Empty ) returns (SQLQueryResult );
494+ rpc DescribeTable (Table ) returns (SQLQueryResult );
495+ rpc VerifiableSQLGet (VerifiableSQLGetRequest ) returns (VerifiableSQLEntry );
496+ }
0 commit comments