pgrx icon indicating copy to clipboard operation
pgrx copied to clipboard

PG18 Support

Open anth0nyleung opened this issue 7 months ago • 10 comments

Hello. The first pg18 beta version is going to be release in about 3 weeks. I could not find any issues tracking the support for Pg18, hence creating a new issue to track this.

I am curious about whether there's any timeline on supporting that or would it be possible to start on that with the current 18_devel branch.

Thank you.

anth0nyleung avatar Apr 30 '25 20:04 anth0nyleung

I plan to work on that, but there's a rule about supporting only final versions. Therefore, it won't be merged till the last moment.

YohDeadfall avatar May 01 '25 12:05 YohDeadfall

Thanks @YohDeadfall ! Im curious where this rule is defined and the reason behind it. Could you also please clarify on what you mean by final version? do you mean the first beta version / rc / .0 version?

anth0nyleung avatar May 01 '25 15:05 anth0nyleung

The 18.0 version. See https://github.com/paradedb/paradedb/issues/1019#issuecomment-2836716401.

YohDeadfall avatar May 01 '25 17:05 YohDeadfall

Hi, we have a branch to support PG18 and already tested it with our pgrx extension. Check it at https://github.com/silver-ymz/pgrx/tree/support-18-devel cc @silver-ymz

VoVAllen avatar May 01 '25 23:05 VoVAllen

Oh, that's cool! Could you please open a pull request then?

YohDeadfall avatar May 02 '25 06:05 YohDeadfall

Could you please open a pull request then?

Yes, I'd like to open a PR then.

silver-ymz avatar May 03 '25 01:05 silver-ymz

Sorry for asking stupid questions, but does that mean that we have to wait until PostgreSQL 18 is released in autumn before we can build extensions with pgrx for it?

I'm unfamiliar with Rust / crago / pgrx, I just want to build extensions for PostgreSQL 18beta1 for testing, so that we can release it simultaneously with PostgreSQL 18.

The following commands fail (I assume that is because PostgreSQL 18 is not supported yet)

cargo install cargo-pgrx # as far as I can tell this installs pgrx 14.3
cargo pgrx init --pg18 # suggests using the argument --pg17 instead :)

As I said before, I'm unfamiliar how rust, cargo and pgrx work together, I'm just trying to understand if I can test building extensions for PostgreSQL 18 ahead of time, or if I need to wait until after it was released.

jakob avatar Jun 23 '25 12:06 jakob

@jakob It's supported in develop branch. Use cargo-pgrx and pgrx in this repo.

usamoi avatar Jun 23 '25 12:06 usamoi

Use cargo-pgrx and pgrx in this repo

How do I do this? The readme says something about using cargo-local-install, is that what I need to use? Again, apologies for asking stupid questions, I'm so unfamiliar with Rust and cargo I feel like I'm in a foreign country and everyone is speaking a foreign language.

jakob avatar Jun 23 '25 12:06 jakob

Use cargo-pgrx and pgrx in this repo

How do I do this? The readme says something about using cargo-local-install, is that what I need to use? Again, apologies for asking stupid questions, I'm so unfamiliar with Rust and cargo I feel like I'm in a foreign country and everyone is speaking a foreign language.

  1. run cargo install cargo-pgrx --git https://github.com/pgcentralfoundation/pgrx.git --branch develop to install cargo-pgrx
  2. edit Cargo.toml of your extension from
[features]
default = ["pg13"]
pg13 = ["pgrx/pg13", "pgrx-tests/pg13" ]
pg14 = ["pgrx/pg14", "pgrx-tests/pg14" ]
pg15 = ["pgrx/pg15", "pgrx-tests/pg15" ]
pg16 = ["pgrx/pg16", "pgrx-tests/pg16" ]
pg17 = ["pgrx/pg17", "pgrx-tests/pg17" ]
pg_test = []

to

[features]
default = ["pg13"]
pg13 = ["pgrx/pg13", "pgrx-tests/pg13" ]
pg14 = ["pgrx/pg14", "pgrx-tests/pg14" ]
pg15 = ["pgrx/pg15", "pgrx-tests/pg15" ]
pg16 = ["pgrx/pg16", "pgrx-tests/pg16" ]
pg17 = ["pgrx/pg17", "pgrx-tests/pg17" ]
pg18 = ["pgrx/pg18", "pgrx-tests/pg18" ]
pg_test = []

and from

[dependencies]
pgrx = "=0.14.3"

[dev-dependencies]
pgrx-tests = "=0.14.3"

to

[dependencies]
pgrx = { git = "https://github.com/pgcentralfoundation/pgrx.git" }

[dev-dependencies]
pgrx-tests = { git = "https://github.com/pgcentralfoundation/pgrx.git" }
  1. build the extension, like original steps

If you encounter any issues, just copy and paste the instructions along with what you see to the AI. It should be able to handle it.

usamoi avatar Jun 23 '25 13:06 usamoi

@usamoi Thank you for the instructions. I got a bit further (I was trying to build pg_search). Unfortunately there are still a lot of errors to fix, I guess I'll have to wait until the developers of pg_search fix the problems.

I think I did find an issue with pgrx, though. As far as I can tell some new header files have been introduced in PG 18 (compared to PG 17) and it looks like they are missing in the pg-sys module.

These headers that are new in PG 18, and they are missing in pgrx-pg-sys/include/pg18.h:

#include "access/cmptype.h"
#include "access/gin_tuple.h"
#include "commands/copyapi.h"
#include "commands/explain_dr.h"
#include "commands/explain_format.h"  // <-- adding this header fixed one of ~50 build errors in pg_search
#include "commands/explain_state.h"
#include "common/oauth-common.h"
#include "executor/execScan.h"
#include "libpq/oauth.h"
#include "libpq/pg-gssapi.h"
#include "port/pg_numa.h"
#include "replication/conflict.h"
#include "replication/snapbuild_internal.h"
#include "snowball/libstemmer/stem_UTF_8_estonian.h"
#include "statistics/stat_utils.h"
#include "storage/aio.h"
#include "storage/aio_internal.h"
#include "storage/aio_subsys.h"
#include "storage/aio_types.h"
#include "storage/io_worker.h"
#include "storage/waiteventset.h"
#include "utils/funccache.h"
#include "utils/pgstat_kind.h"
#include "utils/skipsupport.h"
#include "utils/wait_classes.h"

I'm not sure if they should be added, or if the list is normally autogenerated?

jakob avatar Jun 24 '25 14:06 jakob

We don't generally add headers unless someone needs them, because every header we add increases build times a little. If you need them, adding them is easy.

It seems PG18 support has been added so we're good here on the most basic part.

workingjubilee avatar Oct 28 '25 22:10 workingjubilee