mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +03:00
libpq: Deprecate pg_int64.
Previously we used pg_int64 in three function prototypes in libpq. It was added by commit461ef73f
to expose the platform-dependent type used for int64 in the C89 era. As of commit962da900
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
This commit is contained in:
@ -522,7 +522,7 @@ switch(PQstatus(conn))
|
|||||||
sequence described in the documentation of
|
sequence described in the documentation of
|
||||||
<xref linkend="libpq-PQconnectStartParams"/>.
|
<xref linkend="libpq-PQconnectStartParams"/>.
|
||||||
<synopsis>
|
<synopsis>
|
||||||
typedef pg_int64 pg_usec_time_t;
|
typedef int64_t pg_usec_time_t;
|
||||||
|
|
||||||
int PQsocketPoll(int sock, int forRead, int forWrite,
|
int PQsocketPoll(int sock, int forRead, int forWrite,
|
||||||
pg_usec_time_t end_time);
|
pg_usec_time_t end_time);
|
||||||
|
@ -398,7 +398,7 @@ int lo_lseek(PGconn *conn, int fd, int offset, int whence);
|
|||||||
When dealing with large objects that might exceed 2GB in size,
|
When dealing with large objects that might exceed 2GB in size,
|
||||||
instead use
|
instead use
|
||||||
<synopsis>
|
<synopsis>
|
||||||
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);
|
||||||
</synopsis>
|
</synopsis>
|
||||||
This function has the same behavior
|
This function has the same behavior
|
||||||
as <function>lo_lseek</function>, but it can accept an
|
as <function>lo_lseek</function>, but it can accept an
|
||||||
@ -434,7 +434,7 @@ int lo_tell(PGconn *conn, int fd);
|
|||||||
When dealing with large objects that might exceed 2GB in size,
|
When dealing with large objects that might exceed 2GB in size,
|
||||||
instead use
|
instead use
|
||||||
<synopsis>
|
<synopsis>
|
||||||
pg_int64 lo_tell64(PGconn *conn, int fd);
|
int64_t lo_tell64(PGconn *conn, int fd);
|
||||||
</synopsis>
|
</synopsis>
|
||||||
This function has the same behavior
|
This function has the same behavior
|
||||||
as <function>lo_tell</function>, but it can deliver a result larger
|
as <function>lo_tell</function>, but it can deliver a result larger
|
||||||
@ -485,7 +485,7 @@ int lo_truncate(PGconn *conn, int fd, size_t len);
|
|||||||
When dealing with large objects that might exceed 2GB in size,
|
When dealing with large objects that might exceed 2GB in size,
|
||||||
instead use
|
instead use
|
||||||
<synopsis>
|
<synopsis>
|
||||||
int lo_truncate64(PGconn *conn, int fd, pg_int64 len);
|
int lo_truncate64(PGconn *conn, int fd, int64_t len);
|
||||||
</synopsis>
|
</synopsis>
|
||||||
This function has the same
|
This function has the same
|
||||||
behavior as <function>lo_truncate</function>, but it can accept a
|
behavior as <function>lo_truncate</function>, but it can accept a
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#ifndef POSTGRES_EXT_H
|
#ifndef POSTGRES_EXT_H
|
||||||
#define POSTGRES_EXT_H
|
#define POSTGRES_EXT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Object ID is a fundamental type in Postgres.
|
* Object ID is a fundamental type in Postgres.
|
||||||
*/
|
*/
|
||||||
@ -44,9 +42,6 @@ typedef unsigned int Oid;
|
|||||||
/* the above needs <stdlib.h> */
|
/* the above needs <stdlib.h> */
|
||||||
|
|
||||||
|
|
||||||
/* Define a signed 64-bit integer type for use in client API declarations. */
|
|
||||||
typedef int64_t pg_int64;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Identifiers of error message fields. Kept here to keep common
|
* Identifiers of error message fields. Kept here to keep common
|
||||||
* between frontend and backend, and also to export them to libpq
|
* between frontend and backend, and also to export them to libpq
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
|
|
||||||
static int lo_initialize(PGconn *conn);
|
static int lo_initialize(PGconn *conn);
|
||||||
static Oid lo_import_internal(PGconn *conn, const char *filename, Oid oid);
|
static Oid lo_import_internal(PGconn *conn, const char *filename, Oid oid);
|
||||||
static pg_int64 lo_hton64(pg_int64 host64);
|
static int64_t lo_hton64(int64_t host64);
|
||||||
static pg_int64 lo_ntoh64(pg_int64 net64);
|
static int64_t lo_ntoh64(int64_t net64);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lo_open
|
* lo_open
|
||||||
@ -192,7 +192,7 @@ lo_truncate(PGconn *conn, int fd, size_t len)
|
|||||||
* returns -1 upon failure
|
* returns -1 upon failure
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
lo_truncate64(PGconn *conn, int fd, pg_int64 len)
|
lo_truncate64(PGconn *conn, int fd, int64_t len)
|
||||||
{
|
{
|
||||||
PQArgBlock argv[2];
|
PQArgBlock argv[2];
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
@ -381,12 +381,12 @@ lo_lseek(PGconn *conn, int fd, int offset, int whence)
|
|||||||
* lo_lseek64
|
* lo_lseek64
|
||||||
* change the current read or write location on a large object
|
* change the current read or write location on a large object
|
||||||
*/
|
*/
|
||||||
pg_int64
|
int64_t
|
||||||
lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence)
|
lo_lseek64(PGconn *conn, int fd, int64_t offset, int whence)
|
||||||
{
|
{
|
||||||
PQArgBlock argv[3];
|
PQArgBlock argv[3];
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
pg_int64 retval;
|
int64 retval;
|
||||||
int result_len;
|
int result_len;
|
||||||
|
|
||||||
if (lo_initialize(conn) < 0)
|
if (lo_initialize(conn) < 0)
|
||||||
@ -544,10 +544,10 @@ lo_tell(PGconn *conn, int fd)
|
|||||||
* lo_tell64
|
* lo_tell64
|
||||||
* returns the current seek location of the large object
|
* returns the current seek location of the large object
|
||||||
*/
|
*/
|
||||||
pg_int64
|
int64_t
|
||||||
lo_tell64(PGconn *conn, int fd)
|
lo_tell64(PGconn *conn, int fd)
|
||||||
{
|
{
|
||||||
pg_int64 retval;
|
int64 retval;
|
||||||
PQArgBlock argv[1];
|
PQArgBlock argv[1];
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
int result_len;
|
int result_len;
|
||||||
@ -1019,12 +1019,12 @@ lo_initialize(PGconn *conn)
|
|||||||
* lo_hton64
|
* lo_hton64
|
||||||
* converts a 64-bit integer from host byte order to network byte order
|
* converts a 64-bit integer from host byte order to network byte order
|
||||||
*/
|
*/
|
||||||
static pg_int64
|
static int64_t
|
||||||
lo_hton64(pg_int64 host64)
|
lo_hton64(int64_t host64)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
pg_int64 i64;
|
int64 i64;
|
||||||
uint32 i32[2];
|
uint32 i32[2];
|
||||||
} swap;
|
} swap;
|
||||||
uint32 t;
|
uint32 t;
|
||||||
@ -1044,15 +1044,15 @@ lo_hton64(pg_int64 host64)
|
|||||||
* lo_ntoh64
|
* lo_ntoh64
|
||||||
* converts a 64-bit integer from network byte order to host byte order
|
* converts a 64-bit integer from network byte order to host byte order
|
||||||
*/
|
*/
|
||||||
static pg_int64
|
static int64_t
|
||||||
lo_ntoh64(pg_int64 net64)
|
lo_ntoh64(int64_t net64)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
pg_int64 i64;
|
int64 i64;
|
||||||
uint32 i32[2];
|
uint32 i32[2];
|
||||||
} swap;
|
} swap;
|
||||||
pg_int64 result;
|
int64 result;
|
||||||
|
|
||||||
swap.i64 = net64;
|
swap.i64 = net64;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -233,8 +234,11 @@ typedef struct pgNotify
|
|||||||
struct pgNotify *next; /* list link */
|
struct pgNotify *next; /* list link */
|
||||||
} PGnotify;
|
} PGnotify;
|
||||||
|
|
||||||
|
/* deprecated name for int64_t */
|
||||||
|
typedef int64_t pg_int64;
|
||||||
|
|
||||||
/* pg_usec_time_t is like time_t, but with microsecond resolution */
|
/* 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 */
|
/* Function types for notice-handling callbacks */
|
||||||
typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
|
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_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_write(PGconn *conn, int fd, const char *buf, size_t len);
|
||||||
extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
|
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_creat(PGconn *conn, int mode);
|
||||||
extern Oid lo_create(PGconn *conn, Oid lobjId);
|
extern Oid lo_create(PGconn *conn, Oid lobjId);
|
||||||
extern int lo_tell(PGconn *conn, int fd);
|
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_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 int lo_unlink(PGconn *conn, Oid lobjId);
|
||||||
extern Oid lo_import(PGconn *conn, const char *filename);
|
extern Oid lo_import(PGconn *conn, const char *filename);
|
||||||
extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
|
extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ importFile(PGconn *conn, char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pickout(PGconn *conn, Oid lobjId, pg_int64 start, int len)
|
pickout(PGconn *conn, Oid lobjId, int64_t start, int len)
|
||||||
{
|
{
|
||||||
int lobj_fd;
|
int lobj_fd;
|
||||||
char *buf;
|
char *buf;
|
||||||
@ -110,7 +111,7 @@ pickout(PGconn *conn, Oid lobjId, pg_int64 start, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
overwrite(PGconn *conn, Oid lobjId, pg_int64 start, int len)
|
overwrite(PGconn *conn, Oid lobjId, int64_t start, int len)
|
||||||
{
|
{
|
||||||
int lobj_fd;
|
int lobj_fd;
|
||||||
char *buf;
|
char *buf;
|
||||||
@ -148,7 +149,7 @@ overwrite(PGconn *conn, Oid lobjId, pg_int64 start, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_truncate(PGconn *conn, Oid lobjId, pg_int64 len)
|
my_truncate(PGconn *conn, Oid lobjId, int64_t len)
|
||||||
{
|
{
|
||||||
int lobj_fd;
|
int lobj_fd;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user