diff options
author | Thomas Munro <tmunro@postgresql.org> | 2025-03-25 20:17:53 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2025-03-25 21:40:00 +1300 |
commit | 3c86223c998280ea313480d319ec39f802453218 (patch) | |
tree | 191c1546be748662e8e458f407264cc04e975bb1 /src/interfaces | |
parent | be1cc9aaf5b79f07bc0483a0c95366c77a844d0a (diff) | |
download | postgresql-3c86223c998280ea313480d319ec39f802453218.tar.gz postgresql-3c86223c998280ea313480d319ec39f802453218.zip |
libpq: Deprecate pg_int64.
Previously we used pg_int64 in three function prototypes in libpq. It
was added by commit 461ef73f to expose the platform-dependent type used
for int64 in the C89 era. As of commit 962da900 it is defined as
standard int64_t, and the dust seems to have settled.
Let's just use int64_t directly in these three client-facing functions
instead of (yet) another name. We've required C99 and thus <stdint.h>
since PostgreSQL 12, C89 and C++98 compilers are long gone, and client
applications very likely use standard types for their own 64-bit needs.
This also cleans up the obscure placement of a new #include <stdint.h>
directive in postgres_ext.h, required for the new definition. The
typedef was hiding in there for historical reasons, but it doesn't fit
postgres_ext.h's own description of its purpose and there is no evidence
of client applications including postgres_ext.h directly to see it.
Keep a typedef marked deprecated for backward compatibility, but move it
into libpq-fe.h where it was used.
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/CA%2BhUKGKn_EkNNGMY5RzMcKP%2Ba6urT4JF%3DCPhw_zHtQwjvX6P2g%40mail.gmail.com
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/libpq/fe-lobj.c | 30 | ||||
-rw-r--r-- | src/interfaces/libpq/libpq-fe.h | 12 |
2 files changed, 23 insertions, 19 deletions
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 04b3aef8854..05e17bed508 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -43,8 +43,8 @@ static int lo_initialize(PGconn *conn); static Oid lo_import_internal(PGconn *conn, const char *filename, Oid oid); -static pg_int64 lo_hton64(pg_int64 host64); -static pg_int64 lo_ntoh64(pg_int64 net64); +static int64_t lo_hton64(int64_t host64); +static int64_t lo_ntoh64(int64_t net64); /* * lo_open @@ -192,7 +192,7 @@ lo_truncate(PGconn *conn, int fd, size_t len) * returns -1 upon failure */ int -lo_truncate64(PGconn *conn, int fd, pg_int64 len) +lo_truncate64(PGconn *conn, int fd, int64_t len) { PQArgBlock argv[2]; PGresult *res; @@ -381,12 +381,12 @@ lo_lseek(PGconn *conn, int fd, int offset, int whence) * lo_lseek64 * change the current read or write location on a large object */ -pg_int64 -lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence) +int64_t +lo_lseek64(PGconn *conn, int fd, int64_t offset, int whence) { PQArgBlock argv[3]; PGresult *res; - pg_int64 retval; + int64 retval; int result_len; if (lo_initialize(conn) < 0) @@ -544,10 +544,10 @@ lo_tell(PGconn *conn, int fd) * lo_tell64 * returns the current seek location of the large object */ -pg_int64 +int64_t lo_tell64(PGconn *conn, int fd) { - pg_int64 retval; + int64 retval; PQArgBlock argv[1]; PGresult *res; int result_len; @@ -1019,12 +1019,12 @@ lo_initialize(PGconn *conn) * lo_hton64 * converts a 64-bit integer from host byte order to network byte order */ -static pg_int64 -lo_hton64(pg_int64 host64) +static int64_t +lo_hton64(int64_t host64) { union { - pg_int64 i64; + int64 i64; uint32 i32[2]; } swap; uint32 t; @@ -1044,15 +1044,15 @@ lo_hton64(pg_int64 host64) * lo_ntoh64 * converts a 64-bit integer from network byte order to host byte order */ -static pg_int64 -lo_ntoh64(pg_int64 net64) +static int64_t +lo_ntoh64(int64_t net64) { union { - pg_int64 i64; + int64 i64; uint32 i32[2]; } swap; - pg_int64 result; + int64 result; swap.i64 = net64; diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 34ddfdb1831..7d3a9df6fd5 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -20,6 +20,7 @@ extern "C" { #endif +#include <stdint.h> #include <stdio.h> /* @@ -233,8 +234,11 @@ typedef struct pgNotify struct pgNotify *next; /* list link */ } PGnotify; +/* deprecated name for int64_t */ +typedef int64_t pg_int64; + /* pg_usec_time_t is like time_t, but with microsecond resolution */ -typedef pg_int64 pg_usec_time_t; +typedef int64_t pg_usec_time_t; /* Function types for notice-handling callbacks */ typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res); @@ -691,13 +695,13 @@ extern int lo_close(PGconn *conn, int fd); extern int lo_read(PGconn *conn, int fd, char *buf, size_t len); extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len); extern int lo_lseek(PGconn *conn, int fd, int offset, int whence); -extern pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence); +extern int64_t lo_lseek64(PGconn *conn, int fd, int64_t offset, int whence); extern Oid lo_creat(PGconn *conn, int mode); extern Oid lo_create(PGconn *conn, Oid lobjId); extern int lo_tell(PGconn *conn, int fd); -extern pg_int64 lo_tell64(PGconn *conn, int fd); +extern int64_t lo_tell64(PGconn *conn, int fd); extern int lo_truncate(PGconn *conn, int fd, size_t len); -extern int lo_truncate64(PGconn *conn, int fd, pg_int64 len); +extern int lo_truncate64(PGconn *conn, int fd, int64_t len); extern int lo_unlink(PGconn *conn, Oid lobjId); extern Oid lo_import(PGconn *conn, const char *filename); extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId); |