Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add table_oid and column_id to column structure of prepared statements#1084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletiontokio-postgres/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@

* Disable`rustc-serialize` compatibility of`eui48-1` dependency
* Remove tests for`eui48-04`

* Add`table_oid` and`field_id` fields to`Columns` struct of prepared statements.

##v0.7.10 - 2023-08-25

Expand Down
8 changes: 7 additions & 1 deletiontokio-postgres/src/prepare.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ use log::debug;
use postgres_protocol::message::backend::Message;
use postgres_protocol::message::frontend;
use std::future::Future;
use std::num::{NonZeroI16, NonZeroU32};
use std::pin::Pin;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
Expand DownExpand Up@@ -95,7 +96,12 @@ pub async fn prepare(
let mut it = row_description.fields();
while let Some(field) = it.next().map_err(Error::parse)? {
let type_ = get_type(client, field.type_oid()).await?;
let column = Column::new(field.name().to_string(), type_);
let column = Column {
name: field.name().to_string(),
table_oid: NonZeroU32::new(field.table_oid()),
column_id: NonZeroI16::new(field.column_id()),
r#type: type_,
};
columns.push(column);
}
}
Expand Down
34 changes: 17 additions & 17 deletionstokio-postgres/src/statement.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ use crate::connection::RequestMessages;
use crate::types::Type;
use postgres_protocol::message::frontend;
use std::{
fmt,
num::{NonZeroI16, NonZeroU32},
sync::{Arc, Weak},
};

Expand DownExpand Up@@ -65,32 +65,32 @@ impl Statement {
}

/// Information about a column of a query.
#[derive(Debug)]
pub struct Column {
name: String,
type_: Type,
pub(crate) name: String,
pub(crate) table_oid: Option<NonZeroU32>,
pub(crate) column_id: Option<NonZeroI16>,
pub(crate) r#type: Type,
}

impl Column {
pub(crate) fn new(name: String, type_: Type) -> Column {
Column { name, type_ }
}

/// Returns the name of the column.
pub fn name(&self) -> &str {
&self.name
}

/// Returns the type of the column.
pub fn type_(&self) -> &Type {
&self.type_
/// Returns the OID of the underlying database table.
pub fn table_oid(&self) -> Option<NonZeroU32> {
self.table_oid
}

/// Return the column ID within the underlying database table.
pub fn column_id(&self) -> Option<NonZeroI16> {
self.column_id
}
}

impl fmt::Debug for Column {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Column")
.field("name", &self.name)
.field("type", &self.type_)
.finish()
/// Returns the type of the column.
pub fn type_(&self) -> &Type {
&self.r#type
}
}

[8]ページ先頭

©2009-2025 Movatter.jp