-
Notifications
You must be signed in to change notification settings - Fork 12
/
contextual.go
43 lines (40 loc) · 1.37 KB
/
contextual.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package parse
import (
"github.com/kwilteam/kwil-db/core/types"
)
var (
// caller is the session variable for the caller.
CallerVar = "caller"
// txid is the session variable for the transaction id.
TxidVar = "txid"
// signer is the session variable for the signer.
SignerVar = "signer"
// height is the session variable for the block height.
HeightVar = "height"
// foreign_caller is the dbid of the schema that made a foreign call.
ForeignCaller = "foreign_caller"
// block_timestamp is the unix timestamp of the block, set by the block proposer.
BlockTimestamp = "block_timestamp"
// authenticator provides information on the authenticator used to sign the transaction.
Authenticator = "authenticator"
// SessionVars are the session variables that are available in the engine.
// It maps the variable name to its type.
SessionVars = map[string]*types.DataType{
CallerVar: types.TextType,
TxidVar: types.TextType,
SignerVar: types.BlobType,
HeightVar: types.IntType,
ForeignCaller: types.TextType,
BlockTimestamp: types.IntType,
Authenticator: types.TextType,
}
)
// makeSessionVars creates a new map of session variables.
// It includes the @ symbol in the keys.
func makeSessionVars() map[string]*types.DataType {
newMap := make(map[string]*types.DataType)
for k, v := range SessionVars {
newMap["@"+k] = v.Copy()
}
return newMap
}