macro_rules! include_sql_str {
($subpath:expr) => {
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/sql/", $subpath))
};
}
macro_rules! decl_const_sql_str {
($name:ident, $subpath:expr) => {
#[doc = include_sql_str!($subpath)]
pub const $name: &str = include_sql_str!($subpath);
};
}
pub mod create {
decl_const_sql_str!(BLOCK, "create/block.sql");
decl_const_sql_str!(BLOCK_SOLUTION, "create/block_solution.sql");
decl_const_sql_str!(CONTRACT_PREDICATE, "create/contract_predicate.sql");
decl_const_sql_str!(CONTRACT_PROGRESS, "create/contract_progress.sql");
decl_const_sql_str!(CONTRACT, "create/contract.sql");
decl_const_sql_str!(DEC_VAR, "create/dec_var.sql");
decl_const_sql_str!(FAILED_BLOCK, "create/failed_block.sql");
decl_const_sql_str!(FINALIZED_BLOCK, "create/finalized_block.sql");
decl_const_sql_str!(MUTATION, "create/mutation.sql");
decl_const_sql_str!(PREDICATE, "create/predicate.sql");
decl_const_sql_str!(PUB_VAR, "create/pub_var.sql");
decl_const_sql_str!(SOLUTION, "create/solution.sql");
decl_const_sql_str!(STATE, "create/state.sql");
decl_const_sql_str!(STATE_PROGRESS, "create/state_progress.sql");
decl_const_sql_str!(VALIDATION_PROGRESS, "create/validation_progress.sql");
}
pub mod insert {
decl_const_sql_str!(BLOCK, "insert/block.sql");
decl_const_sql_str!(BLOCK_SOLUTION, "insert/block_solution.sql");
decl_const_sql_str!(CONTRACT, "insert/contract.sql");
decl_const_sql_str!(CONTRACT_PREDICATE, "insert/contract_predicate.sql");
decl_const_sql_str!(CONTRACT_PROGRESS, "insert/contract_progress.sql");
decl_const_sql_str!(DEC_VAR, "insert/dec_var.sql");
decl_const_sql_str!(FAILED_BLOCK, "insert/failed_block.sql");
decl_const_sql_str!(FINALIZE_BLOCK, "insert/finalize_block.sql");
decl_const_sql_str!(MUTATION, "insert/mutation.sql");
decl_const_sql_str!(PREDICATE, "insert/predicate.sql");
decl_const_sql_str!(PUB_VAR, "insert/pub_var.sql");
decl_const_sql_str!(SOLUTION, "insert/solution.sql");
decl_const_sql_str!(STATE_PROGRESS, "insert/state_progress.sql");
decl_const_sql_str!(VALIDATION_PROGRESS, "insert/validation_progress.sql");
}
pub mod query {
decl_const_sql_str!(GET_CONTRACT_PREDICATES, "query/get_contract_predicates.sql");
decl_const_sql_str!(GET_CONTRACT_PROGRESS, "query/get_contract_progress.sql");
decl_const_sql_str!(GET_CONTRACT_SALT, "query/get_contract_salt.sql");
decl_const_sql_str!(GET_BLOCK_NUMBER, "query/get_block_number.sql");
decl_const_sql_str!(GET_LATEST_BLOCK_NUMBER, "query/get_latest_block_number.sql");
decl_const_sql_str!(
GET_LATEST_FINALIZED_BLOCK_ADDRESS,
"query/get_latest_finalized_block_address.sql"
);
decl_const_sql_str!(GET_PREDICATE, "query/get_predicate.sql");
decl_const_sql_str!(GET_SOLUTION, "query/get_solution.sql");
decl_const_sql_str!(GET_STATE_PROGRESS, "query/get_state_progress.sql");
decl_const_sql_str!(GET_STATE, "query/get_state.sql");
decl_const_sql_str!(GET_VALIDATION_PROGRESS, "query/get_validation_progress.sql");
decl_const_sql_str!(LIST_BLOCKS, "query/list_blocks.sql");
decl_const_sql_str!(LIST_CONTRACTS, "query/list_contracts.sql");
decl_const_sql_str!(LIST_BLOCKS_BY_TIME, "query/list_blocks_by_time.sql");
decl_const_sql_str!(LIST_CONTRACTS_BY_TIME, "query/list_contracts_by_time.sql");
decl_const_sql_str!(LIST_FAILED_BLOCKS, "query/list_failed_blocks.sql");
decl_const_sql_str!(
QUERY_STATE_AT_BLOCK_FINALIZED,
"query/query_state_at_block_finalized.sql"
);
decl_const_sql_str!(
QUERY_STATE_AT_SOLUTION_FINALIZED,
"query/query_state_at_solution_finalized.sql"
);
}
pub mod update {
decl_const_sql_str!(STATE, "update/state.sql");
decl_const_sql_str!(DELETE_STATE, "update/delete_state.sql");
}
pub mod table {
use crate::create;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct Table {
pub name: &'static str,
pub create: &'static str,
}
impl Table {
const fn new(name: &'static str, create: &'static str) -> Self {
Self { name, create }
}
}
pub const BLOCK: Table = Table::new("block", create::BLOCK);
pub const BLOCK_SOLUTION: Table = Table::new("block_solution", create::BLOCK_SOLUTION);
pub const CONTRACT: Table = Table::new("contract", create::CONTRACT);
pub const CONTRACT_PREDICATE: Table =
Table::new("contract_predicate", create::CONTRACT_PREDICATE);
pub const CONTRACT_PROGRESS: Table = Table::new("contract_progress", create::CONTRACT_PROGRESS);
pub const DEC_VAR: Table = Table::new("dec_var", create::DEC_VAR);
pub const FAILED_BLOCK: Table = Table::new("failed_block", create::FAILED_BLOCK);
pub const FINALIZED_BLOCK: Table = Table::new("finalized_block", create::FINALIZED_BLOCK);
pub const MUTATION: Table = Table::new("mutation", create::MUTATION);
pub const PREDICATE: Table = Table::new("predicate", create::PREDICATE);
pub const PUB_VAR: Table = Table::new("pub_var", create::PUB_VAR);
pub const SOLUTION: Table = Table::new("solution", create::SOLUTION);
pub const STATE: Table = Table::new("state", create::STATE);
pub const STATE_PROGRESS: Table = Table::new("state_progress", create::STATE_PROGRESS);
pub const VALIDATION_PROGRESS: Table =
Table::new("validation_progress", create::VALIDATION_PROGRESS);
pub const ALL: &[Table] = &[
BLOCK,
CONTRACT,
CONTRACT_PROGRESS,
DEC_VAR,
FINALIZED_BLOCK,
MUTATION,
PREDICATE,
CONTRACT_PREDICATE,
PUB_VAR,
SOLUTION,
BLOCK_SOLUTION,
FAILED_BLOCK,
STATE,
STATE_PROGRESS,
VALIDATION_PROGRESS,
];
}