Queries

This table shows query types:

Tcl proc Description
1 DTC/user delete from stage where xid = ? Delete Keyspace. Used at Stop transaction.
2 DTC select state, step from stage where keyspace = ?

order by step desc

Used at rollback transaction.
3 DTC select ifnull(max(step), 0)+1 from stage where keyspace = ? Get next step value when entering a state.
4 DTC/user Insert into stage (keyspace, timestamp, datatype, data, metadata, state, step) values (?,?,?,?,?,?,?,?)

DTC inserts with keyspace=<XID>, key=<state$step>, datatype=’DTC’, data=<message> metadata=<meta-data>, state=<state> and step=<step>

User inserts message with keyspace=<XID/ Keyspace>, key=<some-key>, datatype=’MSG’, data=<message>, metadata=<meta-data>, state=NULL and step=NULL

User inserts value with keyspace=<XID/ Keyspace>, key=<some-key>, datatype=’DAT’, data=<value>, metadata=NULL, state=NULL and step=NULL

Add key,value to a keyspace

Keyspace: XID, global or user defined.

key:

  • state$step for type is DTC.
  • Alpha-numeric: user provided key.

timestamp: Use SQLite’s strftime('%Y-%m-%d %H:%M:%f', ‘now’) function to store value.

%f stores milliseconds.

datatype:

  • DTC for DTC protocol values.
  • MSG for user’s message data.
  • DAT for user data.

data:

  • Message blob for type is DTC or MSG.
  • String value for type is DAT.
Select data from stage where keyspace = ? and key = ? and datatype = ‘DAT’ Get value by key from a keyspace.
Select data, metadata from stage where keyspace = ? and key = ? and datatype = ‘MSG’ Get message by key from a keyspace.