Skip to content

Commit 1ec8dae

Browse files
committed
Update to postgres 18.0
This commit updates the bundled libpq version to that one from the postgres 18.0 release. It also regenerates the bindings to match the bundled libpq version. Finally it enables the pkg-config feature by default to make compiling in linux like environments a bit easier.
1 parent d6f599a commit 1ec8dae

File tree

11 files changed

+413
-42
lines changed

11 files changed

+413
-42
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777

7878
- name: Install rust toolchain
7979
uses: dtolnay/rust-toolchain@stable
80+
with:
81+
components: rustfmt
8082

8183
- name: Check
8284
shell: bash

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
55

66
## Unreleased
77

8+
### pq-sys [0.7.4] 2025-xx-xx
9+
10+
* Update the bundled version of libpq to 18.0
11+
* Regenerate bindings for the new postgres release
12+
* Enable the `pkg-config` feature by default
13+
814
### pq-sys [0.7.2] 2025-06-12
915

1016
* Bump bindgen to 0.72.0 and regenerate bindings

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pq-sys"
3-
version = "0.7.2"
3+
version = "0.7.3"
44
description = "Auto-generated rust bindings for libpq"
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/sgrif/pq-sys"
@@ -31,7 +31,7 @@ similar-asserts = "1.6.0"
3131
bindgen = "0.72.0"
3232

3333
[features]
34-
default = []
34+
default = ["pkg-config"]
3535
bundled = ["bundled_without_openssl", "pq-src/with-openssl"]
3636
bundled_without_openssl = ["dep:pq-src"]
3737
buildtime_bindgen = ["dep:bindgen"]

pq-src/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pq-src"
3-
version = "0.3.9+libpq-17.5"
3+
version = "0.3.10+libpq-18.0"
44
edition = "2021"
55
include = [
66
"src/**/*.rs",
@@ -46,6 +46,8 @@ include = [
4646
"source/src/include/common/cryptohash.h",
4747
"source/src/include/common/scram-common.h",
4848
"source/src/include/common/sha2.h",
49+
"source/src/include/datatype/timestamp.h",
50+
"source/src/include/pgtime.h",
4951
"source/src/common/sha2_int.h",
5052
"source/src/common/sha1_int.h",
5153
"source/src/include/common/sha1.h",
@@ -69,7 +71,9 @@ include = [
6971
"source/src/include/common/unicode_east_asian_fw_table.h",
7072
"source/src/include/common/restricted_token.h",
7173
"source/src/include/common/openssl.h",
74+
"source/src/include/libpq/pg-gssapi.h",
7275
"source/src/include/mb/pg_wchar.h",
76+
"source/src/include/miscadmin.h",
7377
"source/src/include/utils/ascii.h",
7478
"source/src/include/lib/sort_template.h",
7579
"source/src/include/lib/stringinfo.h",
@@ -186,6 +190,9 @@ include = [
186190
"source/src/interfaces/libpq/fe-auth-sasl.h",
187191
"source/src/interfaces/libpq/pqexpbuffer.h",
188192
"source/src/interfaces/libpq/libpq-events.h",
193+
"source/src/include/common/oauth-common.h",
194+
"source/src/interfaces/libpq/fe-auth-oauth.h",
195+
"source/src/interfaces/libpq/fe-auth-oauth.c",
189196
]
190197
description = "Bundled version of libpq"
191198
license = "PostgreSQL"

pq-src/additional_include/pg_config.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
#define STRERROR_R_INT 1
8181
#endif
8282

83+
/* Define to 1 if you have the <xlocale.h> header file. */
84+
#ifdef __APPLE__
85+
#define HAVE_XLOCALE_H 1
86+
#endif
87+
8388
#endif
8489

8590
// windows does not have that header
@@ -168,9 +173,7 @@
168173
#define PG_VERSION_NUM 160000
169174

170175
/* A string containing the version number, platform, and C compiler */
171-
#define PG_VERSION_STR \
172-
"PostgreSQL 16.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.2.1 " \
173-
"20230728 (Red Hat 13.2.1-1), 64-bit"
176+
#define PG_VERSION_STR "PostgreSQL 18.0"
174177

175178
/* RELSEG_SIZE is the maximum number of blocks allowed in one disk file. Thus,
176179
the maximum size of a single file is RELSEG_SIZE * BLCKSZ; relations bigger

pq-src/build.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ const LIBPORTS_BASE: &[&str] = &[
3131
// If you update this file list also
3232
// update the list of includes files in
3333
// the Cargo.toml file
34-
const LIBPORTS_LINUX: &[&str] = &["getpeereid.c", "user.c"];
34+
const LIBPORTS_LINUX: &[&str] = &["getpeereid.c"];
3535

3636
// If you update this file list also
3737
// update the list of includes files in
3838
// the Cargo.toml file
39-
const LIBPORTS_MACOS: &[&str] = &["user.c"];
39+
const LIBPORTS_MACOS: &[&str] = &[];
4040

4141
// If you update this file list also
4242
// update the list of includes files in
@@ -100,11 +100,7 @@ const LIBCOMMON_BASE: &[&str] = &[
100100
// If you update this file list also
101101
// update the list of includes files in
102102
// the Cargo.toml file
103-
const LIBCOMMON_OPENSSL: &[&str] = &[
104-
"cryptohash_openssl.c",
105-
"hmac_openssl.c",
106-
"protocol_openssl.c",
107-
];
103+
const LIBCOMMON_OPENSSL: &[&str] = &["cryptohash_openssl.c", "hmac_openssl.c"];
108104

109105
// If you update this file list also
110106
// update the list of includes files in
@@ -136,6 +132,7 @@ const LIBPQ_BASE: &[&str] = &[
136132
"fe-protocol3.c",
137133
"fe-secure.c",
138134
"fe-trace.c",
135+
"fe-auth-oauth.c",
139136
"legacy-pqsignal.c",
140137
"libpq-events.c",
141138
"pqexpbuffer.c",

pq-src/source

Submodule source updated 3810 files

src/bindings_linux.rs

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* automatically generated by rust-bindgen 0.72.0 */
1+
/* automatically generated by rust-bindgen 0.72.1 */
22

33
use libc::FILE;
44

@@ -29,6 +29,8 @@ pub const LIBPQ_HAS_CHUNK_MODE: u32 = 1;
2929
pub const LIBPQ_HAS_CLOSE_PREPARED: u32 = 1;
3030
pub const LIBPQ_HAS_SEND_PIPELINE_SYNC: u32 = 1;
3131
pub const LIBPQ_HAS_SOCKET_POLL: u32 = 1;
32+
pub const LIBPQ_HAS_FULL_PROTOCOL_VERSION: u32 = 1;
33+
pub const LIBPQ_HAS_PROMPT_OAUTH_DEVICE: u32 = 1;
3234
pub const PG_COPYRES_ATTRS: u32 = 1;
3335
pub const PG_COPYRES_TUPLES: u32 = 2;
3436
pub const PG_COPYRES_EVENTS: u32 = 4;
@@ -38,7 +40,7 @@ pub const PQTRACE_REGRESS_MODE: u32 = 2;
3840
pub const PQ_QUERY_PARAM_MAX_LIMIT: u32 = 65535;
3941
pub const PQnoPasswordSupplied: &[u8; 35] = b"fe_sendauth: no password supplied\n\0";
4042
pub type Oid = ::std::os::raw::c_uint;
41-
pub type pg_int64 = ::std::os::raw::c_long;
43+
pub type pg_int64 = i64;
4244
#[repr(u32)]
4345
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
4446
pub enum ConnStatusType {
@@ -57,6 +59,7 @@ pub enum ConnStatusType {
5759
CONNECTION_CHECK_TARGET = 12,
5860
CONNECTION_CHECK_STANDBY = 13,
5961
CONNECTION_ALLOCATED = 14,
62+
CONNECTION_AUTHENTICATING = 15,
6063
}
6164
#[repr(u32)]
6265
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -123,6 +126,12 @@ pub enum PGpipelineStatus {
123126
PQ_PIPELINE_ON = 1,
124127
PQ_PIPELINE_ABORTED = 2,
125128
}
129+
#[repr(u32)]
130+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
131+
pub enum PGauthData {
132+
PQAUTHDATA_PROMPT_OAUTH_DEVICE = 0,
133+
PQAUTHDATA_OAUTH_BEARER_TOKEN = 1,
134+
}
126135
#[repr(C)]
127136
#[derive(Debug, Copy, Clone)]
128137
pub struct pg_conn {
@@ -165,7 +174,7 @@ const _: () = {
165174
["Offset of field: pgNotify::next"][::std::mem::offset_of!(pgNotify, next) - 24usize];
166175
};
167176
pub type PGnotify = pgNotify;
168-
pub type pg_usec_time_t = pg_int64;
177+
pub type pg_usec_time_t = i64;
169178
pub type PQnoticeReceiver = ::std::option::Option<
170179
unsafe extern "C" fn(arg: *mut ::std::os::raw::c_void, res: *const PGresult),
171180
>;
@@ -444,6 +453,9 @@ unsafe extern "C" {
444453
unsafe extern "C" {
445454
pub fn PQprotocolVersion(conn: *const PGconn) -> ::std::os::raw::c_int;
446455
}
456+
unsafe extern "C" {
457+
pub fn PQfullProtocolVersion(conn: *const PGconn) -> ::std::os::raw::c_int;
458+
}
447459
unsafe extern "C" {
448460
pub fn PQserverVersion(conn: *const PGconn) -> ::std::os::raw::c_int;
449461
}
@@ -1036,9 +1048,9 @@ unsafe extern "C" {
10361048
pub fn lo_lseek64(
10371049
conn: *mut PGconn,
10381050
fd: ::std::os::raw::c_int,
1039-
offset: pg_int64,
1051+
offset: i64,
10401052
whence: ::std::os::raw::c_int,
1041-
) -> pg_int64;
1053+
) -> i64;
10421054
}
10431055
unsafe extern "C" {
10441056
pub fn lo_creat(conn: *mut PGconn, mode: ::std::os::raw::c_int) -> Oid;
@@ -1050,7 +1062,7 @@ unsafe extern "C" {
10501062
pub fn lo_tell(conn: *mut PGconn, fd: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
10511063
}
10521064
unsafe extern "C" {
1053-
pub fn lo_tell64(conn: *mut PGconn, fd: ::std::os::raw::c_int) -> pg_int64;
1065+
pub fn lo_tell64(conn: *mut PGconn, fd: ::std::os::raw::c_int) -> i64;
10541066
}
10551067
unsafe extern "C" {
10561068
pub fn lo_truncate(
@@ -1063,7 +1075,7 @@ unsafe extern "C" {
10631075
pub fn lo_truncate64(
10641076
conn: *mut PGconn,
10651077
fd: ::std::os::raw::c_int,
1066-
len: pg_int64,
1078+
len: i64,
10671079
) -> ::std::os::raw::c_int;
10681080
}
10691081
unsafe extern "C" {
@@ -1121,6 +1133,63 @@ unsafe extern "C" {
11211133
unsafe extern "C" {
11221134
pub fn PQenv2encoding() -> ::std::os::raw::c_int;
11231135
}
1136+
#[repr(C)]
1137+
#[derive(Debug, Copy, Clone)]
1138+
pub struct _PGpromptOAuthDevice {
1139+
pub verification_uri: *const ::std::os::raw::c_char,
1140+
pub user_code: *const ::std::os::raw::c_char,
1141+
pub verification_uri_complete: *const ::std::os::raw::c_char,
1142+
pub expires_in: ::std::os::raw::c_int,
1143+
}
1144+
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1145+
const _: () = {
1146+
["Size of _PGpromptOAuthDevice"][::std::mem::size_of::<_PGpromptOAuthDevice>() - 32usize];
1147+
["Alignment of _PGpromptOAuthDevice"][::std::mem::align_of::<_PGpromptOAuthDevice>() - 8usize];
1148+
["Offset of field: _PGpromptOAuthDevice::verification_uri"]
1149+
[::std::mem::offset_of!(_PGpromptOAuthDevice, verification_uri) - 0usize];
1150+
["Offset of field: _PGpromptOAuthDevice::user_code"]
1151+
[::std::mem::offset_of!(_PGpromptOAuthDevice, user_code) - 8usize];
1152+
["Offset of field: _PGpromptOAuthDevice::verification_uri_complete"]
1153+
[::std::mem::offset_of!(_PGpromptOAuthDevice, verification_uri_complete) - 16usize];
1154+
["Offset of field: _PGpromptOAuthDevice::expires_in"]
1155+
[::std::mem::offset_of!(_PGpromptOAuthDevice, expires_in) - 24usize];
1156+
};
1157+
pub type PGpromptOAuthDevice = _PGpromptOAuthDevice;
1158+
#[repr(C)]
1159+
#[derive(Debug, Copy, Clone)]
1160+
pub struct PGoauthBearerRequest {
1161+
pub openid_configuration: *const ::std::os::raw::c_char,
1162+
pub scope: *const ::std::os::raw::c_char,
1163+
pub async_: ::std::option::Option<
1164+
unsafe extern "C" fn(
1165+
conn: *mut PGconn,
1166+
request: *mut PGoauthBearerRequest,
1167+
altsock: *mut ::std::os::raw::c_int,
1168+
) -> PostgresPollingStatusType,
1169+
>,
1170+
pub cleanup: ::std::option::Option<
1171+
unsafe extern "C" fn(conn: *mut PGconn, request: *mut PGoauthBearerRequest),
1172+
>,
1173+
pub token: *mut ::std::os::raw::c_char,
1174+
pub user: *mut ::std::os::raw::c_void,
1175+
}
1176+
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1177+
const _: () = {
1178+
["Size of PGoauthBearerRequest"][::std::mem::size_of::<PGoauthBearerRequest>() - 48usize];
1179+
["Alignment of PGoauthBearerRequest"][::std::mem::align_of::<PGoauthBearerRequest>() - 8usize];
1180+
["Offset of field: PGoauthBearerRequest::openid_configuration"]
1181+
[::std::mem::offset_of!(PGoauthBearerRequest, openid_configuration) - 0usize];
1182+
["Offset of field: PGoauthBearerRequest::scope"]
1183+
[::std::mem::offset_of!(PGoauthBearerRequest, scope) - 8usize];
1184+
["Offset of field: PGoauthBearerRequest::async_"]
1185+
[::std::mem::offset_of!(PGoauthBearerRequest, async_) - 16usize];
1186+
["Offset of field: PGoauthBearerRequest::cleanup"]
1187+
[::std::mem::offset_of!(PGoauthBearerRequest, cleanup) - 24usize];
1188+
["Offset of field: PGoauthBearerRequest::token"]
1189+
[::std::mem::offset_of!(PGoauthBearerRequest, token) - 32usize];
1190+
["Offset of field: PGoauthBearerRequest::user"]
1191+
[::std::mem::offset_of!(PGoauthBearerRequest, user) - 40usize];
1192+
};
11241193
unsafe extern "C" {
11251194
pub fn PQencryptPassword(
11261195
passwd: *const ::std::os::raw::c_char,
@@ -1142,6 +1211,26 @@ unsafe extern "C" {
11421211
passwd: *const ::std::os::raw::c_char,
11431212
) -> *mut PGresult;
11441213
}
1214+
pub type PQauthDataHook_type = ::std::option::Option<
1215+
unsafe extern "C" fn(
1216+
type_: PGauthData,
1217+
conn: *mut PGconn,
1218+
data: *mut ::std::os::raw::c_void,
1219+
) -> ::std::os::raw::c_int,
1220+
>;
1221+
unsafe extern "C" {
1222+
pub fn PQsetAuthDataHook(hook: PQauthDataHook_type);
1223+
}
1224+
unsafe extern "C" {
1225+
pub fn PQgetAuthDataHook() -> PQauthDataHook_type;
1226+
}
1227+
unsafe extern "C" {
1228+
pub fn PQdefaultAuthDataHook(
1229+
type_: PGauthData,
1230+
conn: *mut PGconn,
1231+
data: *mut ::std::os::raw::c_void,
1232+
) -> ::std::os::raw::c_int;
1233+
}
11451234
unsafe extern "C" {
11461235
pub fn pg_char_to_encoding(name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
11471236
}

0 commit comments

Comments
 (0)