pub fn describe(
    pcx: &PlanContext,
    catalog: &dyn SessionCatalog,
    stmt: Statement<Raw>,
    param_types_in: &[Option<pgrepr::Type>],
) -> Result<StatementDesc, anyhow::Error> {
    let mut param_types = BTreeMap::new();
    for (i, ty) in param_types_in.iter().enumerate() {
        if let Some(ty) = ty {
            param_types.insert(i + 1, query::scalar_type_from_pg(ty)?);
        }
    }

    let scx = StatementContext {
        pcx: Some(pcx),
        catalog,
        param_types: RefCell::new(param_types),
    };

    let desc = match stmt {
        // DDL statements.
        Statement::CreateDatabase(stmt) => ddl::describe_create_database(&scx, stmt)?,
        Statement::CreateSchema(stmt) => ddl::describe_create_schema(&scx, stmt)?,
        Statement::CreateTable(stmt) => ddl::describe_create_table(&scx, stmt)?,
        Statement::CreateSource(stmt) => ddl::describe_create_source(&scx, stmt)?,
        Statement::CreateView(stmt) => ddl::describe_create_view(&scx, stmt)?,
        Statement::CreateViews(stmt) => ddl::describe_create_views(&scx, stmt)?,
        Statement::CreateSink(stmt) => ddl::describe_create_sink(&scx, stmt)?,
        Statement::CreateIndex(stmt) => ddl::describe_create_index(&scx, stmt)?,
        Statement::CreateType(stmt) => ddl::describe_create_type(&scx, stmt)?,
        Statement::CreateRole(stmt) => ddl::describe_create_role(&scx, stmt)?,
        Statement::DropDatabase(stmt) => ddl::describe_drop_database(&scx, stmt)?,
        Statement::DropObjects(stmt) => ddl::describe_drop_objects(&scx, stmt)?,
        Statement::AlterObjectRename(stmt) => ddl::describe_alter_object_rename(&scx, stmt)?,
        Statement::AlterIndex(stmt) => ddl::describe_alter_index_options(&scx, stmt)?,

        // `SHOW` statements.
        Statement::ShowColumns(stmt) => show::show_columns(&scx, stmt)?.describe()?,
        Statement::ShowCreateTable(stmt) => show::describe_show_create_table(&scx, stmt)?,
        Statement::ShowCreateSource(stmt) => show::describe_show_create_source(&scx, stmt)?,
        Statement::ShowCreateView(stmt) => show::describe_show_create_view(&scx, stmt)?,
        Statement::ShowCreateSink(stmt) => show::describe_show_create_sink(&scx, stmt)?,
        Statement::ShowCreateIndex(stmt) => show::describe_show_create_index(&scx, stmt)?,
        Statement::ShowDatabases(stmt) => show::show_databases(&scx, stmt)?.describe()?,
        Statement::ShowObjects(stmt) => show::show_objects(&scx, stmt)?.describe()?,
        Statement::ShowIndexes(stmt) => show::show_indexes(&scx, stmt)?.describe()?,

        // SCL statements.
        Statement::SetVariable(stmt) => scl::describe_set_variable(&scx, stmt)?,
        Statement::ShowVariable(stmt) => scl::describe_show_variable(&scx, stmt)?,
        Statement::Discard(stmt) => scl::describe_discard(&scx, stmt)?,
        Statement::Declare(stmt) => scl::describe_declare(&scx, stmt)?,
        Statement::Fetch(stmt) => scl::describe_fetch(&scx, stmt)?,
        Statement::Close(stmt) => scl::describe_close(&scx, stmt)?,
        Statement::Prepare(stmt) => scl::describe_prepare(&scx, stmt)?,
        Statement::Execute(stmt) => scl::describe_execute(&scx, stmt)?,
        Statement::Deallocate(stmt) => scl::describe_deallocate(&scx, stmt)?,

        // DML statements.
        Statement::Insert(stmt) => dml::describe_insert(&scx, stmt)?,
        Statement::Update(stmt) => dml::describe_update(&scx, stmt)?,
        Statement::Delete(stmt) => dml::describe_delete(&scx, stmt)?,
        Statement::Select(stmt) => dml::describe_select(&scx, stmt)?,
        Statement::Explain(stmt) => dml::describe_explain(&scx, stmt)?,
        Statement::Tail(stmt) => dml::describe_tail(&scx, stmt)?,
        Statement::Copy(stmt) => dml::describe_copy(&scx, stmt)?,

        // TCL statements.
        Statement::StartTransaction(stmt) => tcl::describe_start_transaction(&scx, stmt)?,
        Statement::SetTransaction(stmt) => tcl::describe_set_transaction(&scx, stmt)?,
        Statement::Rollback(stmt) => tcl::describe_rollback(&scx, stmt)?,
        Statement::Commit(stmt) => tcl::describe_commit(&scx, stmt)?,
    };

    let desc = desc.with_params(scx.finalize_param_types()?);
    Ok(desc)
}
/// Creates a description of the purified statement `stmt`.
///
/// See the documentation of [`StatementDesc`] for details.
Creates a description of the purified statement `stmt`.
See the documentation of [`StatementDesc`] for details.
Creates a description of the purified statement ` stmt ` . See the documentation of [ ` StatementDesc ` ] for details .
pub fn describe(
    pcx: &PlanContext,
    catalog: &dyn SessionCatalog,
    stmt: Statement<Raw>,
    param_types_in: &[Option<pgrepr::Type>],
) -> Result<StatementDesc, anyhow::Error> {
    let mut param_types = BTreeMap::new();
    for (i, ty) in param_types_in.iter().enumerate() {
        if let Some(ty) = ty {
            param_types.insert(i + 1, query::scalar_type_from_pg(ty)?);
        }
    }
    let scx = StatementContext {
        pcx: Some(pcx),
        catalog,
        param_types: RefCell::new(param_types),
    };
    let desc = match stmt {
        // DDL statements.
        Statement::CreateDatabase(stmt) => ddl::describe_create_database(&scx, stmt)?,
        Statement::CreateSchema(stmt) => ddl::describe_create_schema(&scx, stmt)?,
        Statement::CreateTable(stmt) => ddl::describe_create_table(&scx, stmt)?,
        Statement::CreateSource(stmt) => ddl::describe_create_source(&scx, stmt)?,
        Statement::CreateView(stmt) => ddl::describe_create_view(&scx, stmt)?,
        Statement::CreateViews(stmt) => ddl::describe_create_views(&scx, stmt)?,
        Statement::CreateSink(stmt) => ddl::describe_create_sink(&scx, stmt)?,
        Statement::CreateIndex(stmt) => ddl::describe_create_index(&scx, stmt)?,
        Statement::CreateType(stmt) => ddl::describe_create_type(&scx, stmt)?,
        Statement::CreateRole(stmt) => ddl::describe_create_role(&scx, stmt)?,
        Statement::DropDatabase(stmt) => ddl::describe_drop_database(&scx, stmt)?,
        Statement::DropObjects(stmt) => ddl::describe_drop_objects(&scx, stmt)?,
        Statement::AlterObjectRename(stmt) => ddl::describe_alter_object_rename(&scx, stmt)?,
        Statement::AlterIndex(stmt) => ddl::describe_alter_index_options(&scx, stmt)?,
        // `SHOW` statements.
        Statement::ShowColumns(stmt) => show::show_columns(&scx, stmt)?.describe()?,
        Statement::ShowCreateTable(stmt) => show::describe_show_create_table(&scx, stmt)?,
        Statement::ShowCreateSource(stmt) => show::describe_show_create_source(&scx, stmt)?,
        Statement::ShowCreateView(stmt) => show::describe_show_create_view(&scx, stmt)?,
        Statement::ShowCreateSink(stmt) => show::describe_show_create_sink(&scx, stmt)?,
        Statement::ShowCreateIndex(stmt) => show::describe_show_create_index(&scx, stmt)?,
        Statement::ShowDatabases(stmt) => show::show_databases(&scx, stmt)?.describe()?,
        Statement::ShowObjects(stmt) => show::show_objects(&scx, stmt)?.describe()?,
        Statement::ShowIndexes(stmt) => show::show_indexes(&scx, stmt)?.describe()?,
        // SCL statements.
        Statement::SetVariable(stmt) => scl::describe_set_variable(&scx, stmt)?,
        Statement::ShowVariable(stmt) => scl::describe_show_variable(&scx, stmt)?,
        Statement::Discard(stmt) => scl::describe_discard(&scx, stmt)?,
        Statement::Declare(stmt) => scl::describe_declare(&scx, stmt)?,
        Statement::Fetch(stmt) => scl::describe_fetch(&scx, stmt)?,
        Statement::Close(stmt) => scl::describe_close(&scx, stmt)?,
        Statement::Prepare(stmt) => scl::describe_prepare(&scx, stmt)?,
        Statement::Execute(stmt) => scl::describe_execute(&scx, stmt)?,
        Statement::Deallocate(stmt) => scl::describe_deallocate(&scx, stmt)?,
        // DML statements.
        Statement::Insert(stmt) => dml::describe_insert(&scx, stmt)?,
        Statement::Update(stmt) => dml::describe_update(&scx, stmt)?,
        Statement::Delete(stmt) => dml::describe_delete(&scx, stmt)?,
        Statement::Select(stmt) => dml::describe_select(&scx, stmt)?,
        Statement::Explain(stmt) => dml::describe_explain(&scx, stmt)?,
        Statement::Tail(stmt) => dml::describe_tail(&scx, stmt)?,
        Statement::Copy(stmt) => dml::describe_copy(&scx, stmt)?,
        // TCL statements.
        Statement::StartTransaction(stmt) => tcl::describe_start_transaction(&scx, stmt)?,
        Statement::SetTransaction(stmt) => tcl::describe_set_transaction(&scx, stmt)?,
        Statement::Rollback(stmt) => tcl::describe_rollback(&scx, stmt)?,
        Statement::Commit(stmt) => tcl::describe_commit(&scx, stmt)?,
    };
    let desc = desc.with_params(scx.finalize_param_types()?);
    Ok(desc)
}
pub fn describe ( pcx : & PlanContext , catalog : & dyn SessionCatalog , stmt : Statement < Raw > , param_types_in : & [ Option < pgrepr :: Type > ] , ) -> Result < StatementDesc , anyhow :: Error > { let mut param_types = BTreeMap :: new ( ) ; for ( i , ty ) in param_types_in . iter ( ) . enumerate ( ) { if let Some ( ty ) = ty { param_types . insert ( i + 1 , query :: scalar_type_from_pg ( ty ) ? ) ; } } let scx = StatementContext { pcx : Some ( pcx ) , catalog , param_types : RefCell :: new ( param_types ) , } ; let desc = match stmt { // DDL statements. Statement :: CreateDatabase ( stmt ) => ddl :: describe_create_database ( & scx , stmt ) ? , Statement :: CreateSchema ( stmt ) => ddl :: describe_create_schema ( & scx , stmt ) ? , Statement :: CreateTable ( stmt ) => ddl :: describe_create_table ( & scx , stmt ) ? , Statement :: CreateSource ( stmt ) => ddl :: describe_create_source ( & scx , stmt ) ? , Statement :: CreateView ( stmt ) => ddl :: describe_create_view ( & scx , stmt ) ? , Statement :: CreateViews ( stmt ) => ddl :: describe_create_views ( & scx , stmt ) ? , Statement :: CreateSink ( stmt ) => ddl :: describe_create_sink ( & scx , stmt ) ? , Statement :: CreateIndex ( stmt ) => ddl :: describe_create_index ( & scx , stmt ) ? , Statement :: CreateType ( stmt ) => ddl :: describe_create_type ( & scx , stmt ) ? , Statement :: CreateRole ( stmt ) => ddl :: describe_create_role ( & scx , stmt ) ? , Statement :: DropDatabase ( stmt ) => ddl :: describe_drop_database ( & scx , stmt ) ? , Statement :: DropObjects ( stmt ) => ddl :: describe_drop_objects ( & scx , stmt ) ? , Statement :: AlterObjectRename ( stmt ) => ddl :: describe_alter_object_rename ( & scx , stmt ) ? , Statement :: AlterIndex ( stmt ) => ddl :: describe_alter_index_options ( & scx , stmt ) ? , // `SHOW` statements. Statement :: ShowColumns ( stmt ) => show :: show_columns ( & scx , stmt ) ? . describe ( ) ? , Statement :: ShowCreateTable ( stmt ) => show :: describe_show_create_table ( & scx , stmt ) ? , Statement :: ShowCreateSource ( stmt ) => show :: describe_show_create_source ( & scx , stmt ) ? , Statement :: ShowCreateView ( stmt ) => show :: describe_show_create_view ( & scx , stmt ) ? , Statement :: ShowCreateSink ( stmt ) => show :: describe_show_create_sink ( & scx , stmt ) ? , Statement :: ShowCreateIndex ( stmt ) => show :: describe_show_create_index ( & scx , stmt ) ? , Statement :: ShowDatabases ( stmt ) => show :: show_databases ( & scx , stmt ) ? . describe ( ) ? , Statement :: ShowObjects ( stmt ) => show :: show_objects ( & scx , stmt ) ? . describe ( ) ? , Statement :: ShowIndexes ( stmt ) => show :: show_indexes ( & scx , stmt ) ? . describe ( ) ? , // SCL statements. Statement :: SetVariable ( stmt ) => scl :: describe_set_variable ( & scx , stmt ) ? , Statement :: ShowVariable ( stmt ) => scl :: describe_show_variable ( & scx , stmt ) ? , Statement :: Discard ( stmt ) => scl :: describe_discard ( & scx , stmt ) ? , Statement :: Declare ( stmt ) => scl :: describe_declare ( & scx , stmt ) ? , Statement :: Fetch ( stmt ) => scl :: describe_fetch ( & scx , stmt ) ? , Statement :: Close ( stmt ) => scl :: describe_close ( & scx , stmt ) ? , Statement :: Prepare ( stmt ) => scl :: describe_prepare ( & scx , stmt ) ? , Statement :: Execute ( stmt ) => scl :: describe_execute ( & scx , stmt ) ? , Statement :: Deallocate ( stmt ) => scl :: describe_deallocate ( & scx , stmt ) ? , // DML statements. Statement :: Insert ( stmt ) => dml :: describe_insert ( & scx , stmt ) ? , Statement :: Update ( stmt ) => dml :: describe_update ( & scx , stmt ) ? , Statement :: Delete ( stmt ) => dml :: describe_delete ( & scx , stmt ) ? , Statement :: Select ( stmt ) => dml :: describe_select ( & scx , stmt ) ? , Statement :: Explain ( stmt ) => dml :: describe_explain ( & scx , stmt ) ? , Statement :: Tail ( stmt ) => dml :: describe_tail ( & scx , stmt ) ? , Statement :: Copy ( stmt ) => dml :: describe_copy ( & scx , stmt ) ? , // TCL statements. Statement :: StartTransaction ( stmt ) => tcl :: describe_start_transaction ( & scx , stmt ) ? , Statement :: SetTransaction ( stmt ) => tcl :: describe_set_transaction ( & scx , stmt ) ? , Statement :: Rollback ( stmt ) => tcl :: describe_rollback ( & scx , stmt ) ? , Statement :: Commit ( stmt ) => tcl :: describe_commit ( & scx , stmt ) ? , } ; let desc = desc . with_params ( scx . finalize_param_types ( ) ? ) ; Ok ( desc ) }
Creates a description of the purified statement `stmt`.
Creates a description of the purified statement ` stmt ` .
pcx
&PlanContext
catalog
&dyn SessionCatalog
stmt
Statement<Raw>
param_types_in
&[Option<pgrepr::Type>]
pcx
&PlanContext
catalog
&dyn SessionCatalog
stmt
Statement<Raw>
param_types_in
&[Option<pgrepr::Type>]