Re: AIX support - Mailing list pgsql-hackers
| From | Tom Lane |
|---|---|
| Subject | Re: AIX support |
| Date | |
| Msg-id | 2708568.1771545312@sss.pgh.pa.us Whole thread Raw |
| In response to | Re: AIX support (Tom Lane <tgl@sss.pgh.pa.us>) |
| List | pgsql-hackers |
I wrote: > Peter Eisentraut <peter@eisentraut.org> writes: >> Regarding patch 0004, please see the thread >> https://www.postgresql.org/message-id/flat/e8aa97db-872b-4087-b073-f296baae948d%40eisentraut.org >> which is developing a more general and more robust version of that patch. > Ah. I don't object to having a more general version, as long as > the AIX patch can auto-disable static libraries rather than having > a gotcha "it breaks with a mysterious error if you don't say this". Attached is an updated AIX patchset based on the assumption that you'll first commit the v3 patch in that thread (or some close relative of it). v7-0001 below is exactly that v3 patch, and then the rest are rebased on top of it. With that patch, v6-0004 became vestigial, amounting to just the line + build_static_lib = false plus some commentary. So I folded it into the new v7-0004-Various-minor-adjustments-for-AIX.patch and also merged the requested addition of /opt/freeware/lib into that patch. The other patches are the same as before except for some very minor rebasing adjustments. Also, now that p9-aix1-postgres1 has a full Python installation (thanks for that!), I tried --with-python, and sure enough it did not work. But the cause turns out to be quite trivial: python.m4 has hard-wired knowledge about the set of plausible shlib file extensions, and ".a" is not one of them. So v7-0008 attached fixes that. The meson side seems fine already. To be clear, I anticipate squashing all the AIX-specific bits (0003-0008) into one commit in the end. But 0001 and 0002 seem worth committing separately in case they affect any other platforms. In the meantime, keeping the bits separate seems like it might ease review. To my mind this is pretty nearly ready to go. It's waiting on Peter to commit his patch (0001), and I'd really like to retest on AIX 7.3. But cfarm119 is still offline and I won't wait for it forever. regards, tom lane From 80570dbf699e3df4704d2ef8fbb54edd1bda92a6 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Wed, 18 Feb 2026 13:22:37 -0500 Subject: [PATCH v7 1/8] meson: allow disabling building/installation of static libraries. We now support the common meson option -Ddefault_library, with values 'both' (the default), 'shared' (install only shared libraries), and 'static' (install only static libraries). The 'static' choice doesn't actually work, since psql and other programs insist on linking to the shared version of libpq, but it's there pro-forma. It could be built out if we really wanted, but since we have never supported the equivalent in the autoconf build system, I think we don't want it. With an eye to re-supporting AIX, the internal implementation distinguishes whether to install libpgport.a and other static-only libraries from whether to build/install the static variant of libraries that we can build both ways. This detail isn't exposed as a meson option, though it could be if there's demand. Author: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/e8aa97db-872b-4087-b073-f296baae948d@eisentraut.org --- .cirrus.tasks.yml | 1 + meson.build | 38 +++++++++++++++++----- src/common/meson.build | 1 + src/fe_utils/meson.build | 4 ++- src/interfaces/ecpg/compatlib/meson.build | 4 +++ src/interfaces/ecpg/ecpglib/meson.build | 4 +++ src/interfaces/ecpg/pgtypeslib/meson.build | 8 +++-- src/interfaces/libpq-oauth/meson.build | 6 ++++ src/interfaces/libpq/meson.build | 6 ++++ src/port/meson.build | 1 + 10 files changed, 61 insertions(+), 12 deletions(-) diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml index 2a821593ce5..4841a204248 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -133,6 +133,7 @@ task: meson setup \ --buildtype=debug \ --auto-features=disabled \ + -Ddefault_library=shared \ -Dtap_tests=enabled \ build EOF diff --git a/meson.build b/meson.build index 055e96315d0..2ef35f2a0ac 100644 --- a/meson.build +++ b/meson.build @@ -20,6 +20,7 @@ project('postgresql', 'warning_level=1', #-Wall equivalent 'b_pch=false', 'buildtype=debugoptimized', # -O2 + debug + 'default_library=both', # For compatibility with the autoconf build, set a default prefix. This # works even on windows, where it's a drive-relative path (i.e. when on # d:/somepath it'll install to d:/usr/local/pgsql) @@ -50,6 +51,31 @@ not_found_dep = dependency('', required: false) thread_dep = dependency('threads') auto_features = get_option('auto_features') +# Declare variables to disable static or shared libraries. This +# makes the 'default_library' option work even though we don't use the +# library() function but instead shared_library() and static_library() +# separately. +# +# build_shared_lib/build_static_lib control building/installing the two +# versions of libraries that we can build both versions of (e.g., libpq). +# There are also libraries that we only build a static version of (e.g., +# libpgport). These are always built, since we need them while building, +# but they are installed only if install_internal_static_lib is true. +# +# Note: at present, -Ddefault_library=static doesn't actually work, because +# psql and other programs insist on linking to the shared version of libpq. +# This could be fixed if there was interest, but so far there is not. +default_library_opt = get_option('default_library') +build_shared_lib = true +build_static_lib = true +install_internal_static_lib = true +if default_library_opt == 'shared' + build_static_lib = false + install_internal_static_lib = false +elif default_library_opt == 'static' + build_shared_lib = false +endif + ############################################################### @@ -3104,6 +3130,7 @@ add_project_link_arguments(ldflags, language: ['c', 'cpp']) # list of targets for various alias targets backend_targets = [] bin_targets = [] +libpq_targets = [] pl_targets = [] contrib_targets = [] testprep_targets = [] @@ -3530,20 +3557,13 @@ endif installed_targets = [ backend_targets, bin_targets, - libpq_st, + libpq_targets, pl_targets, contrib_targets, nls_mo_targets, ecpg_targets, ] -if oauth_flow_supported - installed_targets += [ - libpq_oauth_so, - libpq_oauth_st, - ] -endif - # all targets that require building code all_built = [ installed_targets, @@ -3880,7 +3900,7 @@ add_test_setup('running', ############################################################### alias_target('backend', backend_targets) -alias_target('bin', bin_targets + [libpq_st]) +alias_target('bin', bin_targets + libpq_targets) alias_target('pl', pl_targets) alias_target('contrib', contrib_targets) alias_target('testprep', testprep_targets) diff --git a/src/common/meson.build b/src/common/meson.build index b757618a9c9..4f9b8b8263d 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -192,6 +192,7 @@ foreach name, opts : pgcommon_variants opts.get('include_directories', []), ], 'dependencies': opts['dependencies'] + [ssl], + 'install': install_internal_static_lib and name != '_srv', } ) pgcommon += {name: lib} diff --git a/src/fe_utils/meson.build b/src/fe_utils/meson.build index a2420ea2d5c..86befca192e 100644 --- a/src/fe_utils/meson.build +++ b/src/fe_utils/meson.build @@ -35,5 +35,7 @@ fe_utils = static_library('libpgfeutils', include_directories: [postgres_inc, libpq_inc], c_args: host_system == 'windows' ? ['-DFD_SETSIZE=1024'] : [], dependencies: frontend_common_code, - kwargs: default_lib_args, + kwargs: default_lib_args + { + 'install': install_internal_static_lib, + }, ) diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build index 6cb1be73407..d578faefe1c 100644 --- a/src/interfaces/ecpg/compatlib/meson.build +++ b/src/interfaces/ecpg/compatlib/meson.build @@ -16,6 +16,7 @@ if host_system == 'windows' endif # see src/interfaces/libpq/meson.build +if build_static_lib ecpg_compat_st = static_library('libecpg_compat', ecpg_compat_sources, include_directories: ecpg_compat_inc, @@ -25,7 +26,9 @@ ecpg_compat_st = static_library('libecpg_compat', kwargs: default_lib_args, ) ecpg_targets += ecpg_compat_st +endif +if build_shared_lib ecpg_compat_so = shared_library('libecpg_compat', ecpg_compat_sources + ecpg_compat_so_sources, include_directories: ecpg_compat_inc, @@ -40,6 +43,7 @@ ecpg_compat_so = shared_library('libecpg_compat', kwargs: default_lib_args, ) ecpg_targets += ecpg_compat_so +endif pkgconfig.generate( name: 'libecpg_compat', diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build index 889bd9efd65..81e92151945 100644 --- a/src/interfaces/ecpg/ecpglib/meson.build +++ b/src/interfaces/ecpg/ecpglib/meson.build @@ -25,6 +25,7 @@ if host_system == 'windows' endif # see src/interfaces/libpq/meson.build +if build_static_lib ecpglib_st = static_library('libecpg', ecpglib_sources, include_directories: ecpglib_inc, @@ -35,7 +36,9 @@ ecpglib_st = static_library('libecpg', kwargs: default_lib_args, ) ecpg_targets += ecpglib_st +endif +if build_shared_lib ecpglib_so = shared_library('libecpg', ecpglib_sources + ecpglib_so_sources, include_directories: ecpglib_inc, @@ -51,6 +54,7 @@ ecpglib_so = shared_library('libecpg', kwargs: default_lib_args, ) ecpg_targets += ecpglib_so +endif pkgconfig.generate( name: 'libecpg', diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build index 6b78f529e53..241fa95e559 100644 --- a/src/interfaces/ecpg/pgtypeslib/meson.build +++ b/src/interfaces/ecpg/pgtypeslib/meson.build @@ -21,22 +21,25 @@ if host_system == 'windows' endif # see src/interfaces/libpq/meson.build +if build_static_lib ecpg_pgtypes_st = static_library('libpgtypes', ecpg_pgtypes_sources, include_directories: ecpg_pgtypes_inc, c_args: ecpg_pgtypes_c_args, c_pch: pch_postgres_fe_h, - dependencies: frontend_stlib_code, + dependencies: [frontend_stlib_code], kwargs: default_lib_args, ) ecpg_targets += ecpg_pgtypes_st +endif +if build_shared_lib ecpg_pgtypes_so = shared_library('libpgtypes', ecpg_pgtypes_sources + ecpg_pgtypes_so_sources, include_directories: ecpg_pgtypes_inc, c_args: ecpg_pgtypes_c_args, c_pch: pch_postgres_fe_h, - dependencies: frontend_shlib_code, + dependencies: [frontend_shlib_code], version: '3.' + pg_version_major.to_string(), soversion: host_system != 'windows' ? '3' : '', darwin_versions: ['3', '3.' + pg_version_major.to_string()], @@ -45,6 +48,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes', kwargs: default_lib_args, ) ecpg_targets += ecpg_pgtypes_so +endif pkgconfig.generate( name: 'libpgtypes', diff --git a/src/interfaces/libpq-oauth/meson.build b/src/interfaces/libpq-oauth/meson.build index d8a0c04095a..27aca2bc324 100644 --- a/src/interfaces/libpq-oauth/meson.build +++ b/src/interfaces/libpq-oauth/meson.build @@ -21,6 +21,7 @@ export_file = custom_target('libpq-oauth.exports', # port needs to be in include path due to pthread-win32.h libpq_oauth_inc = include_directories('.', '../libpq', '../../port') +if build_static_lib libpq_oauth_st = static_library('libpq-oauth', libpq_oauth_sources, include_directories: [libpq_oauth_inc, postgres_inc], @@ -32,11 +33,14 @@ libpq_oauth_st = static_library('libpq-oauth', ], kwargs: default_lib_args, ) +libpq_targets += libpq_oauth_st +endif # This is an internal module; we don't want an SONAME and therefore do not set # SO_MAJOR_VERSION. libpq_oauth_name = 'libpq-oauth-@0@'.format(pg_version_major) +if build_shared_lib libpq_oauth_so = shared_module(libpq_oauth_name, libpq_oauth_sources + libpq_oauth_so_sources, include_directories: [libpq_oauth_inc, postgres_inc], @@ -47,6 +51,8 @@ libpq_oauth_so = shared_module(libpq_oauth_name, link_args: export_fmt.format(export_file.full_path()), kwargs: default_lib_args, ) +libpq_targets += libpq_oauth_so +endif libpq_oauth_test_deps = [] diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build index c5ecd9c3a87..2b95098187e 100644 --- a/src/interfaces/libpq/meson.build +++ b/src/interfaces/libpq/meson.build @@ -57,6 +57,7 @@ libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH'] # We could try to avoid building the source files twice, but it probably adds # more complexity than its worth (reusing object files requires also linking # to the library on windows or breaks precompiled headers). +if build_static_lib libpq_st = static_library('libpq', libpq_sources, include_directories: [libpq_inc], @@ -65,7 +66,10 @@ libpq_st = static_library('libpq', dependencies: [frontend_stlib_code, libpq_deps], kwargs: default_lib_args, ) +libpq_targets += libpq_st +endif +if build_shared_lib libpq_so = shared_library('libpq', libpq_sources + libpq_so_sources, include_directories: [libpq_inc, postgres_inc], @@ -79,6 +83,8 @@ libpq_so = shared_library('libpq', link_args: export_fmt.format(export_file.full_path()), kwargs: default_lib_args, ) +libpq_targets += libpq_so +endif libpq = declare_dependency( link_with: [libpq_so], diff --git a/src/port/meson.build b/src/port/meson.build index d7d4e705b89..52f9b3da631 100644 --- a/src/port/meson.build +++ b/src/port/meson.build @@ -192,6 +192,7 @@ foreach name, opts : pgport_variants c_pch: pch_c_h, kwargs: opts + { 'dependencies': opts['dependencies'] + [ssl], + 'install': install_internal_static_lib and name != '_srv', } ) pgport += {name: lib} -- 2.43.7 From 1b746297d09c74d0fe4ae31c2f008671bc3de250 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Sat, 14 Feb 2026 18:16:46 -0500 Subject: [PATCH v7 2/8] Cope with AIX's alignment woes by using _Pragma("pack"). Because we assume that int64 and double have the same alignment requirement, AIX's default behavior that alignof(double) = 4 while alignof(int64) = 8 is a headache. There are two issues: 1. We align both int8 and float8 tuple columns per ALIGNOF_DOUBLE, which is an ancient choice that can't be undone without breaking pg_upgrade and creating some subtle SQL-level compatibility issues too. However, the cost of that is just some marginal inefficiency in fetching int8 values, which can't be too awful if the platform architects were willing to pay the same costs for fetching float8s. So our decision is to leave that alone. This patch makes our alignment choices the same as they were pre-v17, namely that ALIGNOF_DOUBLE and ALIGNOF_INT64_T are whatever the compiler prefers and then MAXIMUM_ALIGNOF is the larger of the two. (On all supported platforms other than AIX, all three values will be the same.) 2. We need to overlay C structs onto catalog tuples, and int8 fields in those struct declarations may not be aligned to match this rule. In the old branches we had some annoying rules about ordering catalog columns to avoid alignment problems, but nobody wants to resurrect those. However, there's a better answer: make the compiler construe those struct declarations the way we need it to by using the pack(N) pragma. This requires no manual effort to maintain going forward; we only have to insert the pragma into all the catalog *.h files. (As the catalogs stand at this writing, nothing actually changes because we've not moved any affected columns since v16; hence no catversion bump is required. The point of this is to not have to worry about the issue going forward.) We did not have this option when the AIX port was first made. This patch depends on the C99 feature _Pragma(), as well as the pack(N) pragma which dates to somewhere around gcc 4.0, and probably doesn't exist in xlc at all. But now that we've agreed to toss xlc support out the window, there doesn't seem to be a reason not to go this way. In passing, I got rid of LONGALIGN[_DOWN] along with the configure probes for ALIGNOF_LONG. We were not using those anywhere and it seems highly unlikely that we'd do so in future. Instead supply INT64ALIGN[_DOWN], which isn't used either but at least could have a good reason to be used. Discussion: https://postgr.es/m/1127261.1769649624@sss.pgh.pa.us --- configure | 68 ++++--------------- configure.ac | 32 +++------ meson.build | 33 ++++----- src/include/c.h | 4 +- src/include/catalog/genbki.h | 19 ++++++ src/include/catalog/pg_aggregate.h | 4 ++ src/include/catalog/pg_am.h | 4 ++ src/include/catalog/pg_amop.h | 4 ++ src/include/catalog/pg_amproc.h | 4 ++ src/include/catalog/pg_attrdef.h | 4 ++ src/include/catalog/pg_attribute.h | 4 ++ src/include/catalog/pg_auth_members.h | 4 ++ src/include/catalog/pg_authid.h | 4 ++ src/include/catalog/pg_cast.h | 4 ++ src/include/catalog/pg_class.h | 4 ++ src/include/catalog/pg_collation.h | 4 ++ src/include/catalog/pg_constraint.h | 4 ++ src/include/catalog/pg_conversion.h | 4 ++ src/include/catalog/pg_database.h | 4 ++ src/include/catalog/pg_db_role_setting.h | 4 ++ src/include/catalog/pg_default_acl.h | 4 ++ src/include/catalog/pg_depend.h | 4 ++ src/include/catalog/pg_description.h | 4 ++ src/include/catalog/pg_enum.h | 4 ++ src/include/catalog/pg_event_trigger.h | 4 ++ src/include/catalog/pg_extension.h | 4 ++ src/include/catalog/pg_foreign_data_wrapper.h | 4 ++ src/include/catalog/pg_foreign_server.h | 4 ++ src/include/catalog/pg_foreign_table.h | 4 ++ src/include/catalog/pg_index.h | 4 ++ src/include/catalog/pg_inherits.h | 4 ++ src/include/catalog/pg_init_privs.h | 4 ++ src/include/catalog/pg_language.h | 4 ++ src/include/catalog/pg_largeobject.h | 4 ++ src/include/catalog/pg_largeobject_metadata.h | 4 ++ src/include/catalog/pg_namespace.h | 4 ++ src/include/catalog/pg_opclass.h | 4 ++ src/include/catalog/pg_operator.h | 4 ++ src/include/catalog/pg_opfamily.h | 4 ++ src/include/catalog/pg_parameter_acl.h | 4 ++ src/include/catalog/pg_partitioned_table.h | 4 ++ src/include/catalog/pg_policy.h | 4 ++ src/include/catalog/pg_proc.h | 4 ++ src/include/catalog/pg_publication.h | 4 ++ .../catalog/pg_publication_namespace.h | 4 ++ src/include/catalog/pg_publication_rel.h | 4 ++ src/include/catalog/pg_range.h | 4 ++ src/include/catalog/pg_replication_origin.h | 4 ++ src/include/catalog/pg_rewrite.h | 4 ++ src/include/catalog/pg_seclabel.h | 4 ++ src/include/catalog/pg_sequence.h | 4 ++ src/include/catalog/pg_shdepend.h | 4 ++ src/include/catalog/pg_shdescription.h | 4 ++ src/include/catalog/pg_shseclabel.h | 4 ++ src/include/catalog/pg_statistic.h | 4 ++ src/include/catalog/pg_statistic_ext.h | 4 ++ src/include/catalog/pg_statistic_ext_data.h | 4 ++ src/include/catalog/pg_subscription.h | 4 ++ src/include/catalog/pg_subscription_rel.h | 4 ++ src/include/catalog/pg_tablespace.h | 4 ++ src/include/catalog/pg_transform.h | 4 ++ src/include/catalog/pg_trigger.h | 4 ++ src/include/catalog/pg_ts_config.h | 4 ++ src/include/catalog/pg_ts_config_map.h | 4 ++ src/include/catalog/pg_ts_dict.h | 4 ++ src/include/catalog/pg_ts_parser.h | 4 ++ src/include/catalog/pg_ts_template.h | 4 ++ src/include/catalog/pg_type.h | 4 ++ src/include/catalog/pg_user_mapping.h | 4 ++ src/include/pg_config.h.in | 3 - 70 files changed, 315 insertions(+), 100 deletions(-) diff --git a/configure b/configure index a6eab396299..8d95bebdfa7 100755 --- a/configure +++ b/configure @@ -17095,41 +17095,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -# The cast to long int works around a bug in the HP C Compiler, -# see AC_CHECK_SIZEOF for more information. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of long" >&5 -$as_echo_n "checking alignment of long... " >&6; } -if ${ac_cv_alignof_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_long" "$ac_includes_default -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; long y; } ac__type_alignof_;"; then : - -else - if test "$ac_cv_type_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute alignment of long -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_alignof_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_long" >&5 -$as_echo "$ac_cv_alignof_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define ALIGNOF_LONG $ac_cv_alignof_long -_ACEOF - - # The cast to long int works around a bug in the HP C Compiler, # see AC_CHECK_SIZEOF for more information. { $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of int64_t" >&5 @@ -17203,27 +17168,18 @@ _ACEOF # Compute maximum alignment of any basic type. # -# We require 'double' to have the strictest alignment among the basic types, -# because otherwise the C ABI might impose 8-byte alignment on some of the -# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could -# cause a mismatch between the tuple layout and the C struct layout of a -# catalog tuple. We used to carefully order catalog columns such that any -# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless -# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms -# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF. -# -# We assume without checking that long's alignment is at least as strong as -# char, short, or int. Note that we intentionally do not consider any types -# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too -# much of a penalty for disk and memory space. - -MAX_ALIGNOF=$ac_cv_alignof_double - -if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then - as_fn_error $? "alignment of 'long' is greater than the alignment of 'double'" "$LINENO" 5 -fi -if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then - as_fn_error $? "alignment of 'int64_t' is greater than the alignment of 'double'" "$LINENO" 5 +# We assume without checking that the maximum alignment requirement is that +# of int64_t and/or double. (On most platforms those are the same, but not +# everywhere.) For historical reasons, both int8 and float8 datatypes have +# typalign 'd', and therefore will be aligned per ALIGNOF_DOUBLE in database +# tuples even if ALIGNOF_INT64_T is more. Note that we intentionally do not +# consider any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed +# 8 would be too much of a penalty for disk and memory space. + +if test $ac_cv_alignof_int64_t -gt $ac_cv_alignof_double ; then + MAX_ALIGNOF=$ac_cv_alignof_int64_t +else + MAX_ALIGNOF=$ac_cv_alignof_double fi cat >>confdefs.h <<_ACEOF diff --git a/configure.ac b/configure.ac index 455ba31f1d1..2e44abe8dae 100644 --- a/configure.ac +++ b/configure.ac @@ -2031,33 +2031,23 @@ AC_CHECK_SIZEOF([intmax_t]) AC_CHECK_ALIGNOF(short) AC_CHECK_ALIGNOF(int) -AC_CHECK_ALIGNOF(long) AC_CHECK_ALIGNOF(int64_t) AC_CHECK_ALIGNOF(double) # Compute maximum alignment of any basic type. # -# We require 'double' to have the strictest alignment among the basic types, -# because otherwise the C ABI might impose 8-byte alignment on some of the -# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could -# cause a mismatch between the tuple layout and the C struct layout of a -# catalog tuple. We used to carefully order catalog columns such that any -# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless -# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms -# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF. -# -# We assume without checking that long's alignment is at least as strong as -# char, short, or int. Note that we intentionally do not consider any types -# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too -# much of a penalty for disk and memory space. - -MAX_ALIGNOF=$ac_cv_alignof_double +# We assume without checking that the maximum alignment requirement is that +# of int64_t and/or double. (On most platforms those are the same, but not +# everywhere.) For historical reasons, both int8 and float8 datatypes have +# typalign 'd', and therefore will be aligned per ALIGNOF_DOUBLE in database +# tuples even if ALIGNOF_INT64_T is more. Note that we intentionally do not +# consider any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed +# 8 would be too much of a penalty for disk and memory space. -if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then - AC_MSG_ERROR([alignment of 'long' is greater than the alignment of 'double']) -fi -if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then - AC_MSG_ERROR([alignment of 'int64_t' is greater than the alignment of 'double']) +if test $ac_cv_alignof_int64_t -gt $ac_cv_alignof_double ; then + MAX_ALIGNOF=$ac_cv_alignof_int64_t +else + MAX_ALIGNOF=$ac_cv_alignof_double fi AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.]) diff --git a/meson.build b/meson.build index 2ef35f2a0ac..4fc95bee960 100644 --- a/meson.build +++ b/meson.build @@ -1826,32 +1826,29 @@ endif # Determine memory alignment requirements for the basic C data types. -alignof_types = ['short', 'int', 'long', 'double'] +alignof_types = ['short', 'int', 'int64_t', 'double'] foreach t : alignof_types - align = cc.alignment(t, args: test_c_args) + align = cc.alignment(t, args: test_c_args, prefix: '#include <stdint.h>') cdata.set('ALIGNOF_@0@'.format(t.to_upper()), align) endforeach # Compute maximum alignment of any basic type. # -# We require 'double' to have the strictest alignment among the basic types, -# because otherwise the C ABI might impose 8-byte alignment on some of the -# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could -# cause a mismatch between the tuple layout and the C struct layout of a -# catalog tuple. We used to carefully order catalog columns such that any -# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless -# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms -# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF. -# -# We assume without checking that int64_t's alignment is at least as strong -# as long, char, short, or int. Note that we intentionally do not consider -# any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 -# would be too much of a penalty for disk and memory space. +# We assume without checking that the maximum alignment requirement is that +# of int64_t and/or double. (On most platforms those are the same, but not +# everywhere.) For historical reasons, both int8 and float8 datatypes have +# typalign 'd', and therefore will be aligned per ALIGNOF_DOUBLE in database +# tuples even if ALIGNOF_INT64_T is more. Note that we intentionally do not +# consider any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed +# 8 would be too much of a penalty for disk and memory space. + +alignof_int64_t = cdata.get('ALIGNOF_INT64_T') alignof_double = cdata.get('ALIGNOF_DOUBLE') -if cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>') > alignof_double - error('alignment of int64_t is greater than the alignment of double') +if alignof_int64_t > alignof_double + cdata.set('MAXIMUM_ALIGNOF', alignof_int64_t) +else + cdata.set('MAXIMUM_ALIGNOF', alignof_double) endif -cdata.set('MAXIMUM_ALIGNOF', alignof_double) cdata.set('SIZEOF_LONG', cc.sizeof('long', args: test_c_args)) cdata.set('SIZEOF_LONG_LONG', cc.sizeof('long long', args: test_c_args)) diff --git a/src/include/c.h b/src/include/c.h index 7ee4751992f..fb0ea1bc680 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -833,7 +833,7 @@ typedef NameData *Name; #define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN)) #define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN)) -#define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN)) +#define INT64ALIGN(LEN) TYPEALIGN(ALIGNOF_INT64_T, (LEN)) #define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN)) #define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN)) /* MAXALIGN covers only built-in types, not buffers */ @@ -845,7 +845,7 @@ typedef NameData *Name; #define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN)) #define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN)) -#define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN)) +#define INT64ALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT64_T, (LEN)) #define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN)) #define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN)) #define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN)) diff --git a/src/include/catalog/genbki.h b/src/include/catalog/genbki.h index 4606a29160e..12d2a3e295b 100644 --- a/src/include/catalog/genbki.h +++ b/src/include/catalog/genbki.h @@ -19,6 +19,25 @@ #ifndef GENBKI_H #define GENBKI_H +/* + * These macros should be written before and after each catalog structure + * definition. On most platforms they do nothing, but on some platforms + * we need special hacks to coax the compiler into laying out the catalog + * struct compatibly with our tuple forming/deforming rules. + * + * On AIX, where ALIGNOF_DOUBLE < ALIGNOF_INT64_T, we need to coerce int64 + * catalog fields to be aligned on just 4-byte boundaries. Ideally we'd + * write this like pack(push,ALIGNOF_DOUBLE), but gcc seems unwilling + * to take anything but a plain string literal as the argument of _Pragma. + */ +#if ALIGNOF_DOUBLE < ALIGNOF_INT64_T +#define BEGIN_CATALOG_STRUCT _Pragma("pack(push,4)") +#define END_CATALOG_STRUCT _Pragma("pack(pop)") +#else +#define BEGIN_CATALOG_STRUCT +#define END_CATALOG_STRUCT +#endif + /* Introduces a catalog's structure definition */ #define CATALOG(name,oid,oidmacro) typedef struct CppConcat(FormData_,name) diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h index 7ea0f64176c..2b4f5dae5f2 100644 --- a/src/include/catalog/pg_aggregate.h +++ b/src/include/catalog/pg_aggregate.h @@ -29,6 +29,8 @@ * cpp turns this into typedef struct FormData_pg_aggregate * ---------------------------------------------------------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_aggregate,2600,AggregateRelationId) { /* pg_proc OID of the aggregate itself */ @@ -101,6 +103,8 @@ CATALOG(pg_aggregate,2600,AggregateRelationId) #endif } FormData_pg_aggregate; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_aggregate corresponds to a pointer to a tuple with * the format of pg_aggregate relation. diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h index e039315255c..62bc3fb8206 100644 --- a/src/include/catalog/pg_am.h +++ b/src/include/catalog/pg_am.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_am * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_am,2601,AccessMethodRelationId) { Oid oid; /* oid */ @@ -40,6 +42,8 @@ CATALOG(pg_am,2601,AccessMethodRelationId) char amtype; } FormData_pg_am; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_am corresponds to a pointer to a tuple with * the format of pg_am relation. diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index b27abb3b457..ebc774d73fb 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -51,6 +51,8 @@ * typedef struct FormData_pg_amop * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_amop,2602,AccessMethodOperatorRelationId) { Oid oid; /* oid */ @@ -80,6 +82,8 @@ CATALOG(pg_amop,2602,AccessMethodOperatorRelationId) Oid amopsortfamily BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_opfamily); } FormData_pg_amop; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_amop corresponds to a pointer to a tuple with * the format of pg_amop relation. diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index 15c1201ff65..3a3869e75a9 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -40,6 +40,8 @@ * typedef struct FormData_pg_amproc * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_amproc,2603,AccessMethodProcedureRelationId) { Oid oid; /* oid */ @@ -60,6 +62,8 @@ CATALOG(pg_amproc,2603,AccessMethodProcedureRelationId) regproc amproc BKI_LOOKUP(pg_proc); } FormData_pg_amproc; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_amproc corresponds to a pointer to a tuple with * the format of pg_amproc relation. diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h index 89ea89a6daa..8bbc3b88827 100644 --- a/src/include/catalog/pg_attrdef.h +++ b/src/include/catalog/pg_attrdef.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_attrdef * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_attrdef,2604,AttrDefaultRelationId) { Oid oid; /* oid */ @@ -41,6 +43,8 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId) #endif } FormData_pg_attrdef; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_attrdef corresponds to a pointer to a tuple with * the format of pg_attrdef relation. diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 45844bb752c..f33a57573f2 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -34,6 +34,8 @@ * You may need to change catalog/genbki.pl as well. * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,AttributeRelation_Rowtype_Id) BKI_SCHEMA_MACRO { Oid attrelid BKI_LOOKUP(pg_class); /* OID of relation containing @@ -185,6 +187,8 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75, #endif } FormData_pg_attribute; +END_CATALOG_STRUCT + /* * ATTRIBUTE_FIXED_PART_SIZE is the size of the fixed-layout, * guaranteed-not-null part of a pg_attribute row. This is in fact as much diff --git a/src/include/catalog/pg_auth_members.h b/src/include/catalog/pg_auth_members.h index 92cf5271496..b1902321a8f 100644 --- a/src/include/catalog/pg_auth_members.h +++ b/src/include/catalog/pg_auth_members.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_auth_members * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_auth_members,1261,AuthMemRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(2843,AuthMemRelation_Rowtype_Id) BKI_SCHEMA_MACRO { Oid oid; /* oid */ @@ -38,6 +40,8 @@ CATALOG(pg_auth_members,1261,AuthMemRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_ bool set_option; /* use SET ROLE to the target role? */ } FormData_pg_auth_members; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_auth_members corresponds to a pointer to a tuple with * the format of pg_auth_members relation. diff --git a/src/include/catalog/pg_authid.h b/src/include/catalog/pg_authid.h index bddb154cd1b..baf5b099797 100644 --- a/src/include/catalog/pg_authid.h +++ b/src/include/catalog/pg_authid.h @@ -28,6 +28,8 @@ * typedef struct FormData_pg_authid * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(2842,AuthIdRelation_Rowtype_Id) BKI_SCHEMA_MACRO { Oid oid; /* oid */ @@ -48,6 +50,8 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284 #endif } FormData_pg_authid; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_authid corresponds to a pointer to a tuple with * the format of pg_authid relation. diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h index 2c9633a5ecb..d81314946ee 100644 --- a/src/include/catalog/pg_cast.h +++ b/src/include/catalog/pg_cast.h @@ -29,6 +29,8 @@ * typedef struct FormData_pg_cast * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_cast,2605,CastRelationId) { Oid oid; /* oid */ @@ -49,6 +51,8 @@ CATALOG(pg_cast,2605,CastRelationId) char castmethod; } FormData_pg_cast; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_cast corresponds to a pointer to a tuple with * the format of pg_cast relation. diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 89ab34c8349..ae6e36aeff6 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -29,6 +29,8 @@ * BKI_BOOTSTRAP catalogs, since only those rows appear in pg_class.dat. * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,RelationRelation_Rowtype_Id) BKI_SCHEMA_MACRO { /* oid */ @@ -144,6 +146,8 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat #endif } FormData_pg_class; +END_CATALOG_STRUCT + /* Size of fixed part of pg_class tuples, not counting var-length fields */ #define CLASS_TUPLE_SIZE \ (offsetof(FormData_pg_class,relminmxid) + sizeof(TransactionId)) diff --git a/src/include/catalog/pg_collation.h b/src/include/catalog/pg_collation.h index 11abde18be9..8b1917ee99f 100644 --- a/src/include/catalog/pg_collation.h +++ b/src/include/catalog/pg_collation.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_collation * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_collation,3456,CollationRelationId) { Oid oid; /* oid */ @@ -50,6 +52,8 @@ CATALOG(pg_collation,3456,CollationRelationId) #endif } FormData_pg_collation; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_collation corresponds to a pointer to a row with * the format of pg_collation relation. diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h index d5661b5bdff..1b7fedf1750 100644 --- a/src/include/catalog/pg_constraint.h +++ b/src/include/catalog/pg_constraint.h @@ -28,6 +28,8 @@ * typedef struct FormData_pg_constraint * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_constraint,2606,ConstraintRelationId) { Oid oid; /* oid */ @@ -167,6 +169,8 @@ CATALOG(pg_constraint,2606,ConstraintRelationId) #endif } FormData_pg_constraint; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_constraint corresponds to a pointer to a tuple with * the format of pg_constraint relation. diff --git a/src/include/catalog/pg_conversion.h b/src/include/catalog/pg_conversion.h index f6a3d14e6b3..71f5de90497 100644 --- a/src/include/catalog/pg_conversion.h +++ b/src/include/catalog/pg_conversion.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_conversion * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_conversion,2607,ConversionRelationId) { /* oid */ @@ -53,6 +55,8 @@ CATALOG(pg_conversion,2607,ConversionRelationId) bool condefault BKI_DEFAULT(t); } FormData_pg_conversion; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_conversion corresponds to a pointer to a tuple with * the format of pg_conversion relation. diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h index a380bdc5134..8a495e96eed 100644 --- a/src/include/catalog/pg_database.h +++ b/src/include/catalog/pg_database.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_database * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248,DatabaseRelation_Rowtype_Id) BKI_SCHEMA_MACRO { /* oid */ @@ -88,6 +90,8 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID #endif } FormData_pg_database; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_database corresponds to a pointer to a tuple with * the format of pg_database relation. diff --git a/src/include/catalog/pg_db_role_setting.h b/src/include/catalog/pg_db_role_setting.h index c2d728b03db..f1cbba020b2 100644 --- a/src/include/catalog/pg_db_role_setting.h +++ b/src/include/catalog/pg_db_role_setting.h @@ -31,6 +31,8 @@ * typedef struct FormData_pg_db_role_setting * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION { /* database, or 0 for a role-specific setting */ @@ -44,6 +46,8 @@ CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION #endif } FormData_pg_db_role_setting; +END_CATALOG_STRUCT + typedef FormData_pg_db_role_setting * Form_pg_db_role_setting; DECLARE_TOAST_WITH_MACRO(pg_db_role_setting, 2966, 2967, PgDbRoleSettingToastTable, PgDbRoleSettingToastIndex); diff --git a/src/include/catalog/pg_default_acl.h b/src/include/catalog/pg_default_acl.h index c9cb4580010..dc1722f7a68 100644 --- a/src/include/catalog/pg_default_acl.h +++ b/src/include/catalog/pg_default_acl.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_default_acl * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_default_acl,826,DefaultAclRelationId) { Oid oid; /* oid */ @@ -42,6 +44,8 @@ CATALOG(pg_default_acl,826,DefaultAclRelationId) #endif } FormData_pg_default_acl; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_default_acl corresponds to a pointer to a tuple with * the format of pg_default_acl relation. diff --git a/src/include/catalog/pg_depend.h b/src/include/catalog/pg_depend.h index 6b849bc6d4c..af1423ade44 100644 --- a/src/include/catalog/pg_depend.h +++ b/src/include/catalog/pg_depend.h @@ -39,6 +39,8 @@ * typedef struct FormData_pg_depend * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_depend,2608,DependRelationId) { /* @@ -64,6 +66,8 @@ CATALOG(pg_depend,2608,DependRelationId) char deptype; /* see codes in dependency.h */ } FormData_pg_depend; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_depend corresponds to a pointer to a row with * the format of pg_depend relation. diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h index 03fb1555037..98971d8ca11 100644 --- a/src/include/catalog/pg_description.h +++ b/src/include/catalog/pg_description.h @@ -45,6 +45,8 @@ * typedef struct FormData_pg_description * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_description,2609,DescriptionRelationId) { Oid objoid; /* OID of object itself */ @@ -56,6 +58,8 @@ CATALOG(pg_description,2609,DescriptionRelationId) #endif } FormData_pg_description; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_description corresponds to a pointer to a tuple with * the format of pg_description relation. diff --git a/src/include/catalog/pg_enum.h b/src/include/catalog/pg_enum.h index cbcc8fa6280..a1c73817fff 100644 --- a/src/include/catalog/pg_enum.h +++ b/src/include/catalog/pg_enum.h @@ -28,6 +28,8 @@ * typedef struct FormData_pg_enum * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_enum,3501,EnumRelationId) { Oid oid; /* oid */ @@ -36,6 +38,8 @@ CATALOG(pg_enum,3501,EnumRelationId) NameData enumlabel; /* text representation of enum value */ } FormData_pg_enum; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_enum corresponds to a pointer to a tuple with * the format of pg_enum relation. diff --git a/src/include/catalog/pg_event_trigger.h b/src/include/catalog/pg_event_trigger.h index c24113c2973..eaacaaf2e2c 100644 --- a/src/include/catalog/pg_event_trigger.h +++ b/src/include/catalog/pg_event_trigger.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_event_trigger * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_event_trigger,3466,EventTriggerRelationId) { Oid oid; /* oid */ @@ -42,6 +44,8 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId) #endif } FormData_pg_event_trigger; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_event_trigger corresponds to a pointer to a tuple with * the format of pg_event_trigger relation. diff --git a/src/include/catalog/pg_extension.h b/src/include/catalog/pg_extension.h index 8ab5e3141d0..19ec291ad7e 100644 --- a/src/include/catalog/pg_extension.h +++ b/src/include/catalog/pg_extension.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_extension * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_extension,3079,ExtensionRelationId) { Oid oid; /* oid */ @@ -44,6 +46,8 @@ CATALOG(pg_extension,3079,ExtensionRelationId) #endif } FormData_pg_extension; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_extension corresponds to a pointer to a tuple with * the format of pg_extension relation. diff --git a/src/include/catalog/pg_foreign_data_wrapper.h b/src/include/catalog/pg_foreign_data_wrapper.h index d47bf467810..e6009069e82 100644 --- a/src/include/catalog/pg_foreign_data_wrapper.h +++ b/src/include/catalog/pg_foreign_data_wrapper.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_foreign_data_wrapper * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId) { Oid oid; /* oid */ @@ -43,6 +45,8 @@ CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId) #endif } FormData_pg_foreign_data_wrapper; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_foreign_data_wrapper corresponds to a pointer to a tuple with * the format of pg_foreign_data_wrapper relation. diff --git a/src/include/catalog/pg_foreign_server.h b/src/include/catalog/pg_foreign_server.h index beee97a4ddb..cac0b9faafe 100644 --- a/src/include/catalog/pg_foreign_server.h +++ b/src/include/catalog/pg_foreign_server.h @@ -25,6 +25,8 @@ * typedef struct FormData_pg_foreign_server * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_foreign_server,1417,ForeignServerRelationId) { Oid oid; /* oid */ @@ -40,6 +42,8 @@ CATALOG(pg_foreign_server,1417,ForeignServerRelationId) #endif } FormData_pg_foreign_server; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_foreign_server corresponds to a pointer to a tuple with * the format of pg_foreign_server relation. diff --git a/src/include/catalog/pg_foreign_table.h b/src/include/catalog/pg_foreign_table.h index 35c858f9de3..601115c183d 100644 --- a/src/include/catalog/pg_foreign_table.h +++ b/src/include/catalog/pg_foreign_table.h @@ -25,6 +25,8 @@ * typedef struct FormData_pg_foreign_table * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_foreign_table,3118,ForeignTableRelationId) { Oid ftrelid BKI_LOOKUP(pg_class); /* OID of foreign table */ @@ -35,6 +37,8 @@ CATALOG(pg_foreign_table,3118,ForeignTableRelationId) #endif } FormData_pg_foreign_table; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_foreign_table corresponds to a pointer to a tuple with * the format of pg_foreign_table relation. diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index 02c99d70faf..d722efe49b4 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_index. * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO { Oid indexrelid BKI_LOOKUP(pg_class); /* OID of the index */ @@ -62,6 +64,8 @@ CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO #endif } FormData_pg_index; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_index corresponds to a pointer to a tuple with * the format of pg_index relation. diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h index c14aee773c3..7a36241d7b3 100644 --- a/src/include/catalog/pg_inherits.h +++ b/src/include/catalog/pg_inherits.h @@ -29,6 +29,8 @@ * typedef struct FormData_pg_inherits * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_inherits,2611,InheritsRelationId) { Oid inhrelid BKI_LOOKUP(pg_class); @@ -37,6 +39,8 @@ CATALOG(pg_inherits,2611,InheritsRelationId) bool inhdetachpending; } FormData_pg_inherits; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_inherits corresponds to a pointer to a tuple with * the format of pg_inherits relation. diff --git a/src/include/catalog/pg_init_privs.h b/src/include/catalog/pg_init_privs.h index 71d6d1c90d0..44c7e50d470 100644 --- a/src/include/catalog/pg_init_privs.h +++ b/src/include/catalog/pg_init_privs.h @@ -43,6 +43,8 @@ * typedef struct FormData_pg_init_privs * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_init_privs,3394,InitPrivsRelationId) { Oid objoid; /* OID of object itself */ @@ -56,6 +58,8 @@ CATALOG(pg_init_privs,3394,InitPrivsRelationId) #endif } FormData_pg_init_privs; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_init_privs corresponds to a pointer to a tuple with * the format of pg_init_privs relation. diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h index b049f20515a..d64e4525547 100644 --- a/src/include/catalog/pg_language.h +++ b/src/include/catalog/pg_language.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_language * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_language,2612,LanguageRelationId) { Oid oid; /* oid */ @@ -57,6 +59,8 @@ CATALOG(pg_language,2612,LanguageRelationId) #endif } FormData_pg_language; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_language corresponds to a pointer to a tuple with * the format of pg_language relation. diff --git a/src/include/catalog/pg_largeobject.h b/src/include/catalog/pg_largeobject.h index 8f845267c73..4f3c14c7eda 100644 --- a/src/include/catalog/pg_largeobject.h +++ b/src/include/catalog/pg_largeobject.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_largeobject * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_largeobject,2613,LargeObjectRelationId) { Oid loid BKI_LOOKUP(pg_largeobject_metadata); /* Identifier of large @@ -38,6 +40,8 @@ CATALOG(pg_largeobject,2613,LargeObjectRelationId) * zero-length) */ } FormData_pg_largeobject; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_largeobject corresponds to a pointer to a tuple with * the format of pg_largeobject relation. diff --git a/src/include/catalog/pg_largeobject_metadata.h b/src/include/catalog/pg_largeobject_metadata.h index 2ace42e4096..86f369255d4 100644 --- a/src/include/catalog/pg_largeobject_metadata.h +++ b/src/include/catalog/pg_largeobject_metadata.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_largeobject_metadata * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_largeobject_metadata,2995,LargeObjectMetadataRelationId) { Oid oid; /* oid */ @@ -39,6 +41,8 @@ CATALOG(pg_largeobject_metadata,2995,LargeObjectMetadataRelationId) #endif } FormData_pg_largeobject_metadata; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_largeobject_metadata corresponds to a pointer to a tuple * with the format of pg_largeobject_metadata relation. diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h index a84a8db194b..474f4c574e0 100644 --- a/src/include/catalog/pg_namespace.h +++ b/src/include/catalog/pg_namespace.h @@ -32,6 +32,8 @@ * nspacl access privilege list * ---------------------------------------------------------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_namespace,2615,NamespaceRelationId) { Oid oid; /* oid */ @@ -44,6 +46,8 @@ CATALOG(pg_namespace,2615,NamespaceRelationId) #endif } FormData_pg_namespace; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_namespace corresponds to a pointer to a tuple with * the format of pg_namespace relation. diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index 4fed59acb0e..46170c6c3c3 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -46,6 +46,8 @@ * typedef struct FormData_pg_opclass * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_opclass,2616,OperatorClassRelationId) { Oid oid; /* oid */ @@ -75,6 +77,8 @@ CATALOG(pg_opclass,2616,OperatorClassRelationId) Oid opckeytype BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type); } FormData_pg_opclass; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_opclass corresponds to a pointer to a tuple with * the format of pg_opclass relation. diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index 89bec146f5c..f5b4d04783a 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -28,6 +28,8 @@ * typedef struct FormData_pg_operator * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_operator,2617,OperatorRelationId) { Oid oid; /* oid */ @@ -75,6 +77,8 @@ CATALOG(pg_operator,2617,OperatorRelationId) regproc oprjoin BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc); } FormData_pg_operator; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_operator corresponds to a pointer to a tuple with * the format of pg_operator relation. diff --git a/src/include/catalog/pg_opfamily.h b/src/include/catalog/pg_opfamily.h index afebcc9ae5a..563703f0f22 100644 --- a/src/include/catalog/pg_opfamily.h +++ b/src/include/catalog/pg_opfamily.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_opfamily * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_opfamily,2753,OperatorFamilyRelationId) { Oid oid; /* oid */ @@ -43,6 +45,8 @@ CATALOG(pg_opfamily,2753,OperatorFamilyRelationId) Oid opfowner BKI_DEFAULT(POSTGRES) BKI_LOOKUP(pg_authid); } FormData_pg_opfamily; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_opfamily corresponds to a pointer to a tuple with * the format of pg_opfamily relation. diff --git a/src/include/catalog/pg_parameter_acl.h b/src/include/catalog/pg_parameter_acl.h index 13a85db92db..a26b05a9bf2 100644 --- a/src/include/catalog/pg_parameter_acl.h +++ b/src/include/catalog/pg_parameter_acl.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_parameter_acl * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_parameter_acl,6243,ParameterAclRelationId) BKI_SHARED_RELATION { Oid oid; /* oid */ @@ -40,6 +42,8 @@ CATALOG(pg_parameter_acl,6243,ParameterAclRelationId) BKI_SHARED_RELATION #endif } FormData_pg_parameter_acl; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_parameter_acl corresponds to a pointer to a tuple with diff --git a/src/include/catalog/pg_partitioned_table.h b/src/include/catalog/pg_partitioned_table.h index e9a67bf6d40..db477951018 100644 --- a/src/include/catalog/pg_partitioned_table.h +++ b/src/include/catalog/pg_partitioned_table.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_partitioned_table * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_partitioned_table,3350,PartitionedRelationId) { Oid partrelid BKI_LOOKUP(pg_class); /* partitioned table oid */ @@ -57,6 +59,8 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId) #endif } FormData_pg_partitioned_table; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_partitioned_table corresponds to a pointer to a tuple with * the format of pg_partitioned_table relation. diff --git a/src/include/catalog/pg_policy.h b/src/include/catalog/pg_policy.h index f64af8e3279..5bcaf0cd896 100644 --- a/src/include/catalog/pg_policy.h +++ b/src/include/catalog/pg_policy.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_policy * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_policy,3256,PolicyRelationId) { Oid oid; /* oid */ @@ -43,6 +45,8 @@ CATALOG(pg_policy,3256,PolicyRelationId) #endif } FormData_pg_policy; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_policy corresponds to a pointer to a row with * the format of pg_policy relation. diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 6ada01d6e19..2f9e0b695e2 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_proc * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,ProcedureRelation_Rowtype_Id) BKI_SCHEMA_MACRO { Oid oid; /* oid */ @@ -128,6 +130,8 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce #endif } FormData_pg_proc; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_proc corresponds to a pointer to a tuple with * the format of pg_proc relation. diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h index 368becca899..6e5f73caa9e 100644 --- a/src/include/catalog/pg_publication.h +++ b/src/include/catalog/pg_publication.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_publication * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_publication,6104,PublicationRelationId) { Oid oid; /* oid */ @@ -68,6 +70,8 @@ CATALOG(pg_publication,6104,PublicationRelationId) char pubgencols; } FormData_pg_publication; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_publication corresponds to a pointer to a tuple with * the format of pg_publication relation. diff --git a/src/include/catalog/pg_publication_namespace.h b/src/include/catalog/pg_publication_namespace.h index 1ce84fb5da9..6c21b248db2 100644 --- a/src/include/catalog/pg_publication_namespace.h +++ b/src/include/catalog/pg_publication_namespace.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_publication_namespace * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_publication_namespace,6237,PublicationNamespaceRelationId) { Oid oid; /* oid */ @@ -34,6 +36,8 @@ CATALOG(pg_publication_namespace,6237,PublicationNamespaceRelationId) Oid pnnspid BKI_LOOKUP(pg_namespace); /* Oid of the schema */ } FormData_pg_publication_namespace; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_publication_namespace corresponds to a pointer to a tuple with * the format of pg_publication_namespace relation. diff --git a/src/include/catalog/pg_publication_rel.h b/src/include/catalog/pg_publication_rel.h index 3a8790e8482..63eb7c75f53 100644 --- a/src/include/catalog/pg_publication_rel.h +++ b/src/include/catalog/pg_publication_rel.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_publication_rel * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_publication_rel,6106,PublicationRelRelationId) { Oid oid; /* oid */ @@ -38,6 +40,8 @@ CATALOG(pg_publication_rel,6106,PublicationRelRelationId) #endif } FormData_pg_publication_rel; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_publication_rel corresponds to a pointer to a tuple with * the format of pg_publication_rel relation. diff --git a/src/include/catalog/pg_range.h b/src/include/catalog/pg_range.h index 32ee8cf43a0..ee87ed3bf42 100644 --- a/src/include/catalog/pg_range.h +++ b/src/include/catalog/pg_range.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_range * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_range,3541,RangeRelationId) { /* OID of owning range type */ @@ -59,6 +61,8 @@ CATALOG(pg_range,3541,RangeRelationId) regproc rngsubdiff BKI_LOOKUP_OPT(pg_proc); } FormData_pg_range; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_range corresponds to a pointer to a tuple with * the format of pg_range relation. diff --git a/src/include/catalog/pg_replication_origin.h b/src/include/catalog/pg_replication_origin.h index bf54442fd06..565d71ad0b3 100644 --- a/src/include/catalog/pg_replication_origin.h +++ b/src/include/catalog/pg_replication_origin.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_replication_origin * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELATION { /* @@ -52,6 +54,8 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT #endif } FormData_pg_replication_origin; +END_CATALOG_STRUCT + typedef FormData_pg_replication_origin *Form_pg_replication_origin; DECLARE_UNIQUE_INDEX_PKEY(pg_replication_origin_roiident_index, 6001, ReplicationOriginIdentIndex, pg_replication_origin,btree(roident oid_ops)); diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h index c9ce420eb6f..fe82e84be4e 100644 --- a/src/include/catalog/pg_rewrite.h +++ b/src/include/catalog/pg_rewrite.h @@ -29,6 +29,8 @@ * typedef struct FormData_pg_rewrite * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_rewrite,2618,RewriteRelationId) { Oid oid; /* oid */ @@ -44,6 +46,8 @@ CATALOG(pg_rewrite,2618,RewriteRelationId) #endif } FormData_pg_rewrite; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_rewrite corresponds to a pointer to a tuple with * the format of pg_rewrite relation. diff --git a/src/include/catalog/pg_seclabel.h b/src/include/catalog/pg_seclabel.h index 0c9d094b81b..8f5788ca663 100644 --- a/src/include/catalog/pg_seclabel.h +++ b/src/include/catalog/pg_seclabel.h @@ -25,6 +25,8 @@ * typedef struct FormData_pg_seclabel * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_seclabel,3596,SecLabelRelationId) { Oid objoid; /* OID of the object itself */ @@ -38,6 +40,8 @@ CATALOG(pg_seclabel,3596,SecLabelRelationId) #endif } FormData_pg_seclabel; +END_CATALOG_STRUCT + DECLARE_TOAST(pg_seclabel, 3598, 3599); DECLARE_UNIQUE_INDEX_PKEY(pg_seclabel_object_index, 3597, SecLabelObjectIndexId, pg_seclabel, btree(objoid oid_ops, classoidoid_ops, objsubid int4_ops, provider text_ops)); diff --git a/src/include/catalog/pg_sequence.h b/src/include/catalog/pg_sequence.h index f8b9eaa9270..59820a86b8b 100644 --- a/src/include/catalog/pg_sequence.h +++ b/src/include/catalog/pg_sequence.h @@ -20,6 +20,8 @@ #include "catalog/genbki.h" #include "catalog/pg_sequence_d.h" /* IWYU pragma: export */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_sequence,2224,SequenceRelationId) { Oid seqrelid BKI_LOOKUP(pg_class); @@ -32,6 +34,8 @@ CATALOG(pg_sequence,2224,SequenceRelationId) bool seqcycle; } FormData_pg_sequence; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_sequence corresponds to a pointer to a tuple with * the format of pg_sequence relation. diff --git a/src/include/catalog/pg_shdepend.h b/src/include/catalog/pg_shdepend.h index 5e0945c55f2..80d5eb0255e 100644 --- a/src/include/catalog/pg_shdepend.h +++ b/src/include/catalog/pg_shdepend.h @@ -35,6 +35,8 @@ * typedef struct FormData_pg_shdepend * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_shdepend,1214,SharedDependRelationId) BKI_SHARED_RELATION { /* @@ -65,6 +67,8 @@ CATALOG(pg_shdepend,1214,SharedDependRelationId) BKI_SHARED_RELATION char deptype; /* see codes in dependency.h */ } FormData_pg_shdepend; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_shdepend corresponds to a pointer to a row with * the format of pg_shdepend relation. diff --git a/src/include/catalog/pg_shdescription.h b/src/include/catalog/pg_shdescription.h index 8fad7972d4c..f53d9f5dcd6 100644 --- a/src/include/catalog/pg_shdescription.h +++ b/src/include/catalog/pg_shdescription.h @@ -38,6 +38,8 @@ * typedef struct FormData_pg_shdescription * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION { Oid objoid; /* OID of object itself */ @@ -48,6 +50,8 @@ CATALOG(pg_shdescription,2396,SharedDescriptionRelationId) BKI_SHARED_RELATION #endif } FormData_pg_shdescription; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_shdescription corresponds to a pointer to a tuple with * the format of pg_shdescription relation. diff --git a/src/include/catalog/pg_shseclabel.h b/src/include/catalog/pg_shseclabel.h index c13ced36850..273c7790194 100644 --- a/src/include/catalog/pg_shseclabel.h +++ b/src/include/catalog/pg_shseclabel.h @@ -25,6 +25,8 @@ * typedef struct FormData_pg_shseclabel * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(4066,SharedSecLabelRelation_Rowtype_Id)BKI_SCHEMA_MACRO { Oid objoid; /* OID of the shared object itself */ @@ -37,6 +39,8 @@ CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROW #endif } FormData_pg_shseclabel; +END_CATALOG_STRUCT + typedef FormData_pg_shseclabel * Form_pg_shseclabel; DECLARE_TOAST_WITH_MACRO(pg_shseclabel, 4060, 4061, PgShseclabelToastTable, PgShseclabelToastIndex); diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h index c31c163d0cc..032bf177b95 100644 --- a/src/include/catalog/pg_statistic.h +++ b/src/include/catalog/pg_statistic.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_statistic * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_statistic,2619,StatisticRelationId) { /* These fields form the unique key for the entry: */ @@ -124,6 +126,8 @@ CATALOG(pg_statistic,2619,StatisticRelationId) #endif } FormData_pg_statistic; +END_CATALOG_STRUCT + #define STATISTIC_NUM_SLOTS 5 diff --git a/src/include/catalog/pg_statistic_ext.h b/src/include/catalog/pg_statistic_ext.h index 6842954d4cb..e4a0cb4d41c 100644 --- a/src/include/catalog/pg_statistic_ext.h +++ b/src/include/catalog/pg_statistic_ext.h @@ -30,6 +30,8 @@ * typedef struct FormData_pg_statistic_ext * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_statistic_ext,3381,StatisticExtRelationId) { Oid oid; /* oid */ @@ -61,6 +63,8 @@ CATALOG(pg_statistic_ext,3381,StatisticExtRelationId) } FormData_pg_statistic_ext; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_statistic_ext corresponds to a pointer to a tuple with * the format of pg_statistic_ext relation. diff --git a/src/include/catalog/pg_statistic_ext_data.h b/src/include/catalog/pg_statistic_ext_data.h index 7b7f2593491..dbc4acc7d1a 100644 --- a/src/include/catalog/pg_statistic_ext_data.h +++ b/src/include/catalog/pg_statistic_ext_data.h @@ -28,6 +28,8 @@ * typedef struct FormData_pg_statistic_ext_data * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId) { Oid stxoid BKI_LOOKUP(pg_statistic_ext); /* statistics object @@ -45,6 +47,8 @@ CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId) } FormData_pg_statistic_ext_data; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_statistic_ext_data corresponds to a pointer to a tuple with * the format of pg_statistic_ext_data relation. diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h index 805493d85c5..c369b5abfb3 100644 --- a/src/include/catalog/pg_subscription.h +++ b/src/include/catalog/pg_subscription.h @@ -40,6 +40,8 @@ * here, be sure to update that (or, if the new column is not to be publicly * readable, update associated comments and catalogs.sgml instead). */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id)BKI_SCHEMA_MACRO { Oid oid; /* oid */ @@ -111,6 +113,8 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW #endif } FormData_pg_subscription; +END_CATALOG_STRUCT + typedef FormData_pg_subscription *Form_pg_subscription; DECLARE_TOAST_WITH_MACRO(pg_subscription, 4183, 4184, PgSubscriptionToastTable, PgSubscriptionToastIndex); diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h index f810b34c78d..502640d3018 100644 --- a/src/include/catalog/pg_subscription_rel.h +++ b/src/include/catalog/pg_subscription_rel.h @@ -28,6 +28,8 @@ * typedef struct FormData_pg_subscription_rel * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId) { Oid srsubid BKI_LOOKUP(pg_subscription); /* Oid of subscription */ @@ -47,6 +49,8 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId) #endif } FormData_pg_subscription_rel; +END_CATALOG_STRUCT + typedef FormData_pg_subscription_rel *Form_pg_subscription_rel; DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, pg_subscription_rel,btree(srrelid oid_ops, srsubid oid_ops)); diff --git a/src/include/catalog/pg_tablespace.h b/src/include/catalog/pg_tablespace.h index fe7a5ab538f..3bd4a74f003 100644 --- a/src/include/catalog/pg_tablespace.h +++ b/src/include/catalog/pg_tablespace.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_tablespace * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION { Oid oid; /* oid */ @@ -40,6 +42,8 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION #endif } FormData_pg_tablespace; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_tablespace corresponds to a pointer to a tuple with * the format of pg_tablespace relation. diff --git a/src/include/catalog/pg_transform.h b/src/include/catalog/pg_transform.h index f8bdad17897..115608de43c 100644 --- a/src/include/catalog/pg_transform.h +++ b/src/include/catalog/pg_transform.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_transform * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_transform,3576,TransformRelationId) { Oid oid; /* oid */ @@ -35,6 +37,8 @@ CATALOG(pg_transform,3576,TransformRelationId) regproc trftosql BKI_LOOKUP_OPT(pg_proc); } FormData_pg_transform; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_transform corresponds to a pointer to a tuple with * the format of pg_transform relation. diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h index 563aa1ad638..2377e2f3167 100644 --- a/src/include/catalog/pg_trigger.h +++ b/src/include/catalog/pg_trigger.h @@ -31,6 +31,8 @@ * to be associated with a deferrable constraint. * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_trigger,2620,TriggerRelationId) { Oid oid; /* oid */ @@ -72,6 +74,8 @@ CATALOG(pg_trigger,2620,TriggerRelationId) #endif } FormData_pg_trigger; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_trigger corresponds to a pointer to a tuple with * the format of pg_trigger relation. diff --git a/src/include/catalog/pg_ts_config.h b/src/include/catalog/pg_ts_config.h index 3e249e5d85c..0bbcb3249dc 100644 --- a/src/include/catalog/pg_ts_config.h +++ b/src/include/catalog/pg_ts_config.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_ts_config * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_ts_config,3602,TSConfigRelationId) { /* oid */ @@ -45,6 +47,8 @@ CATALOG(pg_ts_config,3602,TSConfigRelationId) Oid cfgparser BKI_LOOKUP(pg_ts_parser); } FormData_pg_ts_config; +END_CATALOG_STRUCT + typedef FormData_pg_ts_config *Form_pg_ts_config; DECLARE_UNIQUE_INDEX(pg_ts_config_cfgname_index, 3608, TSConfigNameNspIndexId, pg_ts_config, btree(cfgname name_ops, cfgnamespaceoid_ops)); diff --git a/src/include/catalog/pg_ts_config_map.h b/src/include/catalog/pg_ts_config_map.h index 46ac7290c3b..51feb1b9e8f 100644 --- a/src/include/catalog/pg_ts_config_map.h +++ b/src/include/catalog/pg_ts_config_map.h @@ -27,6 +27,8 @@ * typedef struct FormData_pg_ts_config_map * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_ts_config_map,3603,TSConfigMapRelationId) { /* OID of configuration owning this entry */ @@ -42,6 +44,8 @@ CATALOG(pg_ts_config_map,3603,TSConfigMapRelationId) Oid mapdict BKI_LOOKUP(pg_ts_dict); } FormData_pg_ts_config_map; +END_CATALOG_STRUCT + typedef FormData_pg_ts_config_map *Form_pg_ts_config_map; DECLARE_UNIQUE_INDEX_PKEY(pg_ts_config_map_index, 3609, TSConfigMapIndexId, pg_ts_config_map, btree(mapcfg oid_ops, maptokentypeint4_ops, mapseqno int4_ops)); diff --git a/src/include/catalog/pg_ts_dict.h b/src/include/catalog/pg_ts_dict.h index 826e79325f0..d47b05ae5cc 100644 --- a/src/include/catalog/pg_ts_dict.h +++ b/src/include/catalog/pg_ts_dict.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_ts_dict * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_ts_dict,3600,TSDictionaryRelationId) { /* oid */ @@ -49,6 +51,8 @@ CATALOG(pg_ts_dict,3600,TSDictionaryRelationId) #endif } FormData_pg_ts_dict; +END_CATALOG_STRUCT + typedef FormData_pg_ts_dict *Form_pg_ts_dict; DECLARE_TOAST(pg_ts_dict, 4169, 4170); diff --git a/src/include/catalog/pg_ts_parser.h b/src/include/catalog/pg_ts_parser.h index 30eabc91c91..181e869ac75 100644 --- a/src/include/catalog/pg_ts_parser.h +++ b/src/include/catalog/pg_ts_parser.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_ts_parser * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_ts_parser,3601,TSParserRelationId) { Oid oid; /* oid */ @@ -52,6 +54,8 @@ CATALOG(pg_ts_parser,3601,TSParserRelationId) regproc prslextype BKI_LOOKUP(pg_proc); } FormData_pg_ts_parser; +END_CATALOG_STRUCT + typedef FormData_pg_ts_parser *Form_pg_ts_parser; DECLARE_UNIQUE_INDEX(pg_ts_parser_prsname_index, 3606, TSParserNameNspIndexId, pg_ts_parser, btree(prsname name_ops, prsnamespaceoid_ops)); diff --git a/src/include/catalog/pg_ts_template.h b/src/include/catalog/pg_ts_template.h index 990f209fec2..5c28991e27b 100644 --- a/src/include/catalog/pg_ts_template.h +++ b/src/include/catalog/pg_ts_template.h @@ -26,6 +26,8 @@ * typedef struct FormData_pg_ts_template * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_ts_template,3764,TSTemplateRelationId) { Oid oid; /* oid */ @@ -43,6 +45,8 @@ CATALOG(pg_ts_template,3764,TSTemplateRelationId) regproc tmpllexize BKI_LOOKUP(pg_proc); } FormData_pg_ts_template; +END_CATALOG_STRUCT + typedef FormData_pg_ts_template *Form_pg_ts_template; DECLARE_UNIQUE_INDEX(pg_ts_template_tmplname_index, 3766, TSTemplateNameNspIndexId, pg_ts_template, btree(tmplname name_ops,tmplnamespace oid_ops)); diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 70d4a20c02b..74183ec5a2e 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -33,6 +33,8 @@ * See struct FormData_pg_attribute for details. * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelation_Rowtype_Id) BKI_SCHEMA_MACRO { Oid oid; /* oid */ @@ -253,6 +255,8 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati #endif } FormData_pg_type; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_type corresponds to a pointer to a row with * the format of pg_type relation. diff --git a/src/include/catalog/pg_user_mapping.h b/src/include/catalog/pg_user_mapping.h index 42fb41a6341..921a9ec009d 100644 --- a/src/include/catalog/pg_user_mapping.h +++ b/src/include/catalog/pg_user_mapping.h @@ -25,6 +25,8 @@ * typedef struct FormData_pg_user_mapping * ---------------- */ +BEGIN_CATALOG_STRUCT + CATALOG(pg_user_mapping,1418,UserMappingRelationId) { Oid oid; /* oid */ @@ -40,6 +42,8 @@ CATALOG(pg_user_mapping,1418,UserMappingRelationId) #endif } FormData_pg_user_mapping; +END_CATALOG_STRUCT + /* ---------------- * Form_pg_user_mapping corresponds to a pointer to a tuple with * the format of pg_user_mapping relation. diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 339268dc8ef..5699c033ade 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -12,9 +12,6 @@ /* The normal alignment of `int64_t', in bytes. */ #undef ALIGNOF_INT64_T -/* The normal alignment of `long', in bytes. */ -#undef ALIGNOF_LONG - /* The normal alignment of `PG_INT128_TYPE', in bytes. */ #undef ALIGNOF_PG_INT128_TYPE -- 2.43.7 From 0339f52a1190fd80783efc2c312ec0eadc5488cd Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Thu, 19 Feb 2026 15:16:49 -0500 Subject: [PATCH v7 3/8] Revert removal of AIX support. This commit is as nearly as possible a straight revert of commits 0b16bb877 and e6bb491bf, except that: * I did not put back anything to do with supporting XLC. * I did some minimal updating of the documentation to reflect that. * The changes in MAXALIGN calculation are no longer needed. * s_lock.h changes are no longer needed either. More work on the docs is needed, in particular we'll likely rip out the discussion of how to make it work in 32 bits. This is mainly to create a reference point for comparing what the IBM crew has done. --- Makefile | 2 - configure | 4 +- configure.ac | 4 +- doc/src/sgml/installation.sgml | 121 ++++++++++++++++++++++++++++- doc/src/sgml/runtime.sgml | 23 ++++++ meson.build | 21 ++++- src/Makefile.shlib | 29 +++++++ src/backend/Makefile | 38 ++++++++- src/backend/meson.build | 15 ++++ src/backend/port/aix/mkldexport.sh | 61 +++++++++++++++ src/backend/utils/error/elog.c | 2 + src/backend/utils/misc/ps_status.c | 4 +- src/include/port/aix.h | 3 + src/interfaces/libpq/Makefile | 2 + src/interfaces/libpq/meson.build | 5 +- src/makefiles/Makefile.aix | 39 ++++++++++ src/port/README | 2 +- src/port/strerror.c | 2 + src/template/aix | 9 +++ src/test/regress/Makefile | 5 ++ src/tools/gen_export.pl | 11 ++- src/tools/pginclude/headerscheck | 1 + 22 files changed, 385 insertions(+), 18 deletions(-) create mode 100755 src/backend/port/aix/mkldexport.sh create mode 100644 src/include/port/aix.h create mode 100644 src/makefiles/Makefile.aix create mode 100644 src/template/aix diff --git a/Makefile b/Makefile index 8a2ec9396b6..9bc1a4ec17b 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,6 @@ # AIX make defaults to building *every* target of the first rule. Start with # a single-target, empty rule to make the other targets non-default. -# (We don't support AIX anymore, but if someone tries to build on AIX anyway, -# at least they'll get the instructions to run 'configure' first.) all: all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheckworld check-world install-world installcheck-world: diff --git a/configure b/configure index 8d95bebdfa7..6a85065279d 100755 --- a/configure +++ b/configure @@ -3022,6 +3022,7 @@ else # --with-template not given case $host_os in + aix*) template=aix ;; cygwin*|msys*) template=cygwin ;; darwin*) template=darwin ;; dragonfly*) template=netbsd ;; @@ -13378,7 +13379,8 @@ fi fi -# Note: We can test for libldap_r only after we know PTHREAD_LIBS +# Note: We can test for libldap_r only after we know PTHREAD_LIBS; +# also, on AIX, we may need to have openssl in LIBS for this step. if test "$with_ldap" = yes ; then _LIBS="$LIBS" if test "$PORTNAME" != "win32"; then diff --git a/configure.ac b/configure.ac index 2e44abe8dae..1ea2ce6a367 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,7 @@ PGAC_ARG_REQ(with, template, [NAME], [override operating system template], # --with-template not given case $host_os in + aix*) template=aix ;; cygwin*|msys*) template=cygwin ;; darwin*) template=darwin ;; dragonfly*) template=netbsd ;; @@ -1469,7 +1470,8 @@ if test "$with_zstd" = yes ; then AC_CHECK_LIB(zstd, ZSTD_compress, [], [AC_MSG_ERROR([library 'zstd' is required for ZSTD support])]) fi -# Note: We can test for libldap_r only after we know PTHREAD_LIBS +# Note: We can test for libldap_r only after we know PTHREAD_LIBS; +# also, on AIX, we may need to have openssl in LIBS for this step. if test "$with_ldap" = yes ; then _LIBS="$LIBS" if test "$PORTNAME" != "win32"; then diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index c903ccff988..554d1bde7e0 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -3439,7 +3439,7 @@ export MANPATH <para> <productname>PostgreSQL</productname> can be expected to work on current versions of these operating systems: Linux, Windows, - FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, Solaris, and illumos. + FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, AIX, Solaris, and illumos. Other Unix-like systems may also work but are not currently being tested. In most cases, all CPU architectures supported by a given operating system will work. Look in @@ -3461,7 +3461,7 @@ export MANPATH Historical versions of <productname>PostgreSQL</productname> or POSTGRES also ran on CPU architectures including Alpha, Itanium, M32R, M68K, M88K, NS32K, PA-RISC, SuperH, and VAX, - and operating systems including 4.3BSD, AIX, BEOS, + and operating systems including 4.3BSD, BEOS, BSD/OS, DG/UX, Dynix, HP-UX, IRIX, NeXTSTEP, QNX, SCO, SINIX, Sprite, SunOS, Tru64 UNIX, and ULTRIX. </para> @@ -3484,6 +3484,123 @@ export MANPATH installation issues. </para> + <sect2 id="installation-notes-aix"> + <title>AIX</title> + + <indexterm zone="installation-notes-aix"> + <primary>AIX</primary> + <secondary>installation on</secondary> + </indexterm> + + <para> + You must use GCC + to build <productname>PostgreSQL</productname> + on <productname>AIX</productname>. + The native IBM compiler <command>xlc</command> is not supported. + </para> + + <para> + <productname>AIX</productname> versions before 7.2 are no longer + tested nor supported by the <productname>PostgreSQL</productname> + community. + </para> + + <sect3 id="installation-notes-aix-mem-management"> + <title>Memory Management</title> + <!-- https://archives.postgresql.org/message-id/603bgqmpl9.fsf@dba2.int.libertyrms.com --> + + <para> + AIX can be somewhat peculiar with regards to the way it does + memory management. You can have a server with many multiples of + gigabytes of RAM free, but still get out of memory or address + space errors when running applications. One example + is loading of extensions failing with unusual errors. + For example, running as the owner of the PostgreSQL installation: +<screen> +=# CREATE EXTENSION plperl; +ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": A memory address is not in the address space for the process. +</screen> + Running as a non-owner in the group possessing the PostgreSQL + installation: +<screen> +=# CREATE EXTENSION plperl; +ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address +</screen> + Another example is out of memory errors in the PostgreSQL server + logs, with every memory allocation near or greater than 256 MB + failing. + </para> + + <para> + The overall cause of all these problems is the default bittedness + and memory model used by the server process. By default, all + binaries built on AIX are 32-bit. This does not depend upon + hardware type or kernel in use. These 32-bit processes are + limited to 4 GB of memory laid out in 256 MB segments using one + of a few models. The default allows for less than 256 MB in the + heap as it shares a single segment with the stack. + </para> + + <para> + In the case of the <literal>plperl</literal> example, above, + check your umask and the permissions of the binaries in your + PostgreSQL installation. The binaries involved in that example + were 32-bit and installed as mode 750 instead of 755. Due to the + permissions being set in this fashion, only the owner or a member + of the possessing group can load the library. Since it isn't + world-readable, the loader places the object into the process' + heap instead of the shared library segments where it would + otherwise be placed. + </para> + + <para> + The <quote>ideal</quote> solution for this is to use a 64-bit + build of PostgreSQL, but that is not always practical, because + systems with 32-bit processors can build, but not run, 64-bit + binaries. + </para> + + <para> + If a 32-bit binary is desired, set <symbol>LDR_CNTRL</symbol> to + <literal>MAXDATA=0x<replaceable>n</replaceable>0000000</literal>, + where 1 <= n <= 8, before starting the PostgreSQL server, + and try different values and <filename>postgresql.conf</filename> + settings to find a configuration that works satisfactorily. This + use of <symbol>LDR_CNTRL</symbol> tells AIX that you want the + server to have <symbol>MAXDATA</symbol> bytes set aside for the + heap, allocated in 256 MB segments. When you find a workable + configuration, + <command>ldedit</command> can be used to modify the binaries so + that they default to using the desired heap size. PostgreSQL can + also be rebuilt, passing <literal>configure + LDFLAGS="-Wl,-bmaxdata:0x<replaceable>n</replaceable>0000000"</literal> + to achieve the same effect. + </para> + + <para> + For a 64-bit build, set <envar>OBJECT_MODE</envar> to 64 and + pass <literal>CC="gcc -maix64"</literal> + and <literal>LDFLAGS="-Wl,-bbigtoc"</literal> + to <command>configure</command>. If you omit the export of + <envar>OBJECT_MODE</envar>, your build may fail with linker errors. When + <envar>OBJECT_MODE</envar> is set, it tells AIX's build utilities + such as <command>ar</command>, <command>as</command>, and <command>ld</command> what + type of objects to default to handling. + </para> + + <para> + By default, overcommit of paging space can happen. While we have + not seen this occur, AIX will kill processes when it runs out of + memory and the overcommit is accessed. The closest to this that + we have seen is fork failing because the system decided that + there was not enough memory for another process. Like many other + parts of AIX, the paging space allocation method and + out-of-memory kill is configurable on a system- or process-wide + basis if this becomes a problem. + </para> + </sect3> + </sect2> + <sect2 id="installation-notes-cygwin"> <title>Cygwin</title> diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 0c60bafac63..b4914faff1c 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -901,6 +901,29 @@ $ <userinput>postgres -D $PGDATA -C num_os_semaphores</userinput> <variablelist> + <varlistentry> + <term><systemitem class="osname">AIX</systemitem> + <indexterm><primary>AIX</primary><secondary>IPC configuration</secondary></indexterm> + </term> + <listitem> + <para> + It should not be necessary to do + any special configuration for such parameters as + <varname>SHMMAX</varname>, as it appears this is configured to + allow all memory to be used as shared memory. That is the + sort of configuration commonly used for other databases such + as <application>DB/2</application>.</para> + + <para> It might, however, be necessary to modify the global + <command>ulimit</command> information in + <filename>/etc/security/limits</filename>, as the default hard + limits for file sizes (<varname>fsize</varname>) and numbers of + files (<varname>nofiles</varname>) might be too low. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><systemitem class="osname">FreeBSD</systemitem> <indexterm><primary>FreeBSD</primary><secondary>IPC configuration</secondary></indexterm> diff --git a/meson.build b/meson.build index 4fc95bee960..21d9a60e063 100644 --- a/meson.build +++ b/meson.build @@ -228,7 +228,26 @@ endif # that purpose. portname = host_system -if host_system == 'cygwin' +if host_system == 'aix' + library_path_var = 'LIBPATH' + + export_file_format = 'aix' + export_fmt = '-Wl,-bE:@0@' + mod_link_args_fmt = ['-Wl,-bI:@0@'] + mod_link_with_dir = 'libdir' + mod_link_with_name = '@0@.imp' + + # M:SRE sets a flag indicating that an object is a shared library. Seems to + # work in some circumstances without, but required in others. + ldflags_sl += '-Wl,-bM:SRE' + ldflags_be += '-Wl,-brtllib' + + # Native memset() is faster, tested on: + # - AIX 5.1 and 5.2, XLC 6.0 (IBM's cc) + # - AIX 5.3 ML3, gcc 4.0.1 + memset_loop_limit = 0 + +elif host_system == 'cygwin' sema_kind = 'unnamed_posix' cppflags += '-D_GNU_SOURCE' dlsuffix = '.dll' diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 3825af5b228..65870d629c2 100644 --- a/src/Makefile.shlib +++ b/src/Makefile.shlib @@ -106,6 +106,20 @@ ifdef SO_MAJOR_VERSION override CPPFLAGS += -DSO_MAJOR_VERSION=$(SO_MAJOR_VERSION) endif +ifeq ($(PORTNAME), aix) + LINK.shared = $(COMPILER) + ifdef SO_MAJOR_VERSION + shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) + endif + haslibarule = yes + # $(exports_file) is also usable as an import file + exports_file = lib$(NAME).exp + BUILD.exports = ( echo '\#! $(shlib)'; $(AWK) '/^[^\#]/ {printf "%s\n",$$1}' $< ) > $@ + ifneq (,$(SHLIB_EXPORTS)) + LINK.shared += -Wl,-bE:$(exports_file) + endif +endif + ifeq ($(PORTNAME), darwin) ifdef soname # linkable library @@ -254,6 +268,14 @@ $(stlib): $(OBJS) | $(SHLIB_PREREQS) touch $@ endif #haslibarule +# AIX wraps shared libraries inside a static library, can be used both +# for static and shared linking +ifeq ($(PORTNAME), aix) +$(stlib): $(shlib) + rm -f $(stlib) + $(AR) $(AROPT) $(stlib) $(shlib) +endif # aix + ifeq (,$(filter cygwin win32,$(PORTNAME))) # Normal case @@ -267,8 +289,11 @@ ifneq ($(shlib), $(shlib_major)) endif # Make sure we have a link to a name without any version numbers ifneq ($(shlib), $(shlib_bare)) +# except on AIX, where that's not a thing +ifneq ($(PORTNAME), aix) rm -f $(shlib_bare) $(LN_S) $(shlib) $(shlib_bare) +endif # aix endif # shlib_bare endif # shlib_major @@ -376,6 +401,9 @@ install-lib-static: $(stlib) installdirs-lib install-lib-shared: $(shlib) installdirs-lib ifdef soname +# we don't install $(shlib) on AIX +# (see http://archives.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at) +ifneq ($(PORTNAME), aix) $(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)' ifneq ($(PORTNAME), cygwin) ifneq ($(PORTNAME), win32) @@ -391,6 +419,7 @@ ifneq ($(shlib), $(shlib_bare)) endif endif # not win32 endif # not cygwin +endif # not aix ifneq (,$(findstring $(PORTNAME),win32 cygwin)) $(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)' endif diff --git a/src/backend/Makefile b/src/backend/Makefile index 05642dc02e3..fe717001951 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -81,16 +81,18 @@ override LDFLAGS := $(LDFLAGS) $(LDFLAGS_EX) $(LDFLAGS_EX_BE) ########################################################################## -all: submake-libpgport submake-catalog-headers submake-utils-headers postgres +all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP) ifneq ($(PORTNAME), cygwin) ifneq ($(PORTNAME), win32) +ifneq ($(PORTNAME), aix) postgres: $(OBJS) $(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@ endif endif +endif ifeq ($(PORTNAME), cygwin) @@ -117,6 +119,24 @@ libpostgres.a: postgres endif # win32 +ifeq ($(PORTNAME), aix) + +postgres: $(POSTGRES_IMP) + $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS)-Wl,-brtllib -o $@ + +# Linking to a single .o with -r is a lot faster than building a .a or passing +# all objects to MKLDEXPORT. +# +# It looks alluring to use $(CC) -r instead of ld -r, but that doesn't +# trivially work with gcc, due to gcc specific static libraries linked in with +# -r. +$(POSTGRES_IMP): $(OBJS) + ld -r -o SUBSYS.o $(call expand_subsys,$^) + $(MKLDEXPORT) SUBSYS.o . > $@ + @rm -f SUBSYS.o + +endif # aix + $(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport @@ -210,8 +230,12 @@ install-postgres-bitcode: $(OBJS) all $(call install_llvm_module,postgres,$(call expand_subsys, $(filter-out $(top_builddir)/src/timezone/objfiles.txt, $(SUBDIROBJS)))) endif -install-bin: postgres installdirs +install-bin: postgres $(POSTGRES_IMP) installdirs $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)' +ifeq ($(MAKE_EXPORTS), true) + $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)' + $(INSTALL_PROGRAM) $(MKLDEXPORT) '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh' +endif .PHONY: install-bin @@ -227,12 +251,20 @@ ifeq ($(MAKE_DLL), true) $(MKDIR_P) '$(DESTDIR)$(libdir)' endif endif +ifeq ($(MAKE_EXPORTS), true) + $(MKDIR_P) '$(DESTDIR)$(pkglibdir)' + $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)' +endif ########################################################################## uninstall: rm -f '$(DESTDIR)$(bindir)/postgres$(X)' +ifeq ($(MAKE_EXPORTS), true) + rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)' + rm -f '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh' +endif ifeq ($(PORTNAME), cygwin) ifeq ($(MAKE_DLL), true) rm -f '$(DESTDIR)$(libdir)/libpostgres.a' @@ -257,7 +289,7 @@ endif ########################################################################## clean: - rm -f $(LOCALOBJS) postgres$(X) + rm -f $(LOCALOBJS) postgres$(X) $(POSTGRES_IMP) ifeq ($(PORTNAME), cygwin) rm -f postgres.dll libpostgres.a endif diff --git a/src/backend/meson.build b/src/backend/meson.build index 712a857cdb4..ba273df24b5 100644 --- a/src/backend/meson.build +++ b/src/backend/meson.build @@ -91,6 +91,21 @@ if cc.get_id() == 'msvc' # be restricted to b_pch=true. backend_link_with += postgres_lib +elif host_system == 'aix' + # The '.' argument leads mkldexport.sh to emit "#! .", which refers to the + # main executable, allowing extension libraries to resolve their undefined + # symbols to symbols in the postgres binary. + postgres_imp = custom_target('postgres.imp', + command: [files('port/aix/mkldexport.sh'), '@INPUT@', '.'], + input: postgres_lib, + output: 'postgres.imp', + capture: true, + install: true, + install_dir: dir_lib, + build_by_default: false, + ) + backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path()) + backend_link_depends += postgres_imp endif backend_input = [] diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh new file mode 100755 index 00000000000..adf3793e868 --- /dev/null +++ b/src/backend/port/aix/mkldexport.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# +# mkldexport +# create an AIX exports file from an object file +# +# src/backend/port/aix/mkldexport.sh +# +# Usage: +# mkldexport objectfile [location] +# where +# objectfile is the current location of the object file. +# location is the eventual (installed) location of the +# object file (if different from the current +# working directory). +# +# [This file comes from the Postgres 4.2 distribution. - ay 7/95] +# +# Header: /usr/local/devel/postgres/src/tools/mkldexport/RCS/mkldexport.sh,v 1.2 1994/03/13 04:59:12 aoki Exp +# + +# setting this to nm -B might be better +# ... due to changes in AIX 4.x ... +# ... let us search in different directories - Gerhard Reithofer +if [ -x /usr/ucb/nm ] +then NM=/usr/ucb/nm +elif [ -x /usr/bin/nm ] +then NM=/usr/bin/nm +elif [ -x /usr/ccs/bin/nm ] +then NM=/usr/ccs/bin/nm +elif [ -x /usr/usg/bin/nm ] +then NM=/usr/usg/bin/nm +else echo "Fatal error: cannot find `nm' ... please check your installation." + exit 1 +fi + +CMDNAME=`basename $0` +if [ -z "$1" ]; then + echo "Usage: $CMDNAME object [location]" + exit 1 +fi +OBJNAME=`basename $1` +if [ "`basename $OBJNAME`" != "`basename $OBJNAME .o`" ]; then + OBJNAME=`basename $OBJNAME .o`.so +fi +if [ -z "$2" ]; then + echo '#!' +else + if [ "$2" = "." ]; then + # for the base executable (AIX 4.2 and up) + echo '#! .' + else + echo '#!' $2 + fi +fi +$NM -BCg $1 | \ + egrep ' [TDB] ' | \ + sed -e 's/.* //' | \ + egrep -v '\$' | \ + sed -e 's/^[.]//' | \ + sort | \ + uniq diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index cb1c9d85ffe..24e8f37f634 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -915,7 +915,9 @@ errcode_for_file_access(void) /* Wrong object type or state */ case ENOTDIR: /* Not a directory */ case EISDIR: /* Is a directory */ +#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */ case ENOTEMPTY: /* Directory not empty */ +#endif edata->sqlerrcode = ERRCODE_WRONG_OBJECT_TYPE; break; diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c index 9e55be244f7..51dce24947a 100644 --- a/src/backend/utils/misc/ps_status.c +++ b/src/backend/utils/misc/ps_status.c @@ -52,7 +52,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE; #define PS_USE_SETPROCTITLE_FAST #elif defined(HAVE_SETPROCTITLE) #define PS_USE_SETPROCTITLE -#elif defined(__linux__) || defined(__sun) || defined(__darwin__) || defined(__GNU__) +#elif defined(__linux__) || defined(_AIX) || defined(__sun) || defined(__darwin__) || defined(__GNU__) #define PS_USE_CLOBBER_ARGV #elif defined(WIN32) #define PS_USE_WIN32 @@ -62,7 +62,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE; /* Different systems want the buffer padded differently */ -#if defined(__linux__) || defined(__darwin__) || defined(__GNU__) +#if defined(_AIX) || defined(__linux__) || defined(__darwin__) || defined(__GNU__) #define PS_PADDING '\0' #else #define PS_PADDING ' ' diff --git a/src/include/port/aix.h b/src/include/port/aix.h new file mode 100644 index 00000000000..c86983a4452 --- /dev/null +++ b/src/include/port/aix.h @@ -0,0 +1,3 @@ +/* + * src/include/port/aix.h + */ diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile index bf4baa92917..0963995eed4 100644 --- a/src/interfaces/libpq/Makefile +++ b/src/interfaces/libpq/Makefile @@ -136,7 +136,9 @@ $(stlib): $(OBJS_STATIC) # expect them to honor this coding rule. libpq-refs-stamp: $(shlib) ifneq ($(enable_coverage), yes) +ifeq (,$(filter aix,$(PORTNAME))) $(PERL) $(srcdir)/libpq_check.pl --input_file $< --nm='$(NM)' +endif endif touch $@ diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build index 2b95098187e..c6d361e7f61 100644 --- a/src/interfaces/libpq/meson.build +++ b/src/interfaces/libpq/meson.build @@ -55,8 +55,9 @@ libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH'] # libpq_st, and {pgport,common}_shlib for libpq_sh # # We could try to avoid building the source files twice, but it probably adds -# more complexity than its worth (reusing object files requires also linking -# to the library on windows or breaks precompiled headers). +# more complexity than its worth (AIX doesn't support link_whole yet, reusing +# object files requires also linking to the library on windows or breaks +# precompiled headers). if build_static_lib libpq_st = static_library('libpq', libpq_sources, diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix new file mode 100644 index 00000000000..dd16a7a0378 --- /dev/null +++ b/src/makefiles/Makefile.aix @@ -0,0 +1,39 @@ +# MAKE_EXPORTS is required for svr4 loaders that want a file of +# symbol names to tell them what to export/import. +MAKE_EXPORTS= true + +# -blibpath must contain ALL directories where we should look for libraries +libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/usr/lib:/lib + +# when building with gcc, need to make sure that libgcc can be found +ifeq ($(GCC), yes) +libpath := $(libpath):$(dir $(shell gcc -print-libgcc-file-name)) +endif + +rpath = -Wl,-blibpath:'$(rpathdir)$(libpath)' + +LDFLAGS_SL += -Wl,-bnoentry -Wl,-H512 -Wl,-bM:SRE + +# gcc needs to know it's building a shared lib, otherwise it'll not emit +# correct code / link to the right support libraries +ifeq ($(GCC), yes) +LDFLAGS_SL += -shared +endif + +# env var name to use in place of LD_LIBRARY_PATH +ld_library_path_var = LIBPATH + + +POSTGRES_IMP= postgres.imp + +ifdef PGXS +BE_DLLLIBS= -Wl,-bI:$(pkglibdir)/$(POSTGRES_IMP) +else +BE_DLLLIBS= -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) +endif + +MKLDEXPORT_DIR=src/backend/port/aix +MKLDEXPORT=$(top_srcdir)/$(MKLDEXPORT_DIR)/mkldexport.sh + +%$(DLSUFFIX): %.o + $(CC) $(CFLAGS) $*.o $(LDFLAGS) $(LDFLAGS_SL) -o $@ $(BE_DLLLIBS) diff --git a/src/port/README b/src/port/README index ed5c54a72fa..97f18a62338 100644 --- a/src/port/README +++ b/src/port/README @@ -28,5 +28,5 @@ applications. from libpgport are linked first. This avoids having applications dependent on symbols that are _used_ by libpq, but not intended to be exported by libpq. libpq's libpgport usage changes over time, so such a -dependency is a problem. Windows, Linux, and macOS use an export +dependency is a problem. Windows, Linux, AIX, and macOS use an export list to control the symbols exported by libpq. diff --git a/src/port/strerror.c b/src/port/strerror.c index 76af67ec2d0..d70734196b2 100644 --- a/src/port/strerror.c +++ b/src/port/strerror.c @@ -214,8 +214,10 @@ get_errno_symbol(int errnum) return "ENOTCONN"; case ENOTDIR: return "ENOTDIR"; +#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */ case ENOTEMPTY: return "ENOTEMPTY"; +#endif case ENOTSOCK: return "ENOTSOCK"; #ifdef ENOTSUP diff --git a/src/template/aix b/src/template/aix new file mode 100644 index 00000000000..f39c680a314 --- /dev/null +++ b/src/template/aix @@ -0,0 +1,9 @@ +# src/template/aix + +# Extra CFLAGS for code that will go into a shared library +CFLAGS_SL="" + +# Native memset() is faster, tested on: +# AIX 5.1 and 5.2, XLC 6.0 (IBM's cc) +# AIX 5.3 ML3, gcc 4.0.1 +MEMSET_LOOP_LIMIT=0 diff --git a/src/test/regress/Makefile b/src/test/regress/Makefile index 6409a485e84..7c665ff892d 100644 --- a/src/test/regress/Makefile +++ b/src/test/regress/Makefile @@ -7,6 +7,11 @@ # GNU make uses a make file named "GNUmakefile" in preference to "Makefile" # if it exists. Postgres is shipped with a "GNUmakefile". + +# AIX make defaults to building *every* target of the first rule. Start with +# a single-target, empty rule to make the other targets non-default. +all: + all install clean check installcheck: @echo "You must use GNU make to use Postgres. It may be installed" @echo "on your system with the name 'gmake'." diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl index 515f6d4a7a6..36f3b79bea7 100644 --- a/src/tools/gen_export.pl +++ b/src/tools/gen_export.pl @@ -16,11 +16,12 @@ GetOptions( 'input:s' => \$input, 'output:s' => \$output) or die "wrong arguments"; -if (not( $format eq 'darwin' +if (not( $format eq 'aix' + or $format eq 'darwin' or $format eq 'gnu' or $format eq 'win')) { - die "$0: $format is not yet handled (only darwin, gnu, win are)\n"; + die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n"; } open(my $input_handle, '<', $input) @@ -55,7 +56,11 @@ while (<$input_handle>) } elsif (/^(\S+)\s+(\S+)/) { - if ($format eq 'darwin') + if ($format eq 'aix') + { + print $output_handle "$1\n"; + } + elsif ($format eq 'darwin') { print $output_handle "_$1\n"; } diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck index 7a6755991bb..3d3e371a8e1 100755 --- a/src/tools/pginclude/headerscheck +++ b/src/tools/pginclude/headerscheck @@ -89,6 +89,7 @@ do # These files are platform-specific, and c.h will include the # one that's relevant for our current platform anyway. + test "$f" = src/include/port/aix.h && continue test "$f" = src/include/port/cygwin.h && continue test "$f" = src/include/port/darwin.h && continue test "$f" = src/include/port/freebsd.h && continue -- 2.43.7 From 5d134a4bf21f603c7d810da27a0c62e24c438fb2 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Thu, 19 Feb 2026 15:37:26 -0500 Subject: [PATCH v7 4/8] Various minor adjustments for AIX. Remove platform-specific adjustment of MEMSET_LOOP_LIMIT; maybe that's still the right thing, but it really ought to be re-tested. (Indeed we should reconsider MemSet altogether, but that's not a job for this patch set.) Prefer unnamed POSIX semaphores, rather than the default choice of SysV semaphores. Prevent building static libraries that duplicate shared libraries, as they would have the same names 'libxxx.a'. Include /opt/freeware/lib in -Wl,-blibpath, even when it is not mentioned anywhere in LDFLAGS. Add some helpful comments. Improve the output of gen_export.pl by adding a header. Author: Aditya Kamath <Aditya.Kamath1@ibm.com> Author: Srirama Kucherlapati <sriram.rk@in.ibm.com> Co-authored-by: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CY5PR11MB63928CC05906F27FB10D74D0FD322@CY5PR11MB6392.namprd11.prod.outlook.com --- meson.build | 17 ++++++++++------- src/Makefile.shlib | 2 +- src/backend/meson.build | 1 + src/backend/port/aix/mkldexport.sh | 17 ++++++++++++----- src/makefiles/Makefile.aix | 2 +- src/template/aix | 10 +++++----- src/tools/gen_export.pl | 6 +++++- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/meson.build b/meson.build index 21d9a60e063..2ebf4a189eb 100644 --- a/meson.build +++ b/meson.build @@ -229,23 +229,26 @@ endif portname = host_system if host_system == 'aix' + sema_kind = 'unnamed_posix' library_path_var = 'LIBPATH' - export_file_format = 'aix' export_fmt = '-Wl,-bE:@0@' mod_link_args_fmt = ['-Wl,-bI:@0@'] mod_link_with_dir = 'libdir' mod_link_with_name = '@0@.imp' - # M:SRE sets a flag indicating that an object is a shared library. Seems to - # work in some circumstances without, but required in others. + # M:SRE sets a flag indicating that an object is a shared library. ldflags_sl += '-Wl,-bM:SRE' + # -brtllib indicates binaries should use runtime-loaded shared libraries. ldflags_be += '-Wl,-brtllib' - # Native memset() is faster, tested on: - # - AIX 5.1 and 5.2, XLC 6.0 (IBM's cc) - # - AIX 5.3 ML3, gcc 4.0.1 - memset_loop_limit = 0 + # On AIX, shared libraries are wrapped in static libraries and can have + # the same extension '.a'. Therefore we must refrain from trying to build + # static libraries alongside shared ones, or meson will complain about + # duplicate targets. Note however that we leave dlsuffix with its default + # value of '.so'; this results in using '.so' for loadable modules, which + # is fine. + build_static_lib = false elif host_system == 'cygwin' sema_kind = 'unnamed_posix' diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 65870d629c2..cd1543550ca 100644 --- a/src/Makefile.shlib +++ b/src/Makefile.shlib @@ -268,7 +268,7 @@ $(stlib): $(OBJS) | $(SHLIB_PREREQS) touch $@ endif #haslibarule -# AIX wraps shared libraries inside a static library, can be used both +# AIX wraps shared libraries inside a static library, which can be used both # for static and shared linking ifeq ($(PORTNAME), aix) $(stlib): $(shlib) diff --git a/src/backend/meson.build b/src/backend/meson.build index ba273df24b5..130144a7d5b 100644 --- a/src/backend/meson.build +++ b/src/backend/meson.build @@ -104,6 +104,7 @@ elif host_system == 'aix' install_dir: dir_lib, build_by_default: false, ) + # -Wl,-bE:exportfile indicates these symbols are exported by postgres binary backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path()) backend_link_depends += postgres_imp endif diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh index adf3793e868..85631ce672a 100755 --- a/src/backend/port/aix/mkldexport.sh +++ b/src/backend/port/aix/mkldexport.sh @@ -13,14 +13,21 @@ # object file (if different from the current # working directory). # -# [This file comes from the Postgres 4.2 distribution. - ay 7/95] +# On AIX, executables do not automatically expose their symbols to shared +# modules. Extensions therefore cannot call functions in the main Postgres +# binary unless those symbols are explicitly exported. Unlike other platforms, +# AIX executables are not default symbol providers; each shared module must +# link against an export list that defines which symbols it can use. # -# Header: /usr/local/devel/postgres/src/tools/mkldexport/RCS/mkldexport.sh,v 1.2 1994/03/13 04:59:12 aoki Exp +# The mkldexport.sh script fixes AIX's symbol export issue by generating an +# explicit export list. It uses nm to gather all symbols from the Postgres +# object files, then writes them into the export file. When invoked with ".", +# it outputs #! ., which tells AIX the list applies to the main executable. +# This way, extension modules can link against that list and resolve their +# undefined symbols directly from the Postgres binary. # -# setting this to nm -B might be better -# ... due to changes in AIX 4.x ... -# ... let us search in different directories - Gerhard Reithofer +# Search for the nm command binary. if [ -x /usr/ucb/nm ] then NM=/usr/ucb/nm elif [ -x /usr/bin/nm ] diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix index dd16a7a0378..828641655aa 100644 --- a/src/makefiles/Makefile.aix +++ b/src/makefiles/Makefile.aix @@ -3,7 +3,7 @@ MAKE_EXPORTS= true # -blibpath must contain ALL directories where we should look for libraries -libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/usr/lib:/lib +libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/opt/freeware/lib:/usr/lib:/lib # when building with gcc, need to make sure that libgcc can be found ifeq ($(GCC), yes) diff --git a/src/template/aix b/src/template/aix index f39c680a314..c7c8706fea5 100644 --- a/src/template/aix +++ b/src/template/aix @@ -1,9 +1,9 @@ # src/template/aix +# Prefer unnamed POSIX semaphores if available, unless user overrides choice +if test x"$PREFERRED_SEMAPHORES" = x"" ; then + PREFERRED_SEMAPHORES=UNNAMED_POSIX +fi + # Extra CFLAGS for code that will go into a shared library CFLAGS_SL="" - -# Native memset() is faster, tested on: -# AIX 5.1 and 5.2, XLC 6.0 (IBM's cc) -# AIX 5.3 ML3, gcc 4.0.1 -MEMSET_LOOP_LIMIT=0 diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl index 36f3b79bea7..c91fa42a675 100644 --- a/src/tools/gen_export.pl +++ b/src/tools/gen_export.pl @@ -31,7 +31,11 @@ open(my $output_handle, '>', $output) or die "$0: could not open output file '$output': $!\n"; -if ($format eq 'gnu') +if ($format eq 'aix') +{ + print $output_handle "#!\n"; +} +elsif ($format eq 'gnu') { print $output_handle "{ global: -- 2.43.7 From 657527453de8d1a4a228ee602680531781d283f2 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Thu, 19 Feb 2026 15:38:17 -0500 Subject: [PATCH v7 5/8] Force 64-bit builds on AIX. There's too many problems with 32-bit builds, due to AIX's inefficient management of address space. Rather than documenting those, let's just desupport the case. In the make-based build system, it's not too hard to force the right things to happen regardless of the OBJECT_MODE setting. But meson seems too obstreperously set on the idea that they know better. Pending somebody working out an end run around that silliness, document that users must set OBJECT_MODE=64 while building. TODO: it doesn't seem that -Wl,-bbigtoc actually works; we still get warnings from ld. Curiously, the meson build doesn't produce those warnings. I see it's inserting -Wl,-bbigtoc under the hood, but seemingly there's some additional secret sauce. TODO: who to credit for this work? --- doc/src/sgml/installation.sgml | 109 ++++------------------------- meson.build | 9 +++ src/backend/Makefile | 2 +- src/backend/port/aix/mkldexport.sh | 3 + src/makefiles/Makefile.aix | 3 + src/template/aix | 10 +++ 6 files changed, 40 insertions(+), 96 deletions(-) diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index 554d1bde7e0..2a0f4d7a781 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -3499,106 +3499,25 @@ export MANPATH The native IBM compiler <command>xlc</command> is not supported. </para> + <para> + Also, only 64-bit builds are supported. While the make-based build + system will automatically create 64-bit executables and libraries, + the meson build system requires you to + set <varname>OBJECT_MODE</varname> before building: +<programlisting> +export OBJECT_MODE=64 +meson setup ... +</programlisting> + Failure to do that will usually manifest as complaints + from <application>ar</application> about files having the wrong + object file mode. + </para> + <para> <productname>AIX</productname> versions before 7.2 are no longer tested nor supported by the <productname>PostgreSQL</productname> community. </para> - - <sect3 id="installation-notes-aix-mem-management"> - <title>Memory Management</title> - <!-- https://archives.postgresql.org/message-id/603bgqmpl9.fsf@dba2.int.libertyrms.com --> - - <para> - AIX can be somewhat peculiar with regards to the way it does - memory management. You can have a server with many multiples of - gigabytes of RAM free, but still get out of memory or address - space errors when running applications. One example - is loading of extensions failing with unusual errors. - For example, running as the owner of the PostgreSQL installation: -<screen> -=# CREATE EXTENSION plperl; -ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": A memory address is not in the address space for the process. -</screen> - Running as a non-owner in the group possessing the PostgreSQL - installation: -<screen> -=# CREATE EXTENSION plperl; -ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address -</screen> - Another example is out of memory errors in the PostgreSQL server - logs, with every memory allocation near or greater than 256 MB - failing. - </para> - - <para> - The overall cause of all these problems is the default bittedness - and memory model used by the server process. By default, all - binaries built on AIX are 32-bit. This does not depend upon - hardware type or kernel in use. These 32-bit processes are - limited to 4 GB of memory laid out in 256 MB segments using one - of a few models. The default allows for less than 256 MB in the - heap as it shares a single segment with the stack. - </para> - - <para> - In the case of the <literal>plperl</literal> example, above, - check your umask and the permissions of the binaries in your - PostgreSQL installation. The binaries involved in that example - were 32-bit and installed as mode 750 instead of 755. Due to the - permissions being set in this fashion, only the owner or a member - of the possessing group can load the library. Since it isn't - world-readable, the loader places the object into the process' - heap instead of the shared library segments where it would - otherwise be placed. - </para> - - <para> - The <quote>ideal</quote> solution for this is to use a 64-bit - build of PostgreSQL, but that is not always practical, because - systems with 32-bit processors can build, but not run, 64-bit - binaries. - </para> - - <para> - If a 32-bit binary is desired, set <symbol>LDR_CNTRL</symbol> to - <literal>MAXDATA=0x<replaceable>n</replaceable>0000000</literal>, - where 1 <= n <= 8, before starting the PostgreSQL server, - and try different values and <filename>postgresql.conf</filename> - settings to find a configuration that works satisfactorily. This - use of <symbol>LDR_CNTRL</symbol> tells AIX that you want the - server to have <symbol>MAXDATA</symbol> bytes set aside for the - heap, allocated in 256 MB segments. When you find a workable - configuration, - <command>ldedit</command> can be used to modify the binaries so - that they default to using the desired heap size. PostgreSQL can - also be rebuilt, passing <literal>configure - LDFLAGS="-Wl,-bmaxdata:0x<replaceable>n</replaceable>0000000"</literal> - to achieve the same effect. - </para> - - <para> - For a 64-bit build, set <envar>OBJECT_MODE</envar> to 64 and - pass <literal>CC="gcc -maix64"</literal> - and <literal>LDFLAGS="-Wl,-bbigtoc"</literal> - to <command>configure</command>. If you omit the export of - <envar>OBJECT_MODE</envar>, your build may fail with linker errors. When - <envar>OBJECT_MODE</envar> is set, it tells AIX's build utilities - such as <command>ar</command>, <command>as</command>, and <command>ld</command> what - type of objects to default to handling. - </para> - - <para> - By default, overcommit of paging space can happen. While we have - not seen this occur, AIX will kill processes when it runs out of - memory and the overcommit is accessed. The closest to this that - we have seen is fork failing because the system decided that - there was not enough memory for another process. Like many other - parts of AIX, the paging space allocation method and - out-of-memory kill is configurable on a system- or process-wide - basis if this becomes a problem. - </para> - </sect3> </sect2> <sect2 id="installation-notes-cygwin"> diff --git a/meson.build b/meson.build index 2ebf4a189eb..d0736ab05ac 100644 --- a/meson.build +++ b/meson.build @@ -237,6 +237,15 @@ if host_system == 'aix' mod_link_with_dir = 'libdir' mod_link_with_name = '@0@.imp' + # We force 64-bit builds, because AIX doesn't play very nice with dynamic + # library loading in 32-bit mode: there's not enough address space. + cppflags += '-maix64' + ldflags += '-maix64' + # Note: it's also necessary to tell programs like 'ar' to work in 64-bit + # mode. Since meson, in its infinite wisdom, doesn't allow us either + # to pass '-X64' to ar or to set the OBJECT_MODE environment variable + # from here, we have to tell the user to set OBJECT_MODE. + # M:SRE sets a flag indicating that an object is a shared library. ldflags_sl += '-Wl,-bM:SRE' # -brtllib indicates binaries should use runtime-loaded shared libraries. diff --git a/src/backend/Makefile b/src/backend/Makefile index fe717001951..ba53cd9d998 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -131,7 +131,7 @@ postgres: $(POSTGRES_IMP) # trivially work with gcc, due to gcc specific static libraries linked in with # -r. $(POSTGRES_IMP): $(OBJS) - ld -r -o SUBSYS.o $(call expand_subsys,$^) + ld -b64 -r -o SUBSYS.o $(call expand_subsys,$^) $(MKLDEXPORT) SUBSYS.o . > $@ @rm -f SUBSYS.o diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh index 85631ce672a..9d016e7afd5 100755 --- a/src/backend/port/aix/mkldexport.sh +++ b/src/backend/port/aix/mkldexport.sh @@ -40,6 +40,9 @@ else echo "Fatal error: cannot find `nm' ... please check your installation." exit 1 fi +# instruct nm to process 64-bit objects +export OBJECT_MODE=64 + CMDNAME=`basename $0` if [ -z "$1" ]; then echo "Usage: $CMDNAME object [location]" diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix index 828641655aa..ecba693b6a9 100644 --- a/src/makefiles/Makefile.aix +++ b/src/makefiles/Makefile.aix @@ -20,6 +20,9 @@ ifeq ($(GCC), yes) LDFLAGS_SL += -shared endif +# instruct ar to process 64-bit objects +AROPT := -X64 $(AROPT) + # env var name to use in place of LD_LIBRARY_PATH ld_library_path_var = LIBPATH diff --git a/src/template/aix b/src/template/aix index c7c8706fea5..9abe1efacd4 100644 --- a/src/template/aix +++ b/src/template/aix @@ -7,3 +7,13 @@ fi # Extra CFLAGS for code that will go into a shared library CFLAGS_SL="" + +if test "$GCC" = yes; then + # We force 64-bit builds, because AIX doesn't play very nice with dynamic + # library loading in 32-bit mode: there's not enough address space. + CPPFLAGS="$CPPFLAGS -maix64" + + # For large binaries/libraries, there will be TOC overflows in AIX. To + # avoid this, pass -bbigtoc linker option to enlarge TOC access range. + LDFLAGS="$LDFLAGS -maix64 -Wl,-bbigtoc" +fi -- 2.43.7 From aefacfeaae17b353e82b54df5a5565e0e9cc6a2c Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Thu, 19 Feb 2026 15:38:39 -0500 Subject: [PATCH v7 6/8] Add some definitions needed for a clean compile. AIX has getpeereid() and wcstombs_l() in libc, so configure finds them and tries to use them. But they aren't declared in system headers (as of 7.3, anyway) so we get implicit-function-declaration warnings. We could probe for the existence of these declarations, but given that they're not in POSIX it's not completely clear which headers to check. Let's just supply hard-wired externs in aix.h, instead. Like old Solaris, AIX never added "const" to the second argument of PAM conversation procs. We can leverage what e6dfd068e did about that to silence the "incompatible pointer" compiler warning (which'll be an error with GCC 14 and later, so fixing it is important). --- src/include/port/aix.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/include/port/aix.h b/src/include/port/aix.h index c86983a4452..211b048cfbf 100644 --- a/src/include/port/aix.h +++ b/src/include/port/aix.h @@ -1,3 +1,22 @@ /* * src/include/port/aix.h */ +#include <stddef.h> /* for size_t */ +#include <sys/types.h> /* for uid_t and gid_t */ +#include <wchar.h> /* for wchar_t and locale_t */ + +/* AIX has getpeereid(), but fails to declare it as of 7.3 */ +extern int getpeereid(int socket, uid_t *euid, gid_t *egid); + +/* AIX has wcstombs_l(), but fails to declare it as of 7.3 */ +extern size_t wcstombs_l(char *dest, const wchar_t *src, size_t n, + locale_t loc); + +/* + * AIX doesn't seem to have ever modernized pam_appl.h to include + * "const" in the declaration of PAM conversation procs. We can avoid + * a compile error by setting _PAM_LEGACY_NONCONST; that doesn't do + * anything in AIX's system headers, but it makes us omit the "const" + * in our own code. (Compare solaris.h.) + */ +#define _PAM_LEGACY_NONCONST 1 -- 2.43.7 From a22b6c26cb0a52ba4e06947a60ddddee3770fb05 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Thu, 19 Feb 2026 15:41:57 -0500 Subject: [PATCH v7 7/8] Fix inconsistencies in the set of installed files. Install postgres.imp in pkglibdir, where the Makefiles have always put it. Also install mkldexport.sh where the Makefiles put it. These seem to have been pre-existing bugs in the meson logic for AIX. It's not really surprising that we never noticed given that we desupported AIX in the same version where meson support was added. Also suppress bogus installed symlinks for client shared libraries. As things stand, "meson install" installs libpgtypes.a, plus a useless symlink libpgtypes.so -> libpgtypes.so.3, and another useless symlink libpgtypes.so.3 -> libpgtypes.so.3.19; similarly for the other ecpg libraries and libpq. Arguably this is a bug in meson's shared_library function, but it seems we can work around it by setting 'soversion' to empty in the shared_library calls. --- src/backend/meson.build | 5 ++++- src/interfaces/ecpg/compatlib/meson.build | 2 +- src/interfaces/ecpg/ecpglib/meson.build | 2 +- src/interfaces/ecpg/pgtypeslib/meson.build | 2 +- src/interfaces/libpq/meson.build | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/backend/meson.build b/src/backend/meson.build index 130144a7d5b..fec9f1d03b4 100644 --- a/src/backend/meson.build +++ b/src/backend/meson.build @@ -101,12 +101,15 @@ elif host_system == 'aix' output: 'postgres.imp', capture: true, install: true, - install_dir: dir_lib, + install_dir: dir_lib_pkg, build_by_default: false, ) # -Wl,-bE:exportfile indicates these symbols are exported by postgres binary backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path()) backend_link_depends += postgres_imp + install_data( + 'port/aix/mkldexport.sh', + install_dir: dir_pgxs / 'src/backend/port/aix') endif backend_input = [] diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build index d578faefe1c..0efe8a38230 100644 --- a/src/interfaces/ecpg/compatlib/meson.build +++ b/src/interfaces/ecpg/compatlib/meson.build @@ -35,7 +35,7 @@ ecpg_compat_so = shared_library('libecpg_compat', c_args: ecpg_compat_c_args, dependencies: [frontend_shlib_code, thread_dep], link_with: [ecpglib_so, ecpg_pgtypes_so], - soversion: host_system != 'windows' ? '3' : '', + soversion: host_system not in ['aix', 'windows'] ? '3' : '', darwin_versions: ['3', '3.' + pg_version_major.to_string()], version: '3.' + pg_version_major.to_string(), link_args: export_fmt.format(export_file.full_path()), diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build index 81e92151945..cb7288f2ee6 100644 --- a/src/interfaces/ecpg/ecpglib/meson.build +++ b/src/interfaces/ecpg/ecpglib/meson.build @@ -46,7 +46,7 @@ ecpglib_so = shared_library('libecpg', c_pch: pch_postgres_fe_h, dependencies: [frontend_shlib_code, libpq, thread_dep], link_with: ecpg_pgtypes_so, - soversion: host_system != 'windows' ? '6' : '', + soversion: host_system not in ['aix', 'windows'] ? '6' : '', darwin_versions: ['6', '6.' + pg_version_major.to_string()], version: '6.' + pg_version_major.to_string(), link_args: export_fmt.format(export_file.full_path()), diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build index 241fa95e559..5b5205ed095 100644 --- a/src/interfaces/ecpg/pgtypeslib/meson.build +++ b/src/interfaces/ecpg/pgtypeslib/meson.build @@ -41,7 +41,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes', c_pch: pch_postgres_fe_h, dependencies: [frontend_shlib_code], version: '3.' + pg_version_major.to_string(), - soversion: host_system != 'windows' ? '3' : '', + soversion: host_system not in ['aix', 'windows'] ? '3' : '', darwin_versions: ['3', '3.' + pg_version_major.to_string()], link_args: export_fmt.format(export_file.full_path()), link_depends: export_file, diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build index c6d361e7f61..b0ae72167a1 100644 --- a/src/interfaces/libpq/meson.build +++ b/src/interfaces/libpq/meson.build @@ -77,7 +77,7 @@ libpq_so = shared_library('libpq', c_args: libpq_c_args + libpq_so_c_args, c_pch: pch_postgres_fe_h, version: '5.' + pg_version_major.to_string(), - soversion: host_system != 'windows' ? '5' : '', + soversion: host_system not in ['aix', 'windows'] ? '5' : '', darwin_versions: ['5', '5.' + pg_version_major.to_string()], dependencies: [frontend_shlib_code, libpq_deps], link_depends: export_file, -- 2.43.7 From f6661415290811d616563003ec6ad7102f354bf8 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Thu, 19 Feb 2026 18:23:40 -0500 Subject: [PATCH v7 8/8] Fix libpython configure check for AIX. This logic didn't believe that "libpythonXXX.a" is a candidate to be a shared library, but on AIX we'd better accept that. --- config/python.m4 | 5 +++++ configure | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/config/python.m4 b/config/python.m4 index b295ad3d3a4..ec3c80cf044 100644 --- a/config/python.m4 +++ b/config/python.m4 @@ -97,6 +97,11 @@ python_ldlibrary=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sys # If LDLIBRARY exists and has a shlib extension, use it verbatim. ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'` +if test "$PORTNAME" = "aix"; then + # On AIX, '.a' should also be believed to be a shlib. + ldlibrary=`echo "${ldlibrary}" | sed -e 's/\.a$//'` +fi + if test -e "${python_libdir}/${python_ldlibrary}" -a x"${python_ldlibrary}" != x"${ldlibrary}" then ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"` diff --git a/configure b/configure index 6a85065279d..bb0b739eb4d 100755 --- a/configure +++ b/configure @@ -10705,6 +10705,11 @@ python_ldlibrary=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sys # If LDLIBRARY exists and has a shlib extension, use it verbatim. ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'` +if test "$PORTNAME" = "aix"; then + # On AIX, '.a' should also be believed to be a shlib. + ldlibrary=`echo "${ldlibrary}" | sed -e 's/\.a$//'` +fi + if test -e "${python_libdir}/${python_ldlibrary}" -a x"${python_ldlibrary}" != x"${ldlibrary}" then ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"` -- 2.43.7
pgsql-hackers by date: