refactor: add standalone PgOid type
This commit is contained in:
parent
bdb6a955df
commit
6d1af26fa8
10 changed files with 136 additions and 66 deletions
|
|
@ -7,10 +7,8 @@ use proto::message::backend::{
|
|||
ReadyForQueryData, RowDescriptionData,
|
||||
};
|
||||
use proto::message::primitive::pglist::PgList;
|
||||
use proto::message::primitive::pgoid::PgOid;
|
||||
use proto::writer::backend::BackendProtoWriter;
|
||||
use rand::Rng;
|
||||
use rand_pcg::Pcg64;
|
||||
use rand_seeder::Seeder;
|
||||
use std::fmt;
|
||||
|
||||
pub enum CompleteStatus {
|
||||
|
|
@ -123,7 +121,7 @@ fn column_to_description(
|
|||
column: Column,
|
||||
) -> anyhow::Result<ColumnDescription> {
|
||||
let table_name = schema.table_name();
|
||||
let table_oid = table_name_to_oid(table_name);
|
||||
let table_oid = PgOid::from_unique_name(table_name);
|
||||
|
||||
let column_type = schema.column_type(column);
|
||||
let name = schema.column_name_from_column(column);
|
||||
|
|
@ -142,10 +140,3 @@ fn column_to_description(
|
|||
format_code: 0, // text format
|
||||
})
|
||||
}
|
||||
|
||||
/// Hashes the table name into single i32 used as a substitute for the table OID
|
||||
/// in the PostgreSQL protocol.
|
||||
fn table_name_to_oid(table_name: &str) -> i32 {
|
||||
let mut rng: Pcg64 = Seeder::from(table_name).make_rng();
|
||||
rng.gen::<i32>()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue