LCOV - code coverage report
Current view: top level - libs/proxy/tokio-postgres2/src - statement.rs (source / functions) Coverage Total Hit
Test: 1e20c4f2b28aa592527961bb32170ebbd2c9172f.info Lines: 0.0 % 51 0
Test Date: 2025-07-16 12:29:03 Functions: 0.0 % 13 0

            Line data    Source code
       1              : use std::fmt;
       2              : use std::sync::Arc;
       3              : 
       4              : use crate::types::Type;
       5              : use postgres_protocol2::Oid;
       6              : use postgres_protocol2::message::backend::Field;
       7              : 
       8              : struct StatementInner {
       9              :     name: &'static str,
      10              :     columns: Vec<Column>,
      11              : }
      12              : 
      13              : /// A prepared statement.
      14              : ///
      15              : /// Prepared statements can only be used with the connection that created them.
      16              : #[derive(Clone)]
      17              : pub struct Statement(Arc<StatementInner>);
      18              : 
      19              : impl Statement {
      20            0 :     pub(crate) fn new(name: &'static str, columns: Vec<Column>) -> Statement {
      21            0 :         Statement(Arc::new(StatementInner { name, columns }))
      22            0 :     }
      23              : 
      24            0 :     pub(crate) fn name(&self) -> &str {
      25            0 :         self.0.name
      26            0 :     }
      27              : 
      28              :     /// Returns information about the columns returned when the statement is queried.
      29            0 :     pub fn columns(&self) -> &[Column] {
      30            0 :         &self.0.columns
      31            0 :     }
      32              : }
      33              : 
      34              : /// Information about a column of a query.
      35              : pub struct Column {
      36              :     name: String,
      37              :     pub(crate) type_: Type,
      38              : 
      39              :     // raw fields from RowDescription
      40              :     table_oid: Oid,
      41              :     column_id: i16,
      42              :     format: i16,
      43              : 
      44              :     // that better be stored in self.type_, but that is more radical refactoring
      45              :     type_oid: Oid,
      46              :     type_size: i16,
      47              :     type_modifier: i32,
      48              : }
      49              : 
      50              : impl Column {
      51            0 :     pub(crate) fn new(name: String, type_: Type, raw_field: Field<'_>) -> Column {
      52            0 :         Column {
      53            0 :             name,
      54            0 :             type_,
      55            0 :             table_oid: raw_field.table_oid(),
      56            0 :             column_id: raw_field.column_id(),
      57            0 :             format: raw_field.format(),
      58            0 :             type_oid: raw_field.type_oid(),
      59            0 :             type_size: raw_field.type_size(),
      60            0 :             type_modifier: raw_field.type_modifier(),
      61            0 :         }
      62            0 :     }
      63              : 
      64              :     /// Returns the name of the column.
      65            0 :     pub fn name(&self) -> &str {
      66            0 :         &self.name
      67            0 :     }
      68              : 
      69              :     /// Returns the type of the column.
      70            0 :     pub fn type_(&self) -> &Type {
      71            0 :         &self.type_
      72            0 :     }
      73              : 
      74              :     /// Returns the table OID of the column.
      75            0 :     pub fn table_oid(&self) -> Oid {
      76            0 :         self.table_oid
      77            0 :     }
      78              : 
      79              :     /// Returns the column ID of the column.
      80            0 :     pub fn column_id(&self) -> i16 {
      81            0 :         self.column_id
      82            0 :     }
      83              : 
      84              :     /// Returns the format of the column.
      85            0 :     pub fn format(&self) -> i16 {
      86            0 :         self.format
      87            0 :     }
      88              : 
      89              :     /// Returns the type OID of the column.
      90            0 :     pub fn type_oid(&self) -> Oid {
      91            0 :         self.type_oid
      92            0 :     }
      93              : 
      94              :     /// Returns the type size of the column.
      95            0 :     pub fn type_size(&self) -> i16 {
      96            0 :         self.type_size
      97            0 :     }
      98              : 
      99              :     /// Returns the type modifier of the column.
     100            0 :     pub fn type_modifier(&self) -> i32 {
     101            0 :         self.type_modifier
     102            0 :     }
     103              : }
     104              : 
     105              : impl fmt::Debug for Column {
     106            0 :     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
     107            0 :         fmt.debug_struct("Column")
     108            0 :             .field("name", &self.name)
     109            0 :             .field("type", &self.type_)
     110            0 :             .finish()
     111            0 :     }
     112              : }
        

Generated by: LCOV version 2.1-beta