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

Commit02bab67

Browse files
committed
Add table_oid and field_id to columns of prepared statements
1 parent10edbcb commit02bab67

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

‎tokio-postgres/CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
* Disable`rustc-serialize` compatibility of`eui48-1` dependency
66
* Remove tests for`eui48-04`
7-
7+
* Add`table_oid` and`field_id` fields to`Columns` struct of prepared statements.
88

99
##v0.7.10 - 2023-08-25
1010

‎tokio-postgres/src/prepare.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use log::debug;
1212
use postgres_protocol::message::backend::Message;
1313
use postgres_protocol::message::frontend;
1414
use std::future::Future;
15+
use std::num::{NonZeroI16,NonZeroU32};
1516
use std::pin::Pin;
1617
use std::sync::atomic::{AtomicUsize,Ordering};
1718
use std::sync::Arc;
@@ -95,7 +96,12 @@ pub async fn prepare(
9596
letmut it = row_description.fields();
9697
whileletSome(field) = it.next().map_err(Error::parse)?{
9798
let type_ =get_type(client, field.type_oid()).await?;
98-
let column =Column::new(field.name().to_string(), type_);
99+
let column =Column{
100+
name: field.name().to_string(),
101+
table_oid:NonZeroU32::new(field.table_oid()),
102+
column_id:NonZeroI16::new(field.column_id()),
103+
type_,
104+
};
99105
columns.push(column);
100106
}
101107
}

‎tokio-postgres/src/statement.rs‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::types::Type;
55
use postgres_protocol::message::frontend;
66
use std::{
77
fmt,
8+
num::{NonZeroI16,NonZeroU32},
89
sync::{Arc,Weak},
910
};
1011

@@ -66,20 +67,28 @@ impl Statement {
6667

6768
/// Information about a column of a query.
6869
pubstructColumn{
69-
name:String,
70-
type_:Type,
70+
pub(crate)name:String,
71+
pub(crate)table_oid:Option<NonZeroU32>,
72+
pub(crate)column_id:Option<NonZeroI16>,
73+
pub(crate)type_:Type,
7174
}
7275

7376
implColumn{
74-
pub(crate)fnnew(name:String,type_:Type) ->Column{
75-
Column{ name, type_}
76-
}
77-
7877
/// Returns the name of the column.
7978
pubfnname(&self) ->&str{
8079
&self.name
8180
}
8281

82+
/// Returns the OID of the underlying database table.
83+
pubfntable_oid(&self) ->Option<NonZeroU32>{
84+
self.table_oid
85+
}
86+
87+
/// Return the column ID within the underlying database table.
88+
pubfncolumn_id(&self) ->Option<NonZeroI16>{
89+
self.column_id
90+
}
91+
8392
/// Returns the type of the column.
8493
pubfntype_(&self) ->&Type{
8594
&self.type_
@@ -90,6 +99,8 @@ impl fmt::Debug for Column {
9099
fnfmt(&self,fmt:&mut fmt::Formatter<'_>) -> fmt::Result{
91100
fmt.debug_struct("Column")
92101
.field("name",&self.name)
102+
.field("table_oid",&self.table_oid)
103+
.field("column_id",&self.column_id)
93104
.field("type",&self.type_)
94105
.finish()
95106
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp