File tree Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ edition = "2021"
6
6
license = " MIT"
7
7
homepage = " https://github.com/pgcentralfoundation/pgrx"
8
8
repository = " https://github.com/pgcentralfoundation/pgrx"
9
- docs = " https://docs.rs/pgrx-bindgen"
9
+ documentation = " https://docs.rs/pgrx-bindgen"
10
10
11
11
[dependencies ]
12
12
pgrx-pg-config.workspace = true
Original file line number Diff line number Diff line change @@ -775,6 +775,10 @@ fn run_bindgen(
775
775
. rustified_non_exhaustive_enum ( "NodeTag" )
776
776
. size_t_is_usize ( true )
777
777
. merge_extern_blocks ( true )
778
+ . wrap_unsafe_ops ( true )
779
+ . use_core ( )
780
+ . generate_cstr ( true )
781
+ . disable_nested_struct_naming ( )
778
782
. formatter ( bindgen:: Formatter :: None )
779
783
. layout_tests ( false )
780
784
. default_non_copy_union_style ( NonCopyUnionStyle :: ManuallyDrop )
@@ -819,9 +823,9 @@ fn add_blocklists(bind: bindgen::Builder) -> bindgen::Builder {
819
823
. blocklist_function ( ".*(?:set|long)jmp" )
820
824
. blocklist_function ( "pg_re_throw" )
821
825
. blocklist_function ( "err(start|code|msg|detail|context_msg|hint|finish)" )
822
- . blocklist_item ( "CONFIGURE_ARGS" ) // configuration during build is hopefully irrelevant
823
- . blocklist_item ( "_*(?:HAVE|have)_.*" ) // header tracking metadata
824
- . blocklist_item ( "_[A-Z_]+_H" ) // more header metadata
826
+ . blocklist_var ( "CONFIGURE_ARGS" ) // configuration during build is hopefully irrelevant
827
+ . blocklist_var ( "_*(?:HAVE|have)_.*" ) // header tracking metadata
828
+ . blocklist_var ( "_[A-Z_]+_H" ) // more header metadata
825
829
. blocklist_item ( "__[A-Z].*" ) // these are reserved and unused by Postgres
826
830
. blocklist_item ( "__darwin.*" ) // this should always be Apple's names
827
831
. blocklist_function ( "pq(?:Strerror|Get.*)" ) // wrappers around platform functions: user can call those themselves
Original file line number Diff line number Diff line change @@ -137,8 +137,7 @@ pub const VARHDRSZ_SHORT: usize = offset_of!(super::varattrib_1b, va_data);
137
137
138
138
#[ inline]
139
139
pub fn get_pg_major_version_string ( ) -> & ' static str {
140
- let mver = core:: ffi:: CStr :: from_bytes_with_nul ( super :: PG_MAJORVERSION ) . unwrap ( ) ;
141
- mver. to_str ( ) . unwrap ( )
140
+ super :: PG_MAJORVERSION . to_str ( ) . unwrap ( )
142
141
}
143
142
144
143
#[ inline]
@@ -148,14 +147,12 @@ pub fn get_pg_major_version_num() -> u16 {
148
147
149
148
#[ inline]
150
149
pub fn get_pg_version_string ( ) -> & ' static str {
151
- let ver = core:: ffi:: CStr :: from_bytes_with_nul ( super :: PG_VERSION_STR ) . unwrap ( ) ;
152
- ver. to_str ( ) . unwrap ( )
150
+ super :: PG_VERSION_STR . to_str ( ) . unwrap ( )
153
151
}
154
152
155
153
#[ inline]
156
154
pub fn get_pg_major_minor_version_string ( ) -> & ' static str {
157
- let mver = core:: ffi:: CStr :: from_bytes_with_nul ( super :: PG_VERSION ) . unwrap ( ) ;
158
- mver. to_str ( ) . unwrap ( )
155
+ super :: PG_VERSION . to_str ( ) . unwrap ( )
159
156
}
160
157
161
158
#[ inline]
Original file line number Diff line number Diff line change @@ -145,22 +145,23 @@ mod seal {
145
145
not( feature = "unsafe-postgres" )
146
146
) ) ]
147
147
const _: ( ) = {
148
+ use core:: ffi:: CStr ;
148
149
// to appease `const`
149
- const fn same_slice ( a : & [ u8 ] , b : & [ u8 ] ) -> bool {
150
- if a. len ( ) != b. len ( ) {
150
+ const fn same_cstr ( a : & CStr , b : & CStr ) -> bool {
151
+ if a. to_bytes ( ) . len ( ) != b. to_bytes ( ) . len ( ) {
151
152
return false ;
152
153
}
153
154
let mut i = 0 ;
154
- while i < a. len ( ) {
155
- if a[ i] != b[ i] {
155
+ while i < a. to_bytes ( ) . len ( ) {
156
+ if a. to_bytes ( ) [ i] != b. to_bytes ( ) [ i] {
156
157
return false ;
157
158
}
158
159
i += 1 ;
159
160
}
160
161
true
161
162
}
162
163
assert ! (
163
- same_slice ( pg_sys:: FMGR_ABI_EXTRA , b "PostgreSQL\0 ") ,
164
+ same_cstr ( pg_sys:: FMGR_ABI_EXTRA , c "PostgreSQL") ,
164
165
"Unsupported Postgres ABI. Perhaps you need `--features unsafe-postgres`?" ,
165
166
) ;
166
167
} ;
@@ -242,11 +243,11 @@ macro_rules! pg_magic_func {
242
243
abi_extra: {
243
244
// we'll use what the bindings tell us, but if it ain't "PostgreSQL" then we'll
244
245
// raise a compilation error unless the `unsafe-postgres` feature is set
245
- let magic = :: pgrx:: pg_sys:: FMGR_ABI_EXTRA ;
246
+ let magic = :: pgrx:: pg_sys:: FMGR_ABI_EXTRA . to_bytes_with_nul ( ) ;
246
247
let mut abi = [ 0 as :: pgrx:: ffi:: c_char; 32 ] ;
247
248
let mut i = 0 ;
248
249
while i < magic. len( ) {
249
- abi[ i] = magic[ i] as _ ;
250
+ abi[ i] = magic[ i] as :: pgrx :: ffi :: c_char ;
250
251
i += 1 ;
251
252
}
252
253
abi
You can’t perform that action at this time.
0 commit comments