pglogical icon indicating copy to clipboard operation
pglogical copied to clipboard

Support for PostgreSQL 18

Open anth0nyleung opened this issue 6 months ago • 1 comments

Hello there 👋 . Im wondering if there is any plan / timeline on support PG18 now that PGBeta1 is out.

Thanks.

anth0nyleung avatar Jun 19 '25 03:06 anth0nyleung

I plan to do it on 2025-08-14. Before that date, I'd welcome pull requests with accompanying make check and make check_prove results.

nmisch avatar Jun 20 '25 04:06 nmisch

Jumping in for the RPM packaging.

devrimgunduz avatar Jul 01 '25 12:07 devrimgunduz

I'm trying to verify where pglogical breaks on version 18beta1.

I followed these steps: cp -rvp compat17 compat18

No changes, of course, got the following:

pglogical_apply.c:138:12: warning: no previous extern declaration for non-static variable 'lsn_mapping' [-Wmissing-variable-declarations]
  138 | dlist_head lsn_mapping = DLIST_STATIC_INIT(lsn_mapping);
      |            ^
pglogical_apply.c:138:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
  138 | dlist_head lsn_mapping = DLIST_STATIC_INIT(lsn_mapping);
      | ^
pglogical_apply.c:1618:8: error: too many arguments to function call, expected 6, have 7
 1615 |                 (void) PortalRun(portal, FETCH_ALL,
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1616 |                                                  isTopLevel,
      |                                                  ~~~~~~~~~~~
 1617 |                                                  receiver, receiver,
      |                                                  ~~~~~~~~~~~~~~~~~~~
 1618 |                                                  NULL);
      |                                                  ^~~~~
/usr/lib64/llvm20/bin/../../../lib/clang/20/include/__stddef_null.h:26:14: note: expanded from macro 'NULL'
   26 | #define NULL ((void*)0)
      |              ^~~~~~~~~~
/home/vinnix/Sources/Github/pglogical/compat18/pglogical_compat.h:25:60: note: expanded from macro 'PortalRun'
   25 |         PortalRun(portal, count, isTopLevel, true, dest, altdest, qc)
      |         ~~~~~~~~~                                                 ^~
/home/vinnix/pg-versions/REL_18_STABLE-20250706-1411/include/postgresql/server/tcop/pquery.h:38:13: note: 'PortalRun' declared here
   38 | extern bool PortalRun(Portal portal, long count, bool isTopLevel,
      |             ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   39 |                                           DestReceiver *dest, DestReceiver *altdest,
      |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   40 |                                           QueryCompletion *qc);
      |                                           ~~~~~~~~~~~~~~~~~~~
pglogical_apply.c:155:29: warning: no previous extern declaration for non-static variable 'errcallback_arg' [-Wmissing-variable-declarations]
  155 | struct ActionErrCallbackArg errcallback_arg;
      |                             ^
pglogical_apply.c:155:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
  155 | struct ActionErrCallbackArg errcallback_arg;
      | ^
2 warnings and 1 error generated.
make: *** [<builtin>: pglogical_apply.o] Error 1

Looking the function signature of REL_18_STABLE at src/backend/tcop/pquery.c:

