AIX support
AIX support
Hello Team,
We are working on AIX systems and noticed that the thread on removing AIX support in Postgres going forward.
https://github.com/postgres/postgres/commit/0b16bb8776bb834eb1ef8204ca95dd7667ab948b”
We would be glad to understand any outstanding issues hindering the support on AIX.
It is important for us to have Postgres to be supported on AIX. As we are using Postgres extensively on AIX.
Also we would like to provide any feasible support from our end for enabling the support on AIX.
We would request the community to extend the support on AIX ..
Thanks & regards,
Sriram.
Re: AIX support
On 2024-Mar-21, Sriram RK wrote: > Hello Team, > > We are working on AIX systems and noticed that the thread on removing AIX support in Postgres going forward. > > https://github.com/postgres/postgres/commit/0b16bb8776bb834eb1ef8204ca95dd7667ab948b” > > We would be glad to understand any outstanding issues hindering the support on AIX. There's a Discussion link at the bottom of that commit message. I suggest you read that discussion complete, and consider how much effort you or your company are willing to spend on doing the maintenance of the port yourselves for the community. Maybe ponder this question: would it be less onerous to migrate your Postgres servers to Linux, like Phil Florent described on the currently-last message of that thread? -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Para tener más hay que desear menos"
Re: AIX support
Sriram RK writes: > We are working on AIX systems and noticed that the thread on removing AIX support in Postgres going forward. > https://github.com/postgres/postgres/commit/0b16bb8776bb834eb1ef8204ca95dd7667ab948b > We would be glad to understand any outstanding issues hindering the > support on AIX. Did you read the linked thread? Starting say about here: https://www.postgresql.org/message-id/flat/20240224172345.32%40rfd.leadboat.com#8b41e50c2190c82c861d91644eed9c30 > Also we would like to provide any feasible support from our end for enabling the support on AIX. Who is "we", and how much resources are you prepared to put into this? > We would request the community to extend the support on AIX .. The community, in the sense of the existing people doing significant work on Postgres, are absolutely not going to do that. If you can bring a bunch of work to fix all the problems noted in the discussion thread, and commit to providing ongoing development manpower and hardware to keep it working, maybe something could happen. But I suspect you will find it cheaper to start thinking about migrating off AIX. regards, tom lane
Re: AIX support
Thanks, Tom and Alvaro, for the info.
We shall look into to details and get back.
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thursday, 21 March 2024 at 7:27 PM
To: Sriram RK <sriram.rk@outlook.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: AIX support
Sriram RK <sriram.rk@outlook.com> writes:
> We are working on AIX systems and noticed that the thread on removing AIX support in Postgres going forward.
> https://github.com/postgres/postgres/commit/0b16bb8776bb834eb1ef8204ca95dd7667ab948b
> We would be glad to understand any outstanding issues hindering the
> support on AIX.
Did you read the linked thread? Starting say about here:
https://www.postgresql.org/message-id/flat/20240224172345.32%40rfd.leadboat.com#8b41e50c2190c82c861d91644eed9c30
> Also we would like to provide any feasible support from our end for enabling the support on AIX.
Who is "we", and how much resources are you prepared to put into this?
> We would request the community to extend the support on AIX ..
The community, in the sense of the existing people doing significant
work on Postgres, are absolutely not going to do that. If you can
bring a bunch of work to fix all the problems noted in the discussion
thread, and commit to providing ongoing development manpower and
hardware to keep it working, maybe something could happen. But I
suspect you will find it cheaper to start thinking about migrating
off AIX.
regards, tom lane
Re: AIX support
Hi Team,
We are setting up the build environment and trying to build the source and also trying to analyze the assert from the Aix point of view.
Also, would like to know if we can access the buildfarm(power machines) to run any of the specific tests to hit this assert.
Thanks & regards,
Sriram.
> From: Sriram RK <sriram.rk@outlook.com>
> Date: Thursday, 21 March 2024 at 10:05 PM
> To: Tom Lane tgl@sss.pgh.pa.us, Alvaro Herrera <alvherre@alvh.no-ip.org>
> Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
> Subject: Re: AIX support
> Thanks, Tom and Alvaro, for the info.
> We shall look into to details and get back.
Re: AIX support
On Thu, Mar 28, 2024 at 11:09:43AM +0000, Sriram RK wrote: > We are setting up the build environment and trying to build the source and also trying to analyze the assert from the Aix point of view. The thread Alvaro and Tom cited contains an analysis. It's a compiler bug. You can get past the compiler bug by upgrading your compiler; both ibm-clang 17.1.1.2 and gcc 13.2.0 are free from the bug. > Also, would like to know if we can access the buildfarm(power machines) to run any of the specific tests to hit this assert. https://portal.cfarm.net/users/new/ is the form to request access. It lists the eligibility criteria.
Re: AIX support
On Fri, Mar 29, 2024 at 3:48 PM Noah Misch wrote: > On Thu, Mar 28, 2024 at 11:09:43AM +0000, Sriram RK wrote: > > We are setting up the build environment and trying to build the source and also trying to analyze the assert from the Aix point of view. > > The thread Alvaro and Tom cited contains an analysis. It's a compiler bug. > You can get past the compiler bug by upgrading your compiler; both ibm-clang > 17.1.1.2 and gcc 13.2.0 are free from the bug. For the specific issue that triggered that, I strongly suspect that it would go away if we just used smgrzeroextend() instead of smgrextend() using that variable with the alignment requirement, since, as far as I can tell from build farm clues, the otherwise similar function-local static variable used by the former (ie one that the linker must still control the location of AFAIK?) seems to work fine. But we didn't remove AIX because of that, it was just the straw that broke the camel's back.
Re: AIX support
Noah Misch writes: > On Thu, Mar 28, 2024 at 11:09:43AM +0000, Sriram RK wrote: >> Also, would like to know if we can access the buildfarm(power machines) to run any of the specific tests to hit this assert. > https://portal.cfarm.net/users/new/ is the form to request access. It lists > the eligibility criteria. There might be some confusion here about what system we are talking about. The Postgres buildfarm is described at https://buildfarm.postgresql.org/index.html but it consists of a large number of individual machines run by individual owners. There would not be a lot of point in adding a new AIX machine to the Postgres buildfarm right now, because it would surely fail to build HEAD. What Noah is referencing is the GCC compile farm, which happens to include some AIX machines. The existing AIX entries in the Postgres buildfarm are run (by Noah) on those GCC compile farm machines, which really the GCC crowd have been *very* forgiving about letting us abuse like that. If you have your own AIX hardware there's not a lot of reason that you should need to access the GCC farm. What you do need to do to reproduce the described problems is check out the Postgres git tree and rewind to just before commit 0b16bb877, where we deleted AIX support. Any attempt to restore AIX support would have to start with reverting that commit (and perhaps the followup f0827b443). regards, tom lane
Re: AIX support
On Fri, Mar 29, 2024 at 4:00 PM Thomas Munro wrote: > On Fri, Mar 29, 2024 at 3:48 PM Noah Misch wrote: > > The thread Alvaro and Tom cited contains an analysis. It's a compiler bug. > > You can get past the compiler bug by upgrading your compiler; both ibm-clang > > 17.1.1.2 and gcc 13.2.0 are free from the bug. > > For the specific issue that triggered that, I strongly suspect that it > would go away if we just used smgrzeroextend() instead of smgrextend() > using that variable with the alignment requirement, since, as far as I > can tell from build farm clues, the otherwise similar function-local > static variable used by the former (ie one that the linker must still > control the location of AFAIK?) seems to work fine. Oh, sorry, I had missed the part where newer compilers fix the issue too. Old out-of-support versions of AIX running old compilers, what fun.
Re: AIX support
Thomas Munro writes: > Oh, sorry, I had missed the part where newer compilers fix the issue > too. Old out-of-support versions of AIX running old compilers, what > fun. Indeed. One of the topics that needs investigation if you want to pursue this is which AIX system and compiler versions still deserve support, and which of the AIX hacks we had been carrying still need to be there based on that analysis. For context, we've been pruning support for extinct-in-the-wild OS versions pretty aggressively over the past couple of years, and I'd expect to apply the same standard to AIX. regards, tom lane
Re: AIX support
> What you do need to do to reproduce the described problems is
> check out the Postgres git tree and rewind to just before
> commit 0b16bb877, where we deleted AIX support. Any attempt
> to restore AIX support would have to start with reverting that
> commit (and perhaps the followup f0827b443).
> regards, tom lane
Hi Team, thank you for all the info.
We progressed to build the source on our nodes and the build was successful with the below configuration.
Postgres - github-bcdfa5f2e2f
AIX - 71c
Xlc - 13.1.0
Bison - 3.0.5
Going ahead, we want to build the changes that were removed as part of “0b16bb8776bb8”, with latest Xlc and gcc version.
We were building the source from the postgres ftp server(https://ftp.postgresql.org/pub/source/), would like to understand if there are any source level changes between the ftp server and the source on github?
Regards,
Sriram.
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Friday, 29 March 2024 at 9:03 AM
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Noah Misch <noah@leadboat.com>, Sriram RK <sriram.rk@outlook.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: AIX support
Thomas Munro <thomas.munro@gmail.com> writes:
> Oh, sorry, I had missed the part where newer compilers fix the issue
> too. Old out-of-support versions of AIX running old compilers, what
> fun.
Indeed. One of the topics that needs investigation if you want to
pursue this is which AIX system and compiler versions still deserve
support, and which of the AIX hacks we had been carrying still need
to be there based on that analysis. For context, we've been pruning
support for extinct-in-the-wild OS versions pretty aggressively
over the past couple of years, and I'd expect to apply the same
standard to AIX.
regards, tom lane
Re: AIX support
On Fri, Apr 05, 2024 at 04:12:06PM +0000, Sriram RK wrote: > > > What you do need to do to reproduce the described problems is > > check out the Postgres git tree and rewind to just before > > commit 0b16bb877, where we deleted AIX support. Any attempt > > to restore AIX support would have to start with reverting that > > commit (and perhaps the followup f0827b443). > Going ahead, we want to build the changes that were removed as part of “0b16bb8776bb8”, with latest Xlc and gcc version. > > We were building the source from the postgres ftp server(https://ftp.postgresql.org/pub/source/), would like to understand if there are any source level changes between the ftp server and the source on github? To succeed in this endeavor, you'll need to develop fluency in the tools to answer questions like that, or bring in someone who is fluent. In this case, GNU diff is the standard tool for answering your question. These resources cover other topics you would need to learn: https://wiki.postgresql.org/wiki/Developer_FAQ https://wiki.postgresql.org/wiki/So,_you_want_to_be_a_developer%3F
Re: AIX support
Thanks Noah and Team,
We (IBM-AIX team) looked into this issue
https://www.postgresql.org/message-id/20240225194322.a5@rfd.leadboat.com
This is related to the compiler issue. The compilers xlc(13.1) and gcc(8.0) have issues. But we verified that this issue is resolved with the newer compiler versions openXL(xlc17.1) and gcc(12.0) onwards.
We reported this issue to the xlc team and they have noted this issue. A fix might be possible in May for this issue in xlc v16. We would like to understand if the community can start using the latest compilers to build the source.
Also as part of the support, we will help in fixing all the issues related to AIX and continue to support AIX for Postgres. If we need another CI environment we can work to make one available. But for time being can we start reverting the patch that has removed AIX support.
We want to make a note that postgres is used extensively in our IBM product and is being exploited by multiple customers.
Please let us know if there are any specific details you'd like to discuss further.
Regards,
Sriram.
Re: AIX support
On 18 April 2024 14:15:43 GMT+03:00, Sriram RK wrote: >Thanks Noah and Team, > >We (IBM-AIX team) looked into this issue > >https://www.postgresql.org/message-id/20240225194322.a5@rfd.leadboat.com > >This is related to the compiler issue. The compilers xlc(13.1) and gcc(8.0) have issues. But we verified that this issue is resolved with the newer compiler versions openXL(xlc17.1) and gcc(12.0) onwards. > >We reported this issue to the xlc team and they have noted this issue. A fix might be possible in May for this issue in xlc v16. We would like to understand if the community can start using the latest compilers to build the source. > >Also as part of the support, we will help in fixing all the issues related to AIX and continue to support AIX for Postgres. If we need another CI environment we can work to make one available. But for time being can we start reverting the patch that has removed AIX support. Let's start by setting up a new AIX buildfarm member. Regardless of what we do with v17, we continue to support AIX on the stable branches, and we really need a buildfarm member to keep the stable branches working anyway. >We want to make a note that postgres is used extensively in our IBM product and is being exploited by multiple customers. Noted. I'm glad to hear you are interested to put in some effort for this. The situation from the current maintainers is that none of us have much interest, or resources or knowledge to keep the AIX build working, so we'll definitely need the help. No promises on v17, but let's at least make sure the stable branches keep working. And with the patches and buildfarm support from you, maybe v17 is feasible too. - Heikki
Re: AIX support
> Let's start by setting up a new AIX buildfarm member. Regardless of what we do with v17, we continue to support AIX on the stable branches, and we really need a buildfarm member to keep the stable branches working anyway.
Thanks Heikki. We had already build the source code(v17+ bcdfa5f2e2f) on our local nodes. We will try to setup the buildfarm and let you know.
Is there any specific configuration we are looking for?
Regards,
Sriram.
Re: AIX support
Hi, On 2024-04-18 11:15:43 +0000, Sriram RK wrote: > We (IBM-AIX team) looked into this issue > > https://www.postgresql.org/message-id/20240225194322.a5@rfd.leadboat.com > > This is related to the compiler issue. The compilers xlc(13.1) and gcc(8.0) > have issues. But we verified that this issue is resolved with the newer > compiler versions openXL(xlc17.1) and gcc(12.0) onwards. The reason we used these compilers was that those were the only ones we had kinda somewhat reasonable access to, via the gcc projects' "compile farm" https://portal.cfarm.net/ We have to rely on whatever the aix machines there provide. They're not particularly plentiful resource-wise either. This is generally one of the big issues with AIX support. There are other niche-y OSs that don't have a lot of users, e.g. openbsd, but in contrast to AIX I can just start an openbsd VM within a few minutes and iron out whatever portability issue I'm dealing with. Not being AIX customers we also can't raise bugs about compiler bugs, so we're stuck doing bad workarounds. > Also as part of the support, we will help in fixing all the issues related > to AIX and continue to support AIX for Postgres. If we need another CI > environment we can work to make one available. But for time being can we > start reverting the patch that has removed AIX support. The state when was removed was not in a state that I am OK with adding back. > We want to make a note that postgres is used extensively in our IBM product > and is being exploited by multiple customers. To be blunt: Then it'd have been nice to see some investment in that before now. Both on the code level and the infrastructure level (i.e. access to machines etc). Greetings, Andres Freund
Re: AIX support
On Fri, Apr 19, 2024 at 6:01 AM Andres Freund wrote: > On 2024-04-18 11:15:43 +0000, Sriram RK wrote: > > We (IBM-AIX team) looked into this issue > > > > https://www.postgresql.org/message-id/20240225194322.a5@rfd.leadboat.com > > > > This is related to the compiler issue. The compilers xlc(13.1) and gcc(8.0) > > have issues. But we verified that this issue is resolved with the newer > > compiler versions openXL(xlc17.1) and gcc(12.0) onwards. > > The reason we used these compilers was that those were the only ones we had > kinda somewhat reasonable access to, via the gcc projects' > "compile farm" https://portal.cfarm.net/ > We have to rely on whatever the aix machines there provide. They're not > particularly plentiful resource-wise either. To be fair, those OSUOSL machines are donated by IBM: https://osuosl.org/services/powerdev/ It's just that they seem to be mostly focused on supporting Linux on POWER, with only a couple of AIX hosts (partitions/virtual machines?) made available via portal.cfarm.net, and they only very recently added a modern AIX 7.3 host. That's cfarm119, upgraded in September-ish, long after many threads on this list that between-the-lines threatened to drop support. > This is generally one of the big issues with AIX support. There are other > niche-y OSs that don't have a lot of users, e.g. openbsd, but in contrast to > AIX I can just start an openbsd VM within a few minutes and iron out whatever > portability issue I'm dealing with. Yeah. It is a known secret that you can run AIX inside Qemu/kvm (it appears that IBM has made changes to it to make that possible, because earlier AIX versions didn't like Qemu's POWER emulation or virtualisation, there are blog posts about it), but IBM doesn't actually make the images available to non-POWER-hardware owners (you need a serial number). If I were an OS vendor and wanted developers to target my OS for free, at the very top of my TODO list I would have: provide an easy to use image for developers to be able to spin something up in minutes and possibly even use in CI systems. That's the reason I can fix any minor portability issue on Linux, illumos, *BSD quickly and Windows with only moderate extra pain. Even Oracle knows this, see Solaris CBE. > > We want to make a note that postgres is used extensively in our IBM product > > and is being exploited by multiple customers. > > To be blunt: Then it'd have been nice to see some investment in that before > now. Both on the code level and the infrastructure level (i.e. access to > machines etc). In the AIX space generally, there were even clues that funding had been completely cut even for packaging PostgreSQL. I was aware of two packaging projects (not sure how they were related): 1. The ATOS packaging group, who used to show up on our mailing lists and discuss code changes, which announced it was shutting down: https://github.com/power-devops/bullfreeware 2. And last time I looked a few months back, the IBM AIX Toolbox packaging project only had PostgreSQL 10 or 11 packages, already out of support by us, meaning that their maintainer had given up, too: https://www.ibm.com/support/pages/aix-toolbox-open-source-software-downloads-alpha However I see that recently (last month?) someone has added PostgreSQL 15, so something has only just reawoken there? There are quite a lot of threads about AIX problems, but they are almost all just us non-AIX-users trying to unbreak stupid stuff on the build farm, which at some points began to seem distinctly quixotic: chivalric hackers valiantly trying to keep the entire Unix family tree working even though we don't remember why and th versions involved are out of support even by the vendor. Of the three old giant commercial Unixes, HP-UX was dropped without another mention (it really was a windmill after all), Solaris is somehow easier to deal with (I could guess it's because it influenced Linux and BSD so much, ELF and linker details spring to mind), while AIX fails on every dimension: unrepresented by users, lacking in build farm, unavailable to non-customers, and unusual among Unixen.
Re: AIX support
For any complier/hardware related issue we should able to provide support.
We are in the process of identifying the AIX systems that can be added to the CI/buildfarm environment.
Regards,
Sriram.
Re: AIX support
On 19.04.24 13:04, Sriram RK wrote: > For any complier/hardware related issue we should able to provide support. > > We are in the process of identifying the AIX systems that can be added > to the CI/buildfarm environment. I think we should manage expectations here, if there is any hope of getting AIX support back into PG17. I have some sympathy for this. The discussion about removing AIX support had a very short turnaround and happened in an unrelated thread, without any sort of public announcement or consultation. So this report of "hey, we were still using that" is timely and fair. But the underlying issue that led to the removal (something to do with direct I/O support and alignment) would still need to be addressed. And this probably wouldn't just need some infrastructure support; it would require contributions from someone who actively knows how to develop on this platform. Now, direct I/O is currently sort of an experimental feature, so disabling it on AIX, as was initially suggested in that discussion, might be okay for now, but the issue will come up again. Even if this new buildfarm support is forthcoming, there has to be some sort of deadline in any resurrection attempts for PG17. The first beta date has been set for 23 May. If we are making the reinstatement of AIX support contingent on new buildfarm support, those machines need to be available, at least initially, at least for backbranches, like in a week. Which seems tight. I can see several ways going forward: 1. We revert the removal of AIX support and carry on with the status quo ante. (The removal of AIX is a regression; it is timely and in scope now to revert the change.) 2. Like (1), but we consider that notice has been given, and we will remove it early in PG18 (like August) unless the situation improves. 3. We leave it out of PG17 and consider a new AIX port for PG18 on its own merits. Note that such a "new" port would probably require quite a bit of development and research work, to clean up all the cruft that had accumulated over the years in the old port. Another looming issue is that the meson build system only supported AIX with gcc before the removal. I don't know what it would take to expand that to support xclang, but if it requires meson upstream work, you have that to do, too.
Re: AIX support
Peter Eisentraut writes: > I have some sympathy for this. The discussion about removing AIX > support had a very short turnaround and happened in an unrelated thread, > without any sort of public announcement or consultation. So this report > of "hey, we were still using that" is timely and fair. Yup, that's a totally fair complaint. Still ... > I can see several ways going forward: > 1. We revert the removal of AIX support and carry on with the status quo > ante. (The removal of AIX is a regression; it is timely and in scope > now to revert the change.) > 2. Like (1), but we consider that notice has been given, and we will > remove it early in PG18 (like August) unless the situation improves. > 3. We leave it out of PG17 and consider a new AIX port for PG18 on its > own merits. Andres has ably summarized the reasons why the status quo ante was getting untenable. The direct-I/O problem could have been tolerable on its own, but in reality it was the straw that broke the camel's back so far as our willingness to maintain AIX support went. There were just too many hacks and workarounds for too many problems, with too few people interested in looking for better answers. So I'm totally not in favor of #1, at least not without some hard commitments and follow-through on really cleaning up the mess (which maybe looks more like your #2). What's needed here, as you said, is for someone with a decent amount of expertise in modern AIX to review all the issues. Maybe framing that as a "new port" per #3 would be a good way to think about it. But I don't want to just revert the AIX-ectomy and continue drifting. On the whole, it wouldn't be the worst thing in the world if PG 17 lacks AIX support but that comes back in PG 18. That approach would solve the schedule-crunch aspect and give time for considered review of how many of the hacks removed in 0b16bb877 really need to be put back, versus being obsolete or amenable to a nicer solution in late-model AIX. If we take a "new port" mindset then it would be totally reasonable to say that it only supports very recent AIX releases, so I'd hope at least some of the cruft could be removed. regards, tom lane
Re: AIX support
Hi Team,
> I have some sympathy for this. The discussion about removing AIX
> support had a very short turnaround and happened in an unrelated thread,
> without any sort of public announcement or consultation. So this report
> of "hey, we were still using that" is timely and fair.
We would really like to thank you & the team for considering our request,
and really appreciate for providing all the possible options to support AIX.
> But the underlying issue that led to the removal (something to do with
> direct I/O support and alignment) would still need to be addressed.
As we already validated that these alignment specific issues are resolved
with the latest versions of the compilers (gcc/ibm-clang). We would request
you to use the latest versions for the build.
> If we are making the reinstatement of AIX
> support contingent on new buildfarm support, those machines need to be
> available, at least initially, at least for back branches, like in a
> week. Which seems tight.
We are already working with the internal team in procuring the nodes
for the buildfarm, which can be accessible by the community.
> I can see several ways going forward:
> 1. We revert the removal of AIX support and carry on with the status quo
> ante. (The removal of AIX is a regression; it is timely and in scope
> now to revert the change.)
> 2. Like (1), but we consider that notice has been given, and we will
> remove it early in PG18 (like August) unless the situation improves.
We would really appreciate you for providing the possible options
and we are very much inclined to these above approaches.
Regards,
Sriram.
Re: AIX support
On Sat Apr 20, 2024 at 10:42 AM CDT, Peter Eisentraut wrote: > > 3. We leave it out of PG17 and consider a new AIX port for PG18 on its > own merits. > > Note that such a "new" port would probably require quite a bit of > development and research work, to clean up all the cruft that had > accumulated over the years in the old port. Another looming issue is > that the meson build system only supported AIX with gcc before the > removal. I don't know what it would take to expand that to support > xclang, but if it requires meson upstream work, you have that to do, too. Happy to help advocate for any PRs from AIX folks on the Meson side. You can find me as @tristan957 on github. -- Tristan Partin Neon (https://neon.tech)
Re: AIX support
On Sat, Apr 20, 2024 at 12:25:47PM -0400, Tom Lane wrote: > > I can see several ways going forward: > > 1. We revert the removal of AIX support and carry on with the status quo > > ante. (The removal of AIX is a regression; it is timely and in scope > > now to revert the change.) > > 2. Like (1), but we consider that notice has been given, and we will > > remove it early in PG18 (like August) unless the situation improves. > > 3. We leave it out of PG17 and consider a new AIX port for PG18 on its > > own merits. > > Andres has ably summarized the reasons why the status quo ante was > getting untenable. The direct-I/O problem could have been tolerable > on its own, but in reality it was the straw that broke the camel's > back so far as our willingness to maintain AIX support went. There > were just too many hacks and workarounds for too many problems, > with too few people interested in looking for better answers. > > So I'm totally not in favor of #1, at least not without some hard > commitments and follow-through on really cleaning up the mess > (which maybe looks more like your #2). What's needed here, as > you said, is for someone with a decent amount of expertise in > modern AIX to review all the issues. Maybe framing that as a > "new port" per #3 would be a good way to think about it. But > I don't want to just revert the AIX-ectomy and continue drifting. > > On the whole, it wouldn't be the worst thing in the world if PG 17 > lacks AIX support but that comes back in PG 18. That approach would > solve the schedule-crunch aspect and give time for considered review > of how many of the hacks removed in 0b16bb877 really need to be put > back, versus being obsolete or amenable to a nicer solution in > late-model AIX. If we take a "new port" mindset then it would be > totally reasonable to say that it only supports very recent AIX > releases, so I'd hope at least some of the cruft could be removed. I agree that targeting PG 18 for a new-er AIX port is the reasonable approach. If there is huge demand, someone can create an AIX fork for PG 17 using the reverted patches --- yeah, lots of pain there, but we have carried the AIX pain for too long with too little support. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.
Re: AIX support
On Wed, Apr 24, 2024 at 11:39:37PM -0400, Bruce Momjian wrote: > On Sat, Apr 20, 2024 at 12:25:47PM -0400, Tom Lane wrote: >> So I'm totally not in favor of #1, at least not without some hard >> commitments and follow-through on really cleaning up the mess >> (which maybe looks more like your #2). What's needed here, as >> you said, is for someone with a decent amount of expertise in >> modern AIX to review all the issues. Maybe framing that as a >> "new port" per #3 would be a good way to think about it. But >> I don't want to just revert the AIX-ectomy and continue drifting. >> >> On the whole, it wouldn't be the worst thing in the world if PG 17 >> lacks AIX support but that comes back in PG 18. That approach would >> solve the schedule-crunch aspect and give time for considered review >> of how many of the hacks removed in 0b16bb877 really need to be put >> back, versus being obsolete or amenable to a nicer solution in >> late-model AIX. If we take a "new port" mindset then it would be >> totally reasonable to say that it only supports very recent AIX >> releases, so I'd hope at least some of the cruft could be removed. > > I agree that targeting PG 18 for a new-er AIX port is the reasonable > approach. If there is huge demand, someone can create an AIX fork for > PG 17 using the reverted patches --- yeah, lots of pain there, but we > have carried the AIX pain for too long with too little support. Some of the portability changes removed in 0b16bb877 feel indeed obsolete, so it may not hurt to start an analysis from scratch to see the minimum amount of work that would be really required with the latest versions of xlc, using the newest compilers as a supported base. I'd like to think backporting these to stable branches should be OK at some point, once the new port is proving baked enough. Anyway, getting an access to such compilers to be able to debug issues on hosts that take less than 12h to just compile the code would certainly help its adoption. So seeing commitment in the form of patches and access to environments would help a lot. Overall, studying that afresh with v18 looks like a good idea, assuming that anybody who commits such patches has access to hosts to evaluate them, with buildfarm members running on top, of course. My 2c. -- Michael
Re: AIX support
Michael Paquier writes: > Some of the portability changes removed in 0b16bb877 feel indeed > obsolete, so it may not hurt to start an analysis from scratch to see > the minimum amount of work that would be really required with the > latest versions of xlc, using the newest compilers as a supported > base. Something I've been mulling over is whether to suggest that the proposed "new port" should only target building with gcc. On the one hand, that would (I think) remove a number of annoying issues, and the average end user is unlikely to care which compiler their database server was built with. On the other hand, I'm a strong proponent of avoiding software monocultures, and xlc is one of the few C compilers still standing that aren't gcc or clang. It would definitely make sense for a new port to start by getting things going with gcc only, and then look at resurrecting xlc support. > I'd like to think backporting these to stable branches should > be OK at some point, once the new port is proving baked enough. If things go as I expect, the "new port" would effectively drop support for older AIX and/or older compiler versions. So back- porting seems like an unlikely decision. > Anyway, getting an access to such compilers to be able to debug issues > on hosts that take less than 12h to just compile the code would > certainly help its adoption. +many regards, tom lane
Re: AIX support
On Thu, Apr 25, 2024 at 12:20:05AM -0400, Tom Lane wrote: > It would definitely make sense for a new port to start by getting > things going with gcc only, and then look at resurrecting xlc > support. Sriram mentioned upthread that he was looking at both of them. I'd be ready to assume that most of the interest is in xlc, not gcc. But I may be wrong. Saying that, dividing the effort into more successive steps is sensible here (didn't consider that previously, you have a good point). -- Michael
Re: AIX support
On 25.04.24 06:20, Tom Lane wrote: > Something I've been mulling over is whether to suggest that the > proposed "new port" should only target building with gcc. > > On the one hand, that would (I think) remove a number of annoying > issues, and the average end user is unlikely to care which compiler > their database server was built with. On the other hand, I'm a strong > proponent of avoiding software monocultures, and xlc is one of the few > C compilers still standing that aren't gcc or clang. My understanding is that the old xlc is dead and has been replaced by "xlclang", which is presumably an xlc-compatible frontend on top of clang/llvm. Hopefully, that will have fewer issues.
Re: AIX support
On 2024-Apr-24, Bruce Momjian wrote:
> I agree that targeting PG 18 for a new-er AIX port is the reasonable
> approach. If there is huge demand, someone can create an AIX fork for
> PG 17 using the reverted patches --- yeah, lots of pain there, but we
> have carried the AIX pain for too long with too little support.
I'm not sure how large the demand would be for an AIX port specifically
of 17, though. I mean, people using older versions can continue to use
16 until 18 is released. Upgrading past one major version is hardly
unheard of.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"If you want to have good ideas, you must have many ideas. Most of them
will be wrong, and what you have to learn is which ones to throw away."
(Linus Pauling)
Re: AIX support
Peter Eisentraut writes: > On 25.04.24 06:20, Tom Lane wrote: >> Something I've been mulling over is whether to suggest that the >> proposed "new port" should only target building with gcc. > My understanding is that the old xlc is dead and has been replaced by > "xlclang", which is presumably an xlc-compatible frontend on top of > clang/llvm. Hopefully, that will have fewer issues. [ googles... ] Actually it seems to be the other way around: per [1] xlclang is a clang-based front end to IBM's existing codegen+optimization logic, and the xlc front end is still there too. It's not at all clear that they have any intention of killing off xlc. Not sure where that leaves us in terms of either one being an interesting target to support. xlclang is presumably an easier lift to get working, but that also makes it much less interesting from the preserve-our-portability standpoint. regards, tom lane [1] https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=new-clang-based-front-end
Re: AIX support
Hi, On 2024-04-25 00:20:05 -0400, Tom Lane wrote: > Something I've been mulling over is whether to suggest that the > proposed "new port" should only target building with gcc. Yes. I also wonder if such a port should only support building with sysv style shared library support, rather than the AIX (and windows) style. That'd make it considerably less impactful on the buildsystem level. I don't know what the performance difference is these days. Greetings, Andres Freund
Re: AIX support
On Thu, Apr 25, 2024 at 10:16:34AM +0200, Álvaro Herrera wrote: > On 2024-Apr-24, Bruce Momjian wrote: > > > I agree that targeting PG 18 for a new-er AIX port is the reasonable > > approach. If there is huge demand, someone can create an AIX fork for > > PG 17 using the reverted patches --- yeah, lots of pain there, but we > > have carried the AIX pain for too long with too little support. > > I'm not sure how large the demand would be for an AIX port specifically > of 17, though. I mean, people using older versions can continue to use > 16 until 18 is released. Upgrading past one major version is hardly > unheard of. Agreed. They seem to have packages for 11/12, and only 15 recently. I don't see how PG 17 would be missed, unless there are many people compiling from source. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.
Re: AIX support
On Thu, Apr 25, 2024 at 01:06:24PM +0900, Michael Paquier wrote: > Anyway, getting an access to such compilers to be able to debug issues > on hosts that take less than 12h to just compile the code would > certainly help its adoption. So seeing commitment in the form of > patches and access to environments would help a lot. Overall, > studying that afresh with v18 looks like a good idea, assuming that > anybody who commits such patches has access to hosts to evaluate them, > with buildfarm members running on top, of course. Agreed. They can't even have buildfarm member for PG 17 since it doesn't compile anymore, so someone has to go over the reverted patch, figure out which ones are still valid, and report back. Trying to add a port, with possible breakage, during beta seems too risky compared to the value. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.
Re: AIX support
> > It would definitely make sense for a new port to start by getting
> > things going with gcc only, and then look at resurrecting xlc
> > support.
> Sriram mentioned upthread that he was looking at both of them. I'd be
> ready to assume that most of the interest is in xlc, not gcc. But I
> may be wrong.
Just a heads-up, we got a node in the OSU lab for the buildfarm. Will let you know once we have the buildfarm setup on that node.
Also, we are making progress on setting up the buildfarm on a local node as well.
But currently there are some tests failing, seems some issue with plperl.
aix01::build-farm-17#
./run_build.pl --keepall --nosend --nostatus --verbose=5 --force REL_16_STABLE
Fri Apr 26 00:53:50 2024: buildfarm run for AIXnode01:REL_16_STABLE starting
AIXnode01:REL_16_STABLE [00:53:50] checking out source ...
AIXnode01:REL_16_STABLE [00:53:56] checking if build run needed ...
AIXnode01:REL_16_STABLE [00:53:56] copying source to pgsql.build ...
AIXnode01:REL_16_STABLE [00:54:08] running configure ...
AIXnode01:REL_16_STABLE [00:55:01] running build ...
AIXnode01:REL_16_STABLE [01:08:09] running basic regression tests ...
AIXnode01:REL_16_STABLE [01:09:51] running make contrib ...
AIXnode01:REL_16_STABLE [01:11:08] running make testmodules ...
AIXnode01:REL_16_STABLE [01:11:19] running install ...
AIXnode01:REL_16_STABLE [01:11:48] running make contrib install ...
AIXnode01:REL_16_STABLE [01:12:01] running testmodules install ...
AIXnode01:REL_16_STABLE [01:12:06] checking test-decoding
gmake: gcc: A file or directory in the path name does not exist.
AIXnode01:REL_16_STABLE [01:12:28] running make check miscellaneous modules ...
gmake: gcc: A file or directory in the path name does not exist.
AIXnode01:REL_16_STABLE [01:13:50] setting up db cluster (C)...
AIXnode01:REL_16_STABLE [01:13:53] starting db (C)...
AIXnode01:REL_16_STABLE [01:13:53] running installcheck (C)...
AIXnode01:REL_16_STABLE [01:15:05] restarting db (C)...
AIXnode01:REL_16_STABLE [01:15:07] running make isolation check ...
AIXnode01:REL_16_STABLE [01:15:51] restarting db (C)...
AIXnode01:REL_16_STABLE [01:15:56] running make PL installcheck (C)...
Branch: REL_16_STABLE
Stage PLCheck-C failed with status 2
Re: AIX support
Hi Team,
There are couple of updates, firstly we got an AIX node on the OSU lab.
Please feel free to reach me, so that we can provide access to the node.
We have started working on setting up the buildfarm on that node.
Secondly, as part of the buildfarm setup on our local nodes, we are hitting
an issue with the plperl extension. In the logs we noticed that when the
plperl extension is being created, it is failing to load the perl library.
- CREATE EXTENSION plperlu;
+ server closed the connection unexpectedly
+ This probably means the server terminated abnormally
+ before or while processing the request.
+ connection to server was lost
In the logfile we could see these
2024-05-04 05:05:17.537 CDT [3997786:17] pg_regress/plperl_setup LOG: statement: CREATE EXTENSION plperl;
Util.c: loadable library and perl binaries are mismatched (got first handshake key 9b80080, needed 9a80080)
We tried to resolve some of the suggestions mentioned here, but things couldn’t resolve.
Any inputs here would be greatly appreciated.
Regards,
Sriram.
Re: AIX support
Hi Team, on further investigation we were able to resolve the perl issue by setting the right PERL env location. Earlier it was pointing to the 32bit perl, as a result the perl lib mismatch seems to be happening.
Now we have successfully built release 15 and 16 stable branches on the OSU lab node.
p9aix (OSU)
OS: AIX 72Z
RELEASE 16
p9aix:REL_16_STABLE [08:31:26] OK
======== log passed to send_result ===========
Branch: REL_16_STABLE
All stages succeeded
RELEASE 15
p9aix:REL_15_STABLE [08:55:37] OK
======== log passed to send_result ===========
Branch: REL_15_STABLE
All stages succeeded
Also, we had successfully built release 16 branch on our local nodes as well
OS: AIX 71C
pgsql-aix71C:REL_16_STABLE [02:25:32] OK
======== log passed to send_result ===========
Branch: REL_16_STABLE
All stages succeeded
OS: AIX72Z
pgsql-aix72Z:REL_16_STABLE [02:35:03] OK
======== log passed to send_result ===========
Branch: REL_16_STABLE
All stages succeeded
OS: AIX73D
pgsql-aix73D:REL_16_STABLE [05:32:29] OK
======== log passed to send_result ===========
Branch: REL_16_STABLE
All stages succeeded
Regards,
Sriram.
Re: AIX support
Hi Team, We have the AIX node ready in OSU lab, and the branches 15 and 16 got build on the node. We had raised a request to register this node as buildfarm member. Yet to receive the approval.
We would like to understand your inputs/plans on reverting the changes for AIX.
Thanks,
Sriram.
Re: AIX support
On 08.05.24 13:39, Sriram RK wrote: > We would like to understand your inputs/plans on reverting the changes > for AIX. I think the ship has sailed for PG17. The way forward would be that you submit a patch for new, modernized AIX support for PG18.
Re: AIX support
On Wed, May 8, 2024 at 03:44:12PM +0200, Peter Eisentraut wrote: > On 08.05.24 13:39, Sriram RK wrote: > > We would like to understand your inputs/plans on reverting the changes > > for AIX. > > I think the ship has sailed for PG17. The way forward would be that you > submit a patch for new, modernized AIX support for PG18. Yes, I think we were clear that someone needs to review the reverted patch and figure out which parts are still needed, and why. We have no "plans" to restore support. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.
Re: AIX support
Hi Team, we have any updated from the XLC team, the issue specific to the alignment is fixed
and XLC had released it as part of 16.1.0.18. The PTF is available at the below location,
You can also find a link here:
https://www.ibm.com/support/pages/fix-list-xl-cc-aix.
>>/opt/IBM/xlC/16.1.0/bin/xlC align.c -o align.xl
>>./align.xl
al4096 4096 @ 0x20008000 (mod 0)
al4096_initialized 4096 @ 0x20004000 (mod 0)
al4096_const 4096 @ 0x2000b000 (mod 0)
al4096_const_initialized 4096 @ 0x10008000 (mod 0)
al4096_static 4096 @ 0x2000e000 (mod 0)
al4096_static_initialized 4096 @ 0x20001000 (mod 0)
al4096_static_const 4096 @ 0x20011000 (mod 0)
al4096_static_const_initialized 4096 @ 0x10001000 (mod 0)
Also would like to know some info related to the request raised for buildfarm access, to register the node in OSU lab. Where can I get the status of the request? Whom can I contact to get the request approved? So that we can add the node to the buildfarm.
Regards,
Sriram.
Re: AIX support
On Wed, May 15, 2024 at 03:33:25PM +0000, Sriram RK wrote: > Hi Team, we have any updated from the XLC team, the issue specific to the alignment is fixed > and XLC had released it as part of 16.1.0.18. The PTF is available at the below location, > > You can also find a link here: > https://www.ibm.com/support/pages/fix-list-xl-cc-aix. > > >>/opt/IBM/xlC/16.1.0/bin/xlC align.c -o align.xl > > >>./align.xl > al4096 4096 @ 0x20008000 (mod 0) > al4096_initialized 4096 @ 0x20004000 (mod 0) > al4096_const 4096 @ 0x2000b000 (mod 0) > al4096_const_initialized 4096 @ 0x10008000 (mod 0) > al4096_static 4096 @ 0x2000e000 (mod 0) > al4096_static_initialized 4096 @ 0x20001000 (mod 0) > al4096_static_const 4096 @ 0x20011000 (mod 0) > al4096_static_const_initialized 4096 @ 0x10001000 (mod 0) That is good news. PGIOAlignedBlock is now in the IBM publication, https://www.ibm.com/support/pages/apar/IJ51032 > Also would like to know some info related to the request raised for buildfarm access, to register the node in OSU lab. Where can I get the status of the request? Whom can I contact to get the request approved? So that we can add the node to the buildfarm. I assume you filled out the form at https://buildfarm.postgresql.org/cgi-bin/register-form.pl? It can take a few weeks, so I wouldn't worry yet.
Re: AIX support
> > Also would like to know some info related to the request raised for buildfarm access, to register the
> > node in OSU lab. Where can I get the status of the request? Whom can I contact to get the request
> > approved? So that we can add the node to the buildfarm.
> I assume you filled out the form at
> https://buildfarm.postgresql.org/cgi-bin/register-form.pl? It can take a few
> weeks, so I wouldn't worry yet.
Thanks Noha, I had already submitted a form a week back, hope it might take another couple of weeks to get it approved.
Re: AIX support
Hi Team,
We have an update wrt to the PG17 AIX port.
We have reverted the changes specific to AIX (that were removed in 0b16bb8776bb8) to the latest PG17 (head).
The Buildfarm succeeded for these changes. All the tests passed.
System config
OS level : AIX-73D
Compiler : gcc-12 & xlc(16.1.0.18)
Wed May 15 21:26:00 2024: buildfarm run for AIXnode01:HEAD starting
AIXnode01:HEAD [21:26:00] running configure ...
AIXnode01:HEAD [21:27:03] running build ...
AIXnode01:HEAD [21:27:27] running basic regression tests ...
AIXnode01:HEAD [21:34:41] running make contrib ...
AIXnode01:HEAD [21:34:43] running make testmodules ...
AIXnode01:HEAD [21:34:44] running install ...
AIXnode01:HEAD [21:34:58] running make contrib install ...
AIXnode01:HEAD [21:35:05] running testmodules install ...
AIXnode01:HEAD [21:35:08] checking pg_upgrade
AIXnode01:HEAD [21:35:08] checking test-decoding
AIXnode01:HEAD [21:35:29] running make check miscellaneous modules ...
AIXnode01:HEAD [21:36:16] setting up db cluster (C)...
AIXnode01:HEAD [21:36:19] starting db (C)...
AIXnode01:HEAD [21:36:19] running installcheck (C)...
AIXnode01:HEAD [21:46:27] restarting db (C)...
AIXnode01:HEAD [21:46:29] running make isolation check ...
AIXnode01:HEAD [21:49:57] restarting db (C)...
AIXnode01:HEAD [21:50:02] running make PL installcheck (C)...
AIXnode01:HEAD [21:50:09] restarting db (C)...
AIXnode01:HEAD [21:50:12] running make contrib installcheck (C)...
AIXnode01:HEAD [21:53:53] restarting db (C)...
AIXnode01:HEAD [21:53:56] running make test-modules installcheck (C)...
AIXnode01:HEAD [21:54:28] stopping db (C)...
AIXnode01:HEAD [21:54:29] running make ecpg check ...
AIXnode01:HEAD [21:54:45] OK
Branch: HEAD
All stages succeeded
The below changes are applied on this commit level
commit 54b69f1bd730a228a666441592a12d2a0cbe2a06 (HEAD -> pgAIX, origin/master, origin/HEAD, master)
On branch pgAIX
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/backend/port/aix/mkldexport.sh
new file: src/include/port/aix.h
new file: src/makefiles/Makefile.aix
new file: src/template/aix
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Makefile
modified: config/c-compiler.m4
modified: configure
modified: configure.ac
modified: doc/src/sgml/dfunc.sgml
modified: doc/src/sgml/installation.sgml
modified: doc/src/sgml/runtime.sgml
modified: meson.build
modified: src/Makefile.shlib
modified: src/backend/Makefile
modified: src/backend/meson.build
modified: src/backend/storage/buffer/bufmgr.c
modified: src/backend/utils/error/elog.c
modified: src/backend/utils/misc/ps_status.c
modified: src/bin/pg_basebackup/t/010_pg_basebackup.pl
modified: src/bin/pg_verifybackup/t/008_untar.pl
modified: src/bin/pg_verifybackup/t/010_client_untar.pl
modified: src/include/c.h
modified: src/include/port/atomics.h
modified: src/include/storage/s_lock.h
modified: src/interfaces/libpq/Makefile
modified: src/interfaces/libpq/meson.build
modified: src/port/README
modified: src/port/strerror.c
modified: src/test/regress/Makefile
modified: src/test/regress/expected/sanity_check.out
modified: src/test/regress/expected/test_setup.out
modified: src/test/regress/regress.c
modified: src/test/regress/sql/sanity_check.sql
modified: src/test/regress/sql/test_setup.sql
modified: src/tools/gen_export.pl
modified: src/tools/pginclude/headerscheck
Can you please let us know, the process to post the changes for review?
Regards,
Sriram.
Re: AIX support
On 2024-May-16, Sriram RK wrote: > Hi Team, > > We have an update wrt to the PG17 AIX port. > > We have reverted the changes specific to AIX (that were removed in 0b16bb8776bb8) to the latest PG17 (head). > > The Buildfarm succeeded for these changes. All the tests passed. Excellent. > Can you please let us know, the process to post the changes for review? Here's some very good advice https://postgr.es/m/20240405172649.d1@rfd.leadboat.com Regards -- Álvaro Herrera
Re: AIX support
Thanks Alvaro, for the info…
Hi Team,
We referred to the below links to build this patch …
https://wiki.postgresql.org/wiki/Submitting_a_Patch
https://peter.eisentraut.org/blog/2023/05/09/how-to-submit-a-patch-by-email-2023-edition
Please find the attached patch.
Apart from the AIX specific changes, there is a minor change in this file wrt to XLC, below is the error for which we removed inline.
Later, the build and tests passed for both XLC(16.1.0.18) and gcc(12) as well.
src/backend/storage/buffer/bufmgr.c
"bufmgr.c", line 811.39: 1506-780 (S) Reference to "RelationGetSmgr" with internal linkage is not allowed within inline definition of "ReadBufferExtended".
"bufmgr.c", line 811.15: 1506-780 (S) Reference to "ReadBuffer_common" with internal linkage is not allowed within inline definition of "ReadBufferExtended".
gmake[4]: *** [<builtin>: bufmgr.o] Error 1
Please let us know your feedback.
Thanks,
Sriram.
Re: AIX support
On 22.05.24 18:15, Sriram RK wrote: > Please find the attached patch. > > Apart from the AIX specific changes, there is a minor change in this > file wrt to XLC, below is the error for which we removed inline. > > Later, the build and tests passed for both XLC(16.1.0.18) and gcc(12) as > well. I think what you should do next is aggressively trim anything that does not apply to current versions of AIX or the current compiler. For example, + # Old xlc versions (<13.1) don't have support for -qvisibility. Use expfull to force + + AIX versions before 7.1 are no longer + tested nor supported by the PostgreSQL + community. + (Probably most of that section needs to be retested and rewritten.) + # 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 + # for the base executable (AIX 4.2 and up) + * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline One of the reasons that the AIX port ultimately became unmaintainable was that so many hacks and caveats were accumulated over the years. A new port should set a more recent baseline and trim all those hacks.
RE: AIX support
Hi Peter, thanks for your feedback.
We are eager to extend our support in resolving the issues specific to AIX or corresponding
compilers (XLC and cLang).
But as there are no issues with the patch after reverting the changes(with the latest compilers
gcc12 and xlc-16.0.1.18), we were wondering if this patch can be merged with the current release 17??
Having said that, we are committed to resolve all the hacks and caveats that got
accumulated specific to AIX over the period by picking and resolving one after the other,
rather than waiting for all the hacks to be fixed.
> One of the reasons that the AIX port ultimately became unmaintainable
> was that so many hacks and caveats were accumulated over the years. A
> new port should set a more recent baseline and trim all those hacks.
Please help me understand this, with respect to the AIX specific hacks, is it just we can find
all the location where _AIX macros are involved OR can we just look at the patch changes only, as all
the changes that were made were specific to AIX. If not, is there any other location where
we could find all the hacks to be resolved.
Can you provide some more details on the expectations here?
Warm regards,
Sriram.
Re: AIX support
On 23/05/2024 18:36, Srirama Kucherlapati wrote: > Hi Peter, thanks for your feedback. > > We are eager to extend our support in resolving the issues specific > to AIX or corresponding compilers (XLC and cLang). > > But as there are no issues with the patch after reverting the > changes(with the latest compilers gcc12 and xlc-16.0.1.18), we were > wondering if this patch can be merged with the current release 17?? > > Having said that, we are committed to resolve all the hacks and > caveats that got accumulated specific to AIX over the period by > picking and resolving one after the other, rather than waiting for > all the hacks to be fixed. I'm not eager to put back those hacks just to have them be removed again. So I'd like to see a minimal patch, with the *minimal* changes required for AIX support. And perhaps split that into two patches: First add back AIX support with GCC, and second patch to add XLC support. I'd like to to see how much of the changes are because of the different compiler and how much from the OS. No promises for v17, but if the patch is small and non-intrusive, I would consider it at least. But let's see what it looks like first. It's the same work that needs to be done whether it goes into v17 or v18 anyway. >> One of the reasons that the AIX port ultimately became >> unmaintainable was that so many hacks and caveats were accumulated >> over the years. A new port should set a more recent baseline and >> trim all those hacks. > > Please help me understand this, with respect to the AIX specific > hacks, is it just we can find all the location where _AIX macros are > involved OR can we just look at the patch changes only, as all the > changes that were made were specific to AIX. If not, is there any > other location where we could find all the hacks to be resolved. > > Can you provide some more details on the expectations here? Smallest possible patch that makes Postgres work on AIX again. Perhaps start with the patch you posted yesterday, but remove hunks from it one by one, to see which ones are still needed. -- Heikki Linnakangas Neon (https://neon.tech)
Re: AIX support
On Thu, May 23, 2024 at 07:03:20PM +0300, Heikki Linnakangas wrote: > > Can you provide some more details on the expectations here? > > Smallest possible patch that makes Postgres work on AIX again. > > Perhaps start with the patch you posted yesterday, but remove hunks from it > one by one, to see which ones are still needed. Yes, bingo, that is exactly what needs to be done, and for the minimal compiler, gcc, and the most recently supported versions of AIX. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.
RE: AIX support
Hi Team, We are pursuing to trim the changes wrt AIX. As of now we trimmed
the changes with respect to XLC and currently with trimmed changes the
buildfarm script passed (build and all the regression tests)
The XLC changes were trimmed only in the below file
modified: configure
modified: configure.ac
We are looking further into the other file changes as well.
Warm regards,
Sriram.
Re: AIX support
On Fri, 2024-06-07 at 16:30 +0000, Srirama Kucherlapati wrote: > Hi Team, We are pursuing to trim the changes wrt AIX. As of now we trimmed > the changes with respect to XLC and currently with trimmed changes the > buildfarm script passed (build and all the regression tests) > The XLC changes were trimmed only in the below file > modified: configure > modified: configure.ac Did you forget an attachment? Yours, Laurenz Albe
RE: AIX support
Hi Laurenz, we are working on the other file changes, we shall post you the updates soon.
Warm regards,
Sriram.
RE: AIX support
Hi Team,
Please find the attached patch, which resumes the AIX support with gcc alone. We have
removed changes wrt to XLC on AIX.
We are also continuing to work on the XLC and IBM-clang(openXLC) specific patch as well.
Once we get an approval for the above patch we can submit a subsequent patch to support
XLC/IBM-clang changes.
Kindly let us know your inputs/feedback.
Warm regards,
Sriram.
Re: AIX support
On 19/06/2024 17:55, Srirama Kucherlapati wrote: > +/* Commenting for XLC > + * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline > + * expansions of ginCompareItemPointers() "long long" arithmetic. To take > + * advantage of inlining, build a 64-bit PostgreSQL. > +#if defined(__ILP32__) && defined(__IBMC__) > +#define PG_FORCE_DISABLE_INLINE > +#endif > + */ This seems irrelevant. > + * Ordinarily, we'd code the branches here using GNU-style local symbols, that > + * is "1f" referencing "1:" and so on. But some people run gcc on AIX with > + * IBM's assembler as backend, and IBM's assembler doesn't do local symbols. > + * So hand-code the branch offsets; fortunately, all PPC instructions are > + * exactly 4 bytes each, so it's not too hard to count. Could you use GCC assembler to avoid this? > @@ -662,6 +666,21 @@ tas(volatile slock_t *lock) > > #if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */ > > +#if defined(_AIX) /* AIX */ > +/* > + * AIX (POWER) > + */ > +#define HAS_TEST_AND_SET > + > +#include > + > +typedef int slock_t; > + > +#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1) > +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0) > +#endif /* _AIX */ > + > + > /* These are in sunstudio_(sparc|x86).s */ > > #if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc)) What CPI/compiler/OS configuration is this for, exactly? Could we rely on GCC-provided __sync_lock_test_and_set() builtin function instead? > +# Allow platforms with buggy compilers to force restrict to not be > +# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant > +# template. Surely we don't need that anymore? Or is the compiler still buggy? Do you still care about 32-bit binaries on AIX? If not, let's make that the default in configure or a check for it, and remove the instructions on building 32-bit binaries from the docs. Please try hard to remove any changes from the diff that are not absolutely necessary. - Heikki
RE: AIX support
Thanks Hikki, for going through the changes.
> +/* Commenting for XLC
> + * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
> + * expansions of ginCompareItemPointers() "long long" arithmetic. To take
> + * advantage of inlining, build a 64-bit PostgreSQL.
> +#if defined(__ILP32__) && defined(__IBMC__)
> +#define PG_FORCE_DISABLE_INLINE
> +#endif
> + */
I can remove these unwanted comments.
I have to analyze the changes for the rest of your comment and will get back to you.
Warm regards,
Sriram.
From: Heikki Linnakangas <hlinnaka@gmail.com>
Date: Wednesday, 19 June 2024 at 8:45 PM
To: Srirama Kucherlapati <sriram.rk@in.ibm.com>, Laurenz Albe <laurenz.albe@cybertec.at>, Bruce Momjian <bruce@momjian.us>, Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Peter Eisentraut <peter@eisentraut.org>, Alvaro Herrera <alvherre@alvh.no-ip.org>, pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>, Noah Misch <noah@leadboat.com>, Michael Paquier <michael@paquier.xyz>, Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, Thomas Munro <thomas.munro@gmail.com>, tvk1271@gmail.com <tvk1271@gmail.com>, postgres-ibm-aix@wwpdl.vnet.ibm.com <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: [EXTERNAL] Re: AIX support
On 19/06/2024 17:55, Srirama Kucherlapati wrote:
> +/* Commenting for XLC
> + * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
> + * expansions of ginCompareItemPointers() "long long" arithmetic. To take
> + * advantage of inlining, build a 64-bit PostgreSQL.
> +#if defined(__ILP32__) && defined(__IBMC__)
> +#define PG_FORCE_DISABLE_INLINE
> +#endif
> + */
This seems irrelevant.
> + * Ordinarily, we'd code the branches here using GNU-style local symbols, that
> + * is "1f" referencing "1:" and so on. But some people run gcc on AIX with
> + * IBM's assembler as backend, and IBM's assembler doesn't do local symbols.
> + * So hand-code the branch offsets; fortunately, all PPC instructions are
> + * exactly 4 bytes each, so it's not too hard to count.
Could you use GCC assembler to avoid this?
> @@ -662,6 +666,21 @@ tas(volatile slock_t *lock)
>
> #if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
>
> +#if defined(_AIX) /* AIX */
> +/*
> + * AIX (POWER)
> + */
> +#define HAS_TEST_AND_SET
> +
> +#include <sys/atomic_op.h>
> +
> +typedef int slock_t;
> +
> +#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
> +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
> +#endif /* _AIX */
> +
> +
> /* These are in sunstudio_(sparc|x86).s */
>
> #if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
What CPI/compiler/OS configuration is this for, exactly? Could we rely
on GCC-provided __sync_lock_test_and_set() builtin function instead?
> +# Allow platforms with buggy compilers to force restrict to not be
> +# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
> +# template.
Surely we don't need that anymore? Or is the compiler still buggy?
Do you still care about 32-bit binaries on AIX? If not, let's make that
the default in configure or a check for it, and remove the instructions
on building 32-bit binaries from the docs.
Please try hard to remove any changes from the diff that are not
absolutely necessary.
- Heikki
RE: AIX support
We are continuing to work on the changes…
> Do you still care about 32-bit binaries on AIX? If not, let's make that
> the default in configure or a check for it, and remove the instructions
> on building 32-bit binaries from the docs.
As most of the products are moving towards 64bit, we will try to remove
this 32bit support.
Warm regards,
Sriram.
RE: AIX support
Hi Heikki & Team,
I tried to look at the assembly code changes with our team, in the below file.
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 29ac6cdcd9..69582f4ae7 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
static __inline__ int
tas(volatile slock_t *lock)
@@ -424,17 +430,15 @@ tas(volatile slock_t *lock)
__asm__ __volatile__(
" lwarx %0,0,%3,1 \n"
" cmpwi %0,0 \n"
" bne $+16 \n" /* branch to li %1,1 */
" addi %0,%0,1 \n"
" stwcx. %0,0,%3 \n"
" beq $+12 \n" /* branch to lwsync */
" li %1,1 \n"
" b $+12 \n" /* branch to end of asm sequence */
" lwsync \n"
" li %1,0 \n"
: "=&b"(_t), "=r"(_res), "+m"(*lock)
: "r"(lock)
: "memory", "cc");
For the changes in the above file, this code is very specific to power architecture we need to use the IBM Power specific asm code only, rather than using the GNU assembler. Also, all these asm specific code is under the macro __ppc__, which should not impact any other platforms. I see there is a GCC specific implementation (under this macro #if defined(HAVE_GCC__SYNC_INT32_TAS)) in the same file as well.
+#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
+#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
The above changes are specific to AIX kernel and it operates on fixed kernel memory. This is more like a compare_and_swap functionality with sync capability. For all the assemble code I think it would be better to use the IBM Power specific asm code to gain additional performance.
I was trying to understand here wrt to both the assemble changes if you are looking for anything specific to the architecture.
Attached is the patch for the previous comments, kindly please let me know your comments.
Warm regards,
Sriram.
Re: AIX support
On 14/08/2024 06:31, Srirama Kucherlapati wrote: > Hi Heikki & Team, > > I tried to look at the assembly code changes with our team, in the below > file. > > diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h > index 29ac6cdcd9..69582f4ae7 100644 > --- a/src/include/storage/s_lock.h > +++ b/src/include/storage/s_lock.h > static __inline__ int > tas(volatile slock_t *lock) > @@ -424,17 +430,15 @@ tas(volatile slock_t *lock) > __asm__ __volatile__( > " lwarx %0,0,%3,1 \n" > " cmpwi %0,0 \n" > " bne $+16 \n" /* branch to li > %1,1 */ > " addi %0,%0,1 \n" > " stwcx. %0,0,%3 \n" > " beq $+12 \n" /* branch to > lwsync */ > " li %1,1 \n" > " b $+12 \n" /* branch to end > of asm sequence */ > " lwsync \n" > " li %1,0 \n" > : "=&b"(_t), "=r"(_res), "+m"(*lock) > : "r"(lock) > : "memory", "cc"); > > For the changes in the above file, this code is very specific to power > architecture we need to use the IBM Power specific asm code only, rather > than using the GNU assembler. Also, all these asm specific code is under > the macro __ppc__, which should not impact any other platforms. I see > there is a GCC specific implementation (under this macro #if > defined(HAVE_GCC__SYNC_INT32_TAS)) in the same file as well. I'm sorry, I don't understand what you're saying here. Do you mean that we don't need to do anything here, and the code we have in s_lock.h in 'master' now will work fine on AIX? Or do we need to (re-)do some changes to support AIX again? If we only support GCC, can we use the __sync_lock_test_and_set() builtin instead? If any changes are required, please include them in the patch. That'll make it clear what exactly you're proposing. > +#define TAS(lock) _check_lock((slock_t *) (lock), > 0, 1) > > +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0) > > The above changes are specific to AIX kernel and it operates on fixed > kernel memory. This is more like a compare_and_swap functionality with > sync capability. For all the assemble code I think it would be better to > use the IBM Power specific asm code to gain additional performance. You mean we don't need the above? Ok, good. > I was trying to understand here wrt to both the assemble changes if you > are looking for anything specific to the architecture. I don't know. You tell me what makes most sense on AIX / powerpc. > Attached is the patch for the previous comments, kindly please let me > know your comments. Is this all that's needed to resurrect AIX support? -- Heikki Linnakangas Neon (https://neon.tech)
Re: AIX support
On 14/08/2024 18:22, Srirama Kucherlapati wrote: > Hi Heikki, > > I have attached the merged patch with all the changes, the earlier patch was > > just only the changes specific to older review comments. > > > I'm sorry, I don't understand what you're saying here. Do you > mean that > > we don't need to do anything here, and the code we have in > s_lock.h in > > 'master' now will work fine on AIX? Or do we need to (re-)do some > > changes to support AIX again? If we only support GCC, can we use the > > __sync_lock_test_and_set() builtin instead? > > Here we need these changes for ppc. These changes are not for > enabling the AIX support, but this is implementing “Enhanced PowerPC > Architecture”. This routine is more of compare_and_increment, which > is different from GCC __sync_lock_test_and_set(). Also I tried to > write a sample function to check the assemble generated by > __sync_lock_test_and_set(), which turned out to be different set of > assemble code. I still don't understand. We have Linux powerpc systems running happily in the buildfarm. They are happy with the current spinlock implementation. Why is this needed? What happens without it? How is this different from __sync_lock_test_and_set()? Is the __sync_lock_test_and_set() on that platform broken, less efficient, or just different but equally good? > > > +#define TAS(lock) _check_lock((slock_t *) > (lock), > > > 0, 1) > > > > >> +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0) > >> > > > The above changes are specific to AIX kernel and it operates on > fixed > > > kernel memory. This is more like a compare_and_swap > functionality with > > > sync capability. For all the assemble code I think it would be > better to > > > use the IBM Power specific asm code to gain additional performance. > > > You mean we don't need the above? Ok, good. > > I mean this part of the code is needed as this is specific to AIX > kernel memory operation which is different from > __sync_lock_test_and_set(). How is it different from __sync_lock_test_and_set()? Why is it needed? What is AIX kernel memory operation? > I would like to mention that the changes made in > src/include/storage/s_lock.h > > are pretty much required and need to be operated in assemble specific to IBM > Power architecture. Note that your patch both modifies the existing powerpc implementation, and introduces a new AIX-specific one. They cannot *both* be required, because only one of them will ever be compiled on a given platform. Which is it? Or are you trying to make this work on multiple different CPUs on AIX, so that different implementation gets chosen on different CPUs? Is the mkldexport stuff still needed on modern AIX? Or was it specific to XLC and never needed on GCC? How do other products do that? On a general note: it's your responsibility to explain all the changes in a way that others will understand and can verify. It is especially important for something critical and platform-specific like spinlocks, because others don't have easy access to the hardware to test these things independently. I also want to remind you that from the Postgres community point of view, you are introducing support for a new platform, AIX, not merely resurrecting the old stuff. Every change needs to be justified anew. -- Heikki Linnakangas Neon (https://neon.tech)
Re: AIX support
On 11/09/2024 15:38, Srirama Kucherlapati wrote: >> I still don't understand. We have Linux powerpc systems running >> happily in the buildfarm. They are happy with the current spinlock >> implementation. Why is this needed? What happens without it? > > Not sure, by the time the below commits were made if there was a > consideration to use the gcc routines. The PPC asm code was originally written in 2002, and the first use of __sync_lock_test_and_set(), for ARM, appeared in 2012. The commit that made __sync_lock_test_and_set() be chosen automatically for platforms that don't specify anything else was added in 2022. > I tried to replace the AIX asm (under__ppc__ macro) with the gcc > routine __sync_lock_test_and_set(), and all the buildfarm tests > passed. Attached patch and the buildfarm output. Please let me know > your feedback. Ok, if we don't need the assembler code at all, that's good. A patch to introduce AIX support should not change it for non-AIX powerpc systems though. That might be a good change, but would need to be justified separately, e.g. by some performance testing, and should be a separate patch. If you make no changes to s_lock.h at all, will it work? Why not? You said earlier: > I mean this part of the code is needed as this is specific to AIX kernel memory > operation which is different from __sync_lock_test_and_set(). > > I would like to mention that the changes made in src/include/storage/s_lock.h > are pretty much required and need to be operated in assemble specific to IBM > Power architecture. Was that earlier statement incorrect? Is the manual wrong or outdated or not applicable to us? Moving on.. Do you still need mkldexport.sh? Surely there's a better way to do that in year 2024. Some quick googling says there's a '-bexpall' option to 'ld', which kind of sounds like what we want. Will that work? How do other programs do this? -- Heikki Linnakangas Neon (https://neon.tech)
Re: AIX support
On Thu, Sep 12, 2024 at 9:57 AM Heikki Linnakangas wrote: > If you make no changes to s_lock.h at all, will it work? Why not? It's good to keep the work independent and I don't want to hold up anything happening in this thread, but just for information: I have been poking around at the idea of entirely removing the old spinlock code and pointing spin.h's function-like-macros to the atomics code. We couldn't do that before, because atomics were sometimes implemented with spinlocks, but now that pg_atomic_flag is never implemented with spinlocks we can flip that around, and then have only one place where we know how to do this stuff. What is needed for that to progress is, I guess, to determine though assembler analysis or experimentation across a bunch of targets that it works out at least as good... https://www.postgresql.org/message-id/flat/CA%2BhUKGJ%2BoA%2B62iUZ-EQb5R2cAOW3Y942ZoOtzOD%3D1sQ05iNg6Q%40mail.gmail.com#23598cafac3dd08ca94fa9e2228a4764
RE: AIX support
> The PPC asm code was originally written in 2002, and the first use of
> _ sync_lock_test_and_set(), for ARM, appeared in 2012. The commit that
> made __sync_lock_test_and_set() be chosen automatically for platforms
> that don't specify anything else was added in 2022.
Thanks for the info.
------------------
> Ok, if we don't need the assembler code at all, that's good. A patch to
> introduce AIX support should not change it for non-AIX powerpc systems
> though. That might be a good change, but would need to be justified
> separately, e.g. by some performance testing, and should be a separate
> patch.
> If you make no changes to s_lock.h at all, will it work? Why not?
With the existing asm code I see there are some syntax errors, being hit.
But after reverting the old changes the issues resolved. Below are diffs.
static __inline__ int
tas(volatile slock_t *lock)
{
@@ -424,17 +413,15 @@ tas(volatile slock_t *lock)
__asm__ __volatile__(
" lwarx %0,0,%3,1 \n"
" cmpwi %0,0 \n"
-" bne 1f \n"
+" bne $+16 \n" /* branch to li %1,1 */
" addi %0,%0,1 \n"
" stwcx. %0,0,%3 \n"
-" beq 2f \n"
-"1: \n"
+" beq $+12 \n" /* branch to lwsync */
" li %1,1 \n"
-" b 3f \n"
-"2: \n"
+" b $+12 \n" /* branch to end of asm sequence */
" lwsync \n"
" li %1,0 \n"
-"3: \n"
+
: "=&b"(_t), "=r"(_res), "+m"(*lock)
: "r"(lock)
: "memory", "cc");
Let me know if I need to run any perf tools to check the performance of
the __sync_lock_test_and_set change.
---------------
> > I mean this part of the code is needed as this is specific to AIX kernel memory
> > operation which is different from __sync_lock_test_and_set().
> >
> > I would like to mention that the changes made in src/include/storage/s_lock.h
> > are pretty much required and need to be operated in assemble specific to IBM
> > Power architecture.
> Was that earlier statement incorrect? Is the manual wrong or outdated or
> not applicable to us?
Here this change is specific to AIX, but since we are compiling with gcc, this
is not applicable. But I will try with __sync* routines and check.
---------------
> Do you still need mkldexport.sh? Surely there's a better way to do that
> in year 2024. Some quick googling says there's a '-bexpall' option to
> 'ld', which kind of sounds like what we want. Will that work? How do
> other programs do this?
Thanks for looking into this, I’m working on this, I will let you know.
Thanks,
Sriram.
RE: AIX support
> Do you still need mkldexport.sh? Surely there's a better way to do that
> in year 2024. Some quick googling says there's a '-bexpall' option to
> 'ld', which kind of sounds like what we want. Will that work? How do
> other programs do this?
We have noticed couple of caveats with these flags -bexpall/-bexpfull in other
opensource tools on AIX. This option would export too many symbols causing
problems because a shared library may re-export symbols from another library
causing confused dependencies, duplicate symbols.
We have similar discussion wrt to these flag in Cmake
https://gitlab.kitware.com/cmake/cmake/-/issues/19163
Also, I tried some sample program to verify the same as below
>> cat foo.c
#include <stdio.h>
#include <string.h>
int func1()
{
char str1[] = "Hello ", str2[] = "world! ";
strcat(str1,str2);
puts(str1);
return 0;
}
>> gcc -c foo.c -o foo.o
>> gcc -shared -Wl,-bexpall -o foo.so foo.o
>> dump -Tov foo.so
foo.so:
***Object Module Header***
# Sections Symbol Ptr # Symbols Opt Hdr Len Flags
4 0x00000d88 120 72 0x3002
Flags=( EXEC DYNLOAD SHROBJ DEP_SYSTEM )
Timestamp = "Sep 17 10:17:35 2024"
Magic = 0x1df (32-bit XCOFF)
***Optional Header***
Tsize Dsize Bsize Tstart Dstart
0x00000548 0x0000010c 0x00000004 0x10000128 0x20000670
SNloader SNentry SNtext SNtoc SNdata
0x0004 0x0000 0x0001 0x0002 0x0002
TXTalign DATAalign TOC vstamp entry
0x0005 0x0004 0x20000750 0x0001 0xffffffff
maxSTACK maxDATA SNbss magic modtype
0x00000000 0x00000000 0x0003 0x010b RE
***Loader Section***
***Loader Symbol Table Information***
[Index] Value Scn IMEX Sclass Type IMPid Name
[0] 0x2000068c .data RW SECdef [noIMid] __rtinit
[1] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) __cxa_finalize
[2] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXI_shr_o
[3] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXD_shr_o
[4] 0x00000000 undef IMP DS EXTref libc.a(shr.o) __strtollmax
[5] 0x00000000 undef IMP DS EXTref libc.a(shr.o) puts
[6] 0x200006f4 .data EXP DS Ldef [noIMid] __init_aix_libgcc_cxa_atexit
[7] 0x20000724 .data EXP DS Ldef [noIMid] _GLOBAL__AIXI_foo_so
[8] 0x20000730 .data EXP DS Ldef [noIMid] _GLOBAL__AIXD_foo_so
>> [9] 0x2000073c .data EXP DS SECdef [noIMid] strcat
[10] 0x20000744 .data EXP DS Ldef [noIMid] func1
The code makes use of strcat from libc but re-exports the symbol (because of -bexpall).
As of now due to the limitation with these flags (-bexpall / -bexpfull ? ), the
solution here is to continue to extract the symbols from the object files and
use that export file as part of building the shared library. (Continue to use
the mkldexport.sh script to generate the export symbols).
Thanks,
Sriram.
Re: AIX support
On 24/09/2024 14:25, Srirama Kucherlapati wrote: > Hi Heikki & team, > > Could you please let me know your comments on the previous details? > > Attached are the individual patches for AIX and gcc(__sync) routines. Repeating what I said earlier: > Ok, if we don't need the assembler code at all, that's good. A patch > to introduce AIX support should not change it for non-AIX powerpc > systems though. That might be a good change, but would need to be > justified separately, e.g. by some performance testing, and should > be a separate patch -- Heikki Linnakangas Neon (https://neon.tech)
Re: AIX support
On Tue, Sep 24, 2024 at 04:09:39PM +0300, Heikki Linnakangas wrote: > On 24/09/2024 14:25, Srirama Kucherlapati wrote: > > Hi Heikki & team, > > > > Could you please let me know your comments on the previous details? > > > > Attached are the individual patches for AIX and gcc(__sync) routines. > > Repeating what I said earlier: > > > Ok, if we don't need the assembler code at all, that's good. A patch > > to introduce AIX support should not change it for non-AIX powerpc > > systems though. That might be a good change, but would need to be > > justified separately, e.g. by some performance testing, and should > > be a separate patch Agreed. Srirama Kucherlapati, you seem to be doing the minimum amount of work and then repeatedly asking the same questions. I suggest you start to take this task more seriously. I would go back and read the entire thread, and take the things we have told you more seriously. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com When a patient asks the doctor, "Am I going to die?", he means "Am I going to die soon?"
RE: AIX support
Hi Heikki,
As requested earlier, I need some assistance from the Postgres side to identify any tool or testcase to calibrate the sync routine performance in Postgres.
I see the below tools for benchmarking.
- Pgbench https://www.postgresql.org/docs/current/pgbench.html
- Pg_test_fsync https://www.postgresql.org/docs/current/pgtestfsync.html
- pg_test_timing https://www.postgresql.org/docs/current/pgtesttiming.html
Please let me know, if these tools are fine or else ca you suggest us with any additional tools to run the benchmarking.
> > Ok, if we don't need the assembler code at all, that's good. A patch to
> > introduce AIX support should not change it for non-AIX powerpc systems
> > though. That might be a good change, but would need to be justified
> > separately, e.g. by some performance testing, and should be a separate
> > patch.
> > If you make no changes to s_lock.h at all, will it work? Why not?
> With the existing asm code I see there are some syntax errors, being hit.
> But after reverting the old changes the issues resolved. Below are diffs.
> Let me know if I need to run any perf tools to check the performance of
> the __sync_lock_test_and_set change.
Thanks,
Sriram.
RE: AIX support
Hi Heikki and team,
A few updates…
> > Ok, if we don't need the assembler code at all, that's good. A patch to
> > introduce AIX support should not change it for non-AIX powerpc systems
> > though. That might be a good change, but would need to be justified
> > separately, e.g. by some performance testing, and should be a separate
> > patch.
We ran pgbench for both the patches on powerpc Linux and below are the test
results and both results are close.
PPCLE sync: is the patch with the spin lock using gcc __sync* routines.
PPCLE asm: is the patch with the assemble code.
>> pgbench -c 100 -p 5432 -d postgres -T 180 -r -P 10 -L 10 -j 20
OS/type : PPCLE sync PPCLE asm
---------------------------------------------------------
latency average : 136.257 138.552
---------------------------------------------------------
latency stddev : 234.74 238.603
---------------------------------------------------------
Initial
connection time : 101.791 88.411
---------------------------------------------------------
TPS(without initial
connection time) : 733.633924 721.440648
---------------------------------------------------------
No. of transactions
actually processed : 132080 129893
---------------------------------------------------------
No of transactions
above the 10.0 ms
latency limit : 124235/132080 122183/129893
(94.060%) (94.064%)
---------------------------------------------------------
Please let us know your comments.
BTW we are working on the other review comments as well.
Warm regards,
Sriram.
RE: AIX support
Hi Team, here are few updates.
As of now we have removed all the old changes and made the changes that are
pretty much required by building from scratch. We had few issues with our
hardware as a result it took a while to build the code.
Below are the changes done as of now.
commit d2b4b4c2259e21ceaf05e393769b69728bfbee99 (HEAD -> master, origin/master, origin/HEAD)
>> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/backend/port/aix/mkldexport.sh
new file: src/include/port/aix.h
new file: src/makefiles/Makefile.aix
new file: src/template/aix
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Makefile
modified: configure
modified: doc/src/sgml/dfunc.sgml
modified: src/Makefile.shlib
modified: src/backend/Makefile
modified: src/backend/port/aix/mkldexport.sh
modified: src/backend/utils/error/elog.c
modified: src/include/storage/s_lock.h
modified: src/port/strerror.c
modified: src/test/regress/expected/jsonb_jsonpath.out
We are seeing this one issue as of now with ‘gmake check’…
1 diff -U3 /home /postgres/src/test/regress/expected/jsonb_jsonpath.out /home/ /postgres/src/test/regress/results/jsonb_jsonpath.out
2 --- /home /postgres/src/test/regress/expected/jsonb_jsonpath.out 2024-10-22 02:30:00.545814423 -0500
3 +++ /home/ postgres/src/test/regress/results/jsonb_jsonpath.out 2024-11-12 03:31:52.251125056 -0600
4 @@ -2687,7 +2687,7 @@
5 select jsonb_path_query_tz('"12:34:56"', '$.time_tz().string()');
6 jsonb_path_query_tz
7 ---------------------
8 - "12:34:56-07:00"
9 + "12:34:56-08:00"
10 (1 row)
11
12 select jsonb_path_query('"12:34:56"', '$.time().string()');
After modifying the expected output for this testcase as below, the issue was
resolved and the test case passed. But we are trying to see the root cause of this.
"12:34:56-08:00"
We are working on the buildfarm setup to check the actual tests.
I shall keep you posted.
Warm regards,
Sriram.
Re: AIX support
On Mon, Nov 25, 2024 at 11:27 AM Srirama Kucherlapati wrote: > After modifying the expected output for this testcase as below, the issue was > resolved and the test case passed. But we are trying to see the root cause of this. > > "12:34:56-08:00" This is not an AIX-specific issue. It was fixed in commit af21152268317323480caa790c4a6347110f8085, committed October 30th. -- Robert Haas EDB: http://www.enterprisedb.com
RE: AIX support
>> This is not an AIX-specific issue. It was fixed in commit
>> af21152268317323480caa790c4a6347110f8085, committed October 30th.
Thanks Robert, it worked after applying this change.
Warm regards,
Sriram.
RE: AIX support
Hi Team, few more updates on the buildfarm, all the tests have passed and below
is the gist of the logs. We are working on the cleaning up the changes and will
post them for review.
Tue Dec 3 04:08:29 2024: buildfarm run for CHANGEME:HEAD starting
CHANGEME:HEAD [04:09:49] running build ...
======== make log ===========
CHANGEME:HEAD [04:09:54] running basic regression tests ...
======== make check logs ===========
CHANGEME:HEAD [04:19:47] running make contrib ...
======== make contrib log ===========
CHANGEME:HEAD [04:19:48] running make testmodules ...
======== make testmodules log ===========
CHANGEME:HEAD [04:19:49] running install ...
======== make install log ===========
CHANGEME:HEAD [04:20:51] running make contrib install ...
======== make contrib install log ===========
CHANGEME:HEAD [04:21:20] running testmodules install ...
======== testmodules install log ===========
CHANGEME:HEAD [04:21:33] checking pg_upgrade
======== pg_upgrade check log ===========
CHANGEME:HEAD [04:21:33] checking test-decoding
======== test-decoding check log ===========
========================== output_iso/log/initdb.log ================
========================== output_iso/log/postmaster.log ================
========================== test_decoding/log/initdb.log ================
========================== test_decoding/log/postmaster.log ================
CHANGEME:HEAD [04:23:40] running make check miscellaneous modules ...
=========== Module commit_ts check =============
=========== Module injection_points check =============
=========== Module test_oat_hooks check =============
=========== Module test_slru check =============
=========== Module unsafe_tests check =============
=========== Module basic_archive check =============
=========== Module pg_freespacemap check =============
=========== Module pg_logicalinspect check =============
=========== Module pg_stat_statements check =============
=========== Module pg_walinspect check =============
=========== Module test_decoding check =============
CHANGEME:HEAD [04:31:54] setting up db cluster (C)...
======== initdb log (C) ===========
CHANGEME:HEAD [04:32:13] starting db (C)...
======== start db (C) : 1 log ========
=========== db log file ==========
CHANGEME:HEAD [04:32:14] running installcheck (C)...
======== make installcheck log ===========
CHANGEME:HEAD [04:44:14] restarting db (C)...
======== stop db (C): 1 log ==========
=========== db log file ==========
======== start db (C) : 2 log ========
=========== db log file ==========
CHANGEME:HEAD [04:44:16] running make isolation check ...
======== make isolation check logs ===========
CHANGEME:HEAD [04:48:22] restarting db (C)...
======== stop db (C): 2 log ==========
=========== db log file ==========
======== start db (C) : 3 log ========
=========== db log file ==========
CHANGEME:HEAD [04:49:24] running make PL installcheck (C)...
======== make pl installcheck log ===========
CHANGEME:HEAD [04:49:44] restarting db (C)...
======== stop db (C): 3 log ==========
=========== db log file ==========
======== start db (C) : 4 log ========
=========== db log file ==========
CHANGEME:HEAD [04:49:47] running make contrib installcheck (C)...
======== make contrib installcheck log ===========
CHANGEME:HEAD [04:55:01] restarting db (C)...
======== stop db (C): 4 log ==========
=========== db log file ==========
======== start db (C) : 5 log ========
=========== db log file ==========
CHANGEME:HEAD [04:55:09] running make test-modules installcheck (C)...
======== make testmodules installcheck log ===========
CHANGEME:HEAD [04:56:54] stopping db (C)...
======== stop db (C): 5 log ==========
=========== db log file ==========
CHANGEME:HEAD [04:56:57] running make ecpg check ...
======== make ecpg check logs ===========
CHANGEME:HEAD [04:58:38] OK
======== log passed to send_result ===========
======== log passed to send_result ===========
All stages succeeded
Generated logs files
aixpg-lpar01:~/build-farm-17/buildroot/HEAD/CHANGEME.fromsource-logs]
>> ls
build.log pl-install-check-C.log
check-pg_upgrade.log startdb-C-1.log
check.log startdb-C-2.log
configure.log startdb-C-3.log
contrib-install-check-C.log startdb-C-4.log
ecpg-check.log startdb-C-5.log
initdb-C.log stopdb-C-1.log
install-check-C.log stopdb-C-2.log
install-contrib.log stopdb-C-3.log
install-testmodules.log stopdb-C-4.log
isolation-check.log stopdb-C-5.log
make-contrib.log test-decoding-check.log
make-install.log testmodules-install-check-C.log
make-testmodules.log web-txn.data
misc-check.log
Warm regards,
Sriram.
Re: AIX support
On 23/12/2024 17:55, Srirama Kucherlapati wrote: > Hello Team, > > In response to our previous discussions, we have refined the code to address > > only the necessary adjustments focusing solely on the essential > modifications > > for AIX compatibility. The codebase was pulled from the GitHub repository > > (https://github.com/postgres/postgres.git postgres.git>) and we resolved all issues > > encountered during the configure and build processes. The following are the > > minimal alterations needed to ensure AIX is supported. Thanks, getting better. Please generate the patches against 'master', rather than v17. We might choose to backport this to v17 later, but let's focus on the current development branch for now. > Overview of Changes > > We consulted with internal teams (GCC/Linker and Open Source) for each > > modification. Details of the changes for the relevant files are as follows: > > - configure: > > - Addressed AIX-specific alignment issues to support MAXALIGN_ALIGNOF. > > - Added comments regarding AIX alignment rules in the file. The patch modifies 'configure', but that file is generated from 'configure.ac'. Please show the changes to 'configure.ac' Please also update the meson build system accordingly. > +# AIX alignment info: We assume long's alignment is at least as strong as char, short, or > +# int; but we must check long long (if it is being used for int64) and double. > +# > +# The AIX 'power' alignment rules apply the natural alignment of the "first > +# member" if it is of a floating-point data type (or is an aggregate whose > +# recursively "first" member or element is such a type). The alignment > +# associated with these types for subsequent members use an alignment value > +# where the floating-point data type is considered to have 4-byte alignment. > +# > +# The double is aligned to 4-bytes on AIX in aggregates. But to maintain > +# alignement across platforms the max alignment of long should be considered. I don't quite understand this comment. Maybe some rephrasing or examples would help. What is an aggregate in this context? A struct or union? We use C99 int64_t for the int64 datatype nowadays, not "long long", so this seems a little outdated. (Since commit 962da900ac) > - doc/src/sgml/dfunc.sgml: > > - Updated related documentation. > diff --git a/doc/src/sgml/dfunc.sgml b/doc/src/sgml/dfunc.sgml > index b94aefcd0c..554f9fac4c 100644 > --- a/doc/src/sgml/dfunc.sgml > +++ b/doc/src/sgml/dfunc.sgml > @@ -202,4 +202,23 @@ gcc -G -o foo.so foo.o > server expects to find the shared library files. > > > + > + > Why is this commented out? You say "updated related documentation", but these instructions were first added to the tree in year 1999, in commit f2f43efbe1, which apparently copied them from old man pages. Are they still current and relevant? > - Shared Libraries Build Process: > > - Files Affected: > > src/Makefile.shlib > > src/backend/Makefile > > - src/backend/port/aix/mkldexport.sh > > - Implemented AIX-specific changes for shared library creation using > export > > files. > - As per discussions with the linker team, the current design > mandates using > > the script method to extract symbols and build shared libraries. > > - This approach aligns with practices in other open-source projects like > > Python, OpenBLAS and other gnu tools(references, link). > > https://github.com/python/cpython/blob/main/Modules/ld_so_aix.in > > > https://github.com/OpenMathLib/OpenBLAS/ > commit/892f8ff3e55e24fda9af3f6364319cce3f60116b#diff-4011a114c75fe804332139868806cbe23f275963e4e6afa9b57e51b2b9817293R261 Thanks for the links. It's disappointing there isn't a standard way to do this. It's nice to see the comments in cpython's makeexp_aix script explaining the "hidden tricks". I'd love to see similar comments in mkldexport.sh explaining what it does. And also why the script is needed on AIX in the first place. I wonder if meson's AIX support would have something built-in to do this? > - src/makefiles/Makefile.aix: Introduced AIX-specific makefile for > building. > +# 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)' Is this still needed? I have no idea, but it seems surprising if gcc and ld don't handle this automatically. > +LDFLAGS_SL += -Wl,-bnoentry -Wl,-H512 -Wl,-bM:SRE What do all these options do? Why are they needed? > - src/template/aix: Defined memset flags for AIX. Why? Did you benchmark it? How big is the difference? I don't know if the default we have for MEMSET_LOOP_LIMIT is any good on modern compilers and systems in general. Perhaps we should just always use the system memset(). So for this patch, e key question is whether there's something AIX specific here. I'd assume no. I'd assume it to depend on the hardware rather than the OS. -- Heikki Linnakangas Neon (https://neon.tech)
RE: AIX support
Hi Heikki, Thanks for your feedback.
> Please generate the patches against 'master', rather than v17. We might
> choose to backport this to v17 later, but let's focus on the current
> development branch for now.
All the changes were made on top of master(development) branch pulled from github repository. Below is the log info.
I’ll pull the latest master and apply the changes for the next patch.
github repository: https://github.com/postgres/postgres.git
commit 103760b2d065081447efd27f4ecc20c5dbb7abcf (HEAD -> aixSupport)
Author: Sriram RK sriram.rk@in.ibm.com
Date: Fri Dec 6 10:36:29 2024 -0600
AIX support
commit d2b4b4c2259e21ceaf05e393769b69728bfbee99 (origin/master, origin/HEAD, gitibm/master, master)
Author: Peter Eisentraut peter@eisentraut.org
Date: Tue Oct 22 08:12:43 2024 +0200
Fix C23 compiler warning
…
commit 45e0ba30fc40581f320fac17ad8b4e0676e1b3b5
Author: Michael Paquier michael@paquier.xyz
Date: Tue Oct 22 13:05:51 2024 +0900
pg_stat_statements: Add tests for nested queries with level tracking
I shall continue to work on the other comments and will keep you posted.
Warm regards,
Sriram.
Re: AIX support
On 25.12.24 11:22, Heikki Linnakangas wrote: > Thanks for the links. It's disappointing there isn't a standard way to > do this. It's nice to see the comments in cpython's makeexp_aix script > explaining the "hidden tricks". I'd love to see similar comments in > mkldexport.sh explaining what it does. And also why the script is needed > on AIX in the first place. > > I wonder if meson's AIX support would have something built-in to do this? Meson appears to have AIX support, so it's worth trying out. If it's working, then it would also be worth considering a meson-only AIX port, which might be much simpler. Conversely, if it doesn't work at all, it would need to be fixed. I don't think we'd want to accept a new port that doesn't work with meson.
Re: AIX support
Hi, On December 30, 2024 10:29:53 AM GMT+01:00, Peter Eisentraut wrote: >On 25.12.24 11:22, Heikki Linnakangas wrote: >> Thanks for the links. It's disappointing there isn't a standard way to do this. It's nice to see the comments in cpython's makeexp_aix script explaining the "hidden tricks". I'd love to see similar comments in mkldexport.sh explaining what it does. And also why the script is needed on AIX in the first place. >> >> I wonder if meson's AIX support would have something built-in to do this? > >Meson appears to have AIX support, so it's worth trying out. If it's working, then it would also be worth considering a meson-only AIX port, which might be much simpler. Conversely, if it doesn't work at all, it would need to be fixed. I don't think we'd want to accept a new port that doesn't work with meson. Before the removal PG passed tests on AIX, when built with meson. IIRC it shared the annoying symbol handling script with autoconf though. Andres -- Sent from my Android device with K-9 Mail. Please excuse my brevity.
RE: AIX support
> Meson appears to have AIX support, so it's worth trying out.
Right, meson is supported on AIX, we have meson in our AIX toolbox.
We are trying to build with meson as well. I shall update you.
BTW, I would like to wish the entire Postgres community a Happy new year.
Warm regards,
Sriram.
RE: AIX support
Hi Team,
A few updates regarding the meson build.
We have successfully resolved issues with the meson build on AIX, allowing the meson configure and build to succeed.
A problem was addressed in the meson script wrt AIX (to build a nested shared libraries), specifically in the symbolextractor.py file. The fix has been implemented and will be submitted to the meson community.
Currently, we are verifying the test results.
Warm regards,
Sriram.
RE: AIX support
Hi Team,
Our team has identified couple of issues with the meson build on AIX, primarily focusing on the following areas:
- Symbol extraction and resolution in object files during binary creation.
- Dynamic runtime library path resolution in shared libraries.
We have resolved them and we plan to submit these fixes to the meson community shortly.
In addition, we are actively working on resolving other test issues. I will provide you with updates once these problems have been resolved.
92/301 postgresql:regress / regress/regress
# 4 of 223 tests failed.
Warm regards,
Sriram.
Re: AIX support
On Fri, Mar 7, 2025 at 9:11 AM Srirama Kucherlapati wrote: > Our team has identified couple of issues with the meson build on AIX, primarily focusing on the following areas: > > Symbol extraction and resolution in object files during binary creation. > Dynamic runtime library path resolution in shared libraries. > > We have resolved them and we plan to submit these fixes to the meson community shortly. Nice! -- Robert Haas EDB: http://www.enterprisedb.com
RE: AIX support
Hi Team,
Here are the updates on the meson on AIX. Our team had pushed the fixes meson github here …
https://github.com/mesonbuild/meson/pull/14335
#14335 Enhance AIX shared library build to use an export List.
Re: AIX support
Hi Team,
Here are the updates on the meson on AIX. Our team had pushed the fixes meson github here …
https://github.com/mesonbuild/meson/pull/14335
#14335 Enhance AIX shared library build to use an export List.
RE: AIX support
Hi Wenhui Qiu,
May I know the freeze dates.
We are nearly ready to deliver the patch. Currently, we have compiled the
source using Meson and are investigating one test case issue. Once we pinpoint
the cause, we will send you the patch. Notably, this test case behaves
differently on AIX, opting for a Bitmap Index Scan instead of an Index Scan.
Not sure if this is really specific to AIX?
>> meson test
396 Ok: 81
397 Expected Fail: 0
398 Fail: 1 (regex)
399 Unexpected Pass: 0
400 Skipped: 219
401 Timeout: 0
>>
7 explain (costs off) select * from pg_proc where proname ~ '^abc';
8 - QUERY PLAN
9 -----------------------------------------------------------------------
10 - Index Scan using pg_proc_proname_args_nsp_index on pg_proc
11 - Index Cond: ((proname >= 'abc'::text) AND (proname < 'abd'::text))
12 + QUERY PLAN
13 +----------------------------------------------------------------------------
14 + Bitmap Heap Scan on pg_proc
15 Filter: (proname ~ '^abc'::text)
16 -(3 rows)
17 + -> Bitmap Index Scan on pg_proc_proname_args_nsp_index
18 + Index Cond: ((proname >= 'abc'::text) AND (proname < 'abd'::text))
19 +(4 rows)
As of now below are the changes wrt to meson.
modified: meson.build
modified: src/backend/meson.build
modified: src/bin/initdb/initdb.c
modified: src/include/c.h
modified: src/include/port/aix.h
modified: src/include/utils/float.h
modified: src/interfaces/ecpg/compatlib/meson.build
modified: src/interfaces/ecpg/ecpglib/meson.build
modified: src/interfaces/ecpg/pgtypeslib/meson.build
modified: src/interfaces/libpq/meson.build
modified: src/test/regress/expected/txid.out
modified: src/test/regress/expected/xid.out
modified: src/test/regress/sql/sanity_check.sql
Warm regards,
Sriram.
Re: AIX support
On 03/04/2025 16:45, Srirama Kucherlapati wrote: > Hi Wenhui Qiu, > > May I know the freeze dates. April 8th is the feature freeze. Any new features must be *committed* by then. We are already very close to that, and given that there's no concrete patch for committer to review yet, I think it's safe to say that you missed it already. -- Heikki Linnakangas Neon (https://neon.tech)
Re: AIX support
Hi, On 2025-04-03 13:45:01 +0000, Srirama Kucherlapati wrote: > We are nearly ready to deliver the patch. Currently, we have compiled the > source using Meson and are investigating one test case issue. Once we pinpoint > the cause, we will send you the patch. Notably, this test case behaves > differently on AIX, opting for a Bitmap Index Scan instead of an Index Scan. > Not sure if this is really specific to AIX? > > >> meson test > > 396 Ok: 81 > 397 Expected Fail: 0 > 398 Fail: 1 (regex) > 399 Unexpected Pass: 0 > 400 Skipped: 219 FWIW, the skipped tests indicate that you are building without tap tests or such - that means most of the testsuite is not run. That certainly is not good enough. Greetings, Andres Freund
RE: AIX support
Hi Heikki and team,
Thank you for considering our request. As discussed, we have revised the patch
to incorporate all the review comments provided.
Please find the attached patch, which focuses solely on the gmake changes.
As discussed the meson specific changes would be provided as different patch.
We have taken into account and resolved the earlier comments within this patch.
https://www.postgresql.org/message-id/e0dc2bff-300b-4edd-912b-b6c52274bdc5%40iki.fi
- Build using latest master. (used commit 898c131b58a0b)
- We have merged our changes to this latest level.
- configure.ac
- Updated the changes aligning to configure file.
- configure
- Updated the comments wrt to the alignment details. Updated with
the gcc specific fix which talks about the alignment.
- updated the int64_t specific changes.
- doc/src/sgml/dfunc.sgml
- This is removed as it is not relevant.
- src/backend/port/aix/mkldexport.sh
- When building shared libraries from various archives on AIX, we encounter a
situation where symbols are not exported. To resolve this, we require an export
file. For instance, the command is used to export symbols.
gcc -shared libtest.so libtest.a -Wl,-bE:test.exp
However, if we directly provide object files in the command line instead of an
archive, the symbols will be exported automatically, as demonstrated by the command
gcc -shared libtest.so test1.o test2.o test3.o.
- We will update the description with additional details in the later point of time. (Considering the time lines)
- src/makefiles/Makefile.aix
- The changes in this file are required
- This change is not required “+LDFLAGS_SL += -Wl,-bnoentry -Wl,-H512 -Wl,-bM:SRE”
- src/template/aix
- WRT to the MEMSET_LOOP_LIMIT flag, this is set to “0”, which would internally use
The system call memset() as mentioned in the below link as well
https://www.postgresql.org/message-id/20060203135315.E08B09DC816%40postgresql.org
I Kindly request you to review the changes and provide your feedback.
With all the above changes we have built and ran the tests. As of now we see
there is only one test case that is failing, which seems to have been
introduced recently. And this might not be related to the above changes as
earlier there were no test cases failing.
64 not ok 12 + float8 235 ms
297 # 1 of 226 tests failed.
20 +ERROR: value out of range: overflow
21 -- test overflow/underflow handling
22 SELECT gamma(float8 '-infinity');
23 ERROR: value out of range: overflow
Warm regards,
Sriram.
Re: AIX support
On 04/04/2025 22:31, Srirama Kucherlapati wrote: > - src/backend/port/aix/mkldexport.sh> > - When building shared libraries from various archives on AIX, we encounter a > situation where symbols are not exported. To resolve this, we require an export > file. For instance, the command is used to export symbols. > > gcc -shared libtest.so libtest.a -Wl,-bE:test.exp > > However, if we directly provide object files in the command line instead of an > archive, the symbols will be exported automatically, as demonstrated by the command > > gcc -shared libtest.so test1.o test2.o test3.o. Oh, that's interesting. So if we do that, we don't need mkldepxort.sh anymore? > - WRT to the MEMSET_LOOP_LIMIT flag, this is set to “0”, which would > internally use > > The system call memset() as mentioned in the below link as well > > https://www.postgresql.org/message- > id/20060203135315.E08B09DC816%40postgresql.org www.postgresql.org/message-id/20060203135315.E08B09DC816%40postgresql.org> Yes, I understand what it does. But why? Whatever benchmarking was done back in 2006 by is no longer relevant. > With all the above changes we have built and ran the tests. As of now we see > > there is only one test case that is failing, which seems to have been > > introduced recently. And this might not be related to the above changes as > > earlier there were no test cases failing. > > 64 not ok 12 + float8 235 ms > > 297 # 1 of 226 tests failed. > > 20 +ERROR: value out of range: overflow > > 21 -- test overflow/underflow handling > > 22 SELECT gamma(float8 '-infinity'); > > 23 ERROR: value out of range: overflow Yeah, that function is new. I don't know if it's a pre-existing problem or something specific to AIX. Please check the archives for prior discussion on that; if you can reproduce it, maybe you can help to fix it? > 12 files changed, 224 insertions(+), 20 deletions(-) I'm glad to see this patch shrinking :-) > diff --git a/src/include/port/aix.h b/src/include/port/aix.h > new file mode 100644 > index 00000000000..7d08480c8c0 > --- /dev/null > +++ b/src/include/port/aix.h > @@ -0,0 +1,4 @@ > +/* > + * src/include/port/aix.h > + */ > + Useless. > diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h > index 2f73f9fcf57..5da9b3acda4 100644 > --- a/src/include/storage/s_lock.h > +++ b/src/include/storage/s_lock.h > @@ -421,17 +421,15 @@ tas(volatile slock_t *lock) > __asm__ __volatile__( > " lwarx %0,0,%3,1 \n" > " cmpwi %0,0 \n" > -" bne 1f \n" > +" bne $+16 \n" /* branch to li %1,1 */ > " addi %0,%0,1 \n" > " stwcx. %0,0,%3 \n" > -" beq 2f \n" > -"1: \n" > +" beq $+12 \n" /* branch to lwsync */ > " li %1,1 \n" > -" b 3f \n" > -"2: \n" > +" b $+12 \n" /* branch to end of asm sequence */ > " lwsync \n" > " li %1,0 \n" > -"3: \n" > + > : "=&b"(_t), "=r"(_res), "+m"(*lock) > : "r"(lock) > : "memory", "cc"); Why is this change needed? Yes, I know we've been over this many times already. I still don't understand why it's needed. The onus is on you to explain it adequately, in comments in the patch, so that I and others understand it. Or even better, remove it if it's not necessary. > diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix > new file mode 100644 > index 00000000000..d33918f91b9 > --- /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 Oh this is interesting. I think MAKE_EXPORTS is actually a leftover that I failed to remove when I removed the AIX support; it's not used on any currently-supported platform. > +# -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 Is this still sensible on modern AIX systems? What happens if you leave it out? > +# 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 Same here. Still relevant? What happens if you leave it out? > +# 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 On other platforms, we have this in LINK.shared, see src/Makefile.shlib. Should we do the same on AIX; if not, why not? > +# env var name to use in place of LD_LIBRARY_PATH > +ld_library_path_var = LIBPATH Does AIX have LD_LIBRARY_PATH? This suggests that it does: https://www.ibm.com/support/pages/aix-libpath-recommendations What's the difference between LIBPATH and LD_LIBRARY_PATH? Why prefer LIBPATH? Separately from the remaining issues with this patch, I still feel pretty reluctant with accepting this, because if I commit this patch, I'm on the hook to keep it working. I do regularly commit stuff that I'm not personally that interested in, but a new port is different: If something breaks on AIX, I have no means (or interest!) in debugging it. That means that I need to be pretty confident that there are others who are interested and invested in keeping working, take ownership, will help to debug problems in a timely fashion, and can submit high-quality fixes. I am not seeing that. I also notice that all the AIX systems we have in the buildfarm are still: - maintained by Noah, who - correct me if I'm wrong - is not particularly interested in AIX or keen on maintaining them - are on AIX 7.1.5, which I believe is already end-of-line - running on power7 hardware which is 15 years old. That's not very reassuring. -- Heikki Linnakangas Neon (https://neon.tech)
RE: AIX support
Hi Heikki,
Please find the attached patch addressing the provided comments. Our responses are outlined below.
>> - src/backend/port/aix/mkldexport.sh>
> Oh, that's interesting. So if we do that, we don't need mkldepxort.sh
> anymore?
Here the better approach still would be to use the script to extract the
symbols build the corresponding shared libraries. As we see there are
lot of extensions that are getting built using the symbols exported from
"postges" binary, we need to definitely use the script to extract the symbols
and import them while building the library extensions.
>> - WRT to the MEMSET_LOOP_LIMIT flag, this is set to “0”, which would
>> internally use
> Yes, I understand what it does. But why? Whatever benchmarking was done
> back in 2006 by is no longer relevant.
We ran the program , mentioned in the below link and collected the
benchmark stats on our node (POWER_10).
https://postgrespro.com/list/thread-id/1673194
The native AIX memset() seems to performs better. The benchmark seems to be still
relevant, so I think we should continue to use the existing optimization for
AIX. Below are the stats (64bit Object mode).
>> ./memset-aix
sizeof(int) = 4
sizeof(long) = 8
Loop by int (size=8) : 0.238024
memset by int (size=8) : 0.280301
Loop by long (size=8) : 0.202650
Loop by int (size=16) : 0.389846
memset by int (size=16) : 0.280979
Loop by long (size=16) : 0.246879
Loop by int (size=32) : 0.773478
memset by int (size=32) : 0.331691
Loop by long (size=32) : 0.422261
Loop by int (size=64) : 1.945150
memset by int (size=64) : 0.319117
Loop by long (size=64) : 0.769770
Loop by int (size=128) : 4.517186
memset by int (size=128) : 0.398292
Loop by long (size=128) : 1.982307
Loop by int (size=256) : 12.486661
memset by int (size=256) : 0.463115
Loop by long (size=256) : 4.526272
Loop by int (size=512) : 24.433075
memset by int (size=512) : 0.681426
Loop by long (size=512) : 12.564701
Loop by int (size=1024) : 48.060486
memset by int (size=1024) : 0.904048
Loop by long (size=1024) : 24.149871
Loop by int (size=2048) : 96.288018
memset by int (size=2048) : 1.509465
Loop by long (size=2048) : 48.216079
Loop by int (size=4096) : 191.847177
memset by int (size=4096) : 1.435403
Loop by long (size=4096) : 96.433072
>> 12 files changed, 224 insertions(+), 20 deletions(-)
> I'm glad to see this patch shrinking :-)
Thanks for your suggestions, yes it further shrinked.
> > diff --git a/src/include/port/aix.h b/src/include/port/aix.h
> Useless.
I too initially felt this was not needed, This file is still required as the below file is
getting auto generated. I attempted to remove it; the below error is hit.
so this is still required.
64 ../../src/include/c.h:59:10: fatal error: pg_config_os.h: No such file or directory
65 59 | #include "pg_config_os.h" /* config from include/port/PORTNAME.h */
66 | ^~~~~~~~~~~~~~~~
> diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
> Why is this change needed?
> Yes, I know we've been over this many times already. I still don't
> understand why it's needed. The onus is on you to explain it adequately,
> in comments in the patch, so that I and others understand it. Or even
> better, remove it if it's not necessary.
If you recall, we previously considered replacing this assembly code with
__sync_lock_test_and_set(). However, as you mentioned earlier, this should be
handled in a separate patch. For now, I'll make a note and submit a separate
patch for this later, as originally planned. Below is the reference to older
discussion.
https://www.postgresql.org/message-id/7751f9c5-e2e6-4252-a9fa-14b3e78ddec9%40iki.fi
>> diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
>> +MAKE_EXPORTS= true
>Oh this is interesting. I think MAKE_EXPORTS is actually a leftover that
>I failed to remove when I removed the AIX support; it's not used on any
>currently-supported platform.
Removed it and its working fine.
>> +# -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
> Is this still sensible on modern AIX systems? What happens if you leave
> it out?
This is required as it is looking for the possible non-default directories for the linker
at the runtime. This is used along with rpath. As suggested, I tested this by removing
the libpath, but at run time the linker is not able to find the dependent libraries path
as a result, the binaries are not getting loaded. After doing some research, AIX uses a stricter,
more explicit approach. The runtime linker expects to tell it exactly where to look using -blibpath.
>> +# 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
> Same here. Still relevant? What happens if you leave it out?
Removed it and it is working fine.
>> +# 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
>On other platforms, we have this in LINK.shared, see src/Makefile.shlib.
>Should we do the same on AIX; if not, why not?
I tried your suggestion to move the gcc "LDFLAGS_SL += -shared" flag to Makefile.shlib,
"LINK.shared = $(COMPILER) -shared", but there are some extensions dependent
on this in "contrib" which are not building with “-shared” flag, as a result a testcase
is failing to load this library "contrib/spi/autoinc.so" . Below is the error.
not ok 78 + triggers 2443 ms
31 +ERROR: incompatible library "/home/pgdev/pgdb/postgres/src/test/regress/autoinc.so": missing magic block
32 +HINT: Extension libraries are required to use the PG_MODULE_MAGIC macro.
I noticed that the “-shared” flag was missing while building the contrib/spi/autoinc.so library.
I tried to add the “include $(top_builddir)/src/Makefile.shlib” in the
contrib/spi/Makefile, but still the “-shared” flag is not getting included while building
the library.
So we will continue to use the earlier change.
> Does AIX have LD_LIBRARY_PATH? This suggests that it does:
> https://www.ibm.com/support/pages/aix-libpath-recommendations
> What's the difference between LIBPATH and LD_LIBRARY_PATH? Why prefer
LIBPATH?
AIX uses only LIBPATH and LD_LIBRARY_PATH is specific to Linux.
> Separately from the remaining issues with this patch, I still feel
> pretty reluctant with accepting this, because if I commit this patch,
> I'm on the hook to keep it working. I do regularly commit stuff that I'm
> not personally that interested in, but a new port is different:
> If something breaks on AIX, I have no means (or interest!) in debugging
> it. That means that I need to be pretty confident that there are others
> who are interested and invested in keeping working, take ownership, will
> help to debug problems in a timely fashion, and can submit high-quality
> fixes. I am not seeing that.
I completely understand your concerns about committing to a new port and
ensuring its long-term maintenance.
Our team would like to extend the support to maintain PostgreSQL on AIX.
We would like to assist by timely debugging and resolving any issues on AIX.
We’re also keen to actively contribute to this effort.
> I also notice that all the AIX systems we have in the buildfarm are still:
> - maintained by Noah, who - correct me if I'm wrong - is not
> particularly interested in AIX or keen on maintaining them
> - are on AIX 7.1.5, which I believe is already end-of-line
> - running on power7 hardware which is 15 years old.
> That's not very reassuring.
From a hardware perspective, we believe it should be feasible to provide
new nodes in the OSU lab. We've already set up a Power9 machine with the
supported AIX version for the community usage. Recently, there was a request from
the community (Mark Wong) for additional nodes, and we're happy to offer
any hardware support needed.
Warm regards,
Sriram.
Re: AIX support
On 05/04/2025 21:29, Srirama Kucherlapati wrote: >>> - WRT to the MEMSET_LOOP_LIMIT flag, this is set to “0”, which would >>> internally use > >> Yes, I understand what it does. But why? Whatever benchmarking was done >> back in 2006 by is no longer relevant. > > We ran the program , mentioned in the below link and collected the > benchmark stats on our node (POWER_10). > > https://postgrespro.com/list/thread-id/1673194 list/thread-id/1673194> > > The native AIX memset() seems to performs better. The benchmark seems to > be still relevant, so I think we should continue to use the existing optimization for > AIX. At least it needs to be updated to match what MemSet() looks like nowadays. The changes may be just cosmetic, but better check. Should also check the effect on MemSetAligned(). That might matter more for performance in practice. A third thing to check is the performance of MemSet() when the pointer is, in fact, aligned. The other question is what do the results look like on other platforms? How much difference does the libc implementation make, vs. the compiler and CPU architecture? If the difference is related to compiler or CPU architecture, then this doesn't belong in the AIX template, but somewhere else. > Below are the stats (64bit Object mode). > >>> ./memset-aix > > sizeof(int) = 4 > sizeof(long) = 8 MemSet() uses 'long', so the int tests are not relevant. I have omitted them below. > memset by int (size=8) : 0.280301 > Loop by long (size=8) : 0.202650 > > memset by int (size=16) : 0.280979 > Loop by long (size=16) : 0.246879 > > memset by int (size=32) : 0.331691 > Loop by long (size=32) : 0.422261 Ok, MemSet() is faster with very small sizes, the crossover is somewhere between 16 and 32 bytes. I'm actually surprised the compiler doesn't replace the memset() call with a few store instructions with these sizes. > memset by int (size=1024) : 0.904048 > Loop by long (size=1024) : 24.149871 So with larger sizes, memset() wins hands down. I'm surprised how big the difference is, because I actually expected the compiler to detect the memory-zeroing loop and replace it with some fancy vector instructions (does powerpc have any?). Or a call to memset(); I've seen compilers convert loops to memset() and vice versa. My gut feeling is actually that we should remove the MemSet() macro altogether and just use memset() everywhere. The compilers are much better at optimizing it in year 2025 than they were back in 2002. I'd love to see some rigorous benchmarks across different platforms and compilers to demonstrate that, and then just get rid of MemSet(). MemSetAligned() might still be worth keeping. Sometimes we know that a piece of memory is aligned, but the compiler does not. But maybe even that should just assert and hint the compiler that the input is aligned, and then call memset(). If you'd like to help the community in general, if you could do some more rigorous benchmarking along those lines, not just for AIX, and start a new thread to discuss that, that'd be much appreciated. That would be the best way to resolve this. For the more narrow question of what should the AIX template do, that comes down to whether there's some *AIX-specific* performance difference. The generated powerpc assembly code is presumably the same on AIX and other operating systems, so it comes down to whether there's some big difference in AIX's memset() implementation vs. glibc's. >> diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h > >> Why is this change needed? > >> Yes, I know we've been over this many times already. I still don't >> understand why it's needed. The onus is on you to explain it adequately, >> in comments in the patch, so that I and others understand it. Or even >> better, remove it if it's not necessary. > > If you recall, we previously considered replacing this assembly code > with __sync_lock_test_and_set(). However, as you mentioned earlier, > this should be handled in a separate patch. For now, I'll make a > note and submit a separate patch for this later, as originally > planned. Below is the reference to older discussion. Yes, I do recall. Please read again my comment above: this all needs to be explained in comments in the code. To be precise, I have these questions: - Does GCC on AIX (still) use the IBM assembler? - Does the IBM assembler still not understand the label syntax? - Is there some other label syntax that would work on the IBM assembler? - Is it possible to use the GNU assembler instead? >>> +# -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 > >> Is this still sensible on modern AIX systems? What happens if you leave >> it out? > > This is required as it is looking for the possible non-default > directories for the linker at the runtime. This is used along with > rpath. As suggested, I tested this by removing the libpath, but at > run time the linker is not able to find the dependent libraries path > as a result, the binaries are not getting loaded. After doing some > research, AIX uses a stricter, more*explicit* approach. The runtime > linker expects to tell it exactly where to look using -blibpath. Ok, some comments would be in order to explain that, maybe with links to the relevant AIX documentation. -- Heikki Linnakangas Neon (https://neon.tech)
RE: AIX support
Here are some stats wrt to loop and native memset after enabling optimization with the same test tool(tested for long and long align using MemSetAligned). Corresponding glibc is linked on PPcle and AIX libc is linked on AIX.
https://postgrespro.com/list/thread-id/1673194
AIX loop-1 PPCle - loop1 AIX loop-2 PPCle - loop2
Loop by long (size=8) : 0 0 0.000001 0
Loop Align by long (size=8) : 0 0 0 0
memset by long (size=8) : 0.00999 0.010229 0.00994 0.010211
Loop by long (size=16) : 0 0 0 0
Loop Align by long (size=16) : 0 0 0 0
memset by long (size=16) : 0.010082 0.010036 0.010094 0.01003
Loop by long (size=32) : 0.32903 0.227726 0.329027 0.227707
Loop Align by long (size=32) : 0.329486 0.227705 0.328932 0.227712
memset by long (size=32) : 0.021061 0.01064 0.021115 0.01064
Loop by long (size=64) : 0.334761 0.227714 0.34326 0.227688
Loop Align by long (size=64) : 0.329005 0.236937 0.329084 0.236906
memset by long (size=64) : 0.059559 0.025612 0.053004 0.029589
Loop by long (size=128) : 0.420381 0.329634 0.420332 0.329524
Loop Align by long (size=128) : 0.420376 0.337169 0.42022 0.337162
memset by long (size=128) : 0.420153 0.098774 0.420312 0.101888
Loop by long (size=256) : 0.472187 0.428049 0.472774 0.429217
Loop Align by long (size=256) : 0.472586 0.438316 0.472447 0.438325
memset by long (size=256) : 0.473731 0.428013 0.473864 0.42759
Loop by long (size=512) : 0.676089 0.435649 0.632774 0.43574
Loop Align by long (size=512) : 0.66702 0.428013 0.630751 0.427319
memset by long (size=512) : 0.666619 0.427989 0.691485 0.427263
Loop by long (size=1024) : 1.00773 0.45079 0.925212 0.452131
Loop Align by long (size=1024) : 0.92114 0.45084 0.920574 0.452994
memset by long (size=1024) : 0.935062 0.450821 0.917 0.452396
Loop by long (size=2048) : 1.52585 0.702127 1.265107 0.701822
Loop Align by long (size=2048) : 1.57524 0.702158 1.439109 0.702651
memset by long (size=2048) : 1.614771 0.702247 1.384672 0.701857
Loop by long (size=4096) : 1.418133 1.37568 1.325803 1.376005
Loop Align by long (size=4096) : 1.421619 1.375741 1.325743 1.376071
memset by long (size=4096) : 1.423404 1.375716 1.325666 1.376091
After enabling optimization levels, both are performing similar.
As both are performing similar we have removed the MEMSET_LOOP in the AIX template and tried the below benchmark after running pgbench.
Run#1
>> pgbench -c 50 -p 5678 -d postgres -T 180 -r -P 10 -L 10 -j 20
pgbench (18devel)
starting vacuum...end.
progress: 10.0 s, 2603.2 tps, lat 18.692 ms stddev 61.947, 0 failed
progress: 20.0 s, 3373.2 tps, lat 14.841 ms stddev 17.724, 0 failed
progress: 30.0 s, 2599.6 tps, lat 19.222 ms stddev 99.307, 0 failed
progress: 40.0 s, 3531.3 tps, lat 14.159 ms stddev 14.786, 0 failed
progress: 50.0 s, 2561.3 tps, lat 15.180 ms stddev 33.532, 0 failed
progress: 60.0 s, 3315.4 tps, lat 18.421 ms stddev 111.988, 0 failed
progress: 70.0 s, 3517.4 tps, lat 14.203 ms stddev 14.931, 0 failed
progress: 80.0 s, 2023.4 tps, lat 21.858 ms stddev 125.718, 0 failed
progress: 90.0 s, 3472.1 tps, lat 16.049 ms stddev 55.152, 0 failed
progress: 100.0 s, 3580.5 tps, lat 13.966 ms stddev 14.636, 0 failed
progress: 110.0 s, 2823.4 tps, lat 14.572 ms stddev 20.433, 0 failed
progress: 120.0 s, 3140.3 tps, lat 18.717 ms stddev 120.447, 0 failed
progress: 130.0 s, 3488.4 tps, lat 14.329 ms stddev 15.057, 0 failed
progress: 140.0 s, 2503.7 tps, lat 19.966 ms stddev 125.551, 0 failed
progress: 150.0 s, 3083.3 tps, lat 16.212 ms stddev 56.652, 0 failed
progress: 160.0 s, 3572.0 tps, lat 13.991 ms stddev 14.660, 0 failed
progress: 170.0 s, 3642.2 tps, lat 13.722 ms stddev 14.507, 0 failed
progress: 180.0 s, 2453.6 tps, lat 20.364 ms stddev 133.126, 0 failed
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 50
query mode: simple
number of clients: 50
number of threads: 20
maximum number of tries: 1
duration: 180 s
number of transactions actually processed: 552889
number of failed transactions: 0 (0.000%)
number of transactions above the 10.0 ms latency limit: 227816/552889 (41.205%)
latency average = 16.252 ms
latency stddev = 69.656 ms
initial connection time = 237.245 ms
tps = 3074.421213 (without initial connection time)
statement latencies in milliseconds and failures:
0.002 0 \set aid random(1, 100000 * :scale)
0.001 0 \set bid random(1, 1 * :scale)
0.001 0 \set tid random(1, 10 * :scale)
0.001 0 \set delta random(-5000, 5000)
1.090 0 BEGIN;
3.153 0 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
1.462 0 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
2.012 0 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
4.060 0 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
1.224 0 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_T
3.246 0 END;
Run#2
>> pgbench -c 50 -p 5678 -d postgres -T 180 -r -P 10 -L 10 -j 20
pgbench (18devel)
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 50
query mode: simple
number of clients: 50
number of threads: 20
maximum number of tries: 1
duration: 180 s
number of transactions actually processed: 577290
number of failed transactions: 0 (0.000%)
number of transactions above the 10.0 ms latency limit: 234815/577290 (40.675%)
latency average = 15.558 ms
latency stddev = 65.428 ms
initial connection time = 314.109 ms
tps = 3211.642930 (without initial connection time)
statement latencies in milliseconds and failures:
0.002 0 \set aid random(1, 100000 * :scale)
0.001 0 \set bid random(1, 1 * :scale)
0.001 0 \set tid random(1, 10 * :scale)
0.001 0 \set delta random(-5000, 5000)
1.084 0 BEGIN;
2.761 0 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
1.371 0 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
2.000 0 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
4.014 0 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
1.229 0 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_T
3.093 0 END;
>> diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
> - Does GCC on AIX (still) use the IBM assembler?
> - Does the IBM assembler still not understand the label syntax?
> - Is there some other label syntax that would work on the IBM assembler?
> - Is it possible to use the GNU assembler instead?
GCC on AIX still uses the AIX native assembler only. The GNU assembler has some level of support in AIX through some of the patches. But still GCC/gnu assembler combination is not very much tested.
We removed AIX specific changes for TAS(), which would now use the __sync_lock_test_and_set() routines directly instead, and we ran pgbench on it.
+ pgbench -c 50 -p 5678 -d postgres -T 180 -r -P 10 -L 10 -j 20
pgbench (18devel)
starting vacuum...end.
scaling factor: 50
query mode: simple
number of clients: 50
number of threads: 20
maximum number of tries: 1
duration: 180 s
number of transactions actually processed: 550838
number of failed transactions: 0 (0.000%)
number of transactions above the 10.0 ms latency limit: 227805/550838 (41.356%)
latency average = 16.323 ms
latency stddev = 68.404 ms
initial connection time = 235.449 ms
tps = 3061.041640 (without initial connection time)
statement latencies in milliseconds and failures:
0.002 0 \set aid random(1, 100000 * :scale)
0.001 0 \set bid random(1, 1 * :scale)
0.001 0 \set tid random(1, 10 * :scale)
0.001 0 \set delta random(-5000, 5000)
1.098 0 BEGIN;
2.993 0 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
1.501 0 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
2.004 0 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
4.127 0 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
1.238 0 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
3.356 0 END;
> 21 -- test overflow/underflow handling
>
> 22 SELECT gamma(float8 '-infinity');
>
> 23 ERROR: value out of range: overflow
WRT failure in lgamma(), we worked with the libm team to resolve it. It’s an issue with the errno that is being set. I’ll work on the testcase.
>> ./gamma-test NaN
Gamma and natural logarithm of gamma for the input values:
Gamma(NaNS) = NaNQ errno: 34
lgamma(NaNS) = NaNQ errno: 34
With fixed libm
+ ./gamma-test NaN
Gamma and natural logarithm of gamma for the input values:
Gamma(NaNS) = NaNQ errno: 0
lgamma(NaNS) = NaNQ errno: 0
Warm Regards,
Sriram
RE: AIX support
Working on the patch. I will update you.
-Sriram.
RE: AIX support
Hi Team, Please find the attached diff with the latest changes.
The diff file changes that were done for memset and spinlock, are modified
on top of the previous patch.
New changes for review: 0001-AIX-support.tas.memset.diffs
Previous patch: 0001-AIX-support.v8.patch
>> diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
>
We have replaced the asm code with the gcc specific routines __sync_lock_test_and_set ()
and ran the pgbench. On AIX both have the similar performance, On PPcle we see a slight
variation in the performance. It seems the asm code is performing better on PPCle. Please
let us know, would it be better to continue to use the PPC assemble code over gcc routines.
Attached are the complete stats. (spinlock.stats.log)
Below is the summary…
AIX With asm AIX With __sync PPCle With asm PPCle With __sync
number of transactions "226554/ "230810/ "356945/ "364346/
above the 10.0 ms 556329 567936 918647 863937
latency limit (40.723%)" (40.640%)" (38.856%)" (42.173%)"
latency average 16.160 ms 15.821 ms 9.796 ms 10.416 ms
initial connection time 230.786 ms 249.668 ms 19.606 ms 20.090 ms
tps 3086.209412 3158.14915 5103.024267 4799.621896
> diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
>
> At least it needs to be updated to match what MemSet() looks like
> nowadays. The changes may be just cosmetic, but better check. Should
> also check the effect on MemSetAligned(). That might matter more for
> performance in practice.
As per the stats in the previous mail wrt to memset, both the loop and the native
memset are performing similar after optimization “-O2”. So for now we removed the
native memset changes.
We will setup the memset performance on different platforms and will post the
details in a different thread.
>>> +# -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
>
Added additional details about the -blibpath usage. These details are available in the below link
https://download.boulder.ibm.com/ibmdl/pub/software/dw/aix/es-aix_ll.pdf
> 21 -- test overflow/underflow handling
>
> 22 SELECT gamma(float8 '-infinity');
>
> 23 ERROR: value out of range: overflow
This testcase is resolved from AIX libm side. Below is the result.
postgres=#
SELECT x, gamma(x),lgamma(x)
FROM (VALUES (0.5), (1), (2), (3), (4), (5),
(float8 'infinity'), (float8 'nan')) AS t(x);
0.5 | 1.772453850905516 | 0.5723649429247001
1 | 1 | 0
2 | 1 | 0
3 | 2 | 0.6931471805599453
4 | 6 | 1.791759469228055
5 | 24 | 3.1780538303479458
Infinity | Infinity | Infinity
NaN | NaN | NaN
Kindly let us know your feedback on the diffs.
I will commit the diffs to the patch(0001-AIX-support.v8.patch) once you are fine.
Warm regards,
Sriram.
Re: AIX support
On Mon, Apr 7, 2025 at 10:04 PM Heikki Linnakangas wrote: > I'm surprised how big the difference is, because I actually expected the > compiler to detect the memory-zeroing loop and replace it with some > fancy vector instructions (does powerpc have any?). It certainly does, and we've played with explicit AltiVec vectorisation before with the idea that our abstraction over x86 and ARM instructions could be extended to POWER, but that was just trying stuff and learning while wondering if those abstractions are general enough and how well all the instructions match up. No one with modern hardware and a vested interest has seriously investigated it. That's independent of automatic vectorisation done by the compiler or libc, and I guess it would not really be AIX-specific since it would also apply to Linux on POWER. One of those patches is linked from this small list of "ideas for a future PostgreSQL/AIX maintainer": https://wiki.postgresql.org/wiki/AIX
RE: AIX support
Hi Heikki and team,
As part of our ongoing efforts to enhance AIX platform compatibility, we’ve been running the code across all stable PostgreSQL release branches using the build farm infrastructure. All test suites, including TAP tests, are passing consistently, indicating no regressions.
https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_13_STABLE
https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_14_STABLE
https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_15_STABLE
https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_16_STABLE << Also tested locally.
To further validated the patch, we executed the build farm scripts locally for PostgreSQL 17 and 18 on AIX. The corresponding test results are attached for reference.
We value your feedback and would appreciate your insights on the attached patch. Kindly request you to review and share your comments.
Warm regards,
Sriram.
Re: AIX support
Hi Team,
Just checking in regarding the AIX support patch shared earlier. As mentioned, we’ve successfully run the patch across all stable PostgreSQL releases using the build farm, and all tests—including TAP—have passed. We also ran the build farm scripts locally for PostgreSQL 17 and 18 on AIX, and the test results were attached for your reference.
We’d appreciate your review and feedback on the patch. Once we receive your input, our next steps will be:
1. Address any comments or suggestions you may have.
2. Finalize the patch based on feedback.
3. Proceed with integration into the relevant branches.
Please let us know if you need any additional details or clarification.
Thanks
Vamshi.
Re: AIX support
On Thu, 2025-09-11 at 10:50 +0530, Vamshikrishna T wrote: > Just checking in regarding the AIX support patch shared earlier. Did you create a commitfest entry? That way, your patch is less likely to fall between the cracks. Yours, Laurenz Albe
Re: AIX support
Thank you Laurenz for the info, Raised the review request here.
Re: AIX support
On Thu, Sep 11, 2025 at 10:50:45AM +0530, Vamshikrishna T wrote: > We’d appreciate your review and feedback on the patch. Once we receive your > input, our next steps will be: > > 1. Address any comments or suggestions you may have. > > 2. Finalize the patch based on feedback. > > 3. Proceed with integration into the relevant branches. I assume the only relevant branch is PG 19. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Do not let urgent matters crowd out time for investment in the future.
RE: AIX support
Hi Bruce,
Please find the attached patch that is run on master branch PG19.
Kindly request you to go through and let us know your feedback.
Also attached are the builfarm results.
Warm regards,
Sriram.
Re: AIX support
This patch marked 10/10 with all CI checks passing. Your feedback on the patch would be greatly appreciated.
Re: AIX support
On 2025-Sep-03, Srirama Kucherlapati wrote: > As part of our ongoing efforts to enhance AIX platform compatibility, > we’ve been running the code across all stable PostgreSQL release > branches using the build farm infrastructure. All test suites, > including TAP tests, are passing consistently, indicating no > regressions. The buildfarm results you sent look good. You should definitely be testing branch master though rather than the stable ones, because it's not clear to me, as Bruce said, that we would really backpatch AIX support to stable branches. (You're of course free to produce your own packages from patched versions, in the interim). I noticed that you add mkldexport.sh and that the makefiles use it. I wonder if that really is necessary with the current AIX tooling (it looks an outdated gadget). Also, I notice that Meson supports AIX starting from version 0.56; did you verify whether it works to build this with that? -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
Re: AIX support
Hi Alvaro,
Thank you for taking your time to look into the details.
I’ve submitted the latest changes to the master branch, which are now available in the annotations section here:
https://commitfest.postgresql.org/patch/6050/
I kindly request you to review this updated patch and share your valuable feedback.
Regarding your observation about the inclusion of mkldexport.sh and its usage in the makefiles — as previously
discussed, this is a necessary workaround due to current limitations on AIX. To build shared libraries, we need to
extract symbols using this script. The relevant details are as follows:
Script Location: src/backend/port/aix/mkldexport.sh
Purpose: Implements AIX-specific changes for shared library creation using export files.
Background: Based on discussions with the internal linker team, this method is currently required to extract symbols and build shared libraries.
Reference Practices: This approach is consistent with methods used in other open-source projects such as Python and OpenBLAS:
Python
https://github.com/python/cpython/blob/main/Modules/ld_so_aix.in
OpenBLAS
https://github.com/OpenMathLib/OpenBLAS/commit/892f8ff3e55e24fda9af3f6364319cce3f60116b#diff-4011a114c75fe804332139868806cbe23f275963e4e6afa9b57e51b2b98
As for Meson builds, we did explore them earlier but encountered some issues. Here are some issues/fixes we submitted to the meson community
https://github.com/mesonbuild/meson/issues/14334
For now, we would like to focus initially on the regular gmake build since our buildfarms predominantly use it. That said, we do plan to submit Meson-related changes as a separate patch in the future.
Looking forward to your feedback.
-SriramRe: AIX support
Hi, On 2025-09-22 11:09:53 +0000, AIX PG user wrote: > As for Meson builds, we did explore them earlier but encountered some > issues. Here are some issues/fixes we submitted to the meson community > https://github.com/mesonbuild/meson/issues/14334 For now, we would like to > focus initially on the regular gmake build since our buildfarms > predominantly use it. That said, we do plan to submit Meson-related changes > as a separate patch in the future. I think we should do the opposite if anything. We're planning to eventually remove make based builds. But I'm also suprprised - before the removal meson based builds on AIX were working. Why didn't you just revive it as it was? Greetings, Andres Freund
Re: AIX support
Hi Andres,
Thank you for your feedback and for highlighting the importance of Meson-based builds.
We fully recognize the long-term objective of transitioning away from
make-based builds, and we are actively working on reviving Meson support for
AIX in alignment with that direction. However, we are currently encountering a
few errors with the revived changes, and we are working actively to
resolve them. I will keep you updated and share the finalized Meson-related
changes at the earliest opportunity.
In the meantime, we would sincerely appreciate it if you/team could review the patch
with respect to the gmake build and the associated source-level modifications
submitted on commitfest.
https://commitfest.postgresql.org/patch/6050/
Your input would be invaluable in helping us ensure the correctness and
completeness of the implementation before we proceed further. Thank you once
again for your continued guidance and support.
Warm regards,
Sriram.Re: AIX support
Hi, On 2025-09-23 14:26:08 +0000, AIX PG user wrote: > Thank you for your feedback and for highlighting the importance of Meson-based builds. > > We fully recognize the long-term objective of transitioning away from > make-based builds, and we are actively working on reviving Meson support for > AIX in alignment with that direction. However, we are currently encountering a > few errors with the revived changes, and we are working actively to > resolve them. I will keep you updated and share the finalized Meson-related > changes at the earliest opportunity. It worked without meson changes just before the AIX support was dropped. I do not see why you *need* that meson patch, rather it just being convenient - after all I had made it work before, without that. > In the meantime, we would sincerely appreciate it if you/team could review the patch > with respect to the gmake build and the associated source-level modifications > submitted on commitfest. I'd personally just not add gmake support at all, but ... > https://commitfest.postgresql.org/patch/6050/ > > Your input would be invaluable in helping us ensure the correctness and > completeness of the implementation before we proceed further. Thank you once > again for your continued guidance and support. One suggestion I do have is to split the patch into a few constitutent pieces. Greetings, Andres Freund
RE: AIX support
Hi Andres,
> It worked without meson changes just before the AIX support was dropped. I do
> not see why you *need* that meson patch, rather it just being convenient -
> after all I had made it work before, without that.
I was able to build successfully using Meson on PostgreSQL 16. However, when attempting the same on the latest master(with the revived changes), I encountered a few errors. We are currently investigating these issues and working on the necessary fixes.
I’ll keep you updated once the Meson-related fixes are ready.
> One suggestion I do have is to split the patch into a few constitutent pieces.
Thank you for the suggestion.
Splitting the patch into smaller, constituent pieces makes sense and would certainly help with clarity and review.
Appreciate your guidance.
Warm regards,
Sriram.
RE: AIX support
Hi Andres and team,
Please find attached the patch addressing Meson build changes for AIX.
We tried to build using below meson
## meson -v
1.6.1
For the following files, the shared_module() function requires specifying the
appropriate symbol import file, which is provided via the aix_link_args
variable:
src/backend/jit/llvm/meson.build
src/backend/replication/libpqwalreceiver/meson.build
src/backend/replication/pgoutput/meson.build
src/backend/snowball/meson.build
src/backend/utils/mb/conversion_procs/meson.build
Additionally, with the latest version of Meson, when building static libraries,
the library file name must be suffixed with “_static” in the following files:
src/interfaces/ecpg/compatlib/meson.build
src/interfaces/ecpg/ecpglib/meson.build
src/interfaces/ecpg/pgtypeslib/meson.build
src/interfaces/libpq/meson.build
Main AIX changes patch - 0001-Changes-to-add-support-for-AIX.v9.pg19.patch (previously submitted one)
Meson AIX changes patch - 0001-AIX-changes-for-meson-build.patch
Looking forward to hearing your thoughts on these changes.
Your feedback on these updates is highly valued.
Thanks,
Sriram.
Re: AIX support
On 15.10.25 17:58, Srirama Kucherlapati wrote: > Main AIX changes patch - 0001-Changes-to-add-support-for- > AIX.v9.pg19.patch (previously submitted one) > > Meson AIX changes patch - 0001-AIX-changes-for-meson-build.patch > > Looking forward to hearing your thoughts on these changes. > > Your feedback on these updates is highly valued. The largest problem I see in this patch set is that you are making unexplained changes in src/include/storage/s_lock.h. The code that you are changing does not only affect AIX but also PPC with other operating systems. AFAICT, the change you are proposing does not correspond to the commit that removed AIX support. Maybe the proposed changes are beneficial for other operating systems as well. But in that case, propose this as a separate patch in a separate thread, with supporting information (and probably benchmarks in this case). If not, then you need to find a way to make this work on AIX without materially changing the code that exists for already-supported operating systems.
Re: AIX support
Hi Peter,
Thank you for your comments.
We’ve had a few discussions in the past regarding the changes related to the
spin lock. Some of those conversations stemmed from this thread:
"https://www.postgresql.org/message-id/95a44be0-b2f8-464a-8984-771d892b1cac%40iki.fi"
The earlier assembly code was generic across the PPC platform. However, based
on previous discussions, we transitioned to using GCC-specific routines to
enhance platform independence and maintain generality.
These are the comments I have added, let me know if you need more info here.
+/* On PPC, use the compiler provided Built-in functions for atomic memory
+ * exchange operations.
+ */
For reference, here are some benchmark statistics we gathered earlier:
"https://www.postgresql.org/message-id/CY8PR15MB5602EB54EFE30D4C21F061BEDB722%40CY8PR15MB5602.namprd15.prod.outlook.com"
I'll run some more benchmarking on this sync_lock and submit the results.
Meanwhile, it would be helpful if you and your team could take a look at the remaining changes.
Thank you,
Sriram.
The new status of this patch is: Needs review
Re: AIX support
Hi Team, We look forward to your comments and kindly request you to share your feedback on the proposed changes(in the annotations). Your input is greatly appreciated and will help us refine the solution while ensuring all aspects are thoughtfully addressed. Thank you in advance for your time and support. -Sriram.
Re: AIX support
On 16/10/2025 18:28, AIX PG user wrote: > diff --git a/src/template/aix b/src/template/aix > new file mode 100644 > index 00000000000..bfc193348f4 > --- /dev/null > +++ b/src/template/aix > @@ -0,0 +1,7 @@ > +# This file is referred for specific flags wrt to AIX build process like > +# cflags. > +# src/template/aix > + > +# Extra CFLAGS for code that will go into a shared library > +# With optimization, the MemSet() and MemSetAlign() perform better. > +CFLAGS_SL=" -O2 " > -- This looks weird. Sure, "-O2" makes things faster, but we shouldn't force that here. If you want optimizations, you should use pass CFLAGS="-O2" or CFLAGS="-O3" to configure. And why the special mention of MemSet() and MemSetAlign()? > @@ -95,6 +97,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 I see there's some references to MAKE_EXPORTS in src/backend/Makefile. They seem related to MKLDEXPORT, but we never set MAKE_EXPORTS. Are they still needed? - Heikki
Re: AIX support
Hi Heikki, Thank you for your feedback. > This looks weird. Sure, "-O2" makes things faster, but we shouldn't > force that here. If you want optimizations, you should use pass > CFLAGS="-O2" or CFLAGS="-O3" to configure. And why the special mention > of MemSet() and MemSetAlign()? I have removed these. > I see there's some references to MAKE_EXPORTS in src/backend/Makefile. > They seem related to MKLDEXPORT, but we never set MAKE_EXPORTS. Are they > still needed? If MAKE_EXPORTS is not being used by any platforms other than AIX, we can consider removing it. However, I’m not entirely certain whether it might still be required elsewhere. Since these changes appear to be general and not strictly AIX-specific, would it be fine to submit them as a separate patch? Looking forward to your continued support and guidance. - Sriram.
Re: AIX support
On 15.10.25 17:58, Srirama Kucherlapati wrote: > Hi Andres and team, > > Please find attached the patch addressing Meson build changes for AIX. > > We tried to build using below meson > > ## meson -v > > 1.6.1 > > For the following files, the shared_module() function requires > specifying the > > appropriate symbol import file, which is provided via the aix_link_args > > variable: > > src/backend/jit/llvm/meson.build > > src/backend/replication/libpqwalreceiver/meson.build > > src/backend/replication/pgoutput/meson.build > > src/backend/snowball/meson.build > > src/backend/utils/mb/conversion_procs/meson.build > > Additionally, with the latest version of Meson, when building static > libraries, > > the library file name must be suffixed with “_static” in the following > files: > > src/interfaces/ecpg/compatlib/meson.build > > src/interfaces/ecpg/ecpglib/meson.build > > src/interfaces/ecpg/pgtypeslib/meson.build > > src/interfaces/libpq/meson.build It is not going to be acceptable to sprinkle this much AIX-specific code around. Those changes to the meson.build files were not needed before AIX support was removed. You should find a way to do it without these changes. The changes in src/include/port/aix.h in your patch don't make sense. This indicates that you are doing something wrong in your local builds. Please fix that.
Re: AIX support
Hi Peter, >> Those changes to the meson.build files were not needed before >> AIX support was removed. You should find a way to do it without these >> changes. The change was necessary to ensure that the import file used during the static PostgreSQL library build begins with the required #! directive and includes the correct symbol references from the object files. This structure is essential for compatibility with AIX's linking behaviour, which relies on explicitly defined symbol import files during static linking. Without this adjustment, the build process may fail or result in incomplete symbol resolution, particularly on AIX systems. By aligning the import file format and symbol inclusion with platform-specific requirements. We referred to previously removed code that handled similar logic and found it to be effective. Based on this, we plan to revert the changes in the affected files and proceed with a more robust solution. https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=0b16bb8776bb834eb1ef8204ca95dd7667ab948b#patch11 src/backend/jit/llvm/meson.build src/backend/replication/libpqwalreceiver/meson.build src/backend/replication/pgoutput/meson.build src/backend/snowball/meson.build src/backend/utils/mb/conversion_procs/meson.build Regarding the archiving of shared and static libraries, the latest version of Meson raises a conflict as both targets have the same name. This issue arises because, on AIX, both shared and static libraries are named as same archive, which leads to naming collisions during the build process. We would still need the below changes. src/interfaces/ecpg/compatlib/meson.build src/interfaces/ecpg/ecpglib/meson.build ecpglib_st = static_library(libname, src/interfaces/ecpg/pgtypeslib/meson.build ecpg_pgtypes_st = static_library(libname, src/interfaces/libpq/meson.build libpq_st = static_library(libname >> The changes in src/include/port/aix.h in your patch don't make sense. >> This indicates that you are doing something wrong in your local builds. >> Please fix that. We had to do these changes in the src/include/c.h, As the MACROS, are getting undefined by the below sys header files. We made changes to src/include/c.h because certain macros were being undefined by the system header files listed below. To address this issue, we introduced updates in aix.h. +#ifndef PGDLLIMPORT +#define PGDLLIMPORT #include #include #include We are continuing to analyze the impact of these changes and will refine the solution as needed. Once finalized, we will submit the updated changes accordingly. -Sriram.
RE: AIX support
I have implemented the requested modifications in the latest patch. Below are the key technical updates:
• Meson Build Configuration: Adjusted below meson.build scripts to incorporate the suggested changes, ensuring proper dependency resolution and improved build consistency.
Removed the AIX changes in the below from the previous patch.
src/backend/jit/llvm/meson.build
src/backend/replication/libpqwalreceiver/meson.build
src/backend/replication/pgoutput/meson.build
src/backend/snowball/meson.build
src/backend/utils/mb/conversion_procs/meson.build
Added the static_library() changes.
> Regarding the archiving of shared and static libraries, the latest version of
> Meson raises a conflict as both targets have the same name. This issue
> arises because, on AIX, both shared and static libraries are named as same
> archive, which leads to naming collisions during the build process. We
> would still need the below changes.
src/interfaces/ecpg/compatlib/meson.build
src/interfaces/ecpg/ecpglib/meson.build
src/interfaces/ecpg/pgtypeslib/meson.build
src/interfaces/libpq/meson.build
I would greatly appreciate it if you could review the patch and share your feedback or any additional recommendations.
Apologies for the delayed response; I was occupied with other tasks.
Your insights are greatly appreciated and will help enhance the patch.
Re: AIX support
On 09/12/2025 18:50, Srirama Kucherlapati wrote:
> @@ -1766,9 +1785,9 @@ endforeach
> # 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_double = cdata.get('ALIGNOF_DOUBLE')
> -if cc.alignment('int64_t', args: test_c_args, prefix: '#include ') > alignof_double
> - error('alignment of int64_t is greater than the alignment of double')
> -endif
> +#if cc.alignment('int64_t', args: test_c_args, prefix: '#include ') > alignof_double
> +# error('alignment of int64_t is greater than the alignment of double')
> +#endif
> cdata.set('MAXIMUM_ALIGNOF', alignof_double)
>
> cdata.set('SIZEOF_LONG', cc.sizeof('long', args: test_c_args))
This is unfinished.
> @@ -1820,7 +1839,7 @@ if cc.links('''
> if not meson.is_cross_build()
> r = cc.run('''
> /* This must match the corresponding code in c.h: */
> - #if defined(__GNUC__)
> + #if defined(__GNUC__) || defined(__IBMC__)
> #define pg_attribute_aligned(a) __attribute__((aligned(a)))
> #elif defined(_MSC_VER)
> #define pg_attribute_aligned(a) __declspec(align(a))
There's a comment right there that it must match the corresponding code
in c.h, but you didn't modify c.h.
> + # Native memset() is faster, tested on:
> + memset_loop_limit = 0
Incomplete sentence: tested on what?
We talked about this before. I'm reluctant to have a special case for
AIX, because I suspect this has little to do with the operating system,
and more with the compiler and the CPU architecture. I could be wrong;
maybe the libc memset() implementation on AIX is superior to that on
linux, for example. I'd love to see thorough performance testing of
MemSetAligned() vs memset() on common combinations of CPUs and libc
implementations. Ideally, we can just replace MemSetAligned() with
memset() everywhere.
If you do such testing, please start a separate thread for that. On this
thread, it will get lost with all the AIX-specific stuff.
> +/* This change is required for the meson changes as the autoconf is not run and
> + * to resolve the conflicts in picking the float.h details by default from the
> + * postgres defined datatypes.
> + */
> +#ifdef _AIX
> +#ifndef PGDLLIMPORT
> +#define PGDLLIMPORT
> +#endif /* PGDLLIMPORT */
> +typedef float float4;
> +typedef double float8;
I don't understand these typedefs. What is the conflict the comment
talks about?
> +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
> +#define pg_noreturn _Noreturn
> +#elif defined(__GNUC__)
> +#define pg_noreturn __attribute__((noreturn))
> +#else
> +#define pg_noreturn
> +#endif
Isn't this just duplicating the snippet in c.h?
> +#include
This is in c.h too.
> src/include/storage/s_lock.h
> [ switches to __sync_lock_release(lock) on all powerpc systems ]
We talked about this before.
> @@ -18,7 +18,8 @@ GetOptions(
>
> if (not( $format eq 'darwin'
> or $format eq 'gnu'
> - or $format eq 'win'))
> + or $format eq 'win'
> + or $format eq 'aix'))
> {
> die "$0: $format is not yet handled (only darwin, gnu, win are)\n";
> }
Forgot to update the error message.
I didn't review the autoconf / Makefile changes.
> Apologies for the delayed response; I was occupied with other tasks.
Oh no worries, I'm not in any hurry with this. On the contrary to be honest.
- Heikki
Re: AIX support
On 09.12.25 17:50, Srirama Kucherlapati wrote:
> Hi Team, (Peter/Heikki)
>
> I have implemented the requested modifications in the latest patch.
> Below are the key technical updates:
>
> • Meson Build Configuration: Adjusted below meson.build scripts to
> incorporate the suggested changes, ensuring proper dependency resolution
> and improved build consistency.
>
> Removed the AIX changes in the below from the previous patch.
>
> src/backend/jit/llvm/meson.build
> src/backend/replication/libpqwalreceiver/meson.build
> src/backend/replication/pgoutput/meson.build
> src/backend/snowball/meson.build
> src/backend/utils/mb/conversion_procs/meson.build
>
> Added the static_library() changes.
>
> > Regarding the archiving of shared and static libraries, the
> latest version of
>> Meson raises a conflict as both targets have the same name. This issue
>> arises because, on AIX, both shared and static libraries are named as same
>> archive, which leads to naming collisions during the build process. We
>> would still need the below changes.
>
> src/interfaces/ecpg/compatlib/meson.build
> src/interfaces/ecpg/ecpglib/meson.build
> src/interfaces/ecpg/pgtypeslib/meson.build
> src/interfaces/libpq/meson.build
>
> • CFLAGS Optimization Removal: Removed high-level optimization flags
> from CFLAGS to prevent unpredictable behaviour and maintain stability
> during compilation.
>
> I would greatly appreciate it if you could review the patch and share
> your feedback or any additional recommendations.
>
> Apologies for the delayed response; I was occupied with other tasks.
>
> Your insights are greatly appreciated and will help enhance the patch.
>
>
> Warm regards,
> -Sriram.
>
>
1) In meson.build:
+ cppflags += '-D_GNU_SOURCE'
I don't think this symbol is applicable to AIX.
2) In meson.build:
+ # Native memset() is faster, tested on:
+ memset_loop_limit = 0
The comment sentence appears to be truncated.
3) In meson.build:
+#if cc.alignment('int64_t', args: test_c_args, prefix: '#include
') > alignof_double
+# error('alignment of int64_t is greater than the alignment of double')
+#endif
This commented out code cannot be left like this. Either remove it or
adjust it as required.
4) In meson.build:
/* This must match the corresponding code in c.h: */
- #if defined(__GNUC__)
+ #if defined(__GNUC__) || defined(__IBMC__)
You code does not observe what the comment says.
5) The changes in src/include/port/aix.h are nonsense. This was
previously pointed out and you said you would address this.
6) I had previously pointed out that the changes in
src/include/storage/s_lock.h are not acceptable like that and you had
said that you would address that.
Re: AIX support
Howdy, Heikki asked me to look at the renames of the static Meson targets. I don't understand the reasoning for the changes. I am completely unfamiliar with AIX, so maybe it's obvious. Does Meson produce a static library and a shared library with the same file extension? If so, why is that? That's the only reason I can think of for making those changes. Is it AIX-specific or whatever OS you are testing on? In your patch, I found a link to https://www.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at. > -> On AIX, you can do a static as well as a dynamic > -> link against a shared library, it depends on how you > -> invoke the linker. > > When you link statically, the shared objects from > the library are added to your executable as required; > when you link dynamically, only references > to the shared objects are included in the executable. > > Consequently you do not need a separate static library > on AIX if you have a dynamic library. This seems to imply that we don't need a static library at all on AIX. However this email is also nearing 20 years old :D. Could we get away without the renames on the Meson targets by just not defining the static library targets? -- Tristan Partin Databricks (https://databricks.com)
RE: AIX support
Thank you for reviewing the patch.
BTW, thank you, Heikki and Peter, for your comments. I’m working on the comments
and I’ll keep you updated.
Warm regards,
Sriram.
Re: AIX support
On Wed Dec 10, 2025 at 8:32 AM CST, Srirama Kucherlapati wrote: > We encountered the following error when building without the "_static" suffix in the library name: > Found ninja-1.12.1 at /opt/freeware/bin/ninja > ERROR: Multiple producers for Ninja target "src/interfaces/ecpg/compatlib/libecpg_compat.a”. > Please rename your targets. > > On AIX, shared libraries are archived in a way that allows multiple versions to > coexist within the same archive. This is primarily because shared library(.so) > is archived into .a, which leads to naming conflicts between static and shared > libraries. To address this, we suffixed the library with “_static". > > However, we later tested by completely skipping the static library build, and > this approach worked successfully since it eliminates the conflict between > static and shared libraries. I'm working on the changes and will validate > further on this. Thanks for the explanation. I'm glad we can workaround this without renaming the targets! -- Tristan Partin Databricks (https://databricks.com)
RE: AIX support
Please find the attached changes for the below comments. Along with comments from Tristan.
>> 1) In meson.build:
>> + cppflags += '-D_GNU_SOURCE’
>> I don't think this symbol is applicable to AIX.
>> 2) In meson.build:
>> + # Native memset() is faster, tested on:
>> + memset_loop_limit = 0
>> The comment sentence appears to be truncated.
>> 3) In meson.build:
>> +#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’)
>> +#endif
>> This commented out code cannot be left like this. Either remove it or
>> adjust it as required.
>> 4) In meson.build:
>> /* This must match the corresponding code in c.h: */
>> - #if defined(__GNUC__)
>> + #if defined(__GNUC__) || defined(__IBMC__)
>> You code does not observe what the comment says.
>> 5) The changes in src/include/port/aix.h are nonsense. This was
>> previously pointed out and you said you would address this.
I’d like to finalize all Meson-specific changes first. Meanwhile, I’m also working on the other comments.
Kindly let me know your thoughts and feedback on the changes.
Thanks,
Sriram.
Re: AIX support
Thanks for your continued push for AIX support! Here are a few comments: > # The static libpq is skipped in AIX. This is not required. For comments like this, I would generally like to see some links or inline documentation to why this is the case. Maybe Peter or Heikki disagree. There are a few places in the Meson code like the following: if AIX: don't define the static library target endif Make sure that the innards of the if statements are indented. Alternatively, you could define something like: static_library_dependencies = [] if host_machine.system() == 'AIX' # TODO: Document this AIX_poison_pill = disabler() static_library_dependencies += AIX_poison_pill endif And then for all static library definitions, you would just make sure that they all depend on the poison pill. You could document the AIX shared/static library situation where the AIX_poison_pill variable is defined. I'd like to see if Peter thinks this is a good idea before implementing it. I'm also a little confused by the second patch. Some of it seems to be the same, and some other parts seem to be new. Should we consolidate all Meson AIX support into one patch? Overall, I think the size of the patch is good, and seem pretty maintainable. -- Tristan Partin Databricks (https://databricks.com)
RE: AIX support
As suggested, we have tried to implement a dependency-driven approach for static library builds, rather than using AIX platform tags.
> I'd like to see if Peter thinks this is a good idea before implementing it.
> Should we consolidate all Meson AIX support into one patch?
Thank you, Tristan, for your assistance. At present, the build appears stable
with the recent changes, however, the new dependency is causing impacts
RE: AIX support
RE: AIX support
Hi Tristan, Heikki, Peter,
Greetings!
As suggested, we have addressed all your comments(wrt to meson) and incorporated the dependency-based approach for static libraries in this patch. We believe this solution provides a more generic and maintainable approach.
• Implemented a dependency-driven mechanism for static library builds instead of platform-specific tags.
I kindly request you to review the attached Meson changes based on your earlier feedback. Your input is highly valued and will help us further refine and improve these changes.
Thank you for your time and consideration. I look forward to your valuable feedback.
Warm regards,
Sriram.
Re: AIX support
On 13.01.26 17:06, Srirama Kucherlapati wrote: > As suggested, we have addressed all your comments(wrt to meson) and > incorporated the dependency-based approach for static libraries in this > patch. We believe this solution provides a more generic and maintainable > approach. This patch appears to be incomplete. It references a file mkldexport.sh but that file does not exist and is not included in the patch.
RE: AIX support
> This patch appears to be incomplete. It references a file mkldexport.sh
> but that file does not exist and is not included in the patch.
As requested, I have now included the mkldexport.sh changes in the attached file. We want to initially close all the meson review comments.
Please review the changes and let me know your thoughts or if any further adjustments are needed.
Looking forward to your feedback.
Warm regards,
Sriram.
Re: AIX support
On 15.01.26 06:51, Srirama Kucherlapati wrote: >> This patch appears to be incomplete. It references a file mkldexport.sh >> but that file does not exist and is not included in the patch. > > The initial patch contained only Meson-specific changes addressing the > comments provided regarding Meson in this discussion. > https://www.postgresql.org/message-id/ > DF3QX1B91OKO.182K0IH9QDQUY%40partin.io message-id/DF3QX1B91OKO.182K0IH9QDQUY%40partin.io> > > As requested, I have now included the mkldexport.sh changes in the > attached file. We want to initially close all the meson review comments. > > Please review the changes and let me know your thoughts or if any > further adjustments are needed. I took this idea of disabling static libraries in meson and made it a separate patch; see [0]. It looks like this patch is getting close to consensus, so we could commit it soon. Then you could rebase your patch over it, which would make it quite a bit simpler. I think in general, the meson changes are ok. But I needed some changes, for example, your patch contains +if not dep_static_lib.disabled() but the method .disabled() doesn't exist, it should be .found(). So I'm wondering how this patch was tested. Another patch of interest to you could be [1], which moves the MAXIMUM_ALIGNOF computation into c.h. This should also simplify your patch. But that patch has not received any discussion so far. In any case, you should post complete patch series. It's ok to split changes into multiple patches, and then recommend which parts you want reviewed first. But we need to see at least a rough outline of the complete plan before spending significant effort on reviewing the pieces. [0]: https://www.postgresql.org/message-id/e8aa97db-872b-4087-b073-f296baae948d%40eisentraut.org [1]: https://www.postgresql.org/message-id/58cedbc7-5658-468d-868e-a4d06de04ca6%40eisentraut.org
RE: AIX support
> separate patch; see [0]. It looks like this patch is getting close to
> consensus, so we could commit it soon. Then you could rebase your patch
> over it, which would make it quite a bit simpler.
That’s a great idea and will definitely help simplify the overall changes.
Once that patch is committed, I’ll rebase my changes accordingly to align with the new approach.
> I think in general, the meson changes are ok. But I needed some
> changes, for example, your patch contains
Thanks for reviewing the changes.
> but the method .disabled() doesn't exist, it should be .found(). So I’m
> wondering how this patch was tested.
You’re correct — the method .disabled() doesn’t exist; it should be .found(). We initially tried to follow the same approach used for other dependencies (like docs, docs_pdf, gssapi), and didn’t encounter any errors during testing.
In Meson, the option() class implements disabled(), but the disabler() object does not. When we ran a sample test, we observed that Meson’s behaviour on AIX/Linux seems to ignore any unknown methods. As a result, the .disabled() conditional check was silently skipped, which explains why it didn’t fail during our tests.
> MAXIMUM_ALIGNOF computation into c.h. This should also simplify your
> patch. But that patch has not received any discussion so far.
> reviewed first. But we need to see at least a rough outline of the
> complete plan before spending significant effort on reviewing the pieces.
Thanks again for your guidance and support!
Warm regards,
Sriram.
RE: AIX support
> reviewed first. But we need to see at least a rough outline of the
> complete plan before spending significant effort on reviewing the pieces.
Warm regards,
Sriram.
Re: AIX support
On 23.01.26 17:11, Srirama Kucherlapati wrote: > Hi Peter, > > > It's ok to split changes into multiple patches, and then recommend > which parts you want >> reviewed first. But we need to see at least a rough outline of the > > complete plan before spending significant effort on reviewing the pieces. > Please find attached patches. > Meson changes - 0001-Support-for-AIX-pg19-meson.2.diff > Complete changes - 0001-Support-for-AIX.pg19.v11.patch > > We have updated couple of changes in the full patch wrt to your previous > comments as well. Also, we are working to get the stats for the s_lock.h wrt > TAS. Will submit in a different thread. Ok, that patch set looks pretty reasonable now. Can you confirm that this is the complete patch set required for AIX support? What version of AIX are you testing with? What compilers are you testing with?
RE: AIX support
> Ok, that patch set looks pretty reasonable now.
Thank you, Peter, for taking the time to review the patches. I really appreciate your feedback, and it’s great to hear your positive assessment.
> Can you confirm that this is the complete patch set required for AIX support?
Yes, the complete patch attached in the previous mail has all the changes for AIX support.
> What version of AIX are you testing with?
We are testing on an AIX 73F node.
> What compilers are you testing with?
Warm regards,
Sriram.
Re: AIX support
Hi,
From what I can tell the meson patch *AGAIN* is missing mkldexport.sh. Also,
you seem to reference the script as files('port/aix/mkldexport.sh'), but that
that's not a path that makes sense for our source code structure (nor where
the "complete" patch adds it).
You really need to actually start testing your patches.
Doesn't the meson patch also require the changes to src/tools/gen_export.pl?
On 2026-01-23 16:11:25 +0000, Srirama Kucherlapati wrote:
> diff --git a/meson.build b/meson.build
> index 6e7ddd74683..17ad9c6ca32 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -198,6 +198,8 @@ endif
> # that purpose.
> portname = host_system
>
> +dep_static_lib = declare_dependency()
Add a comment saying something like
# In some configurations we don't want to install static libraries. For those
# dep_static_lib can be set to disabler() below.
The introduction of dep_static_lib should be broken out into its own patch.
> + # This flag is required to make sure the user spefic float.h is
> + # picked instead of the system float.h header file, which doesnot
> + # have definition like float8, etc
> + cflags += '-D_H_FLOAT'
I don't understand this one - how does defining _H_FLOAT lead to a different
header being picked? Also, float8 is defined in c.h, so it hardly could be
influenced by a system float.h header?
Our float.h header is only included as "utils/float.h", so it really shouldn't
be confused with a system header?
> @@ -1765,10 +1793,49 @@ endforeach
> # 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.
> -alignof_double = cdata.get('ALIGNOF_DOUBLE')
> -if cc.alignment('int64_t', args: test_c_args, prefix: '#include ') > alignof_double
> - error('alignment of int64_t is greater than the alignment of double')
> -endif
> +if host_system != 'aix'
> + alignof_double = cdata.get('ALIGNOF_DOUBLE')
> + if cc.alignment('int64_t', args: test_c_args, prefix: '#include ') > alignof_double
> + error('alignment of int64_t is greater than the alignment of double')
> + endif
> +else
> + # The AIX 'power' alignment rules apply the natural alignment of the "first
> + # member" if it is of a floating-point data type (or is an aggregate whose
> + # recursively "first" member or element is such a type). The alignment
> + # associated with these types for subsequent members use an alignment value
> + # where the floating-point data type is considered to have 4-byte alignment.
> + # More info
> + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99557
> + #
> + # The double is aligned to 4-bytes on AIX in aggregates. But to maintain
> + # alignement across platforms the max alignment of long should be considered.
How are these "AIX 'power' alignment rules" for float not just completely
broken?
I assume this means that 4 byte aligned floats work just fine, but have
degraded peformance?
Is there documentation about this that isn't an already fixed bug report in gcc?
Maybe I'm confused, but doesn't this power alignment rule mean that the
cc.alignment('double') will always return 8? That computation won't apply the
"subsequent member" rule, and therefore will have an alignment of 8. Which in
turn seems to make this entire change pointless?
> + # Get the alignment values
> + ac_cv_alignof_long = cc.alignment('long', args: test_c_args, prefix: '#include ')
> + ac_cv_alignof_double = cc.alignment('double', args: test_c_args, prefix: '#include ')
> + ac_cv_alignof_int64_t = cc.alignment('int64_t', args: test_c_args, prefix: '#include ')
I've previously complained about these av_cv_ variable names. This isn't
autoconf. What is this doing here?
Why do we need a platform specific alignment determination for long, int64?
> + message('Alignment of long : @0@'.format(ac_cv_alignof_long))
> + message('Alignment of double : @0@'.format(ac_cv_alignof_double))
> + message('Alignment of int64_t : @0@'.format(ac_cv_alignof_int64_t))
These are already going to be output by cc.alignment, this is just redundant,
no?
> + # Start with long
> + alignof_double = ac_cv_alignof_long
> + message('MAX ALIGN ac_cv_alignof_long')
> +
> + # Compare with double
> + if alignof_double < ac_cv_alignof_double
> + alignof_double = ac_cv_alignof_double
> + message('MAX ALIGN ac_cv_alignof_double')
> + endif
> +
> + # Compare with int64_t
> + if alignof_double < ac_cv_alignof_int64_t
> + alignof_double = ac_cv_alignof_int64_t
> + message('MAX ALIGN ac_cv_alignof_int64_t')
> + endif
> +endif
> +message('MAX ALIGN OF DOUBLE : @0@'.format(alignof_double))
This is a lot of output for something that's just computing a maximum of three
variables.
> diff --git a/src/backend/meson.build b/src/backend/meson.build
> index b831a541652..4838f245ab3 100644
> --- a/src/backend/meson.build
> +++ b/src/backend/meson.build
> @@ -125,6 +125,24 @@ if host_system == 'windows'
> '--FILEDESC', 'PostgreSQL Server',])
> endif
>
> +if 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
This should be moved next to the msvc specific block (the one about
postgres_def) and should use an elif.
Greetings,
Andres Freund
Re: AIX support
Peter Eisentraut writes:
> Ok, that patch set looks pretty reasonable now.
> Can you confirm that this is the complete patch set required for AIX
> support?
> What version of AIX are you testing with?
> What compilers are you testing with?
I tried to build HEAD with 0001-Support-for-AIX.pg19.v11.patch
on the GCC compile farm (cfarm119.cfarm.net, which is running
AIX 7.3); I used gcc 13.3.0. I observed the following problems:
* The patch's changes to configure do not match those to configure.ac.
I used configure as-patched, so I don't know if it'd work after
re-running autoconf.
* In my tree, mkldexport.sh was created without execute permissions,
causing a build failure. I see that the patch says
new file mode 100755
so this is arguably the fault of the rather hoary version of
patch(1) that cfarm119 has. I mention it mainly to remind the
eventual committer to make sure mkldexport.sh is committed with
the correct permissions.
* I got this:
In file included from ../../../../src/include/postgres.h:48,
from pgstat_slru.c:18:
pgstat_slru.c:60:11: warning: no previous prototype for 'pgstat_count_slru_truncate64' [-Wmissing-prototypes]
60 | CppConcat(pgstat_count_slru_,stat)(int slru_idx) \
| ^~~~~~~~~~~~~~~~~~
../../../../src/include/c.h:429:41: note: in definition of macro 'CppConcat'
429 | #define CppConcat(x, y) x##y
| ^
pgstat_slru.c:84:1: note: in expansion of macro 'PGSTAT_COUNT_SLRU'
84 | PGSTAT_COUNT_SLRU(truncate)
| ^~~~~~~~~~~~~~~~~
and then
ld: 0711-317 ERROR: Undefined symbol: .pgstat_count_slru_truncate
On investigation, this is happening because has
#define truncate truncate64
which causes "PGSTAT_COUNT_SLRU(truncate)" to expand as
"pgstat_count_slru_truncate64", which is not the name declared in
pgstat.h. An even more unfortunate result is that the "truncate"
field in PgStat_SLRUStats might actually be named "truncate64",
depending on whether was read before pgstat.h.
I got around that by partially reverting eccba079c2ea:
diff --git a/src/backend/utils/activity/pgstat_slru.c b/src/backend/utils/activity/pgstat_slru.c
index 2190f388eae..4d8ad3f20fc 100644
--- a/src/backend/utils/activity/pgstat_slru.c
+++ b/src/backend/utils/activity/pgstat_slru.c
@@ -81,7 +81,11 @@ PGSTAT_COUNT_SLRU(blocks_written)
PGSTAT_COUNT_SLRU(flush)
/* pgstat_count_slru_truncate */
-PGSTAT_COUNT_SLRU(truncate)
+void
+pgstat_count_slru_truncate(int slru_idx)
+{
+ get_slru_entry(slru_idx)->truncate += 1;
+}
I didn't have to make any other changes, so it seems that we are
currently consistent about always reading first, but this
seems terribly fragile. We probably need some more-invasive answer,
like changing both the function and field name to "trunc" or something
like that.
* I also got some warnings:
auth.c: In function 'auth_peer':
auth.c:1877:13: warning: implicit declaration of function 'getpeereid' [-Wimplicit-function-declaration]
1877 | if (getpeereid(port->sock, &uid, &gid) != 0)
pg_locale_libc.c: In function 'wchar2char':
pg_locale_libc.c:1243:26: warning: implicit declaration of function 'wcstombs_l'; did you mean 'wcstombs'? [-Wimplicit-function-declaration]
1243 | result = wcstombs_l(to, from, tolen, loc);
fe-connect.c: In function 'PQconnectPoll':
fe-connect.c:3598:45: warning: implicit declaration of function 'getpeereid'; did you mean 'getpwuid'? [-Wimplicit-function-declaration]
3598 | if (getpeereid(conn->sock, &uid, &gid) != 0)
These did not break the build (so the functions do exist...) but
they need to be fixed.
After all that I was able to get through "make" and "make install",
but testing failed immediately:
bash-5.3$ initdb
exec(): 0509-036 Cannot load program initdb because of the following errors:
0509-022 Cannot load module /home/tgl/testversion/lib/libpq.a(libpq.so.5).
0509-150 Dependent module libgcc_s.a(shr.o) could not be loaded.
0509-022 Cannot load module libgcc_s.a(shr.o).
0509-026 System error: A file or directory in the path name does not exist.
So there's something wrong with the make rules for using libpq.so.
I do not know anything about AIX, so I can't debug this.
I was unable to test the meson patches, because meson isn't installed
on this machine.
I haven't actually read the patch, so don't take this as an
endorsement of the changes otherwise.
regards, tom lane
RE: AIX support
Warm regards,
Sriram.
Re: AIX support
Srirama Kucherlapati writes:
> We have set the below flags for building the source
> export OBJECT_MODE=64
> export FLAG64="-maix64"
> export CC__=/opt/freeware/bin//gcc-12
> export CXX__=/opt/freeware/bin//g++-12
> export CC64="${CC__}"
> export CFLAGS="${FLAG64} -O2 "
> export GLOBAL_CC_OPTIONS="-O2"
> export CC="${CC64} "
> export LDFLAGS="-L/opt/freeware/lib64 -L/usr/lib64 -L/opt/freeware/lib -L/usr/lib -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib"
> export LDFLAGS=$LDFLAGS:/opt/freeware/lib64/perl5/5.38/CORE/:
> export PYTHON=/opt/freeware/bin/python3.9
> export AR='/usr/bin/ar -X64’
Ouch. Our normal expectation is that you can build a working
Postgres with nothing more complicated than
./configure && make && make install
(well, maybe you want a nondefault --prefix and some feature
options, but getting to a working executable shouldn't take
much more than that). It's totally not okay to expect users
to preset a bunch of environment variables, especially not if
that requirement appears nowhere in the documentation.
So one TODO item for your patch is to restore (and update)
the AIX-specific portions of the documentation, particularly
the build instructions. But I do not want to see anything as
messy as the above in the build instructions.
After re-reading what used to be in installation.sgml, I'm inclined
to suggest that we just say that only 64-bit builds using gcc are
supported on AIX. Surely the number of users still wanting 32-bit
Postgres on AIX is indistinguishable from zero. Then we could remove
the documentation about likely failure modes of a 32-bit build.
(Also, perhaps we could bake the bits about OBJECT_MODE=64 and -maix64
into the autoconf/meson logic and not burden users with dealing with
those?)
After some digging, I realized that the cause of my build failure with
not finding libgcc_s.a was that you'd removed this stanza that
Makefile.aix used to have:
# 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
I don't really understand how it works for you without that.
I suppose that your explicit setting of LDFLAGS masked the problem,
but doing that did not work for me, which I found was because our
rpath logic overrides any externally-given -Wl,-blibpath setting.
Were you perhaps building with --disable-rpath? In any case, manually
putting every required directory into LDFLAGS is not sustainable.
There's a reason our makefiles work so hard to build that list
automatically.
In any case, once I put back the missing Makefile.aix bit, I was
able to get a working 64-bit build after doing what installation.sgml
used to tell people:
For a 64-bit build, set OBJECT_MODE to 64 and
pass CC="gcc -maix64"
to configure.
(It also said to set LDFLAGS="-Wl,-bbigtoc", but that doesn't
seem to be necessary anymore?)
However, my build doesn't pass the core regression tests. There
is one failure in float8.out, which on investigation is because
lgamma(NaN) is failing (returning ERANGE) instead of silently
returning NaN. That behavior is directly contradictory to what
"man lgamma" says, so I guess they fixed it in recent AIX, but we
probably need a workaround for AIXen that are still in the field.
cfarm119 is running a just slightly back-rev AIX:
$ oslevel -s
7300-01-02-2320
With the patch attached, I can get through "make installcheck".
However, I'm unable to attempt "make check-world" because
src/test/modules/test_cplusplusext doesn't compile:
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2 -fvisibility=hidden -fvisibility-inlines-hidden -I. -I. -I../../../../src/include -c -o test_cplusplusext.o test_cplusplusext.cpp
In file included from ../../../../src/include/c.h:57,
from ../../../../src/include/postgres.h:48,
from test_cplusplusext.cpp:18:
../../../../src/include/pg_config.h:588:24: error: expected unqualified-id before '__int128'
588 | #define PG_INT128_TYPE __int128
| ^~~~~~~~
../../../../src/include/c.h:580:9: note: in expansion of macro 'PG_INT128_TYPE'
580 | typedef PG_INT128_TYPE int128
| ^~~~~~~~~~~~~~
../../../../src/include/pg_config.h:588:24: error: expected unqualified-id before '__int128'
588 | #define PG_INT128_TYPE __int128
| ^~~~~~~~
../../../../src/include/c.h:586:18: note: in expansion of macro 'PG_INT128_TYPE'
586 | typedef unsigned PG_INT128_TYPE uint128
| ^~~~~~~~~~~~~~
make: *** [: test_cplusplusext.o] Error 1
| ^~~~~~~~~~~~~~
make[5]: *** [: test_cplusplusext.o] Error 1
I poked at trying to fix that, without success. This is a
reasonably late-model g++:
$ g++ --version
g++ (GCC) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
so I don't know why it doesn't like __int128. This is very new code,
so there may be a non-AIX-specific issue for us to fix. (But I
could not reproduce the issue on the nearest version I have at hand,
g++ (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7)
from Fedora 38.)
Another thing I noticed: ps status isn't working. (All the postmaster
child processes look the same in "ps auxww".) I suppose you need to
restore the AIX support in ps_status.c.
FWIW, attached is a delta patch showing where I am now (on top of
your v11 patch and the pgstat_slru.c hack I showed earlier).
regards, tom lane
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index b5a7c57e53a..641e7de21a0 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -2852,6 +2852,12 @@ dlgamma(PG_FUNCTION_ARGS)
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
+ /* On some versions of AIX, lgamma(NaN) fails with ERANGE */
+#if defined(_AIX)
+ if (isnan(arg1))
+ PG_RETURN_FLOAT8(arg1);
+#endif
+
/*
* Note: lgamma may not be thread-safe because it may write to a global
* variable signgam, which may not be thread-local. However, this doesn't
diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
index e91b250fd19..d8d8a4d68b0 100644
--- a/src/makefiles/Makefile.aix
+++ b/src/makefiles/Makefile.aix
@@ -6,8 +6,11 @@
# -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
-# AIX uses a stricter, more explicit approach. The runtime linker expects
-# to tell it exactly where to look using -blibpath.
+# 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)'
# gcc needs to know it's building a shared lib, otherwise it'll not emit
Re: AIX support
... btw, I was annoyed to notice that AIX still does this in 64-bit builds: checking size of void *... 8 checking size of size_t... 8 checking size of long... 8 checking size of long long... 8 checking size of intmax_t... 8 checking alignment of short... 2 checking alignment of int... 4 checking alignment of long... 8 checking alignment of int64_t... 8 checking alignment of double... 4 Normally we reject alignof(double) < alignof(int64), for the reasons explained in configure.ac: # 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. I see that your patch summarily overrides that restriction (without bothering to touch this comment), but I fear that the chances of that being acceptable as-is are zero. We're not going to go back to having to count bytes every time we change a system catalog rowtype that involves an 'int8' or 'float8' column. I think the only way we could deal with this in a maintainable fashion would be to remove the assumption that int64 and double have the same alignment requirement. That is tech debt that we really should have cleaned up years ago anyway. The main thing that's discouraged people from pursuing it is the fear of adding overhead to tuple assembly/disassembly loops. But I think maybe we could avoid adding such overhead by mapping two different type alignment symbols at the source-code level into appropriate values at runtime. Or a bunch of conditional compilation, or whatever. Any modern machine is going to have to be able to deal with both 4-byte and 8-byte alignment requirements, it's just a question of which datatypes have which requirement. While I don't foresee that being an enormous patch, it's not trivial either. I'd encourage you to write and submit it as a separate patch rather than something directly tied to the AIX-restoration patch. regards, tom lane
Re: AIX support
I wrote: > With the patch attached, I can get through "make installcheck". > However, I'm unable to attempt "make check-world" because > src/test/modules/test_cplusplusext doesn't compile: Ah, I figured out that bit: g++ will take this if you specify -maix64 to it too. The built module would not have worked anyway without that, since it'd be 32-bit (AFAICT neither gcc nor g++ react to the OBJECT_MODE environment variable). It's not exactly clear why gcc will accept __int128 in 32-bit mode while g++ won't, but that seems like another good reason to decide that we won't support 32-bit builds on AIX anymore. regards, tom lane
RE: AIX support
>> + # picked instead of the system float.h header file, which doesnot
>> + # have definition like float8, etc
>> + cflags += '-D_H_FLOAT’
>I don't understand this one - how does defining _H_FLOAT lead to a >different
>header being picked? Also, float8 is defined in c.h, so it hardly could >be
>influenced by a system float.h header?
>Our float.h header is only included as "utils/float.h", so it really >shouldn’t
>be confused with a system header?
FAILED: src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.ogcc -Isrc/backend/utils/activity/wait_event_names.a.p -Isrc/include/utils -I../src/include/utils -Isrc/include -I../src/include -I/opt/freeware/include -I/opt/freeware/include/libxml2 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation -maix64 -fPIC -pthread -DBUILDING_DLL1233 -MD -MQ src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o -MF src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o.d -o src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o -c ../src/backend/utils/activity/wait_event_funcs.cIn file included from /usr/include/sys/limits.h:307,from /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/include-fixed/stdio.h:589,from ../src/include/c.h:65,from ../src/include/postgres.h:48,from ../src/backend/utils/activity/wait_event_funcs.c:15:../src/include/utils/float.h:28:19: error: expected ';' before 'int'28 | extern PGDLLIMPORT int extra_float_digits;../src/include/utils/float.h:289:37: error: unknown type name 'float4'289 | float4_min(const float4 val1, const float4 val2)../src/include/utils/float.h:294:15: error: unknown type name 'float8'294 | static inline float8
Is there a preferred or cleaner way you know to ensure the correct include ordering like using implicit_include_directories so that utils/float.h is not included before c.h?
Date: Wednesday, 28 January 2026 at 9:34 AM
To: Aditya Kamath <Aditya.Kamath1@ibm.com>
Subject: FW: [EXTERNAL] Re: AIX support
Warm regards,
Sriram.
------------------------------------------
VIOS/SSP Development,
ISDL, IBM India Pvt Ltd.
Date: Monday, 26 January 2026 at 21:11
To: Srirama Kucherlapati <sriram.rk@in.ibm.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>, Heikki Linnakangas <hlinnaka@iki.fi>, Tristan Partin <tristan@partin.io>, AIX PG user <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: [EXTERNAL] Re: AIX support
From what I can tell the meson patch *AGAIN* is missing mkldexport.sh. Also,
you seem to reference the script as files('port/aix/mkldexport.sh'), but that
that's not a path that makes sense for our source code structure (nor where
the "complete" patch adds it).
You really need to actually start testing your patches.
Doesn't the meson patch also require the changes to src/tools/gen_export.pl?
On 2026-01-23 16:11:25 +0000, Srirama Kucherlapati wrote:
> diff --git a/meson.build b/meson.build
> index 6e7ddd74683..17ad9c6ca32 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -198,6 +198,8 @@ endif
> # that purpose.
> portname = host_system
>
> +dep_static_lib = declare_dependency()
Add a comment saying something like
# In some configurations we don't want to install static libraries. For those
# dep_static_lib can be set to disabler() below.
The introduction of dep_static_lib should be broken out into its own patch.
> + # This flag is required to make sure the user spefic float.h is
> + # picked instead of the system float.h header file, which doesnot
> + # have definition like float8, etc
> + cflags += '-D_H_FLOAT'
I don't understand this one - how does defining _H_FLOAT lead to a different
header being picked? Also, float8 is defined in c.h, so it hardly could be
influenced by a system float.h header?
Our float.h header is only included as "utils/float.h", so it really shouldn't
be confused with a system header?
> @@ -1765,10 +1793,49 @@ endforeach
> # 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.
> -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')
> -endif
> +if host_system != 'aix'
> + 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')
> + endif
> +else
> + # The AIX 'power' alignment rules apply the natural alignment of the "first
> + # member" if it is of a floating-point data type (or is an aggregate whose
> + # recursively "first" member or element is such a type). The alignment
> + # associated with these types for subsequent members use an alignment value
> + # where the floating-point data type is considered to have 4-byte alignment.
> + # More info
> + # https://urldefense.proofpoint.com/v2/url?u=https-3A__gcc.gnu.org_bugzilla_show-5Fbug.cgi-3Fid-3D99557&d=DwIBAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=vAjXYU48syuVpPwT4QhmwXMV4E--HIOXIW0gSQS4cHk&m=spxpHlbU-oUOjZWtuXCtkVhprvgA3G5mhMCfcMRz7RhvcqbJQbX0erzJ-MgCiBKp&s=cdf4qUM5zjhQjv8rAUj5eMnRTtNyjaOEuuJFiHMu0uY&e=
> + #
> + # The double is aligned to 4-bytes on AIX in aggregates. But to maintain
> + # alignement across platforms the max alignment of long should be considered.
How are these "AIX 'power' alignment rules" for float not just completely
broken?
I assume this means that 4 byte aligned floats work just fine, but have
degraded peformance?
Is there documentation about this that isn't an already fixed bug report in gcc?
Maybe I'm confused, but doesn't this power alignment rule mean that the
cc.alignment('double') will always return 8? That computation won't apply the
"subsequent member" rule, and therefore will have an alignment of 8. Which in
turn seems to make this entire change pointless?
> + # Get the alignment values
> + ac_cv_alignof_long = cc.alignment('long', args: test_c_args, prefix: '#include <stdint.h>')
> + ac_cv_alignof_double = cc.alignment('double', args: test_c_args, prefix: '#include <stdint.h>')
> + ac_cv_alignof_int64_t = cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>')
I've previously complained about these av_cv_ variable names. This isn't
autoconf. What is this doing here?
Why do we need a platform specific alignment determination for long, int64?
> + message('Alignment of long : @0@'.format(ac_cv_alignof_long))
> + message('Alignment of double : @0@'.format(ac_cv_alignof_double))
> + message('Alignment of int64_t : @0@'.format(ac_cv_alignof_int64_t))
These are already going to be output by cc.alignment, this is just redundant,
no?
> + # Start with long
> + alignof_double = ac_cv_alignof_long
> + message('MAX ALIGN ac_cv_alignof_long')
> +
> + # Compare with double
> + if alignof_double < ac_cv_alignof_double
> + alignof_double = ac_cv_alignof_double
> + message('MAX ALIGN ac_cv_alignof_double')
> + endif
> +
> + # Compare with int64_t
> + if alignof_double < ac_cv_alignof_int64_t
> + alignof_double = ac_cv_alignof_int64_t
> + message('MAX ALIGN ac_cv_alignof_int64_t')
> + endif
> +endif
> +message('MAX ALIGN OF DOUBLE : @0@'.format(alignof_double))
This is a lot of output for something that's just computing a maximum of three
variables.
> diff --git a/src/backend/meson.build b/src/backend/meson.build
> index b831a541652..4838f245ab3 100644
> --- a/src/backend/meson.build
> +++ b/src/backend/meson.build
> @@ -125,6 +125,24 @@ if host_system == 'windows'
> '--FILEDESC', 'PostgreSQL Server',])
> endif
>
> +if 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
This should be moved next to the msvc specific block (the one about
postgres_def) and should use an elif.
Greetings,
Andres Freund
RE: AIX support
>> + # picked instead of the system float.h header file, which doesnot
>> + # have definition like float8, etc
>> + cflags += '-D_H_FLOAT’
>I don't understand this one - how does defining _H_FLOAT lead to a >different
>header being picked?
gcc -Isrc/backend/utils/activity/wait_event_names.a.p -Isrc/include/utils -I../src/include/utils -Isrc/include -I../src/include -I/opt/freeware/include -I/opt/freeware/include/libxml2 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation -maix64 -fPIC -pthread -DBUILDING_DLL1233 -MD -MQ
28 | extern PGDLLIMPORT int extra_float_digits;
#include_next float.h under ifdef _AIX guardKindly let us know if this explanation helps and what you think. Also If there is a preferred or cleaner way you know let us know.
Have a nice day ahead.
Thanks and regards,
Aditya.
Date: Wednesday, 28 January 2026 at 3:55 PM
To: Srirama Kucherlapati <sriram.rk@in.ibm.com>, peter@eisentraut.org <peter@eisentraut.org>, andres@anarazel.de <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>, hlinnaka@iki.fi <hlinnaka@iki.fi>, tristan@partin.io <tristan@partin.io>, postgres-ibm-aix@wwpdl.vnet.ibm.com <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: Re: [EXTERNAL] Re: AIX support
>> + # picked instead of the system float.h header file, which doesnot
>> + # have definition like float8, etc
>> + cflags += '-D_H_FLOAT’
>I don't understand this one - how does defining _H_FLOAT lead to a >different
>header being picked? Also, float8 is defined in c.h, so it hardly could >be
>influenced by a system float.h header?
>Our float.h header is only included as "utils/float.h", so it really >shouldn’t
>be confused with a system header?
FAILED: src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.ogcc -Isrc/backend/utils/activity/wait_event_names.a.p -Isrc/include/utils -I../src/include/utils -Isrc/include -I../src/include -I/opt/freeware/include -I/opt/freeware/include/libxml2 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation -maix64 -fPIC -pthread -DBUILDING_DLL1233 -MD -MQ src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o -MF src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o.d -o src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o -c ../src/backend/utils/activity/wait_event_funcs.cIn file included from /usr/include/sys/limits.h:307,from /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/include-fixed/stdio.h:589,from ../src/include/c.h:65,from ../src/include/postgres.h:48,from ../src/backend/utils/activity/wait_event_funcs.c:15:../src/include/utils/float.h:28:19: error: expected ';' before 'int'28 | extern PGDLLIMPORT int extra_float_digits;../src/include/utils/float.h:289:37: error: unknown type name 'float4'289 | float4_min(const float4 val1, const float4 val2)../src/include/utils/float.h:294:15: error: unknown type name 'float8'294 | static inline float8
Is there a preferred or cleaner way you know to ensure the correct include ordering like using implicit_include_directories so that utils/float.h is not included before c.h?
Date: Wednesday, 28 January 2026 at 9:34 AM
To: Aditya Kamath <Aditya.Kamath1@ibm.com>
Subject: FW: [EXTERNAL] Re: AIX support
Warm regards,
Sriram.
------------------------------------------
VIOS/SSP Development,
ISDL, IBM India Pvt Ltd.
Date: Monday, 26 January 2026 at 21:11
To: Srirama Kucherlapati <sriram.rk@in.ibm.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>, Heikki Linnakangas <hlinnaka@iki.fi>, Tristan Partin <tristan@partin.io>, AIX PG user <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: [EXTERNAL] Re: AIX support
From what I can tell the meson patch *AGAIN* is missing mkldexport.sh. Also,
you seem to reference the script as files('port/aix/mkldexport.sh'), but that
that's not a path that makes sense for our source code structure (nor where
the "complete" patch adds it).
You really need to actually start testing your patches.
Doesn't the meson patch also require the changes to src/tools/gen_export.pl?
On 2026-01-23 16:11:25 +0000, Srirama Kucherlapati wrote:
> diff --git a/meson.build b/meson.build
> index 6e7ddd74683..17ad9c6ca32 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -198,6 +198,8 @@ endif
> # that purpose.
> portname = host_system
>
> +dep_static_lib = declare_dependency()
Add a comment saying something like
# In some configurations we don't want to install static libraries. For those
# dep_static_lib can be set to disabler() below.
The introduction of dep_static_lib should be broken out into its own patch.
> + # This flag is required to make sure the user spefic float.h is
> + # picked instead of the system float.h header file, which doesnot
> + # have definition like float8, etc
> + cflags += '-D_H_FLOAT'
I don't understand this one - how does defining _H_FLOAT lead to a different
header being picked? Also, float8 is defined in c.h, so it hardly could be
influenced by a system float.h header?
Our float.h header is only included as "utils/float.h", so it really shouldn't
be confused with a system header?
> @@ -1765,10 +1793,49 @@ endforeach
> # 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.
> -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')
> -endif
> +if host_system != 'aix'
> + 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')
> + endif
> +else
> + # The AIX 'power' alignment rules apply the natural alignment of the "first
> + # member" if it is of a floating-point data type (or is an aggregate whose
> + # recursively "first" member or element is such a type). The alignment
> + # associated with these types for subsequent members use an alignment value
> + # where the floating-point data type is considered to have 4-byte alignment.
> + # More info
> + # https://urldefense.proofpoint.com/v2/url?u=https-3A__gcc.gnu.org_bugzilla_show-5Fbug.cgi-3Fid-3D99557&d=DwIBAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=vAjXYU48syuVpPwT4QhmwXMV4E--HIOXIW0gSQS4cHk&m=spxpHlbU-oUOjZWtuXCtkVhprvgA3G5mhMCfcMRz7RhvcqbJQbX0erzJ-MgCiBKp&s=cdf4qUM5zjhQjv8rAUj5eMnRTtNyjaOEuuJFiHMu0uY&e=
> + #
> + # The double is aligned to 4-bytes on AIX in aggregates. But to maintain
> + # alignement across platforms the max alignment of long should be considered.
How are these "AIX 'power' alignment rules" for float not just completely
broken?
I assume this means that 4 byte aligned floats work just fine, but have
degraded peformance?
Is there documentation about this that isn't an already fixed bug report in gcc?
Maybe I'm confused, but doesn't this power alignment rule mean that the
cc.alignment('double') will always return 8? That computation won't apply the
"subsequent member" rule, and therefore will have an alignment of 8. Which in
turn seems to make this entire change pointless?
> + # Get the alignment values
> + ac_cv_alignof_long = cc.alignment('long', args: test_c_args, prefix: '#include <stdint.h>')
> + ac_cv_alignof_double = cc.alignment('double', args: test_c_args, prefix: '#include <stdint.h>')
> + ac_cv_alignof_int64_t = cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>')
I've previously complained about these av_cv_ variable names. This isn't
autoconf. What is this doing here?
Why do we need a platform specific alignment determination for long, int64?
> + message('Alignment of long : @0@'.format(ac_cv_alignof_long))
> + message('Alignment of double : @0@'.format(ac_cv_alignof_double))
> + message('Alignment of int64_t : @0@'.format(ac_cv_alignof_int64_t))
These are already going to be output by cc.alignment, this is just redundant,
no?
> + # Start with long
> + alignof_double = ac_cv_alignof_long
> + message('MAX ALIGN ac_cv_alignof_long')
> +
> + # Compare with double
> + if alignof_double < ac_cv_alignof_double
> + alignof_double = ac_cv_alignof_double
> + message('MAX ALIGN ac_cv_alignof_double')
> + endif
> +
> + # Compare with int64_t
> + if alignof_double < ac_cv_alignof_int64_t
> + alignof_double = ac_cv_alignof_int64_t
> + message('MAX ALIGN ac_cv_alignof_int64_t')
> + endif
> +endif
> +message('MAX ALIGN OF DOUBLE : @0@'.format(alignof_double))
This is a lot of output for something that's just computing a maximum of three
variables.
> diff --git a/src/backend/meson.build b/src/backend/meson.build
> index b831a541652..4838f245ab3 100644
> --- a/src/backend/meson.build
> +++ b/src/backend/meson.build
> @@ -125,6 +125,24 @@ if host_system == 'windows'
> '--FILEDESC', 'PostgreSQL Server',])
> endif
>
> +if 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
This should be moved next to the msvc specific block (the one about
postgres_def) and should use an elif.
Greetings,
Andres Freund
Re: AIX support
On Mon, Jan 26, 2026 at 10:41 AM Andres Freund wrote: > You really need to actually start testing your patches. +1. The quality of the patches posted to this thread is very noticeably lower than what we typically expect or accept. They are missing files, or they don't work, or the changes are not properly explained, or they do things that are clearly unlike anything else we do anywhere in the source tree, or they change how things work for other platforms rather than just being AIX-specific, or they don't work unless you follow a bunch of undocumented steps, or whatever the case may be. -- Robert Haas EDB: http://www.enterprisedb.com
Re: AIX support
On Wed, Jan 28, 2026 at 10:20 AM Aditya Kamath wrote:
> But here is the catch. It won’t pick the AIX system float.h. It will pick the Postgres "src/include/utilsfloat.h”.
PostgreSQL's header should always be included as "utils/float.h" and
the system header should always be included as "float.h" (or, well,
, presumably). So this confusion should not exist unless the
include paths are messed up. It doesn't seem correct to me that the
include path includes src/include/utils rather than just src/include,
but I see the same thing here:
"command": "ccache clang
-Isrc/backend/utils/activity/wait_event_names.a.p -Isrc/include/utils
-I../pgsql/src/include/utils -Isrc/include -I../pgsql/src/include
-I/opt/local/include -I/opt/local/include/libxml2
-I/opt/local/libexec/openssl3/include -fdiagnostics-color=always -Wall
-Winvalid-pch -O2 -g -isysroot
/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk
-fno-strict-aliasing -fwrapv -fexcess-precision=standard
-Wmissing-prototypes -Wpointer-arith -Werror=vla
-Werror=unguarded-availability-new -Wendif-labels
-Wmissing-format-attribute -Wcast-function-type -Wformat-security
-Wdeclaration-after-statement -Wmissing-variable-declarations
-Wno-unused-command-line-argument -Wno-compound-token-split-by-macro
-Wno-format-truncation -Wno-cast-function-type-strict -DBUILDING_DLL
-MD -MQ src/backend/utils/activity/wait_event_names.a.p/wait_event.c.o
-MF src/backend/utils/activity/wait_event_names.a.p/wait_event.c.o.d
-o src/backend/utils/activity/wait_event_names.a.p/wait_event.c.o -c
../pgsql/src/backend/utils/activity/wait_event.c",
which happens because of:
wait_event = static_library('wait_event_names',
waitevent_sources,
dependencies: [backend_code],
include_directories: include_directories('../../../include/utils'),
kwargs: internal_lib_args,
)
which happens because wait_event_funcs.c contains:
#include "wait_event_funcs_data.c"
and for some reason, that file gets placed in src/include/utils.
The attached patch, which also adjusts wait_events.c, fixes it for me.
This is kind of a good example of how you are not pursuing your goals
here in the best way possible. The issue here is legitimate, in the
sense that including src/include/utils in the include path for some
file doesn't seem legit to me. But fixing that problem by defining,
just on AIX, the same symbol that the system header defines seems like
clearly the wrong fix. What if we needed to include the actual float.h
somewhere? What if the problem also occurred on some other platform?
Please put a bit more thought into the right ways to (1) describe the
things you find to us and (2) fix them.
Thanks,
--
Robert Haas
EDB: http://www.enterprisedb.com
Re: AIX support
On 2026-Jan-28, Aditya Kamath wrote:
> Below is the error message we get in AIX if we do not use '-D_H_FLOAT’
> FAILED: src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o
> gcc -Isrc/backend/utils/activity/wait_event_names.a.p -Isrc/include/utils -I../src/include/utils -Isrc/include -I../src/include -I/opt/freeware/include -I/opt/freeware/include/libxml2 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation -maix64 -fPIC -pthread -DBUILDING_DLL1233 -MD -MQ
> ./src/include/utils/float.h:28:19: error: expected ';' before 'int'
> 28 | extern PGDLLIMPORT int extra_float_digits;
This makes no sense to me.
> There is a clear missing of float.h definitions, the reason being
> float.h got included before "src/include/c.h”.
We have a rule that postgres.h must always go first in all our backend
source files, and wait_event_funcs.c is no exception. This file
includes postgres.h before anything else; and postgres.h in turns
includes c.h before anything else. So the claim that "float.h" got
somehow included before c.h is not easy to believe. Also,
wait_event_funcs.c does not include "float.h".
Note also that we don't have all that many places that include
. So why is float.h being included by wait_event_names.c?
> Kindly observe the command "-I../src/include/utils” flag came in the front.
This only means that if your source code asks for any files to be
included, they will be sought there. It does not imply to actually
include any files.
Maybe you can post the output of doing "gcc -E" for the file where this
breaks in your system (without the -D_FLOAT_H of course), that is the
output of the C preprocessor, to try to understand what it is doing.
... Oh, I see now that gcc's manpage says there's a distinction between
-I and -iquote:
-I dir
-iquote dir
[...]
Directories specified with -iquote apply only to the
quote form of the directive, "#include "file"".
Directories specified with -I, -isystem, or -idirafter
apply to lookup for both the "#include "file"" and
"#include " directives.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end." (2nd Commandment for C programmers)
Re: AIX support
Hi,
On 2026-01-28 10:41:52 -0500, Robert Haas wrote:
> On Wed, Jan 28, 2026 at 10:20 AM Aditya Kamath wrote:
> > But here is the catch. It won’t pick the AIX system float.h. It will pick the Postgres "src/include/utilsfloat.h”.
>
> PostgreSQL's header should always be included as "utils/float.h" and
> the system header should always be included as "float.h" (or, well,
> , presumably). So this confusion should not exist unless the
> include paths are messed up. It doesn't seem correct to me that the
> include path includes src/include/utils rather than just src/include,
> but I see the same thing here:
I agree that this is wrong.
CCing Michael and Bertrand, they added this in fa88928470b5 and 1e68e43d3f0f.
> which happens because of:
>
> wait_event = static_library('wait_event_names',
> waitevent_sources,
> dependencies: [backend_code],
> include_directories: include_directories('../../../include/utils'),
> kwargs: internal_lib_args,
> )
>
> which happens because wait_event_funcs.c contains:
>
> #include "wait_event_funcs_data.c"
>
> and for some reason, that file gets placed in src/include/utils.
The reason for that is that the same invocation also generates
wait_event_types.h, which is included by other headers.
> The attached patch, which also adjusts wait_events.c, fixes it for me.
Unfortunately I suspect that'll cause issues with make builds, because there
the files are generated in a different place (src/backend/activity) and then
only wait_event_types.h is copied to src/include. So including the files as
utils/ won't work.
I'd fix that aspect by doing the same thing in the autoconf build as we do in
meson, i.e. keep the file in the include dir. We already do that e.g. for
guc_tables.inc.c, see this src/backend/utils/Makefile stanza:
# These generated headers must be symlinked into src/include/.
# We use header-stamp to record that we've done this because the symlinks
# themselves may appear older than fmgr-stamp.
$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h guc_tables.inc.c
cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h guc_tables.inc.c; do \
rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
done
touch $@
Alternatively: I'm not a fan of including .c files that are not actually
working C. You could just make wait_event_funcs_data.c be a complete C file,
defining waitEventData, that is then built as a standalone file.
Greetings,
Andres Freund
Re: AIX support
I wrote: > I think the only way we could deal with this in a maintainable > fashion would be to remove the assumption that int64 and double > have the same alignment requirement. That is tech debt that > we really should have cleaned up years ago anyway. In hopes of moving this effort along, I've posted a draft patch for that part here: https://www.postgresql.org/message-id/1127261.1769649624%40sss.pgh.pa.us We are running out of time to make this happen for v19, so I suggest focusing your effort if you don't want to see AIX support slide for another year. regards, tom lane
RE: AIX support
> In hopes of moving this effort along, I've posted a draft patch
> for that part here:
Warm regards,
Sriram.
Re: AIX support
On 2026-Jan-28, Robert Haas wrote:
> [...]
> which happens because wait_event_funcs.c contains:
>
> #include "wait_event_funcs_data.c"
>
> and for some reason, that file gets placed in src/include/utils.
>
> The attached patch, which also adjusts wait_events.c, fixes it for me.
Hmm, I think this setup is bogus and that your patch is clearly an
improvement. Unfortunately, it doesn't work under Make using a VPATH
build; see below.
> This is kind of a good example of how you are not pursuing your goals
> here in the best way possible.
I agree.
It seems the files are being generated in the wrong place
(src/backend/utils/activity). This is what I get:
make -C utils/activity wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
'/usr/bin/perl' /pgsql/source/master/src/backend/utils/activity/generate-wait_event_types.pl --code /pgsql/source/master/src/backend/utils/activity/wait_event_names.txt
make[2]: 'pgstat_wait_event.c' is up to date.
make[2]: Nothing to be done for 'wait_event_funcs_data.c'.
prereqdir=`cd 'utils/activity/' >/dev/null && pwd` && \
cd '../../src/include/utils/' && rm -f wait_event_types.h && \
ln -s "$prereqdir/wait_event_types.h" .
[... much later ...]
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wmissing-variable-declarations -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2 -I. -I/pgsql/source/master/src/backend/utils/activity -I../../../../src/include -I/pgsql/source/master/src/include -D_GNU_SOURCE -c -o wait_event.o /pgsql/source/master/src/backend/utils/activity/wait_event.c -MMD -MP -MF .deps/wait_event.Po
/pgsql/source/master/src/backend/utils/activity/wait_event.c:506:10: fatal error: utils/pgstat_wait_event.c: No such file or directory
506 | #include "utils/pgstat_wait_event.c"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[4]: *** [../../../../src/Makefile.global:972: wait_event.o] Error 1
make[3]: *** [/pgsql/source/master/src/backend/common.mk:37: activity-recursive] Error 2
make[2]: *** [/pgsql/source/master/src/backend/common.mk:37: utils-recursive] Error 2
Now I have these files:
$ find . -name \*wait_event\*.[ch]
./src/backend/utils/activity/wait_event_types.h
./src/backend/utils/activity/pgstat_wait_event.c
./src/backend/utils/activity/wait_event_funcs_data.c
./src/include/utils/wait_event_types.h
Not sure what a good fix for this is.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"I am amazed at [the pgsql-sql] mailing list for the wonderful support, and
lack of hesitasion in answering a lost soul's question, I just wished the rest
of the mailing list could be like this." (Fotis)
https://postgr.es/m/200606261359.k5QDxE2p004593@auth-smtp.hol.gr
RE: AIX support
>meson, i.e. keep the file in the include dir. We already do that e.g. for
>guc_tables.inc.c, see this src/backend/utils/Makefile stanza:
># These generated headers must be symlinked into src/include/.
># We use header-stamp to record that we've done this because the symlinks
># themselves may appear older than fmgr-stamp.
>$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h >probes.h guc_tables.inc.c
> cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h >guc_tables.inc.c; do \
> rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
> done
> touch $@
lrwxrwxrwx 1 root system 59 Jan 29 06:49 ./src/include/utils/wait_event_funcs_data.c -> ../../../src/backend/utils/activity/wait_event_funcs_data.c
>sense that including src/include/utils in the include path for some
>file doesn't seem legit to me. But fixing that problem by defining,
>just on AIX, the same symbol that the system header defines seems like
>clearly the wrong fix. What if we needed to include the actual float.h
>somewhere? What if the problem also occurred on some other platform?
>Please put a bit more thought into the right ways to (1) describe the
>things you find to us and (2) fix them.
You're right: adding src/include/utils to the include path was not legitimate and defining _H_FLOAT on AIX was only masking the underlying ordering issue rather than solving it correctly. After re‑evaluating the problem, I agree that the real fix is to go with the way we all along are discussing suggested in the last couple of threads.
Hope this works for all of us. Let us know if we missed something or did it wrong.
Will send a git format patch for meson build tool after this thread for review which will include all this information and what Tom suggested for the alignment such that one can git apply the patch and build using meson in AIX.
Once again thank you for all your inputs.
Have a nice day ahead.
Thanks and regards,
Aditya.
Date: Wednesday, 28 January 2026 at 11:03 PM
To: Robert Haas <robertmhaas@gmail.com>, Michael Paquier <michael@paquier.xyz>
Cc: Aditya Kamath <Aditya.Kamath1@ibm.com>, Srirama Kucherlapati <sriram.rk@in.ibm.com>, peter@eisentraut.org <peter@eisentraut.org>, pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>, hlinnaka@iki.fi <hlinnaka@iki.fi>, tristan@partin.io <tristan@partin.io>, postgres-ibm-aix@wwpdl.vnet.ibm.com <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: [EXTERNAL] Re: AIX support
On 2026-01-28 10:41:52 -0500, Robert Haas wrote:
> On Wed, Jan 28, 2026 at 10:20 AM Aditya Kamath <Aditya.Kamath1@ibm.com> wrote:
> > But here is the catch. It won’t pick the AIX system float.h. It will pick the Postgres "src/include/utilsfloat.h”.
>
> PostgreSQL's header should always be included as "utils/float.h" and
> the system header should always be included as "float.h" (or, well,
> <float.h>, presumably). So this confusion should not exist unless the
> include paths are messed up. It doesn't seem correct to me that the
> include path includes src/include/utils rather than just src/include,
> but I see the same thing here:
I agree that this is wrong.
CCing Michael and Bertrand, they added this in fa88928470b5 and 1e68e43d3f0f.
> which happens because of:
>
> wait_event = static_library('wait_event_names',
> waitevent_sources,
> dependencies: [backend_code],
> include_directories: include_directories('../../../include/utils'),
> kwargs: internal_lib_args,
> )
>
> which happens because wait_event_funcs.c contains:
>
> #include "wait_event_funcs_data.c"
>
> and for some reason, that file gets placed in src/include/utils.
The reason for that is that the same invocation also generates
wait_event_types.h, which is included by other headers.
> The attached patch, which also adjusts wait_events.c, fixes it for me.
Unfortunately I suspect that'll cause issues with make builds, because there
the files are generated in a different place (src/backend/activity) and then
only wait_event_types.h is copied to src/include. So including the files as
utils/ won't work.
I'd fix that aspect by doing the same thing in the autoconf build as we do in
meson, i.e. keep the file in the include dir. We already do that e.g. for
guc_tables.inc.c, see this src/backend/utils/Makefile stanza:
# These generated headers must be symlinked into src/include/.
# We use header-stamp to record that we've done this because the symlinks
# themselves may appear older than fmgr-stamp.
$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h guc_tables.inc.c
cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h guc_tables.inc.c; do \
rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
done
touch $@
Alternatively: I'm not a fan of including .c files that are not actually
working C. You could just make wait_event_funcs_data.c be a complete C file,
defining waitEventData, that is then built as a standalone file.
Greetings,
Andres Freund
RE: AIX support
Hi Tom,
Thank you for taking the time to review the patch and share your feedback.
We are currently working on the comments related to performing a regular build
>So one TODO item for your patch is to restore (and update)
>the AIX-specific portions of the documentation, particularly
>the build instructions.
We are updating the AIX‑specific documentation accordingly. Would you prefer these details to be added in configure or included in installation.sgml?
>to suggest that we just say that only 64-bit builds using gcc are
>supported on AIX. Surely the number of users still wanting 32-bit
>Postgres on AIX is indistinguishable from zero.
We are now building only 64‑bit on AIX by default, aligning both OBJECT_MODE and the -maix64 flag in configure as well as in src/template/aix.
> seem to be necessary anymore?)
> is one failure in float8.out, which on investigation is because
>lgamma(NaN) is failing (returning ERANGE) instead of silently
>returning NaN.
>so I don't know why it doesn't like __int128. This is very new code,
>so there may be a non-AIX-specific issue for us to fix.
>Another thing I noticed: ps status isn't working. (All the postmaster
>child processes look the same in "ps auxww".) I suppose you need to
>restore the AIX support in ps_status.c.
> FWIW, attached is a delta patch showing where I am now (on top of
> your v11 patch and the pgstat_slru.c hack I showed earlier).
Thank you for the patch.
I will keep you updated once all the changes have been finalized.
Warm regards,
Sriram.
Re: AIX support
On Wed, Jan 28, 2026 at 12:33:01PM -0500, Andres Freund wrote: > Unfortunately I suspect that'll cause issues with make builds, because there > the files are generated in a different place (src/backend/activity) and then > only wait_event_types.h is copied to src/include. So including the files as > utils/ won't work. Sorry for the crickets and the delay in replying. > I'd fix that aspect by doing the same thing in the autoconf build as we do in > meson, i.e. keep the file in the include dir. We already do that e.g. for > guc_tables.inc.c, see this src/backend/utils/Makefile stanza: > > # These generated headers must be symlinked into src/include/. > # We use header-stamp to record that we've done this because the symlinks > # themselves may appear older than fmgr-stamp. > $(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h guc_tables.inc.c > cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h guc_tables.inc.c; do \ > rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \ > done > touch $@ Yeah, using this route would be sensible, removing the trick with the incorrect include dir. Let me a couple of hours to see if I can sort out a patch.. Should any of these be backpatched, actually? Based on the lack of complaints, it does not seem so to me, but if we are targetting a backpatch of the AIX port, that would be required. > Alternatively: I'm not a fan of including .c files that are not actually > working C. You could just make wait_event_funcs_data.c be a complete C file, > defining waitEventData, that is then built as a standalone file. FWIW, that does not strike me as an issue. We do some of that already in src/backend/nodes/ for the switch files. It comes down to simpler scripts generating the code. -- Michael
Re: AIX support
Michael Paquier writes: > Should any of these be backpatched, actually? Based on the lack of > complaints, it does not seem so to me, but if we are targetting a > backpatch of the AIX port, that would be required. There's no plan to backpatch the AIX port ... but if we can clean up this include-path mess not too invasively, I think it might be a good idea to back-patch that much. I'm concerned that confusion between and utils/float.h might be a problem on other platforms too. regards, tom lane
Re: AIX support
On Thu, Jan 29, 2026 at 06:48:37PM -0500, Tom Lane wrote: > Michael Paquier writes: >> Should any of these be backpatched, actually? Based on the lack of >> complaints, it does not seem so to me, but if we are targetting a >> backpatch of the AIX port, that would be required. > > There's no plan to backpatch the AIX port ... but if we can clean > up this include-path mess not too invasively, I think it might be > a good idea to back-patch that much. I'm concerned that confusion > between and utils/float.h might be a problem on other > platforms too. Noted. Attached is the patch I am finishing with, tested with meson and configure/make with and without VPATH. While looking at the whole object dependency tree in the builds, I have settled down to a reuse of the same logic as guc_tables.inc.c for configure/make, by pushing down one level the generation of the three wait event files. These are not anymore saved in src/backend/utils/activity/, just src/backend/utils/, including them under header-stamp. Building directly in src/backend/utils/activity/ also works, with two rules in src/backend/utils/activity/Makefile to force a rebuild. The files are then included as if they were in include/utils/, with the generation of links from src/backend/utils/ to src/include/utils/, just like guc_tables.inc.c. That's the least invasive method I could come up with. I have run out of tokens for the CI this month, so I have not been able to check it there. My manual tests across all three build methods are working. -- Michael
Re: AIX support
On Fri, Jan 30, 2026 at 01:38:42PM +0900, Michael Paquier wrote: > While looking at the whole object dependency tree in the builds, I > have settled down to a reuse of the same logic as guc_tables.inc.c for > configure/make, by pushing down one level the generation of the three > wait event files. These are not anymore saved in > src/backend/utils/activity/, just src/backend/utils/, including them > under header-stamp. Building directly in src/backend/utils/activity/ > also works, with two rules in src/backend/utils/activity/Makefile to > force a rebuild. The files are then included as if they were in > include/utils/, with the generation of links from src/backend/utils/ > to src/include/utils/, just like guc_tables.inc.c. That's the least > invasive method I could come up with. > > I have run out of tokens for the CI this month, so I have not been > able to check it there. My manual tests across all three build > methods are working. Scratch that a bit.. Some grepping is pointing out that generated_sources_ac would become incorrect in src/include/utils/meson.build. Three paths in wait_event_names.txt were also inconsistent. It is worth noting that the sgml path is entirely wrong, this is generated in doc/src/sgml/. Comments and thoughts are welcome. -- Michael
RE: AIX support
Thanks Michael for this patch. — we applied it on my AIX setup and can confirm that it works correctly here. The include‑path issue is resolved with the changes.
We’ve taken your patch along with the maintainers earlier suggestions and combined them into a single, consolidated Meson patch that aligns with the Autoconf build layout. This version can serve as the first patch to land for enabling PostgreSQL to build via Meson on AIX.
One can git apply the attachment ( See: 0001-Add-AIX-support-for-Postgresql-using-meson-build-too.patch) to the master branch of Postgres. Have also summarised all the topics discussed so far in the commit message with the links and build instructions.
The default compilation mode in AIX is 32 bit even today. So, the ar command triggeried via meson in AIX to archive shared libraries will need the OBJECT_MODE set to 64 which is the only flag we need to set. Rest will all come via the build.
This patch covers only the Meson build system. We will handle the GNU configure/make changes for AIX in a separate thread, since there is already ongoing discussion on that front.
The patch incorporates all the points discussed, including:
1. Supporting only 64‑bit builds on AIX
2. Allowing both static and shared builds, with AIX using shared libraries
3. Including Tom’s fix for the max‑alignment issue
4. The usage of scripts for their respective purposes
5. Fixing the header include‑path issue we have been discussing
Thank you everyone for your support and guidance so far — much appreciated. Kindly review and let me know if anything further is needed.
References to prior discussion threads:
[0] https://www.postgresql.org/message-id/e8aa97db-872b-4087-b073-f296baae948d@eisentraut.org
[1] https://www.postgresql.org/message-id/1127261.1769649624%40sss.pgh.pa.us
Kindly review the patch and let me know if there is any adjustments needed or if we missed something.
Once again thank you all for the effort, discussions and guidance given.
Have a nice day ahead.
Best regards,
Aditya.
Re: AIX support
On Fri, Jan 30, 2026 at 11:41:51AM +0000, Aditya Kamath wrote: > Thanks Michael for this patch. — we applied it on my AIX setup and > can confirm that it works correctly here. The include‑path issue is > resolved with the changes. Thanks for the feedback and checking the patch, I'll try to look at that again at the beginning of next week, with more tests in the CI. -- Michael
Re: AIX support
On Fri, Jan 30, 2026 at 11:41:51AM +0000, Aditya Kamath wrote: > Thanks Michael for this patch. — we applied it on my AIX setup and > can confirm that it works correctly here. The include‑path issue is > resolved with the changes. I have done more tests with this patch, and committed it down to v17. This had some conflicts on v18 and v17 to due guc_tables.inc.c not existing there, but nothing huge. I have tested the patch with the CI across all the branches, in case, combined with local tests for meson and configure, VPATH included. If somebody notices anything, please feel free to ping me here. -- Michael
Re: AIX support
I thought it might be a good idea to take a step back and survey the landscape for this patch. Back when we decided to drop AIX support for v17, several senior hackers opined that we ought to kill it off permanently, eg Noah said "There's no way forward in which AIX support stops doing net harm" [1] and Andres said "The only platform rivalling AIX on the pain-caused metric is windows. And at least that can be tested via CI (or locally). We've been relying on the gcc buildfarm to be able to maintain AIX at all, and that's not a resource that scales to many users" [2]. Have things really changed enough to justify reversing those opinions? I think perhaps they have, based on these things: 1. AIX 7.1 is now EOL, and people seem comfortable with not re-supporting it. 2. People also seem comfortable with only supporting gcc not xlr (and reasonably late-model gcc, to avoid some old bugs therein). We are probably also okay with only supporting 64-bit builds. 3. We have a buildfarm animal running AIX 7.3 (douc); currently it only builds the pre-v17 branches, but that is easy to adjust once a patch lands. It'd be better if douc were using --enable-tap-tests, but at least it's there. 4. We have some support now from IBM people. I looked through the specific pain points that have been mentioned in this thread and others, and most though not all seem to be solved or soluble in this landscape. Past problems include: * failure to honor PG_IO_ALIGN_SIZE on a static variable https://www.postgresql.org/message-id/20240224172345.32%40rfd.leadboat.com My testing says this is fixed in AIX 7.3. * xlc codegen bugs affecting timetz https://postgr.es/m/CA+hUKGK=DOC+hE-62FKfZy=Ybt5uLkrg3zCZD-jFykM-iPn8yw%40mail.gmail.com Dropping xlc support resolves this (and some other problems I've not bothered to list here). Live problems with the current patch include: * int8 vs float8 alignment issue The configure changes in the present patch are hacky, and worse they do not solve the problem: we'd still need weird coding rules for any float8 column in the system catalogs. I have a proposal here: https://www.postgresql.org/message-id/flat/1127261.1769649624%40sss.pgh.pa.us which is reasonably clean code-wise but would force a dump-and-reload rather than pg_upgrade to go from <= v16 to v19. Is that good enough? * s_lock.h changes: it's not okay to change anything affecting non-AIX I've done a little research on this topic, which I'll include in a separate message. * -D_H_FLOAT hack This should no longer be necessary after Michael's commit d46aa32ea. * do we really still need mkldexport.sh? I can understand people's distaste for this, but in the big scheme of things I don't find it to be a showstopper. It'd be nice if someone who's familiar with the relevant AIX tools would annotate it with some comments explaining what it's doing, though. * assorted random changes in the meson.build files What we had before 0b16bb877 worked; it didn't support xlc but that's now moot. So it's not clear why this patch is introducing things like dep_static_lib, and the lack of comments about that doesn't help. * patch is missing documentation, ps_status.c, and a few other fixes This stuff does not seem like a major amount of work, but it does need to get done. So, with the possible exception of the int8/float8 alignment issue, it seems to me we're within striking distance of a committable patch. I wonder whether anyone still wants to argue that AIX support is unsustainable on these terms. My own opinion is that it's probably okay, and we can always rip it out again if IBM fails to follow through on support from their end. regards, tom lane [1] https://www.postgresql.org/message-id/20240225194322.a5%40rfd.leadboat.com [2] https://www.postgresql.org/message-id/20240229093531.zc5bpnfhpwz5fulx%40alap3.anarazel.de
Re: AIX support
I wrote:
> * s_lock.h changes: it's not okay to change anything affecting non-AIX
> I've done a little research on this topic, which I'll include in a
> separate message.
So, as previously mentioned, the problem with what the v11 patch
does in s_lock.h is that it changes the implementation of spinlocks
for every PPC platform not only AIX. We would accept that given
proof that __sync_lock_test_and_set() is as good or better than the
existing hand-rolled assembler on every PPC platform. But you've
offered no such proof and it seems like sufficient evidence would be
pretty hard to come by. I think you're far better off not changing
this code for non-AIX in the initial commit. We can always revisit
the topic later at leisure.
There are a couple of ways you could do that. An easy answer is
some #ifdefs:
static __inline__ int
tas(volatile slock_t *lock)
{
+#ifndef _AIX
slock_t _t;
int _res;
...
: "memory", "cc");
return _res;
+#else
+ return __sync_lock_test_and_set(lock, 1);
+endif
}
However, I wonder whether you've even proven that
__sync_lock_test_and_set is a win on AIX. On the same principle
of "get it working again first and optimize later", it might be
better to resurrect the longstanding asm implementation and then
later look into whether the compiler intrinsic improves matters.
One way to do that is to undo what Heikki did in 0b16bb877, and
put back the hard-wired branch offsets I introduced in c41a1215f.
But I totally sympathize with Heikki's edits: those hard-wired
offsets were hard to read and harder to maintain. Googling led
me to another answer: we can use gcc's "%=" insn counter to
generate normal assembler labels that are distinct across
multiple uses of TAS(). I don't know why we didn't choose
this approach in 2015, other than that I didn't know of that
feature personally. Some archaeology shows that gcc has had
"%=" since gcc 2.0, so it's hardly too new.
Hence, I suggest the attached alternative solution, at least for
the first pass at this. I've checked that this works on both AIX
(cfarm119) and NetBSD/ppc (mamba's host).
regards, tom lane
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 2522cae0c31..d6c16bce31e 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -411,6 +411,11 @@ typedef unsigned int slock_t;
* an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
* But if the spinlock is in ordinary memory, we can use lwsync instead for
* better performance.
+ *
+ * Ordinarily, we'd code the branches here using GNU-style local symbols, that
+ * is "1f" referencing "1:" and so on. But some people run gcc on AIX with
+ * IBM's assembler as backend, and IBM's assembler doesn't do local symbols.
+ * Instead, use %= to make the symbols unique.
*/
static __inline__ int
tas(volatile slock_t *lock)
@@ -421,17 +426,17 @@ tas(volatile slock_t *lock)
__asm__ __volatile__(
" lwarx %0,0,%3,1 \n"
" cmpwi %0,0 \n"
-" bne 1f \n"
+" bne TAS_fail%= \n"
" addi %0,%0,1 \n"
" stwcx. %0,0,%3 \n"
-" beq 2f \n"
-"1: \n"
+" beq TAS_ok%= \n"
+"TAS_fail%=: \n"
" li %1,1 \n"
-" b 3f \n"
-"2: \n"
+" b TAS_out%= \n"
+"TAS_ok%=: \n"
" lwsync \n"
" li %1,0 \n"
-"3: \n"
+"TAS_out%=: \n"
: "=&b"(_t), "=r"(_res), "+m"(*lock)
: "r"(lock)
: "memory", "cc");
RE: AIX support
Based on your feedback for the s_lock.h changes, we have integrated the changes to our patch and tested the same in our environment (Power AIX and Power Linux).
Please git apply this patch and kindly build using meson in AIX. Build instructions and the patch summary are in the commit message.
>1. AIX 7.1 is now EOL, and people seem comfortable with not
>re-supporting it.
>2. People also seem comfortable with only supporting gcc not xlr
>(and reasonably late-model gcc, to avoid some old bugs therein).
>We are probably also okay with only supporting 64-bit builds.
One example is meson as mentioned in the document here.
>* int8 vs float8 alignment issue
>The configure changes in the present patch are hacky, and worse they
>do not solve the problem: we'd still need weird coding rules for any
>float8 column in the system catalogs.
>which is reasonably clean code-wise but would force a dump-and-reload
>rather than pg_upgrade to go from <= v16 to v19. Is that good enough?
>* s_lock.h changes: it's not okay to change anything affecting non-AIX
>I've done a little research on this topic, which I'll include in a
>separate message.
We have checked your changes and integrated the same in this version of the patch which worked. Thank you once again for the same. Please check the s_lock.h file in this patch.
>* -D_H_FLOAT hack
>This should no longer be necessary after Michael's commit d46aa32ea.
>* do we really still need mkldexport.sh?
>I can understand people's distaste for this, but in the big scheme
>of things I don't find it to be a showstopper. It'd be nice if
>someone who's familiar with the relevant AIX tools would annotate
> it with some comments explaining what it's doing, though.
Yes Tom. We have added the comment in the "src/backend/meson.build” file. Please check the same.
AIX does not automatically make symbols from an executable available to shared modules at runtime. As a result, extension modules cannot resolve references to functions in the main postgres binary unless those symbols are explicitly exported. On AIX an executable is not a default provider of symbols; shared modules must link against an export list that specifies exactly which symbols they may import. The mkldexport.sh script uses nm command to extract symbols from the object files that form the postgres executable and generates this export list. When invoked with ".", the script emits "#! .", indicating that the export list refers to the main executable itself, which in turn allows extension libraries to resolve their undefined symbols against the postgres binary. The linker flags -Wl,-bE:<exportfile> mark symbols exported by the postgres binary, while -Wl,-bI:<exportfile> instruct the AIX linker/loader to import those symbols for a shared module that depends on them. So while making the Postgres binary the line
backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path())
Creates a -Wl,bE:<path>/postgres.imp export file which will be used by the plugins to import.
One example being ./build/tmp_install/usr/local/pgsql/lib64/latin_and_mic.so which will have -Wl,bI:<path>/postgres.imp when it is getting created.
> So it's not clear why this patch is introducing things
> like dep_static_lib, and the lack of comments about that doesn't help.
On AIX, both static and shared libraries are archived, because multiple shared libraries with different ABIs or versions may need to coexist within the same archive for backward compatibility. Meson follows this AIX convention when using the Ninja backend, which means that static and shared libraries end up with identical archive names. Unlike Linux, where static archives use “.a” and shared libraries use “.so”, AIX archives both under “.a”, causing Meson to report name conflicts when a target tries to build both forms. To address this, the dep_static_lib variable was introduced so that each target can explicitly choose whether it wants to build the static version, the shared version, or both, with the default remaining flexible. For AIX, we are building only shared.
Comments are kept in meson.build file.
Link for the same: https://mesonbuild.com/Release-notes-for-1-6-0.html#support-for-openxl-compiler-in-aix
>So, with the possible exception of the int8/float8 alignment issue,
>it seems to me we're within striking distance of a committable patch.
>I wonder whether anyone still wants to argue that AIX support is
>unsustainable on these terms. My own opinion is that it's probably
>okay, and we can always rip it out again if IBM fails to follow
>through on support from their end.
Thank you for the encouraging words. We are glad to hear the patch is now considered close to committable. We also appreciate the perspective on the sustainability of AIX support under the updated terms. We are committed on our side to ensuring the platform remains supportable and maintainable going forward.
Thanks again for the guidance and support throughout this effort.
Let us know what you think of this version of the patch. Your feedback is greatly appreciated.
Best regards,
Aditya.
Re: AIX support
Aditya Kamath writes: > Thank you very much for the support and guidance so far. Please find attached v2 of the meson changes. (See: 0001-Add-AIX-support-for-Postgresql-using-meson-build-too.patch) Please, don't squash all of the changes under discussion into a single patch. We aren't likely to commit it like that, and merging different topics into one patch just makes it harder to review everything. In this case, it'd have been much better if you kept my changes from https://www.postgresql.org/message-id/1694571.1769736080@sss.pgh.pa.us separate from the rest, so that it'd be easier to compare your work to the previous version 0001-Support-for-AIX.pg19.v11.patch. Also, please pretty please use systematic naming including a version number for new patches. It's far from obvious that 0001-Add-AIX-support-for-Postgresql-using-meson-build-too.patch is newer than 0001-Support-for-AIX.pg19.v11.patch. (If you're making the patch files with git format-patch, use "-v N".) regards, tom lane
Re: AIX support
I wrote: > Hence, I suggest the attached alternative solution, at least for > the first pass at this. I've checked that this works on both AIX > (cfarm119) and NetBSD/ppc (mamba's host). I realized that there was only one other local label in s_lock.h, so that + * Ordinarily, we'd code the branches here using GNU-style local symbols, felt a little silly: local labels would now be the minority usage. And to me, this approach is actually superior to a local label. "1:" has zero mnemonic value while "TAS%=_fail" conveys something useful. So I converted that other usage too and documented this as the new standard approach for s_lock.h. Pushed at 0c9f46c42. regards, tom lane
RE: AIX support
>Please, don't squash all of the changes under discussion into a single
>patch. We aren't likely to commit it like that, and merging different
>topics into one patch just makes it harder to review everything.
>In this case, it'd have been much better if you kept my changes from
>https://urldefense.proofpoint.com/v2/url?u=https-3A__www.postgresql.org_message-2Did_1694571.1769736080-40sss.pgh.pa.us&d=DwIFAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=f-oUQ8ByG1nZ71OI9p76qywCPh7mxzU69hBYnkP9Nis&m=dyY-gcWS2Xjotl8-Qex9QwI6MDbnbGcKvghelG6GrW7SVQL3kExDhCzFif0sWkTA&s=Nbdnq5St72HOehkkV5kU2jH_Ofyg6Z7tKt846xg-plg&e=
>separate from the rest, so that it'd be easier to compare your work
>to the previous version 0001-Support-for-AIX.pg19.v11.patch.
>Also, please pretty please use systematic naming including a version
>number for new patches. It's far from obvious that
>0001-Add-AIX-support-for-Postgresql-using-meson-build-too.patch is
>newer than 0001-Support-for-AIX.pg19.v11.patch. (If you're making
>the patch files with git format-patch, use "-v N".)
I have taken care of the same. Please see now and let me know.
RE: AIX support
Date: Monday, 2 February 2026 at 11:40 PM
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Noah Misch <noah@leadboat.com>, Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>, Srirama Kucherlapati <sriram.rk@in.ibm.com>, peter@eisentraut.org <peter@eisentraut.org>, pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>, hlinnaka@iki.fi <hlinnaka@iki.fi>, tristan@partin.io <tristan@partin.io>, postgres-ibm-aix@wwpdl.vnet.ibm.com <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: Re: [EXTERNAL] Re: AIX support
>Please, don't squash all of the changes under discussion into a single
>patch. We aren't likely to commit it like that, and merging different
>topics into one patch just makes it harder to review everything.
>In this case, it'd have been much better if you kept my changes from
>https://urldefense.proofpoint.com/v2/url?u=https-3A__www.postgresql.org_message-2Did_1694571.1769736080-40sss.pgh.pa.us&d=DwIFAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=f-oUQ8ByG1nZ71OI9p76qywCPh7mxzU69hBYnkP9Nis&m=dyY-gcWS2Xjotl8-Qex9QwI6MDbnbGcKvghelG6GrW7SVQL3kExDhCzFif0sWkTA&s=Nbdnq5St72HOehkkV5kU2jH_Ofyg6Z7tKt846xg-plg&e=
>separate from the rest, so that it'd be easier to compare your work
>to the previous version 0001-Support-for-AIX.pg19.v11.patch.
>Also, please pretty please use systematic naming including a version
>number for new patches. It's far from obvious that
>0001-Add-AIX-support-for-Postgresql-using-meson-build-too.patch is
>newer than 0001-Support-for-AIX.pg19.v11.patch. (If you're making
>the patch files with git format-patch, use "-v N".)
I have taken care of the same. Please see now and let me know.
RE: AIX support
Kindly let us know your feedback on the patch.
Thank you once again for all your guidance and support during this process.
Warm regards,
Sriram.
Re: AIX support
Just to play devil's advocate for a minute:
I've managed to run check-world (with --enable-tap-tests, but few
optional features) on the GCC compile farm's AIX 7.3 machine,
cfarm119.cfarm.net.
It took more than five hours.
bash-5.3$ time make -s check-world -j2 PROVE_FLAGS='--quiet --nocolor --nocount' >/dev/null
real 311m10.942s
user 4m26.936s
sys 4m13.243s
(I can't go higher than -j2 due to the machine's restrictive ulimit -u
setting. Perfectly reasonable policy for a shared resource, and
that's not what I'm griping about.)
This compares unfavorably to my 2004-vintage Mac PPC G4 laptop
(running NetBSD 10.1), let alone anything remotely modern. The G4
needs about three-and-two-thirds hours for substantially the same
test:
$ time make -s check-world -j2 PROVE_FLAGS='--quiet --nocolor --nocount' >/dev/null
13188.92s real 1229.68s user 1210.25s system
If the user/system times are to be trusted, the AIX machine is indeed
several times faster than the G4 CPU-wise, so why is it so slow?
Apparently, because its file system sucks. One thing we do over and
over in the TAP tests is to copy an initialized data directory to
prepare a new instance, basically "cp -RPp template-dir $PGDATA".
I'm observing that taking about 22 seconds on the AIX machine
(which is actually slower than running initdb would be: about 15s),
compared to 2.6s on the G4, and about 0.035s on my Linux workstation
(which can do the same overall -j2 check-world in five minutes).
To be clear, there is as far as I can tell next to zero background
I/O load on cfarm119. This is a typical readout when I'm not
running anything:
$ iostat 1
System configuration: lcpu=40 drives=12 ent=4.00 paths=10 vdisks=6
tty: tin tout avg-cpu: % user % sys % idle % iowait physc % entc
0.0 70.0 24.9 33.5 41.6 0.0 4.0 100.5
Disks: % tm_act Kbps tps Kb_read Kb_wrtn
cd1 0.0 0.0 0.0 0 0
cd0 0.0 0.0 0.0 0 0
hdisk1 0.0 0.0 0.0 0 0
hdisk4 0.0 0.0 0.0 0 0
hdisk9 0.0 0.0 0.0 0 0
hdisk8 0.0 0.0 0.0 0 0
hdisk7 0.0 0.0 0.0 0 0
hdisk6 0.0 0.0 0.0 0 0
hdisk3 0.0 0.0 0.0 0 0
hdisk2 100.0 640.0 160.0 0 640
hdisk5 0.0 0.0 0.0 0 0
hdisk0 0.0 0.0 0.0 0 0
Unless there is something seriously wrong with how cfarm119 is set up,
the conclusion has to be that AIX is mind-bogglingly bad at disk I/O.
This conclusion is borne out by some simple pgbench testing:
the AIX machine performs somewhat-respectably on select-only
tests, or on pgbench's default test with fsync off, but on the
default test with fsync on it gets half the TPS rate of the G4:
cfarm119:
bash-5.3$ pgbench -T 60 -j 4 -c 4 bench
pgbench (19devel)
starting vacuum...end.
transaction type:
scaling factor: 10
query mode: simple
number of clients: 4
number of threads: 4
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 2493
number of failed transactions: 0 (0.000%)
latency average = 96.455 ms
initial connection time = 33.624 ms
tps = 41.469913 (without initial connection time)
g4:
[tgl@g42]$ pgbench -T 60 -j 4 -c 4 bench
pgbench (19devel)
starting vacuum...end.
transaction type:
scaling factor: 10
query mode: simple
number of clients: 4
number of threads: 4
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 5767
number of failed transactions: 0 (0.000%)
latency average = 41.619 ms
initial connection time = 122.045 ms
tps = 96.109550 (without initial connection time)
Remind me again why anyone would choose to run Postgres on this
platform? Why are we moving mountains to make it possible?
regards, tom lane
Re: AIX support
On Tue, Feb 03, 2026 at 11:33:20AM -0500, Tom Lane wrote: > Remind me again why anyone would choose to run Postgres on this > platform? Why are we moving mountains to make it possible? Based on the numbers you are posting for the environment tested, I cannot think of a sane reason that somebody would do that. That points to the same feeling that I always have when reading this thread: as far as I understand it is not really possible to have an access to hardware that one could use to test any of this stuff or even write patches to support it. If I/O is bad in any environments where a patch is run, the time investment is moot compared to other nix or even WIN32 environments where a full check-world usually takes no more than 10 minutes for one branch, even on a laptop. Saying that, I'm really glad for the report that has led to the discovery fixed in d46aa32ea5ce. Opportunistic improvements not specific to AIX are also good to know about: they show long-term benefits everywhere. -- Michael
Re: AIX support
On 03/02/2026 18:33, Tom Lane wrote: > Just to play devil's advocate for a minute: > > I've managed to run check-world (with --enable-tap-tests, but few > optional features) on the GCC compile farm's AIX 7.3 machine, > cfarm119.cfarm.net. > > ... > > Apparently, because its file system sucks. I bet it's the GCC compile farm's storage system that sucks. Buildfarm animal 'douc' doesn't seem to have that problem: https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_16_STABLE - Heikki
RE: AIX support
>I bet it's the GCC compile farm's storage system that sucks. Buildfarm
>animal 'douc' doesn't seem to have that problem:
Topas Monitor for host:gcc119 EVENTS/QUEUES FILE/TTY Wed Feb 4 06:43:28 2026 Interval:2 Cswitch 470 Readch 298 Syscall 3381.3K Writech 19189 CPU User% Kern% Wait% Idle% Physc Entc% Reads 3379.3K Rawin 0 Total 24.9 33.5 0.0 41.6 4.02 100.47 Writes 979 Ttyout 298 Forks 0 Igets 7 Network BPS I-Pkts O-Pkts B-In B-Out Execs 0 Namei 534 Total 1.76K 31.50 0.50 1.42K 351.0 Runqueue 5.50 Dirblk 0 Waitqueue 0.0 Disk Busy% BPS TPS B-Read B-Writ MEMORY Total 7.9 626K 156.5 0 626K PAGING Real,MB 163840 Faults 0 % Comp 16 FileSystem BPS TPS B-Read B-Writ Steals 0 % Noncomp 36 Total 18.4K 133.5 298.5 18.1K PgspIn 0 % Client 36 PgspOut 0 Name PID CPU% PgSp Owner PageIn 0 PAGING SPACE plog-con 35520802 16.3 304K bradking PageOut 0 Size,MB 2048 plog-con 29753802 15.3 308K bradking Sios 0 % Used 5 plog-con 31392046 15.3 308K bradking % Free 95 plog-con 35914140 14.3 304K bradking NFS (calls/sec) tar 23789996 0.2 280K sortie SerV2 0 WPAR Activ 0 topas 19661074 0.0 9.48M root CliV2 0 WPAR Total 0 getty 18415934 0.0 664K root SerV3 0 Press: "h"-help rpc.lock 8126804 0.0 1.19M root CliV3 0 "q"-quit
RE: AIX support
Our goal is to ensure that AIX users have access to the modern tools available in the open-source world. This is why we want to work closely and consistently with the PostgreSQL community.
As part of the efforts, we recently contributed a patch in the below link for PostgreSQL to work well with meson without exporting OBJECT_MODE=64
>the conclusion has to be that AIX is mind-bogglingly bad at disk I/O.
We reviewed the configuration of cfarm119 and found that it is running as a shared LPAR using vSCSI‑backed disks. The filesystem under /home is shared with other communities as well, including the CMake community, so multiple workloads are accessing the same storage concurrently. This shared and virtualized setup can significantly affect I/O performance. Our teams are continuously investigating the setup to understand the issue.
For more representative performance measurements, we recommend using the douc node instead. Let us know and we will provide you the access to this node.
Thanks for that, and I’m really glad the investigation led to fixes that benefit all platforms.
We greatly appreciate all the feedback and guidance so far, and we look forward to continuing as active contributors to the PostgreSQL and AIX communities.
Have a nice day,
Best regards,
Aditya.
Re: AIX support
On Tue, Feb 3, 2026 at 11:33 AM Tom Lane wrote: > Apparently, because its file system sucks. One thing we do over and > over in the TAP tests is to copy an initialized data directory to > prepare a new instance, basically "cp -RPp template-dir $PGDATA". > I'm observing that taking about 22 seconds on the AIX machine > (which is actually slower than running initdb would be: about 15s), > compared to 2.6s on the G4, and about 0.035s on my Linux workstation > (which can do the same overall -j2 check-world in five minutes). > > To be clear, there is as far as I can tell next to zero background > I/O load on cfarm119. This is a typical readout when I'm not > running anything: I'd kinda want to see some evidence that this affects all machines rather than just this one. I mean, AIX may not be the most modern thing out there, so maybe it's not great at disk I/O, but these tests don't tell us whether it's the OS that sucks or the hardware. -- Robert Haas EDB: http://www.enterprisedb.com
Re: AIX support
Heikki Linnakangas writes: > On 03/02/2026 18:33, Tom Lane wrote: >> Apparently, because its file system sucks. > I bet it's the GCC compile farm's storage system that sucks. Certainly possible; I have no visibility into what's actually in there. But it seems to have about a dozen drives, which ought to give a decent amount of bandwidth ... > Buildfarm > animal 'douc' doesn't seem to have that problem: > https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_16_STABLE douc isn't running the TAP tests, so it's not directly comparable. But I don't find that a 25-minute BF cycle time without TAP tests is impressive. Anyway, I would be happy if someone would put forward evidence refuting my results, and even more happy if community members trying to work on this patch had access to AIX hardware that wasn't ridiculously slow. As things stand right now, I have zero motivation to continue working on it. regards, tom lane
Re: AIX support
Robert Haas writes: > I'd kinda want to see some evidence that this affects all machines > rather than just this one. I mean, AIX may not be the most modern > thing out there, so maybe it's not great at disk I/O, but these tests > don't tell us whether it's the OS that sucks or the hardware. True. My point is that the AIX hardware available to our community is so slow as to make working on this patch quite unpleasant. If what OSUOSL has is not representative of typical AIX installations, why not, and could we have access to a machine that is? regards, tom lane
RE: AIX support
> True. My point is that the AIX hardware available to our community
> is so slow as to make working on this patch quite unpleasant.
> If what OSUOSL has is not representative of typical AIX installations,
> why not, and could we have access to a machine that is?
Warm regards,
Sriram.
RE: AIX support
>is so slow as to make working on this patch quite unpleasant.
>If what OSUOSL has is not representative of typical AIX installations,
>why not, and could we have access to a machine that is?
Thank you for your patience.
We have provisioned access to a well‑configured node in the OSU lab (p9‑aix1‑postgres1), equipped with 4 processors and 8 SMT threads per processor. We updated the system configuration earlier today. Please share your public key so we can grant you access, and you can continue your testing on this machine. Let us know if you have any questions or if you need anything specific.
We’ve also resolved the issues in the GNU build, and we’re sharing the build-time and TAP test results collected on the p9‑aix1‑postgres1 node.
Since this system provides 32 hardware threads, you can safely use up to -j32 for parallel builds. Below are the timings for configure, make, and test runs (including TAP tests).
time gmake check-world -j 16 t/040_standby_failover_slots_sync.pl .. ok t/041_checkpoint_at_promote.pl ........ skipped: Injection points not supported by this build t/042_low_level_backup.pl ............. ok t/043_no_contrecord_switch.pl ......... ok t/044_invalidate_inactive_slots.pl .... skipped: Injection points not supported by this build t/045_archive_restartpoint.pl ......... ok t/046_checkpoint_logical_slot.pl ...... skipped: Injection points not supported by this build t/047_checkpoint_physical_slot.pl ..... skipped: Injection points not supported by this build t/048_vacuum_horizon_floor.pl ......... ok t/049_wait_for_lsn.pl ................. ok t/050_redo_segment_missing.pl ......... skipped: Injection points not supported by this build t/051_effective_wal_level.pl .......... ok All tests successful. Files=50, Tests=584, 580 wallclock secs ( 0.15 usr 0.06 sys + 15.75 cusr 23.02 csys = 38.98 CPU) Result: PASS gmake[2]: Leaving directory '/home/buildusr/postgres/src/test/recovery' gmake[1]: Leaving directory '/home/buildusr/postgres/src/test' real 10m5.303s user 2m1.573s sys 1m50.873s
Configure time in RAMFS time ./configure --enable-tap-tests --without-icu config.status: creating GNUmakefile config.status: creating src/Makefile.global config.status: creating src/include/pg_config.h config.status: creating src/interfaces/ecpg/include/ecpg_config.h config.status: linking src/backend/port/sysv_sema.c to src/backend/port/pg_sema.c config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c config.status: linking src/include/port/aix.h to src/include/pg_config_os.h config.status: linking src/makefiles/Makefile.aix to src/Makefile.port real 0m33.371s user 0m7.485s sys 0m2.456s
time gmake world-bin -j 16 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -maix64 -fvisibility=hidden -o postgres_fdw.so connection.o deparse.o option.o postgres_fdw.o shippable.o -L../../src/port -L../../src/common -L../../src/interfaces/libpq -lpq -maix64 -Wl,-bbigtoc -shared -fvisibility=hidden -Wl,-bI:../../src/backend/postgres.imp gmake[2]: Leaving directory '/postgres_build/postgres/contrib/postgres_fdw' gmake[1]: Leaving directory '/postgres_build/postgres/contrib' real 0m47.181s user 1m22.055s sys 0m7.948s
t/040_standby_failover_slots_sync.pl .. ok t/041_checkpoint_at_promote.pl ........ skipped: Injection points not supported by this build t/042_low_level_backup.pl ............. ok t/043_no_contrecord_switch.pl ......... ok t/044_invalidate_inactive_slots.pl .... skipped: Injection points not supported by this build t/045_archive_restartpoint.pl ......... ok t/046_checkpoint_logical_slot.pl ...... skipped: Injection points not supported by this build t/047_checkpoint_physical_slot.pl ..... skipped: Injection points not supported by this build t/048_vacuum_horizon_floor.pl ......... ok t/049_wait_for_lsn.pl ................. ok t/050_redo_segment_missing.pl ......... skipped: Injection points not supported by this build t/051_effective_wal_level.pl .......... ok All tests successful. Files=50, Tests=584, 365 wallclock secs ( 0.14 usr 0.06 sys + 15.10 cusr 20.42 csys = 35.72 CPU) Result: PASS gmake[2]: Leaving directory '/postgres_build/postgres/src/test/recovery' gmake[1]: Leaving directory '/postgres_build/postgres/src/test' real 6m16.401s user 1m51.771s sys 1m35.747s
Re: AIX support
On Wed, Feb 4, 2026 at 10:10:55AM -0500, Tom Lane wrote: > Heikki Linnakangas writes: > > On 03/02/2026 18:33, Tom Lane wrote: > >> Apparently, because its file system sucks. > > > I bet it's the GCC compile farm's storage system that sucks. > > Certainly possible; I have no visibility into what's actually > in there. But it seems to have about a dozen drives, which > ought to give a decent amount of bandwidth ... > > > Buildfarm > > animal 'douc' doesn't seem to have that problem: > > https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_16_STABLE > > douc isn't running the TAP tests, so it's not directly comparable. > But I don't find that a 25-minute BF cycle time without TAP tests > is impressive. > > Anyway, I would be happy if someone would put forward evidence > refuting my results, and even more happy if community members > trying to work on this patch had access to AIX hardware that > wasn't ridiculously slow. As things stand right now, I have > zero motivation to continue working on it. I would have given up on this AIX effort long ago. It was clear to me the developer work wasn't worth the value to the user base, and the quality of the patches has been consistently low, as pointed out by Robert Haas recently: https://www.postgresql.org/message-id/CA+Tgmobh=69ud8J62XFAErS-R=mxXC_9RT85hoFMPG_M8+650Q@mail.gmail.com Patch authors have been enthusiastic, but patch activity has been inconsistent. The recent testing problems is just one in a long list of hurdles to resurrect this platform. Probably the only value to the community of adding AIX is platform diversity testing. In hindsight, a verbal meeting two years ago might have avoided many of these problems, though patch author turnover might have made that ineffective. I think the gap between AIX features and other platforms, the amount of work required to make AIX a _clean_ port, the amount of time and skills patch authors have, and the value the community of having an AIX port is just too wide, though I will say I am surprised the patch authors have gotten as far as they have. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Do not let urgent matters crowd out time for investment in the future.
Re: AIX support
Srirama Kucherlapati writes:
> Please find the attached, patch to enable the PostgreSQL project to build
> successfully on AIX using GNU.
This seems to be a regression from the v11 patch. I see
this during build:
ld: 0711-783 WARNING: TOC overflow. TOC size: 325208 Maximum size: 65536
Extra instructions are being generated for each reference to a TOC
symbol if the symbol is in the TOC overflow area.
ld: 0711-783 WARNING: TOC overflow. TOC size: 325360 Maximum size: 65536
Extra instructions are being generated for each reference to a TOC
symbol if the symbol is in the TOC overflow area.
and then initdb fails like this:
exec(): 0509-036 Cannot load program initdb because of the following errors:
0509-150 Dependent module libpq.a(libpq.so.5) could not be loaded.
0509-022 Cannot load module libpq.a(libpq.so.5).
0509-026 System error: A file or directory in the path name does not exist.
Neither of those things happen with the v11 patch
(testing both on p9-aix1-postgres1).
regards, tom lane
Re: AIX support
Aditya Kamath writes: > Please find attached the patch (See: v4-0001-Add-AIX-support-for-Postgresql-using-meson-build-.patch) This doesn't work for me. "meson setup" gets through all its configuration probes and then dies while trying to make the ninja recipe: $ meson setup build ... ... Found ninja-1.12.1 at /opt/freeware/bin/ninja ERROR: Multiple producers for Ninja target "src/interfaces/libpq/libpq.a". Please rename your targets. A full log can be found at /home/tgl/pgsql/build/meson-logs/meson-log.txt This is on p9-aix1-postgres1. There was no meson installed on the GCC compile farm machine, so I can't say whether earlier iterations of the patch worked any better. I'm still wondering why you didn't simply reverse the effects of 0b16bb877 on the meson files. Do we really need to do anything different from what was working before? regards, tom lane
RE: AIX support
>exec(): 0509-036 Cannot load program initdb because of the following errors:
> 0509-150 Dependent module libpq.a(libpq.so.5) could not be loaded.
> 0509-022 Cannot load module libpq.a(libpq.so.5).
> 0509-026 System error: A file or directory in the path name does not exist.
This issue can occur when gmake install installs the build into a custom directory using the DESTDIR flag. After installation, the loader inspects the binary’s library path to locate the required libpq.a libraries.
If the installation directory differs from the default location, we need to set the LIBPATH environment variable to point to the custom directory where the libraries have been placed.
This command lists the paths the runtime linker will check when resolving shared libraries
RE: AIX support
Hi Tom,
>This doesn't work for me. "meson setup" gets through all its
>configuration probes and then dies while trying to make the
>ninja recipe:
>$ meson setup build …
>…
>Found ninja-1.12.1 at /opt/freeware/bin/ninja
>ERROR: Multiple producers for Ninja target "src/interfaces/libpq/libpq.a". Please rename your targets.
>This is on p9-aix1-postgres1. There was no meson installed on the GCC
>compile farm machine, so I can't say whether earlier iterations of
>the patch worked any better.
>I'm still wondering why you didn't simply reverse the effects of
>0b16bb877 on the meson files. Do we really need to do anything
>different from what was working before?
Re: AIX support
Aditya Kamath writes: > Thank you for trying to compile Postgres using meson in AIX. Feel free to ask any questions or packages you need in this node and we will install the same. I did mean to ask for installation of python and ccache if possible. plpython often presents portability issues so it'd be good to check that, and ccache just makes things faster, >> This doesn't work for me. "meson setup" gets through all its >> configuration probes and then dies while trying to make the >> ninja recipe: > Kindly use meson setup build -Ddefault_library=shared to configure > using meson. Hmm. That might be an acceptable answer if there were any documentation instructing users to do that, but there isn't. (This gets back to the gripe I raised before that the patch series still hasn't paid any attention to resurrecting the AIX-specific documentation bits.) In the bigger picture though, if that's the only way that works and we have no intention of making it different, why should users have to specify that explicitly rather than meson.build just assuming it? We are not in the business of making builds painful. Anyway, I did get through a build just now after adding -Ddefault_library=shared, but then I got OSError: [Errno 28] No space left on device while trying to do "meson test", and "df" confirmed that I'd run the /home partition down to zero free space. Can we get some more disk space provisioned on p9-aix1-postgres1, or get other people to clean up their unused files? regards, tom lane
Re: AIX support
Srirama Kucherlapati writes: >> exec(): 0509-036 Cannot load program initdb because of the following errors: >> 0509-150 Dependent module libpq.a(libpq.so.5) could not be loaded. >> 0509-022 Cannot load module libpq.a(libpq.so.5). >> 0509-026 System error: A file or directory in the path name does not exist. > Let me know, if exporting the LIBPATH to the custom directory works for you. That does seem to fix it (though the TOC-size warnings are still there). But as I remarked to Aditya, (1) that's quite an unacceptable answer when there is no documentation about the requirement, and (2) I don't really see why users should have to specify something that the build process can easily infer for itself. Perhaps more to the point though: (3) the previous patch version worked without this. So I don't believe this requirement is necessary. regards, tom lane
Re: AIX support
I have spent some time going through this patchset in detail,
and have refactored it in a way that I hope makes it easier
to review. I could use some review of the meson bits, because
I'm still pretty unfamiliar with that tool.
0001 is the same patch I posted before to solve the alignment
issue by using _Pragma(pack).
0002 is as close as I could get to a straight revert of the
AIX-support-removal commits 0b16bb877 and e6bb491bf. I did
not put back the bits concerned with xlc support, since we're
tossing that overboard. I also didn't put back the changes
in maxalign computation (mooted by 0001), nor the regression
test for catalog column alignment (ditto), nor the changes in
s_lock.h (unnecessary after 0c9f46c42).
0003 through 0005 are changes needed on top of that, mostly
borrowed from your patches although I corrected a few things.
I think these are small enough bites to be easily reviewable.
0006 adds some definitions I found necessary to get a warning-free
compile.
0007 arose from comparing the file sets installed by the autoconf
build vs. the meson build and making the latter match the former.
At least the first couple of changes in this seem to be bugs that
were there before we removed AIX support.
Barring suggestions about how to do the meson code better,
I think this is close to committable. The loose ends that
I know about are:
* The autoconf build produces warnings about TOC overflow
while linking the backend, as I showed upthread. I don't
understand why -Wl,-bbigtoc doesn't silence that, especially
since no such warnings appear in the meson build. (Meson
seems to be injecting -Wl,-bbigtoc of its own accord, but
there must be some additional special thing it's doing.)
The executable works fine, so it's not critical, but
why the warning?
* The meson build, but not the autoconf build, produces
complaints about
../src/common/pg_get_line.c: In function 'pg_get_line_append':
../src/common/pg_get_line.c:129:27: warning: '({anonymous})' may be used uninitialized [-Wmaybe-uninitialized]
129 | if (prompt_ctx && sigsetjmp(*((sigjmp_buf *) prompt_ctx->jmpbuf), 1) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm not so worried about the warning itself --- buildfarm member
hake has also been showing this --- but why are the two builds
different? Same compiler, pretty much the same switches, although
I see Meson is injecting -pthread without being asked. Could that
be responsible?
* plpython probably needs work, and I'm not sure about --with-llvm.
I can't really test either of those for lack of installed packages.
(Curiously, p9-aix1-postgres1 does seem to have a python installation
in /opt/freeware, but it's incomplete: there's no Python.h anywhere.)
BTW, who should the commit message(s) list as authors on these
patches, besides the two of you?
regards, tom lane
From a8425cf8c4ebf2f9692cf55533bda8270eb70c5f Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Sat, 14 Feb 2026 18:16:46 -0500
Subject: [PATCH v6 1/7] 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 a10a2c85c6a..ef6ca1422a5 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 814e64a967e..5edcccc0a15 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 f6d5842d852..4b3bd5c9a7e 100644
--- a/meson.build
+++ b/meson.build
@@ -1800,32 +1800,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 ')
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 ') > 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 3fc09ec1e4a..367b5496971 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -821,7 +821,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 */
@@ -833,7 +833,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, classoid oid_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 f3571d2bfcf..45d7a975ed2 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 */
@@ -108,6 +110,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, cfgnamespace oid_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, maptokentype int4_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, prsnamespace oid_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 c66d280c37e5a65a1bddd161d90ddf040bb0ca26 Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Sat, 14 Feb 2026 18:19:56 -0500
Subject: [PATCH v6 2/7] 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 distcheck world check-world install-world installcheck-world:
diff --git a/configure b/configure
index ef6ca1422a5..215f56bb227 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 5edcccc0a15..e5255d55587 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
PostgreSQL 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 PostgreSQL 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.
@@ -3484,6 +3484,123 @@ export MANPATH
installation issues.
+
+ AIX
+
+
+ AIX
+ installation on
+
+
+
+ You must use GCC
+ to build PostgreSQL
+ on AIX.
+ The native IBM compiler xlc is not supported.
+
+
+
+ AIX versions before 7.2 are no longer
+ tested nor supported by the PostgreSQL
+ community.
+
+
+
+ Memory Management
+
+
+
+ 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:
+
+=# 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.
+
+ Running as a non-owner in the group possessing the PostgreSQL
+ installation:
+
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
+
+ Another example is out of memory errors in the PostgreSQL server
+ logs, with every memory allocation near or greater than 256 MB
+ failing.
+
+
+
+ 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.
+
+
+
+ In the case of the plperl 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.
+
+
+
+ The ideal 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.
+
+
+
+ If a 32-bit binary is desired, set LDR_CNTRL to
+ MAXDATA=0xn0000000,
+ where 1 <= n <= 8, before starting the PostgreSQL server,
+ and try different values and postgresql.conf
+ settings to find a configuration that works satisfactorily. This
+ use of LDR_CNTRL tells AIX that you want the
+ server to have MAXDATA bytes set aside for the
+ heap, allocated in 256 MB segments. When you find a workable
+ configuration,
+ ldedit can be used to modify the binaries so
+ that they default to using the desired heap size. PostgreSQL can
+ also be rebuilt, passing configure
+ LDFLAGS="-Wl,-bmaxdata:0xn0000000"
+ to achieve the same effect.
+
+
+
+ For a 64-bit build, set OBJECT_MODE to 64 and
+ pass CC="gcc -maix64"
+ and LDFLAGS="-Wl,-bbigtoc"
+ to configure. If you omit the export of
+ OBJECT_MODE, your build may fail with linker errors. When
+ OBJECT_MODE is set, it tells AIX's build utilities
+ such as ar, as, and ld what
+ type of objects to default to handling.
+
+
+
+ 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.
+
+
+
+
Cygwin
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 @@ $ postgres -D $PGDATA -C num_os_semaphores
+
+ AIX
+ AIXIPC configuration
+
+
+
+ It should not be necessary to do
+ any special configuration for such parameters as
+ SHMMAX, 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 DB/2.
+
+ It might, however, be necessary to modify the global
+ ulimit information in
+ /etc/security/limits, as the default hard
+ limits for file sizes (fsize) and numbers of
+ files (nofiles) might be too low.
+
+
+
+
+
FreeBSD
FreeBSDIPC configuration
diff --git a/meson.build b/meson.build
index 4b3bd5c9a7e..77a122b43c8 100644
--- a/meson.build
+++ b/meson.build
@@ -202,7 +202,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 59315e94e3e..b4fb828dffd 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 c5ecd9c3a87..3333f6d00c8 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).
libpq_st = static_library('libpq',
libpq_sources,
include_directories: [libpq_inc],
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 20debce9941edc07037a09231307b4a6d75d5258 Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Sat, 14 Feb 2026 18:29:48 -0500
Subject: [PATCH v6 3/7] 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.
Add some helpful comments.
Improve the output of gen_export.pl by adding a header.
TODO: who to credit for these?
---
meson.build | 11 +++--------
src/Makefile.shlib | 2 +-
src/backend/meson.build | 1 +
src/backend/port/aix/mkldexport.sh | 17 ++++++++++++-----
src/template/aix | 10 +++++-----
src/tools/gen_export.pl | 6 +++++-
6 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/meson.build b/meson.build
index 77a122b43c8..7e382aebab6 100644
--- a/meson.build
+++ b/meson.build
@@ -203,24 +203,19 @@ 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
-
elif host_system == 'cygwin'
sema_kind = 'unnamed_posix'
cppflags += '-D_GNU_SOURCE'
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/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 3af0cc8969eb030fa73a2470dba13da5a54d5a92 Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Sun, 15 Feb 2026 16:00:03 -0500
Subject: [PATCH v6 4/7] Teach meson build infrastructure not to build static
libs on AIX.
On AIX, shared and static libraries are really the same thing.
We must avoid having two rules that both build 'libpq.a',
for instance. Add dependencies to make that work.
Note: in principle this could be extended to allow disabling
shared library build, but no platform needs that so not all
of the code to support it has been filled in.
Note: the original submission suppressed installation of the
libpgport, libpgcommon, and libpgfeutils static libraries,
which is wrong.
TODO: who to credit for this work?
---
meson.build | 28 ++++++++++++++++++----
src/interfaces/ecpg/compatlib/meson.build | 8 ++++---
src/interfaces/ecpg/ecpglib/meson.build | 8 ++++---
src/interfaces/ecpg/pgtypeslib/meson.build | 8 ++++---
src/interfaces/libpq-oauth/meson.build | 1 +
src/interfaces/libpq/meson.build | 4 ++--
6 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/meson.build b/meson.build
index 7e382aebab6..32d82b244e1 100644
--- a/meson.build
+++ b/meson.build
@@ -185,6 +185,14 @@ memset_loop_limit = 1024
shmem_kind = 'sysv'
sema_kind = 'sysv'
+# Most platforms want to build both shared and static libraries,
+# but on some we only want one kind. We use these variables to
+# control building/installation of the two kinds.
+# Note: in principle you can disable building of shared libraries,
+# but that case is not used and therefore not built out completely...
+dep_shared_lib = declare_dependency()
+dep_static_lib = declare_dependency()
+
# We implement support for some operating systems by pretending they're
# another. Map here, before determining system properties below
if host_system == 'dragonfly'
@@ -216,6 +224,13 @@ if host_system == 'aix'
# -brtllib indicates binaries should use runtime-loaded shared libraries.
ldflags_be += '-Wl,-brtllib'
+ # 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, 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.
+ dep_static_lib = disabler()
+
elif host_system == 'cygwin'
sema_kind = 'unnamed_posix'
cppflags += '-D_GNU_SOURCE'
@@ -3541,18 +3556,21 @@ endif
installed_targets = [
backend_targets,
bin_targets,
- libpq_st,
pl_targets,
contrib_targets,
nls_mo_targets,
ecpg_targets,
]
+if dep_static_lib.found()
+ installed_targets += libpq_st
+endif
+
if oauth_flow_supported
- installed_targets += [
- libpq_oauth_so,
- libpq_oauth_st,
- ]
+ installed_targets += libpq_oauth_so
+ if dep_static_lib.found()
+ installed_targets += libpq_oauth_st
+ endif
endif
# all targets that require building code
diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build
index 6cb1be73407..94dcc67c03c 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -20,17 +20,19 @@ ecpg_compat_st = static_library('libecpg_compat',
ecpg_compat_sources,
include_directories: ecpg_compat_inc,
c_args: ecpg_compat_c_args,
- dependencies: [frontend_stlib_code, thread_dep],
+ dependencies: [dep_static_lib, frontend_stlib_code, thread_dep],
link_with: [ecpglib_st, ecpg_pgtypes_st],
kwargs: default_lib_args,
)
-ecpg_targets += ecpg_compat_st
+if dep_static_lib.found()
+ ecpg_targets += ecpg_compat_st
+endif
ecpg_compat_so = shared_library('libecpg_compat',
ecpg_compat_sources + ecpg_compat_so_sources,
include_directories: ecpg_compat_inc,
c_args: ecpg_compat_c_args,
- dependencies: [frontend_shlib_code, thread_dep],
+ dependencies: [dep_shared_lib, frontend_shlib_code, thread_dep],
link_with: [ecpglib_so, ecpg_pgtypes_so],
soversion: host_system != 'windows' ? '3' : '',
darwin_versions: ['3', '3.' + pg_version_major.to_string()],
diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build
index 889bd9efd65..a81d772aa69 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -30,18 +30,20 @@ ecpglib_st = static_library('libecpg',
include_directories: ecpglib_inc,
c_args: ecpglib_c_args,
c_pch: pch_postgres_fe_h,
- dependencies: [frontend_stlib_code, thread_dep, libpq],
+ dependencies: [dep_static_lib, frontend_stlib_code, thread_dep, libpq],
link_with: [ecpg_pgtypes_st],
kwargs: default_lib_args,
)
-ecpg_targets += ecpglib_st
+if dep_static_lib.found()
+ ecpg_targets += ecpglib_st
+endif
ecpglib_so = shared_library('libecpg',
ecpglib_sources + ecpglib_so_sources,
include_directories: ecpglib_inc,
c_args: ecpglib_c_args,
c_pch: pch_postgres_fe_h,
- dependencies: [frontend_shlib_code, libpq, thread_dep],
+ dependencies: [dep_shared_lib, frontend_shlib_code, libpq, thread_dep],
link_with: ecpg_pgtypes_so,
soversion: host_system != 'windows' ? '6' : '',
darwin_versions: ['6', '6.' + pg_version_major.to_string()],
diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build
index 6b78f529e53..897a8febc76 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -26,17 +26,19 @@ ecpg_pgtypes_st = static_library('libpgtypes',
include_directories: ecpg_pgtypes_inc,
c_args: ecpg_pgtypes_c_args,
c_pch: pch_postgres_fe_h,
- dependencies: frontend_stlib_code,
+ dependencies: [dep_static_lib, frontend_stlib_code],
kwargs: default_lib_args,
)
-ecpg_targets += ecpg_pgtypes_st
+if dep_static_lib.found()
+ ecpg_targets += ecpg_pgtypes_st
+endif
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: [dep_shared_lib, frontend_shlib_code],
version: '3.' + pg_version_major.to_string(),
soversion: host_system != 'windows' ? '3' : '',
darwin_versions: ['3', '3.' + pg_version_major.to_string()],
diff --git a/src/interfaces/libpq-oauth/meson.build b/src/interfaces/libpq-oauth/meson.build
index d8a0c04095a..b0083f279aa 100644
--- a/src/interfaces/libpq-oauth/meson.build
+++ b/src/interfaces/libpq-oauth/meson.build
@@ -26,6 +26,7 @@ libpq_oauth_st = static_library('libpq-oauth',
include_directories: [libpq_oauth_inc, postgres_inc],
c_pch: pch_postgres_fe_h,
dependencies: [
+ dep_static_lib,
frontend_stlib_code,
libpq_oauth_deps,
ssl, # libpq-int.h includes OpenSSL headers
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index 3333f6d00c8..ea98596b936 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -63,7 +63,7 @@ libpq_st = static_library('libpq',
include_directories: [libpq_inc],
c_args: libpq_c_args,
c_pch: pch_postgres_fe_h,
- dependencies: [frontend_stlib_code, libpq_deps],
+ dependencies: [dep_static_lib, frontend_stlib_code, libpq_deps],
kwargs: default_lib_args,
)
@@ -75,7 +75,7 @@ libpq_so = shared_library('libpq',
version: '5.' + pg_version_major.to_string(),
soversion: host_system != 'windows' ? '5' : '',
darwin_versions: ['5', '5.' + pg_version_major.to_string()],
- dependencies: [frontend_shlib_code, libpq_deps],
+ dependencies: [dep_shared_lib, frontend_shlib_code, libpq_deps],
link_depends: export_file,
link_args: export_fmt.format(export_file.full_path()),
kwargs: default_lib_args,
--
2.43.7
From c5a1af49ba5d18d9bb10d3f04e78fd248f2cdbc3 Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Sun, 15 Feb 2026 16:09:01 -0500
Subject: [PATCH v6 5/7] 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 xlc is not supported.
+
+ 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 OBJECT_MODE before building:
+
+export OBJECT_MODE=64
+meson setup ...
+
+ Failure to do that will usually manifest as complaints
+ from ar about files having the wrong
+ object file mode.
+
+
AIX versions before 7.2 are no longer
tested nor supported by the PostgreSQL
community.
-
-
- Memory Management
-
-
-
- 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:
-
-=# 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.
-
- Running as a non-owner in the group possessing the PostgreSQL
- installation:
-
-=# CREATE EXTENSION plperl;
-ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
-
- Another example is out of memory errors in the PostgreSQL server
- logs, with every memory allocation near or greater than 256 MB
- failing.
-
-
-
- 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.
-
-
-
- In the case of the plperl 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.
-
-
-
- The ideal 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.
-
-
-
- If a 32-bit binary is desired, set LDR_CNTRL to
- MAXDATA=0xn0000000,
- where 1 <= n <= 8, before starting the PostgreSQL server,
- and try different values and postgresql.conf
- settings to find a configuration that works satisfactorily. This
- use of LDR_CNTRL tells AIX that you want the
- server to have MAXDATA bytes set aside for the
- heap, allocated in 256 MB segments. When you find a workable
- configuration,
- ldedit can be used to modify the binaries so
- that they default to using the desired heap size. PostgreSQL can
- also be rebuilt, passing configure
- LDFLAGS="-Wl,-bmaxdata:0xn0000000"
- to achieve the same effect.
-
-
-
- For a 64-bit build, set OBJECT_MODE to 64 and
- pass CC="gcc -maix64"
- and LDFLAGS="-Wl,-bbigtoc"
- to configure. If you omit the export of
- OBJECT_MODE, your build may fail with linker errors. When
- OBJECT_MODE is set, it tells AIX's build utilities
- such as ar, as, and ld what
- type of objects to default to handling.
-
-
-
- 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.
-
-
diff --git a/meson.build b/meson.build
index 32d82b244e1..baf124f46c7 100644
--- a/meson.build
+++ b/meson.build
@@ -219,6 +219,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 dd16a7a0378..a7dee8a76b4 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 5e91e7f54e6fef4ac2dd77e93cd909a4b5dc3e3e Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Sun, 15 Feb 2026 16:10:05 -0500
Subject: [PATCH v6 6/7] 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 /* for size_t */
+#include /* for uid_t and gid_t */
+#include /* 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 e733e72a0091579594457a664f6182a3f593e091 Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Sun, 15 Feb 2026 16:19:41 -0500
Subject: [PATCH v6 7/7] 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 'version' 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 94dcc67c03c..fc6fc434e2e 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -34,7 +34,7 @@ ecpg_compat_so = shared_library('libecpg_compat',
c_args: ecpg_compat_c_args,
dependencies: [dep_shared_lib, 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 a81d772aa69..04ba2c6e2de 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -45,7 +45,7 @@ ecpglib_so = shared_library('libecpg',
c_pch: pch_postgres_fe_h,
dependencies: [dep_shared_lib, 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 897a8febc76..175691d1321 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -40,7 +40,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes',
c_pch: pch_postgres_fe_h,
dependencies: [dep_shared_lib, 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 ea98596b936..d3dfa0328e1 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -73,7 +73,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: [dep_shared_lib, frontend_shlib_code, libpq_deps],
link_depends: export_file,
--
2.43.7
Re: AIX support
I wrote: > * The autoconf build produces warnings about TOC overflow > while linking the backend, as I showed upthread. I don't > understand why -Wl,-bbigtoc doesn't silence that, especially > since no such warnings appear in the meson build. Hah, I've got at least part of the answer: that TOC warning appears if the backend is built with -O0, but not at higher -O levels. The apparent connection to autoconf vs. meson is because earlier versions of the patch were building at -O0, due to template/aix overriding CFLAGS and thereby preventing configure.ac from inserting its default -O2. After I got rid of that interaction, autoconf builds at -O2 by default and there's no warning. Conversely, the warning does appear in the meson build if I set -Dc_args=-O0. Now, this is still a bit confusing, because the backend executable is actually smaller at -O0 (due to less inlining, I guess), so shouldn't it be less prone to TOC overflow? But I mainly cared about the discrepancy between autoconf and meson builds, and that seems adequately explained. regards, tom lane
RE: AIX support
+# -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)’These lines are no longer required, and we have removed it in v12 patch as well. And this is the root cause of GNU tests failing.The above lines cause the binary’s lib path to be as below:***Import File Strings***INDEX PATH BASE MEMBER0 /usr/local/pgsql/lib:/usr/lib:/lib:/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/13/
The GCC compiler on AIX will leave it to the IBM AIX linker to derive the runtime loader path from the compile time library search paths.
When we run "gcc -print-search-dirs” it lists all the library paths as below.
In practice, the GCC driver also contributes its own runtime support directory (where libgcc_s lives) to the link search, and the derived runtime path written into the loader section ends up containing those locations without us manually constructing -blibpath.
After removing the lib path and path from Makefile.aix we get the below library search paths which is what we need to run test cases or run binaries,
***Import File Strings*** INDEX PATH BASE MEMBER 0 ../../../src/port:../../../src/common:../../../src/fe_utils:../../../src/interfaces/libpq:/opt/freeware/lib:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/ppc64:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/../../../ppc64:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/../../..:/usr/lib:/lib
We tried it in the same node and were able to run the TAP tests as well successfully without the mentioned above lines in Makefile.aix . Let me know if you have any issues after removing the same. But those lines are no longer needed given we will move to GCC and Clang(IBM openXL) in AIX for PostgreSQL.
>0001 is the same patch I posted before to solve the alignment
>issue by using _Pragma(pack).
>0002 is as close as I could get to a straight revert of the
>AIX-support-removal commits 0b16bb877 and e6bb491bf. I did
>not put back the bits concerned with xlc support, since we’re
>tossing that overboard. I also didn't put back the changes
>in maxalign computation (mooted by 0001), nor the regression
>test for catalog column alignment (ditto), nor the changes in
>s_lock.h (unnecessary after 0c9f46c42).
We want to remove the blibpath calculation from this patch for reasons mentioned above.
>0003 through 0005 are changes needed on top of that, mostly
>0006 adds some definitions I found necessary to get a warning-free
>0007 arose from comparing the file sets installed by the autoconf
All these patches look good.
>* The meson build, but not the autoconf build, produces
>complaints about
>../src/common/pg_get_line.c: In function 'pg_get_line_append’:
>../src/common/pg_get_line.c:129:27: warning: '({anonymous})' may be used uninitialized [-Wmaybe-uninitialized]
> 129 | if (prompt_ctx && sigsetjmp(*((sigjmp_buf *) prompt_ctx->jmpbuf), 1) != 0)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>I'm not so worried about the warning itself --- buildfarm member
>hake has also been showing this --- but why are the two builds
>different? Same compiler, pretty much the same switches, although
>I see Meson is injecting -pthread without being asked. Could that
>be responsible?
This is our understanding so far: when pthread support is enabled, sigsetjmp is
no longer a straightforward function call—it expands into a more complex macro.
The compiler’s warning refers to an “anonymous” value because the macro
expansion likely uses a GCC statement expression of the form ({ ... }). Within
that expansion, GCC creates a temporary variable to capture some intermediate
state or return value. Since the compiler cannot clearly determine that this
internal temporary is always initialized—especially under certain optimization
levels—it raises the -Wmaybe-uninitialized warning, even though the code itself
is correct.
>* plpython probably needs work, and I'm not sure about --with-llvm.
?I can't really test either of those for lack of installed packages.
>(Curiously, p9-aix1-postgres1 does seem to have a python installation
>in /opt/freeware, but it's incomplete: there's no Python.h anywhere.)
>BTW, who should the commit message(s) list as authors on these
>patches, besides the two of you?
>>> exec(): 0509-036 Cannot load program initdb because of the following errors:
>>> 0509-150 Dependent module libpq.a(libpq.so.5) could not be loaded.
>>> 0509-022 Cannot load module libpq.a(libpq.so.5).
>>> 0509-026 System error: A file or directory in the path name does not exist.
>(2) I don't really see why users should have to specify something that
>the build process can easily infer for itself.
>(3) the previous patch version worked without this. So, I don’t
>believe this requirement is necessary.
initdb: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
>I did mean to ask for installation of python and ccache if possible.
>plpython often presents portability issues so it'd be good to check that,
>and ccache just makes things faster,
>Hmm. That might be an acceptable answer if there were any
>documentation instructing users to do that, but there isn’t.
Sure.
>OSError: [Errno 28] No space left on device
Please see now. I have freed up my working directory.
>Hah, I've got at least part of the answer: that TOC warning appears
>if the backend is built with -O0, but not at higher -O levels.
>The apparent connection to autoconf vs. meson is because earlier
>versions of the patch were building at -O0, due to template/aix
Yes, Tom — you’re right. From what I know, TOC size on AIX is influenced not
just by the overall code size but by the number of unique references a module
needs. The TOC holds entries for external functions, global data pointers,
constants, and other symbols that require relocation. That means TOC pressure
increases with the number of distinct items that need TOC slots. At -O0, the
compiler performs no inlining or dead‑code elimination, so the unoptimized IR
often contains more relocations and unused globals, each of which can
contribute additional TOC entries. This is why TOC usage can actually be higher
in an unoptimized build, even if the resulting binary is smaller. Hope that
clarifies the behavior.
Re: AIX support
Aditya Kamath writes: > +# -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)’ > These lines are no longer required, and we have removed it in v12 patch as well. And this is the root cause of GNU tests failing. Hmm, I'm not sure how "these lines are not required" squares with "the tests fail after we remove them". More generally, we do need rpath support for many installation scenarios. So even if you can make it work for your own scenario without that, I think the answer is "you can use --disable-rpath" not "we should remove rpath support for everybody". > After removing the lib path and path from Makefile.aix we get the below library search paths which is what we need to run test cases or run binaries, > ***Import File Strings*** > INDEX PATH BASE MEMBER > 0 ../../../src/port:../../../src/common:../../../src/fe_utils:../../../src/interfaces/libpq:/opt/freeware/lib:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/ppc64:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/../../../ppc64:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13:/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/../../..:/usr/lib:/lib You should be quite scared of that result, because the relative paths will only work in a build tree not for an installed server executable. My recollection is that I put those lines back after discovering that "make install; make installcheck" didn't work without 'em. That was on the GCC farm's machine, so there may also be an AIX 7.2 vs 7.3 difference involved here, and/or some difference in the configuration of the gcc compiler. I intend to test the final patch version on cfarm119 before committing, but it has been down for a couple days, no doubt because of OSUOSL's ongoing data center move. regards, tom lane
Re: AIX support
I wrote:
> Aditya Kamath writes:
>> +# -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)’
>> These lines are no longer required, and we have removed it in v12 patch as well. And this is the root cause of GNU tests failing.
> Hmm, I'm not sure how "these lines are not required" squares with
> "the tests fail after we remove them". More generally, we do need
> rpath support for many installation scenarios.
I wondered if AIX 7.2 behaves differently from the 7.3 machine where
I'd determined that we need this. But it doesn't. I tried removing
these lines, and found that an installed system is entirely
nonfunctional:
$ ./configure --prefix=$HOME/testversion
$ make
$ make install
$ $HOME/testversion/bin/initdb
exec(): 0509-036 Cannot load program initdb because of the following errors:
0509-150 Dependent module libpq.a(libpq.so.5) could not be loaded.
0509-022 Cannot load module libpq.a(libpq.so.5).
0509-026 System error: A file or directory in the path name does not exist.
So we need at least rpathdir support. It might be that this code
can be simplified or otherwise improved, but just deleting it
won't do.
It did seem that the part about adding -print-libgcc-file-name
might be unnecessary: it seems to work without that bit on
p9-aix1-postgres1. But I'm pretty certain I saw that to be
necessary on cfarm119, which would not be hugely surprising
with a different gcc version or configuration. Can't recheck
till that machine comes back ...
regards, tom lane
Re: AIX support
On Mon, Feb 16, 2026 at 12:35 PM Tom Lane wrote: > * plpython probably needs work, and I'm not sure about --with-llvm. > I can't really test either of those for lack of installed packages. I'm willing to help look into LLVM when enough pieces have fallen into place. I expect it to work: LLVM's commit log is full of AIX-related commits from @ibm.com addresses, and LLVM 21 gained AIX/ppc64 JITLink support (the newer linking layer that we'll soon need to switch to). I don't see the 32 bit variant, and I don't know if the older RTDyldObjectLinkingLayer works on AIX (I'd have guessed so, but I can also see that is has special kludges for COFF, so perhaps it'd need something special for XCOFF too, *shrug*). If I guessed correctly, the end goal is packaging including all dependencies at https://www.ibm.com/support/pages/aix-toolbox-open-source-software-downloads-alpha? That already lists PostgreSQL 18 (with some version of these patches applied?), but doesn't appear to have LLVM packages yet, so I guess someone would need to address that. I wondered about building LLVM from source just to see what happens, but there isn't anywhere near enough free disk space on p9-aix1-postgres1. But that's all getting quite far ahead of the basic AIX-port-restoration project, ie something for later...
Re: AIX support
On Wed, Feb 04, 2026 at 10:10:55AM -0500, Tom Lane wrote: > Heikki Linnakangas writes: > > https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=douc&br=REL_16_STABLE > > douc isn't running the TAP tests, so it's not directly comparable. The other four AIX buildfarm members run on cfarm111, which its owner will decommission later this month: https://lists.tetaneutral.net/pipermail/cfarm-users/2026-February/001476.html FYI, I'll stop its buildfarm runs on 2026-02-25.
RE: AIX support
>I wondered if AIX 7.2 behaves differently from the 7.3 machine >where
>I'd determined that we need this. But it doesn't. I tried removing
>these lines, and found that an installed system is entirely
>nonfunctional:
>$ ./configure --prefix=$HOME/testversion
>$ make
>$ make install
>$ $HOME/testversion/bin/initdb
>exec(): 0509-036 Cannot load program initdb because of the >following errors:
> 0509-150 Dependent module libpq.a(libpq.so.5) could not be loaded.
> 0509-022 Cannot load module libpq.a(libpq.so.5).
> 0509-026 System error: A file or directory in the path name does not exist.
>So we need at least rpathdir support. It might be that this code
>can be simplified or otherwise improved, but just deleting it
>won't do.
libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/opt/freeware/lib:/usr/lib:/lib
Re: AIX support
Aditya Kamath writes: > Just that if someone runs test cases without disabling rpath then the test cases wont run.(Only while using the GNU build system in AIX) Hmm, I'm not sure why that should be. All the cases I've tried work fine, and I'm not disabling rpath. > For which I have one suggestion, > # -blibpath must contain ALL directories where we should look for libraries > libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/opt/freeware/lib:/usr/lib:/lib > How about adding "/opt/freeware/lib" to the calculation like the above lines. This is the standard path where all AIX open-source freeware libraries will exist, and system libraries will be in /usr/lib. We have this differentiation in AIX. Okay. In my testing that's already gotten into LDFLAGS at this point, but I can't see any harm in hard-wiring it into the list given that we're already hard-wiring /usr/lib and /lib. regards, tom lane
RE: AIX support
>> Just that if someone runs test cases without disabling rpath then the test cases won’t run.(Only while using the GNU build system in AIX)
>Hmm, I'm not sure why that should be. All the cases I've tried work
fine, and I'm not disabling rpath.
>> How about adding "/opt/freeware/lib" to the calculation like the above lines. This is the standard path where all AIX open-source freeware libraries will exist, and system libraries will be in /usr/lib. We have this differentiation in AIX.
>Okay. In my testing that's already gotten into LDFLAGS at this point,
but I can't see any harm in hard-wiring it into the list given that
we're already hard-wiring /usr/lib and /lib.
Sure Tom. I have added this in the patch attached.
Re: AIX support
On 16.02.26 00:34, Tom Lane wrote: > 0003 through 0005 are changes needed on top of that, mostly > borrowed from your patches although I corrected a few things. > I think these are small enough bites to be easily reviewable. 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. Separately, there is also this thread https://www.postgresql.org/message-id/flat/58cedbc7-5658-468d-868e-a4d06de04ca6%40eisentraut.org which was developed with the AIX support in mind. It seems it's no longer needed for the AIX support, but it might still be interesting on its own.
Re: AIX support
Peter Eisentraut 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". However ... this bit of that patchset is a problem: > The internal use static libraries like libpgcommon.a are still built in > any case, but if you disable static libraries, they are not installed. If we want to replicate the port's historical behavior, it needs to install those by default. So we need something more fine-grained than "all statics" or "no statics" internally. regards, tom lane
Re: AIX support
I wrote:
> Peter Eisentraut 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
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
Reviewed-by: Andres Freund
Reviewed-by: Tom Lane
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
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 ')
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 ') > 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, classoid oid_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, cfgnamespace oid_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, maptokentype int4_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, prsnamespace oid_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
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 distcheck world 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
PostgreSQL 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 PostgreSQL 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.
@@ -3484,6 +3484,123 @@ export MANPATH
installation issues.
+
+ AIX
+
+
+ AIX
+ installation on
+
+
+
+ You must use GCC
+ to build PostgreSQL
+ on AIX.
+ The native IBM compiler xlc is not supported.
+
+
+
+ AIX versions before 7.2 are no longer
+ tested nor supported by the PostgreSQL
+ community.
+
+
+
+ Memory Management
+
+
+
+ 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:
+
+=# 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.
+
+ Running as a non-owner in the group possessing the PostgreSQL
+ installation:
+
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
+
+ Another example is out of memory errors in the PostgreSQL server
+ logs, with every memory allocation near or greater than 256 MB
+ failing.
+
+
+
+ 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.
+
+
+
+ In the case of the plperl 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.
+
+
+
+ The ideal 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.
+
+
+
+ If a 32-bit binary is desired, set LDR_CNTRL to
+ MAXDATA=0xn0000000,
+ where 1 <= n <= 8, before starting the PostgreSQL server,
+ and try different values and postgresql.conf
+ settings to find a configuration that works satisfactorily. This
+ use of LDR_CNTRL tells AIX that you want the
+ server to have MAXDATA bytes set aside for the
+ heap, allocated in 256 MB segments. When you find a workable
+ configuration,
+ ldedit can be used to modify the binaries so
+ that they default to using the desired heap size. PostgreSQL can
+ also be rebuilt, passing configure
+ LDFLAGS="-Wl,-bmaxdata:0xn0000000"
+ to achieve the same effect.
+
+
+
+ For a 64-bit build, set OBJECT_MODE to 64 and
+ pass CC="gcc -maix64"
+ and LDFLAGS="-Wl,-bbigtoc"
+ to configure. If you omit the export of
+ OBJECT_MODE, your build may fail with linker errors. When
+ OBJECT_MODE is set, it tells AIX's build utilities
+ such as ar, as, and ld what
+ type of objects to default to handling.
+
+
+
+ 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.
+
+
+
+
Cygwin
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 @@ $ postgres -D $PGDATA -C num_os_semaphores
+
+ AIX
+ AIXIPC configuration
+
+
+
+ It should not be necessary to do
+ any special configuration for such parameters as
+ SHMMAX, 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 DB/2.
+
+ It might, however, be necessary to modify the global
+ ulimit information in
+ /etc/security/limits, as the default hard
+ limits for file sizes (fsize) and numbers of
+ files (nofiles) might be too low.
+
+
+
+
+
FreeBSD
FreeBSDIPC configuration
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
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
Author: Srirama Kucherlapati
Co-authored-by: Peter Eisentraut
Reviewed-by: Tom Lane
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
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 xlc is not supported.
+
+ 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 OBJECT_MODE before building:
+
+export OBJECT_MODE=64
+meson setup ...
+
+ Failure to do that will usually manifest as complaints
+ from ar about files having the wrong
+ object file mode.
+
+
AIX versions before 7.2 are no longer
tested nor supported by the PostgreSQL
community.
-
-
- Memory Management
-
-
-
- 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:
-
-=# 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.
-
- Running as a non-owner in the group possessing the PostgreSQL
- installation:
-
-=# CREATE EXTENSION plperl;
-ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
-
- Another example is out of memory errors in the PostgreSQL server
- logs, with every memory allocation near or greater than 256 MB
- failing.
-
-
-
- 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.
-
-
-
- In the case of the plperl 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.
-
-
-
- The ideal 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.
-
-
-
- If a 32-bit binary is desired, set LDR_CNTRL to
- MAXDATA=0xn0000000,
- where 1 <= n <= 8, before starting the PostgreSQL server,
- and try different values and postgresql.conf
- settings to find a configuration that works satisfactorily. This
- use of LDR_CNTRL tells AIX that you want the
- server to have MAXDATA bytes set aside for the
- heap, allocated in 256 MB segments. When you find a workable
- configuration,
- ldedit can be used to modify the binaries so
- that they default to using the desired heap size. PostgreSQL can
- also be rebuilt, passing configure
- LDFLAGS="-Wl,-bmaxdata:0xn0000000"
- to achieve the same effect.
-
-
-
- For a 64-bit build, set OBJECT_MODE to 64 and
- pass CC="gcc -maix64"
- and LDFLAGS="-Wl,-bbigtoc"
- to configure. If you omit the export of
- OBJECT_MODE, your build may fail with linker errors. When
- OBJECT_MODE is set, it tells AIX's build utilities
- such as ar, as, and ld what
- type of objects to default to handling.
-
-
-
- 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.
-
-
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
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 /* for size_t */
+#include /* for uid_t and gid_t */
+#include /* 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
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
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
RE: AIX support
From: Tom Lane <tgl@sss.pgh.pa.us>
> 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.
Thank you for all your support and patience.
Re: AIX support
Srirama Kucherlapati writes: > From: Tom Lane >> 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. > We have been coordinating with the OSU lab administrators regarding the > cfarm119 migration. There seems to be some networking issues in their lab. It looks like cfarm119 just came up again. I have the AIX patches all staged here and was planning to push as soon as I finish polishing the commit message. I will try it on cfarm119 once that's done; if there are any corrections to be made I expect they'd be minor. In the longer term, it'd be advisable to have buildfarm instances running on both 7.2 and 7.3. regards, tom lane
RE: AIX support
Hi Tom, thank you for all the updates.
> It looks like cfarm119 just came up again.
That’s good to hear.
>I have the AIX patches all staged here and was planning to push as
>soon as I finish polishing the commit message. I will try it on
>cfarm119 once that's done; if there are any corrections to be made
>I expect they'd be minor.
Thank you for your support.
>In the longer term, it'd be advisable to have buildfarm >instances running
>on both 7.2 and 7.3.
Sure, we will plan to setup accordingly and update you.
Re: AIX support
I wrote: > I have the AIX patches all staged here and was planning to push as > soon as I finish polishing the commit message. I will try it on > cfarm119 once that's done; if there are any corrections to be made > I expect they'd be minor. I confirmed that HEAD passes check-world on p9-aix1-postgres1 with both autoconf and meson builds; that was expected given previous testing, but it shows I didn't mess up the final commit. cfarm119 soon reminded me that I'd forgotten about the lgamma(NaN) problem discussed in [1]. I'm inclined to go ahead and push the patch shown there. Even though it's fixed in bleeding-edge AIX, there's no reason to believe that the average AIX installation in the field is any more up-to-date than cfarm119. Also, reviewing the thread, I wondered why the pgstat_slru.c build failure mentioned at [2] is not there anymore; it's not like we did anything to that code since January. On closer investigation, what's in unistd.h is actually #ifdef _LARGE_FILES #define ftruncate ftruncate64 #define truncate truncate64 #endif and it seems that we are setting _LARGE_FILES in 32-bit builds but not 64-bit ones. So not having that problem is an accidental consequence of deciding not to support 32-bit AIX builds. I wonder whether we should do something about it anyway. regards, tom lane [1] https://www.postgresql.org/message-id/573836.1769545598%40sss.pgh.pa.us [2] https://www.postgresql.org/message-id/190704.1769449537%40sss.pgh.pa.us
Re: AIX support
I wrote: > cfarm119 soon reminded me that I'd forgotten about the lgamma(NaN) > problem discussed in [1]. I'm inclined to go ahead and push the > patch shown there. [ time passes ... ] OK, cfarm119 is also happy, given the addition of that patch. So we should be good to go on re-enabling douc to run on master. (BTW, it looks like it hasn't run on the back branches either for a couple of weeks?) regards, tom lane
RE: AIX support
>[ time passes ... ] OK, cfarm119 is also happy, given the addition
>of that patch.
Thanks, Tom, for all your support and guidance.
We could see the AIX changes as part of this commit.
On behalf of our AIX team, we would like to extend our sincere thanks to the entire
>So we should be good to go on re-enabling douc to run on master.
>(BTW, it looks like it hasn't run on the back branches either
>for a couple of weeks?
Yes, the buildfarm scripts on that node were disabled earlier due to extensive
RE: AIX support
>Yes, the buildfarm scripts on that node were disabled earlier due to extensive
Re: AIX support
Srirama Kucherlapati writes: > Also we ran it on master and all the tests are passing > douc:HEAD [15:30:25] running make PL installcheck (C)... > douc:HEAD [15:30:29] restarting db (C)... > douc:HEAD [15:30:32] running make contrib installcheck (C)... > douc:HEAD [15:31:20] restarting db (C)... > douc:HEAD [15:31:22] running make test-modules installcheck (C)... > douc:HEAD [15:31:59] stopping db (C)... > douc:HEAD [15:32:08] running make ecpg check ... > douc:HEAD [15:32:29] OK > Branch: HEAD > All stages succeeded Good, but I don't see a report on the buildfarm server? regards, tom lane
RE: AIX support
> Also we ran it on master and all the tests are passing
>> douc:HEAD [15:30:25] running make PL installcheck (C)...
>> douc:HEAD [15:30:29] restarting db (C)...
>> douc:HEAD [15:30:32] running make contrib installcheck (C)...
>> douc:HEAD [15:31:20] restarting db (C)...
>> douc:HEAD [15:31:22] running make test-modules installcheck (C)...
>> douc:HEAD [15:31:59] stopping db (C)...
>> douc:HEAD [15:32:08] running make ecpg check ...
>> douc:HEAD [15:32:29] OK
>> Branch: HEAD
>> All stages succeeded
>Good, but I don't see a report on the buildfarm server?
Below is the error in the diff file
+ERROR: could not register background process
+HINT: You may need to increase "max_worker_processes".
After setting the ‘max_worker_processes=16”, in the "./inst/data-C/postgresql.conf” and ran
## gmake check installcheck-C
RE: AIX support
Attesting to the demand for Postgres support on AIX, associated with the use of SAS, I am aware of ~200 Customers running Postgres on AIX on some 600 unique deployments.
SAS is engaged with IBM regarding Postgres on AX and is a strong advocate to have support for this operating system restored.
-------------------------------------------------------------------
Joe Hatcher
SAS Cloud and Platform - Compute Services ▪ Product Manager
Tel: 919-531-0692 ▪ Mobile: 919-624-6149
www.sas.com
SAS® … THE POWER TO KNOW®
From: Aditya Kamath <Aditya.Kamath1@ibm.com>
Sent: Wednesday, January 28, 2026 10:20 AM
To: Srirama Kucherlapati <sriram.rk@in.ibm.com>; peter@eisentraut.org; andres@anarazel.de
Cc: pgsql-hackers@lists.postgresql.org; hlinnaka@iki.fi; tristan@partin.io; postgres-ibm-aix@wwpdl.vnet.ibm.com
Subject: RE: AIX support
EXTERNAL
Hi Andres,
I can explain this differently as well.
We know that include_directories property in meson will include the source and the build directory in the command. Ex: If we give “src/include” then “-Isrc/include” and “-I../src/include” are added.
>> + # This flag is required to make sure the user spefic float.h is
>> + # picked instead of the system float.h header file, which doesnot
>> + # have definition like float8, etc
>> + cflags += '-D_H_FLOAT’
>I don't understand this one - how does defining _H_FLOAT lead to a >different
>header being picked?
Below is the error message we get in AIX if we do not use '-D_H_FLOAT’
FAILED: src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o
gcc -Isrc/backend/utils/activity/wait_event_names.a.p -Isrc/include/utils -I../src/include/utils -Isrc/include -I../src/include -I/opt/freeware/include -I/opt/freeware/include/libxml2 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation -maix64 -fPIC -pthread -DBUILDING_DLL1233 -MD -MQ
./src/include/utils/float.h:28:19: error: expected ';' before 'int'
28 | extern PGDLLIMPORT int extra_float_digits;
There is a clear missing of float.h definitions, the reason being float.h got included before "src/include/c.h”.
Kindly observe the command "-I../src/include/utils” flag came in the front.
Now in c.h when stdio.h is called in AIX at line 65, then AIX system limits.h is called and then within that AIX system float.h is called.
But here is the catch. It won’t pick the AIX system float.h. It will pick the Postgres "src/include/utilsfloat.h”.
The reason being the compiler is designed to pick what comes first in -I flag. One proof of that is here. https://gcc.gnu.org/onlinedocs/cpp/Wrapper-Headers.html
I am assuming all systems behave like this.
This is the root cause of the problem. That "-I../src/include/utils” which meson adds.
So now "src/include/utils/float.h”.is picked up first even before "src/include/c.h”.
That is why we saw the error. When we define “_H_FLOAT” we essentially force the system header to be ignored in the system limits.h where it is called and then the Postgres "src/include/utils/float.h” takes over.
Hope this explains Andres.
There are multiple things we can do here.
One being define “_H_FLOAT”
The other being use #include_next float.h under ifdef _AIX guard
The third we are experimenting is to have implicit_include_directories: false as per document here https://mesonbuild.com/Include-directories.html, but that might difficult since recursive include directories exists in Postgres.
Kindly let us know if this explanation helps and what you think. Also If there is a preferred or cleaner way you know let us know.
Have a nice day ahead.
Thanks and regards,
Aditya.
From: Aditya Kamath <Aditya.Kamath1@ibm.com>
Date: Wednesday, 28 January 2026 at 3:55 PM
To: Srirama Kucherlapati <sriram.rk@in.ibm.com>, peter@eisentraut.org <peter@eisentraut.org>, andres@anarazel.de <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>, hlinnaka@iki.fi <hlinnaka@iki.fi>, tristan@partin.io <tristan@partin.io>, postgres-ibm-aix@wwpdl.vnet.ibm.com <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: Re: [EXTERNAL] Re: AIX support
Hi Andrew,
Thank you for your review comments for AIX so far.
While we are working on the rest of the comments you had sent here is our explanation for using the '-D_H_FLOAT’ flag in the source directory meson.build file.
>> + # This flag is required to make sure the user spefic float.h is
>> + # picked instead of the system float.h header file, which doesnot
>> + # have definition like float8, etc
>> + cflags += '-D_H_FLOAT’
>I don't understand this one - how does defining _H_FLOAT lead to a >different
>header being picked? Also, float8 is defined in c.h, so it hardly could >be
>influenced by a system float.h header?
>Our float.h header is only included as "utils/float.h", so it really >shouldn’t
>be confused with a system header?
So If we do not use the flag the error we get is as follows,
FAILED: src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o
gcc -Isrc/backend/utils/activity/wait_event_names.a.p -Isrc/include/utils -I../src/include/utils -Isrc/include -I../src/include -I/opt/freeware/include -I/opt/freeware/include/libxml2 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation -maix64 -fPIC -pthread -DBUILDING_DLL1233 -MD -MQ src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o -MF src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o.d -o src/backend/utils/activity/wait_event_names.a.p/wait_event_funcs.c.o -c ../src/backend/utils/activity/wait_event_funcs.c
In file included from /usr/include/sys/limits.h:307,
from /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/include-fixed/stdio.h:589,
from ../src/include/c.h:65,
from ../src/include/postgres.h:48,
from ../src/backend/utils/activity/wait_event_funcs.c:15:
../src/include/utils/float.h:28:19: error: expected ';' before 'int'
28 | extern PGDLLIMPORT int extra_float_digits;
../src/include/utils/float.h:289:37: error: unknown type name 'float4'
289 | float4_min(const float4 val1, const float4 val2)
../src/include/utils/float.h:294:15: error: unknown type name 'float8'
294 | static inline float8
The reason this happened is because -I../src/include/utils argument in the command included the float.h header first before the ./src/include/c.h header of postgresql which actually has the
PGDLLIMPORT, float4 and float8 definitions.
So, the header files have mismatched in the order they are processed. If we eliminate -I../src/include/utils in the command, then it will work.
But that will not happen automatically since we use include_directories() everywhere which adds both the source and the build directory includes. If we can get meson to not use
-I../src/include/ in AIX while including headers we will be able to compile.
We are currently experimenting with implicit_include_directories from the document below to see if we can remove the same
Reason for -D_H_FLOAT
This prevents AIX libc’s float.h to be included via c.h -> stdio.h -> limits.h -> float.h. The real problem is header include order in AIX. Compiler sees src/include/utils/float.h first and then c.h. This is a problem. When this flag is set, AIX’s float.h is skipped causing system header include chain to change. AIX no longer injects float.h early which results in c.h included before utils/float.h. the way Postgres expects.
Let us know what you think.
Is there a preferred or cleaner way you know to ensure the correct include ordering like using implicit_include_directories so that utils/float.h is not included before c.h?
Have a nice day ahead.
Thanks and regards,
Aditya.
From: Srirama Kucherlapati <sriram.rk@in.ibm.com>
Date: Wednesday, 28 January 2026 at 9:34 AM
To: Aditya Kamath <Aditya.Kamath1@ibm.com>
Subject: FW: [EXTERNAL] Re: AIX support
FYI
Warm regards,
Sriram.
------------------------------------------
VIOS/SSP Development,
ISDL, IBM India Pvt Ltd.
From: Andres Freund <andres@anarazel.de>
Date: Monday, 26 January 2026 at 21:11
To: Srirama Kucherlapati <sriram.rk@in.ibm.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>, Heikki Linnakangas <hlinnaka@iki.fi>, Tristan Partin <tristan@partin.io>, AIX PG user <postgres-ibm-aix@wwpdl.vnet.ibm.com>
Subject: [EXTERNAL] Re: AIX support
Hi,
From what I can tell the meson patch *AGAIN* is missing mkldexport.sh. Also,
you seem to reference the script as files('port/aix/mkldexport.sh'), but that
that's not a path that makes sense for our source code structure (nor where
the "complete" patch adds it).
You really need to actually start testing your patches.
Doesn't the meson patch also require the changes to src/tools/gen_export.pl?
On 2026-01-23 16:11:25 +0000, Srirama Kucherlapati wrote:
> diff --git a/meson.build b/meson.build
> index 6e7ddd74683..17ad9c6ca32 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -198,6 +198,8 @@ endif
> # that purpose.
> portname = host_system
>
> +dep_static_lib = declare_dependency()
Add a comment saying something like
# In some configurations we don't want to install static libraries. For those
# dep_static_lib can be set to disabler() below.
The introduction of dep_static_lib should be broken out into its own patch.
> + # This flag is required to make sure the user spefic float.h is
> + # picked instead of the system float.h header file, which doesnot
> + # have definition like float8, etc
> + cflags += '-D_H_FLOAT'
I don't understand this one - how does defining _H_FLOAT lead to a different
header being picked? Also, float8 is defined in c.h, so it hardly could be
influenced by a system float.h header?
Our float.h header is only included as "utils/float.h", so it really shouldn't
be confused with a system header?
> @@ -1765,10 +1793,49 @@ endforeach
> # 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.
> -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')
> -endif
> +if host_system != 'aix'
> + 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')
> + endif
> +else
> + # The AIX 'power' alignment rules apply the natural alignment of the "first
> + # member" if it is of a floating-point data type (or is an aggregate whose
> + # recursively "first" member or element is such a type). The alignment
> + # associated with these types for subsequent members use an alignment value
> + # where the floating-point data type is considered to have 4-byte alignment.
> + # More info
> + # https://urldefense.proofpoint.com/v2/url?u=https-3A__gcc.gnu.org_bugzilla_show-5Fbug.cgi-3Fid-3D99557&d=DwIBAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=vAjXYU48syuVpPwT4QhmwXMV4E--HIOXIW0gSQS4cHk&m=spxpHlbU-oUOjZWtuXCtkVhprvgA3G5mhMCfcMRz7RhvcqbJQbX0erzJ-MgCiBKp&s=cdf4qUM5zjhQjv8rAUj5eMnRTtNyjaOEuuJFiHMu0uY&e=
> + #
> + # The double is aligned to 4-bytes on AIX in aggregates. But to maintain
> + # alignement across platforms the max alignment of long should be considered.
How are these "AIX 'power' alignment rules" for float not just completely
broken?
I assume this means that 4 byte aligned floats work just fine, but have
degraded peformance?
Is there documentation about this that isn't an already fixed bug report in gcc?
Maybe I'm confused, but doesn't this power alignment rule mean that the
cc.alignment('double') will always return 8? That computation won't apply the
"subsequent member" rule, and therefore will have an alignment of 8. Which in
turn seems to make this entire change pointless?
> + # Get the alignment values
> + ac_cv_alignof_long = cc.alignment('long', args: test_c_args, prefix: '#include <stdint.h>')
> + ac_cv_alignof_double = cc.alignment('double', args: test_c_args, prefix: '#include <stdint.h>')
> + ac_cv_alignof_int64_t = cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>')
I've previously complained about these av_cv_ variable names. This isn't
autoconf. What is this doing here?
Why do we need a platform specific alignment determination for long, int64?
> + message('Alignment of long : @0@'.format(ac_cv_alignof_long))
> + message('Alignment of double : @0@'.format(ac_cv_alignof_double))
> + message('Alignment of int64_t : @0@'.format(ac_cv_alignof_int64_t))
These are already going to be output by cc.alignment, this is just redundant,
no?
> + # Start with long
> + alignof_double = ac_cv_alignof_long
> + message('MAX ALIGN ac_cv_alignof_long')
> +
> + # Compare with double
> + if alignof_double < ac_cv_alignof_double
> + alignof_double = ac_cv_alignof_double
> + message('MAX ALIGN ac_cv_alignof_double')
> + endif
> +
> + # Compare with int64_t
> + if alignof_double < ac_cv_alignof_int64_t
> + alignof_double = ac_cv_alignof_int64_t
> + message('MAX ALIGN ac_cv_alignof_int64_t')
> + endif
> +endif
> +message('MAX ALIGN OF DOUBLE : @0@'.format(alignof_double))
This is a lot of output for something that's just computing a maximum of three
variables.
> diff --git a/src/backend/meson.build b/src/backend/meson.build
> index b831a541652..4838f245ab3 100644
> --- a/src/backend/meson.build
> +++ b/src/backend/meson.build
> @@ -125,6 +125,24 @@ if host_system == 'windows'
> '--FILEDESC', 'PostgreSQL Server',])
> endif
>
> +if 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
This should be moved next to the msvc specific block (the one about
postgres_def) and should use an elif.
Greetings,
Andres Freund