File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,33 @@ pub struct PgColumn {
10
10
pub ( crate ) name : UStr ,
11
11
pub ( crate ) type_info : PgTypeInfo ,
12
12
#[ cfg_attr( feature = "offline" , serde( skip) ) ]
13
- pub ( crate ) relation_id : Option < i32 > ,
13
+ pub ( crate ) relation_id : Option < crate :: types :: Oid > ,
14
14
#[ cfg_attr( feature = "offline" , serde( skip) ) ]
15
15
pub ( crate ) relation_attribute_no : Option < i16 > ,
16
16
}
17
17
18
+ impl PgColumn {
19
+ /// Returns the OID of the table this column is from, if applicable.
20
+ ///
21
+ /// This will be `None` if the column is the result of an expression.
22
+ ///
23
+ /// Corresponds to column `attrelid` of the `pg_catalog.pg_attribute` table:
24
+ /// <https://www.postgresql.org/docs/current/catalog-pg-attribute.html>
25
+ pub fn relation_id ( & self ) -> Option < crate :: types:: Oid > {
26
+ self . relation_id
27
+ }
28
+
29
+ /// Returns the 1-based index of this column in its parent table, if applicable.
30
+ ///
31
+ /// This will be `None` if the column is the result of an expression.
32
+ ///
33
+ /// Corresponds to column `attnum` of the `pg_catalog.pg_attribute` table:
34
+ /// <https://www.postgresql.org/docs/current/catalog-pg-attribute.html>
35
+ pub fn relation_attribute_no ( & self ) -> Option < i16 > {
36
+ self . relation_attribute_no
37
+ }
38
+ }
39
+
18
40
impl Column for PgColumn {
19
41
type Database = Postgres ;
20
42
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ pub struct Field {
17
17
18
18
/// If the field can be identified as a column of a specific table, the
19
19
/// object ID of the table; otherwise zero.
20
- pub relation_id : Option < i32 > ,
20
+ pub relation_id : Option < Oid > ,
21
21
22
22
/// If the field can be identified as a column of a specific table, the attribute number of
23
23
/// the column; otherwise zero.
@@ -65,7 +65,7 @@ impl BackendMessage for RowDescription {
65
65
) ) ;
66
66
}
67
67
68
- let relation_id = buf. get_i32 ( ) ;
68
+ let relation_id = buf. get_u32 ( ) ;
69
69
let relation_attribute_no = buf. get_i16 ( ) ;
70
70
let data_type_id = Oid ( buf. get_u32 ( ) ) ;
71
71
let data_type_size = buf. get_i16 ( ) ;
@@ -77,7 +77,7 @@ impl BackendMessage for RowDescription {
77
77
relation_id : if relation_id == 0 {
78
78
None
79
79
} else {
80
- Some ( relation_id)
80
+ Some ( Oid ( relation_id) )
81
81
} ,
82
82
relation_attribute_no : if relation_attribute_no == 0 {
83
83
None
You can’t perform that action at this time.
0 commit comments