v0.5.3-pre.002
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
// file: ks-store/src/postgres/query/table_diagnostics_queries.rs
|
||||
// version: 3
|
||||
// version: 6
|
||||
|
||||
//! Read-only PostgreSQL diagnostics for known Solana store tables.
|
||||
|
||||
use sqlx::Row; // rust-rules: trait-import
|
||||
|
||||
pub(in crate::postgres) async fn table_exists(
|
||||
pool: &sqlx::PgPool,
|
||||
table_name: &str,
|
||||
) -> ks_core::Result<bool> {
|
||||
pub(crate) async fn table_exists(pool: &sqlx::PgPool, table_name: &str) -> ks_core::Result<bool> {
|
||||
let query_result =
|
||||
sqlx::query_scalar::<sqlx::Postgres, bool>("SELECT to_regclass($1)::text IS NOT NULL")
|
||||
.bind(table_name)
|
||||
@@ -22,111 +19,111 @@ pub(in crate::postgres) async fn table_exists(
|
||||
};
|
||||
}
|
||||
|
||||
pub(in crate::postgres) async fn load_table_statistics(
|
||||
pub(crate) async fn load_table_statistics(
|
||||
pool: &sqlx::PgPool,
|
||||
table_name: &str,
|
||||
) -> ks_core::Result<crate::PostgresTableStatistics> {
|
||||
) -> ks_core::Result<crate::StoreResourceStatistics> {
|
||||
return match table_name {
|
||||
crate::RAW_TRANSACTIONS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_raw_transactions_sql(),
|
||||
crate::table_stats_kb_sol_raw_transactions_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::TRANSACTION_OBSERVATIONS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_obs_transaction_observations_sql(),
|
||||
crate::table_stats_kb_sol_obs_transaction_observations_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::CORE_TRANSACTIONS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_core_transactions_sql(),
|
||||
crate::table_stats_kb_sol_core_transactions_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::CORE_ACCOUNT_KEYS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_core_account_keys_sql(),
|
||||
crate::table_stats_kb_sol_core_account_keys_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::CORE_INSTRUCTIONS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_core_instructions_sql(),
|
||||
crate::table_stats_kb_sol_core_instructions_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::CORE_INNER_INSTRUCTIONS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_core_inner_instructions_sql(),
|
||||
crate::table_stats_kb_sol_core_inner_instructions_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::CORE_LOGS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_core_logs_sql(),
|
||||
crate::table_stats_kb_sol_core_logs_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::CORE_BALANCE_CHANGES_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_core_balance_changes_sql(),
|
||||
crate::table_stats_kb_sol_core_balance_changes_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::PROCESSING_LEDGER_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_ops_processing_ledger_sql(),
|
||||
crate::table_stats_kb_sol_ops_processing_ledger_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::DECODE_EVENTS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_decode_events_sql(),
|
||||
crate::table_stats_kb_sol_decode_events_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::DECODE_COVERAGE_DECLARATIONS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_decode_coverage_declarations_sql(),
|
||||
crate::table_stats_kb_sol_decode_coverage_declarations_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::DECODE_COVERAGE_OBSERVATIONS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_decode_coverage_observations_sql(),
|
||||
crate::table_stats_kb_sol_decode_coverage_observations_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
},
|
||||
crate::MATERIALIZED_EVENTS_TABLE_NAME => {
|
||||
crate::postgres::query::table_diagnostics_queries::load_table_statistics_from_sql(
|
||||
load_table_statistics_from_sql(
|
||||
pool,
|
||||
crate::postgres::migrations::table_stats_kb_sol_mat_events_sql(),
|
||||
crate::table_stats_kb_sol_mat_events_sql(),
|
||||
table_name,
|
||||
)
|
||||
.await
|
||||
@@ -141,7 +138,7 @@ async fn load_table_statistics_from_sql(
|
||||
pool: &sqlx::PgPool,
|
||||
sql: &'static str,
|
||||
table_name: &str,
|
||||
) -> ks_core::Result<crate::PostgresTableStatistics> {
|
||||
) -> ks_core::Result<crate::StoreResourceStatistics> {
|
||||
let query_result = sqlx::query(sql).fetch_one(pool).await;
|
||||
let row = match query_result {
|
||||
std::result::Result::Ok(value) => value,
|
||||
@@ -188,8 +185,8 @@ async fn load_table_statistics_from_sql(
|
||||
)));
|
||||
},
|
||||
};
|
||||
return std::result::Result::Ok(crate::PostgresTableStatistics {
|
||||
row_count,
|
||||
return std::result::Result::Ok(crate::StoreResourceStatistics {
|
||||
record_count: row_count,
|
||||
min_slot,
|
||||
max_slot,
|
||||
latest_created_at,
|
||||
|
||||
Reference in New Issue
Block a user