de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  661) /*
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  662)  * PortalRun
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  663)  *               Run a portal's query or queries.
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  664)  *
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  665)  * count <= 0 is interpreted as a no-op: the destination gets started up
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  666)  * and shut down, but nothing else happens.  Also, count == FETCH_ALL is
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  667)  * interpreted as "all rows".  Note that count is ignored in multi-query
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  668)  * situations, where we always run the portal to completion.
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  669)  *
b9527e984092 (Tom Lane         2007-03-13 00:33:44 +0000  670)  * isTopLevel: true if query is being executed at backend "top level"
b9527e984092 (Tom Lane         2007-03-13 00:33:44 +0000  671)  * (that is, directly from a client command message)
b9527e984092 (Tom Lane         2007-03-13 00:33:44 +0000  672)  *
556f7b7bc18d (Tom Lane         2024-12-09 14:38:19 -0500  673)  * run_once: ignored, present only to avoid an API break in stable branches.
556f7b7bc18d (Tom Lane         2024-12-09 14:38:19 -0500  674)  *
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  675)  * dest: where to send output of primary (canSetTag) query
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  676)  *
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  677)  * altdest: where to send output of non-primary queries
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  678)  *
2f9661311b83 (Alvaro Herrera   2020-03-02 18:19:51 -0300  679)  * qc: where to store command completion status data.
2f9661311b83 (Alvaro Herrera   2020-03-02 18:19:51 -0300  680)  *               May be NULL if caller doesn't want status data.
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  681)  *
2eb4a831e5fb (Peter Eisentraut 2017-08-16 00:22:32 -0400  682)  * Returns true if the portal's execution is complete, false if it was
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  683)  * suspended due to exhaustion of the count parameter.
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  684)  */
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  685) bool
691b8d59281b (Robert Haas      2017-03-23 13:05:48 -0400  686) PortalRun(Portal portal, long count, bool isTopLevel, bool run_once,
79913910d4b5 (Tom Lane         2003-05-06 20:26:28 +0000  687)            DestReceiver *dest, DestReceiver *altdest,
2f9661311b83 (Alvaro Herrera   2020-03-02 18:19:51 -0300  688)            QueryCompletion *qc)
de28dc9a04c4 (Tom Lane         2003-05-02 20:54:36 +0000  689) {

I was trying to understand which parameters that might be missing, here I want to presume REL_18_STABLE is correct when using PortalRun, because it's actually working and passing my tests.

Now, when looking at master branch:

e984092 (Tom Lane           2007-03-13 00:33:44 +0000  671)  * isTopLevel: true if query is being executed at backend "top level"
b9527e984092 (Tom Lane           2007-03-13 00:33:44 +0000  672)  * (that is, directly from a client command message)
b9527e984092 (Tom Lane           2007-03-13 00:33:44 +0000  673)  *
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  674)  * dest: where to send output of primary (canSetTag) query
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  675)  *
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  676)  * altdest: where to send output of non-primary queries
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  677)  *
2f9661311b83 (Álvaro Herrera     2020-03-02 18:19:51 -0300  678)  * qc: where to store command completion status data.
2f9661311b83 (Álvaro Herrera     2020-03-02 18:19:51 -0300  679)  *             May be NULL if caller doesn't want status data.
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  680)  *
2eb4a831e5fb (Peter Eisentraut   2017-08-16 00:22:32 -0400  681)  * Returns true if the portal's execution is complete, false if it was
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  682)  * suspended due to exhaustion of the count parameter.
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  683)  */
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  684) bool
3eea7a0c97e9 (Tom Lane           2024-12-09 14:38:19 -0500  685) PortalRun(Portal portal, long count, bool isTopLevel,
79913910d4b5 (Tom Lane           2003-05-06 20:26:28 +0000  686)                  DestReceiver *dest, DestReceiver *altdest,
2f9661311b83 (Álvaro Herrera     2020-03-02 18:19:51 -0300  687)                  QueryCompletion *qc)
de28dc9a04c4 (Tom Lane           2003-05-02 20:54:36 +0000  688) {

It looks like the commit 691b8d59281b https://github.com/postgres/postgres/commit/691b8d59281b from Robert Haas is included on REL_18_STABLE (note this commit is from Mar 23, 2017) and is missing from master.

What are the commiters positions on this?

[update] Taking a closer look at the commit, I can see it's included on REL_18_BETA1, so I think that will be included on REL_18_STABLE as well.

vinnix avatar Jul 07 '25 20:07 vinnix

I can't reproduce that blame result:

$ git blame origin/REL_18_STABLE src/backend/tcop/pquery.c | grep ') PortalRun('
Blaming lines: 100% (1799/1799), done.
3eea7a0c (Tom Lane           2024-12-09 14:38:19 -0500  685) PortalRun(Portal portal, long count, bool isTopLevel,
$ git blame origin/master src/backend/tcop/pquery.c | grep ') PortalRun('
Blaming lines: 100% (1799/1799), done.
3eea7a0c (Tom Lane           2024-12-09 14:38:19 -0500  685) PortalRun(Portal portal, long count, bool isTopLevel,

My best guess is that your local "master" branch was created long ago and not recently fast-forwarded. git checkout master && git pull should fix that. You can also use remote tracking branch origin/master.

nmisch avatar Jul 11 '25 19:07 nmisch

See https://postgr.es/m/flat/[email protected] for an upstream decision involving the pglogical row_filter feature.

nmisch avatar Aug 09 '25 23:08 nmisch