@@ -3,6 +3,7 @@ use crate::ext::ustr::UStr;
3
3
use crate :: postgres:: message:: { ParameterDescription , RowDescription } ;
4
4
use crate :: postgres:: statement:: PgStatementMetadata ;
5
5
use crate :: postgres:: type_info:: { PgCustomType , PgType , PgTypeKind } ;
6
+ use crate :: postgres:: types:: Oid ;
6
7
use crate :: postgres:: { PgArguments , PgColumn , PgConnection , PgTypeInfo } ;
7
8
use crate :: query_as:: query_as;
8
9
use crate :: query_scalar:: { query_scalar, query_scalar_with} ;
@@ -147,7 +148,7 @@ impl PgConnection {
147
148
148
149
async fn maybe_fetch_type_info_by_oid (
149
150
& mut self ,
150
- oid : u32 ,
151
+ oid : Oid ,
151
152
should_fetch : bool ,
152
153
) -> Result < PgTypeInfo , Error > {
153
154
// first we check if this is a built-in type
@@ -183,9 +184,9 @@ impl PgConnection {
183
184
}
184
185
}
185
186
186
- fn fetch_type_by_oid ( & mut self , oid : u32 ) -> BoxFuture < ' _ , Result < PgTypeInfo , Error > > {
187
+ fn fetch_type_by_oid ( & mut self , oid : Oid ) -> BoxFuture < ' _ , Result < PgTypeInfo , Error > > {
187
188
Box :: pin ( async move {
188
- let ( name, typ_type, category, relation_id, element, base_type) : ( String , i8 , i8 , u32 , u32 , u32 ) = query_as (
189
+ let ( name, typ_type, category, relation_id, element, base_type) : ( String , i8 , i8 , Oid , Oid , Oid ) = query_as (
189
190
"SELECT typname, typtype, typcategory, typrelid, typelem, typbasetype FROM pg_catalog.pg_type WHERE oid = $1" ,
190
191
)
191
192
. bind ( oid)
@@ -237,7 +238,7 @@ impl PgConnection {
237
238
} )
238
239
}
239
240
240
- async fn fetch_enum_by_oid ( & mut self , oid : u32 , name : String ) -> Result < PgTypeInfo , Error > {
241
+ async fn fetch_enum_by_oid ( & mut self , oid : Oid , name : String ) -> Result < PgTypeInfo , Error > {
241
242
let variants: Vec < String > = query_scalar (
242
243
r#"
243
244
SELECT enumlabel
@@ -259,12 +260,12 @@ ORDER BY enumsortorder
259
260
260
261
fn fetch_composite_by_oid (
261
262
& mut self ,
262
- oid : u32 ,
263
- relation_id : u32 ,
263
+ oid : Oid ,
264
+ relation_id : Oid ,
264
265
name : String ,
265
266
) -> BoxFuture < ' _ , Result < PgTypeInfo , Error > > {
266
267
Box :: pin ( async move {
267
- let raw_fields: Vec < ( String , u32 ) > = query_as (
268
+ let raw_fields: Vec < ( String , Oid ) > = query_as (
268
269
r#"
269
270
SELECT attname, atttypid
270
271
FROM pg_catalog.pg_attribute
@@ -296,8 +297,8 @@ ORDER BY attnum
296
297
297
298
fn fetch_domain_by_oid (
298
299
& mut self ,
299
- oid : u32 ,
300
- base_type : u32 ,
300
+ oid : Oid ,
301
+ base_type : Oid ,
301
302
name : String ,
302
303
) -> BoxFuture < ' _ , Result < PgTypeInfo , Error > > {
303
304
Box :: pin ( async move {
@@ -313,11 +314,11 @@ ORDER BY attnum
313
314
314
315
fn fetch_range_by_oid (
315
316
& mut self ,
316
- oid : u32 ,
317
+ oid : Oid ,
317
318
name : String ,
318
319
) -> BoxFuture < ' _ , Result < PgTypeInfo , Error > > {
319
320
Box :: pin ( async move {
320
- let element_oid: u32 = query_scalar (
321
+ let element_oid: Oid = query_scalar (
321
322
r#"
322
323
SELECT rngsubtype
323
324
FROM pg_catalog.pg_range
@@ -338,13 +339,13 @@ WHERE rngtypid = $1
338
339
} )
339
340
}
340
341
341
- pub ( crate ) async fn fetch_type_id_by_name ( & mut self , name : & str ) -> Result < u32 , Error > {
342
+ pub ( crate ) async fn fetch_type_id_by_name ( & mut self , name : & str ) -> Result < Oid , Error > {
342
343
if let Some ( oid) = self . cache_type_oid . get ( name) {
343
344
return Ok ( * oid) ;
344
345
}
345
346
346
347
// language=SQL
347
- let ( oid, ) : ( u32 , ) = query_as (
348
+ let ( oid, ) : ( Oid , ) = query_as (
348
349
"
349
350
SELECT oid FROM pg_catalog.pg_type WHERE typname ILIKE $1
350
351
" ,
@@ -362,7 +363,7 @@ SELECT oid FROM pg_catalog.pg_type WHERE typname ILIKE $1
362
363
363
364
pub ( crate ) async fn get_nullable_for_columns (
364
365
& mut self ,
365
- stmt_id : u32 ,
366
+ stmt_id : Oid ,
366
367
meta : & PgStatementMetadata ,
367
368
) -> Result < Vec < Option < bool > > , Error > {
368
369
if meta. columns . is_empty ( ) {
@@ -424,10 +425,13 @@ SELECT oid FROM pg_catalog.pg_type WHERE typname ILIKE $1
424
425
/// and returns `None` for all others.
425
426
async fn nullables_from_explain (
426
427
& mut self ,
427
- stmt_id : u32 ,
428
+ stmt_id : Oid ,
428
429
params_len : usize ,
429
430
) -> Result < Vec < Option < bool > > , Error > {
430
- let mut explain = format ! ( "EXPLAIN (VERBOSE, FORMAT JSON) EXECUTE sqlx_s_{}" , stmt_id) ;
431
+ let mut explain = format ! (
432
+ "EXPLAIN (VERBOSE, FORMAT JSON) EXECUTE sqlx_s_{}" ,
433
+ stmt_id. 0
434
+ ) ;
431
435
let mut comma = false ;
432
436
433
437
if params_len > 0 {
0 commit comments