mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Autoconfiscate selection of 64-bit int type for 64-bit large object API.
Get rid of the fundamentally indefensible assumption that "long long int" exists and is exactly 64 bits wide on every platform Postgres runs on. Instead let the configure script select the type to use for "pg_int64". This is a bit of a pain in the rear since we do not want to pollute client namespace with all the random symbols that pg_config.h defines; instead we have to create a separate generated header file, "pg_config_ext.h". But now that the infrastructure is there, we might have the ability to add some other stuff that's long been wanting in this area.
This commit is contained in:
3
src/include/.gitignore
vendored
3
src/include/.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
/stamp-h
|
||||
/stamp-ext-h
|
||||
/pg_config.h
|
||||
/pg_config_ext.h
|
||||
/pg_config_os.h
|
||||
/dynloader.h
|
||||
|
||||
|
@@ -13,7 +13,7 @@ top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
|
||||
all: pg_config.h pg_config_os.h
|
||||
all: pg_config.h pg_config_ext.h pg_config_os.h
|
||||
|
||||
|
||||
# Subdirectories containing headers for server-side dev
|
||||
@@ -29,8 +29,9 @@ install: all installdirs
|
||||
# These headers are needed by the public headers of the interfaces.
|
||||
$(INSTALL_DATA) $(srcdir)/postgres_ext.h '$(DESTDIR)$(includedir)'
|
||||
$(INSTALL_DATA) $(srcdir)/libpq/libpq-fs.h '$(DESTDIR)$(includedir)/libpq'
|
||||
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir)'
|
||||
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir)'
|
||||
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir)'
|
||||
$(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir)'
|
||||
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir)'
|
||||
$(INSTALL_DATA) $(srcdir)/pg_config_manual.h '$(DESTDIR)$(includedir)'
|
||||
# These headers are needed by the not-so-public headers of the interfaces.
|
||||
$(INSTALL_DATA) $(srcdir)/c.h '$(DESTDIR)$(includedir_internal)'
|
||||
@@ -38,8 +39,9 @@ install: all installdirs
|
||||
$(INSTALL_DATA) $(srcdir)/postgres_fe.h '$(DESTDIR)$(includedir_internal)'
|
||||
$(INSTALL_DATA) $(srcdir)/libpq/pqcomm.h '$(DESTDIR)$(includedir_internal)/libpq'
|
||||
# These headers are needed for server-side development
|
||||
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir_server)'
|
||||
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir_server)'
|
||||
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir_server)'
|
||||
$(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir_server)'
|
||||
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir_server)'
|
||||
$(INSTALL_DATA) utils/errcodes.h '$(DESTDIR)$(includedir_server)/utils'
|
||||
$(INSTALL_DATA) utils/fmgroids.h '$(DESTDIR)$(includedir_server)/utils'
|
||||
# We don't use INSTALL_DATA for performance reasons --- there are a lot of files
|
||||
@@ -62,7 +64,7 @@ installdirs:
|
||||
|
||||
|
||||
uninstall:
|
||||
rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
|
||||
rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_ext.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
|
||||
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h)
|
||||
# heuristic...
|
||||
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
|
||||
@@ -72,7 +74,7 @@ clean:
|
||||
rm -f utils/fmgroids.h utils/errcodes.h parser/gram.h utils/probes.h catalog/schemapg.h
|
||||
|
||||
distclean maintainer-clean: clean
|
||||
rm -f pg_config.h dynloader.h pg_config_os.h stamp-h
|
||||
rm -f pg_config.h pg_config_ext.h pg_config_os.h dynloader.h stamp-h stamp-ext-h
|
||||
|
||||
maintainer-check:
|
||||
cd catalog && ./duplicate_oids
|
||||
|
@@ -44,19 +44,17 @@
|
||||
#ifndef C_H
|
||||
#define C_H
|
||||
|
||||
/*
|
||||
* We have to include stdlib.h here because it defines many of these macros
|
||||
* on some platforms, and we only want our definitions used if stdlib.h doesn't
|
||||
* have its own. The same goes for stddef and stdarg if present.
|
||||
*/
|
||||
#include "postgres_ext.h"
|
||||
|
||||
/* Must undef pg_config_ext.h symbols before including pg_config.h */
|
||||
#undef PG_INT64_TYPE
|
||||
|
||||
#include "pg_config.h"
|
||||
#include "pg_config_manual.h" /* must be after pg_config.h */
|
||||
#if !defined(WIN32) && !defined(__CYGWIN__) /* win32 will include further
|
||||
* down */
|
||||
|
||||
#if !defined(WIN32) && !defined(__CYGWIN__) /* win32 includes further down */
|
||||
#include "pg_config_os.h" /* must be before any system header files */
|
||||
#endif
|
||||
#include "postgres_ext.h"
|
||||
|
||||
#if _MSC_VER >= 1400 || defined(HAVE_CRTDEFS_H)
|
||||
#define errcode __msvc_errcode
|
||||
@@ -64,6 +62,12 @@
|
||||
#undef errcode
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We have to include stdlib.h here because it defines many of these macros
|
||||
* on some platforms, and we only want our definitions used if stdlib.h doesn't
|
||||
* have its own. The same goes for stddef and stdarg if present.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@@ -671,6 +671,9 @@
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to the name of a signed 64-bit integer type. */
|
||||
#undef PG_INT64_TYPE
|
||||
|
||||
/* Define to the name of the default PostgreSQL service principal in Kerberos.
|
||||
(--with-krb-srvnam=NAME) */
|
||||
#undef PG_KRB_SRVNAM
|
||||
|
@@ -562,6 +562,9 @@
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "9.3devel"
|
||||
|
||||
/* Define to the name of a signed 64-bit integer type. */
|
||||
#define PG_INT64_TYPE long long int
|
||||
|
||||
/* PostgreSQL version as a string */
|
||||
#define PG_VERSION "9.3devel"
|
||||
|
||||
|
7
src/include/pg_config_ext.h.in
Normal file
7
src/include/pg_config_ext.h.in
Normal file
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* src/include/pg_config_ext.h.in. This is generated manually, not by
|
||||
* autoheader, since we want to limit which symbols get defined here.
|
||||
*/
|
||||
|
||||
/* Define to the name of a signed 64-bit integer type. */
|
||||
#undef PG_INT64_TYPE
|
7
src/include/pg_config_ext.h.win32
Normal file
7
src/include/pg_config_ext.h.win32
Normal file
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* src/include/pg_config_ext.h.win32. This is generated manually, not by
|
||||
* autoheader, since we want to limit which symbols get defined here.
|
||||
*/
|
||||
|
||||
/* Define to the name of a signed 64-bit integer type. */
|
||||
#define PG_INT64_TYPE long long int
|
@@ -23,6 +23,8 @@
|
||||
#ifndef POSTGRES_EXT_H
|
||||
#define POSTGRES_EXT_H
|
||||
|
||||
#include "pg_config_ext.h"
|
||||
|
||||
/*
|
||||
* Object ID is a fundamental type in Postgres.
|
||||
*/
|
||||
@@ -37,6 +39,9 @@ typedef unsigned int Oid;
|
||||
#define OID_MAX UINT_MAX
|
||||
/* you will need to include <limits.h> to use the above #define */
|
||||
|
||||
/* Define a signed 64-bit integer type for use in client API declarations. */
|
||||
typedef PG_INT64_TYPE pg_int64;
|
||||
|
||||
|
||||
/*
|
||||
* Identifiers of error message fields. Kept here to keep common
|
||||
@@ -56,9 +61,4 @@ typedef unsigned int Oid;
|
||||
#define PG_DIAG_SOURCE_LINE 'L'
|
||||
#define PG_DIAG_SOURCE_FUNCTION 'R'
|
||||
|
||||
#ifndef NO_PG_INT64
|
||||
#define HAVE_PG_INT64 1
|
||||
typedef long long int pg_int64;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* POSTGRES_EXT_H */
|
||||
|
@@ -62,10 +62,13 @@ typedef struct LargeObjectDesc
|
||||
* This avoids unnecessary tuple updates caused by partial-page writes.
|
||||
*/
|
||||
#define LOBLKSIZE (BLCKSZ / 4)
|
||||
|
||||
/*
|
||||
* Maximum byte length for each large object
|
||||
*/
|
||||
#define MAX_LARGE_OBJECT_SIZE ((int64)INT_MAX * LOBLKSIZE)
|
||||
* Maximum length in bytes for a large object. To make this larger, we'd
|
||||
* have to widen pg_largeobject.pageno as well as various internal variables.
|
||||
*/
|
||||
#define MAX_LARGE_OBJECT_SIZE ((int64) INT_MAX * LOBLKSIZE)
|
||||
|
||||
|
||||
/*
|
||||
* Function definitions...
|
||||
@@ -77,8 +80,8 @@ extern Oid inv_create(Oid lobjId);
|
||||
extern LargeObjectDesc *inv_open(Oid lobjId, int flags, MemoryContext mcxt);
|
||||
extern void inv_close(LargeObjectDesc *obj_desc);
|
||||
extern int inv_drop(Oid lobjId);
|
||||
extern int64 inv_seek(LargeObjectDesc *obj_desc, int64 offset, int whence);
|
||||
extern int64 inv_tell(LargeObjectDesc *obj_desc);
|
||||
extern int64 inv_seek(LargeObjectDesc *obj_desc, int64 offset, int whence);
|
||||
extern int64 inv_tell(LargeObjectDesc *obj_desc);
|
||||
extern int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
|
||||
extern int inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes);
|
||||
extern void inv_truncate(LargeObjectDesc *obj_desc, int64 len);
|
||||
|
Reference in New Issue
Block a user