Skip to content

Commit ae7d54f

Browse files
committed
Add PostgreSQL 19 compatibility
1 parent 7e7a8d9 commit ae7d54f

6 files changed

Lines changed: 43 additions & 6 deletions

File tree

include/clientauth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
* contains the changes needed by uni_api to load the functionality for
1919
* clientauth.
2020
*/
21-
void clientauth_init();
21+
void clientauth_init(void);

include/compatibility.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,11 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
382382
CastCreate(sourcetypeid, targettypeid, funcid, castcontext, castmethod, behavior)
383383
#endif
384384

385-
#if PG_VERSION_NUM >= 140000
385+
#if PG_VERSION_NUM >= 190000
386+
#define FUNCNAME_GET_CANDIDATES(names, nargs, argnames, expand_variadic, expand_defaults, missing_ok) \
387+
({ int _fgc_flags = 0; \
388+
FuncnameGetCandidates(names, nargs, argnames, expand_variadic, expand_defaults, false /* include_out_arguments */, missing_ok, &_fgc_flags); })
389+
#elif PG_VERSION_NUM >= 140000
386390
#define FUNCNAME_GET_CANDIDATES(names, nargs, argnames, expand_variadic, expand_defaults, missing_ok) \
387391
FuncnameGetCandidates(names, nargs, argnames, expand_variadic, expand_defaults, false /* include_out_arguments */, missing_ok)
388392
#else
@@ -635,4 +639,22 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
635639
ExecutorRun((queryDesc), (direction), (count), (execute_once))
636640
#endif
637641

642+
/*
643+
* PostgreSQL version 19
644+
*
645+
* pgstat.h no longer transitively includes utils/wait_event.h
646+
* log_min_messages changed from int to int[]
647+
* get_database_name moved to utils/lsyscache.h
648+
* get_database_oid moved to catalog/pg_database.h
649+
* CreateSchemaCommand signature changed to (ParseState*, CreateSchemaStmt*, int, int)
650+
*/
651+
#if (PG_VERSION_NUM >= 190000)
652+
#include "utils/wait_event.h"
653+
#include "catalog/pg_database.h"
654+
#include "utils/lsyscache.h"
655+
#define LOG_MIN_MESSAGES_VALUE log_min_messages[0]
656+
#else
657+
#define LOG_MIN_MESSAGES_VALUE log_min_messages
658+
#endif
659+
638660
#endif /* SET_USER_COMPAT_H */

include/passcheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
* contains the changes needed by uni_api to load the functionality for
1919
* passcheck.
2020
*/
21-
void passcheck_init();
21+
void passcheck_init(void);

src/clientauth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ clientauth_sighup(SIGNAL_ARGS)
831831
* 3. pgtle.enable_clientauth is ON and no functions are registered with the clientauth feature
832832
*/
833833
static bool
834-
can_allow_without_executing()
834+
can_allow_without_executing(void)
835835
{
836836
List *proc_names;
837837
Oid extOid;
@@ -865,7 +865,7 @@ can_allow_without_executing()
865865
* 2. pgtle.enable_clientauth is REQUIRE and no functions are registered with the clientauth feature
866866
*/
867867
static bool
868-
can_reject_without_executing()
868+
can_reject_without_executing(void)
869869
{
870870
List *proc_names;
871871
Oid extOid;

src/tleextension.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
#include "nodes/plannodes.h"
7474
#include "parser/parse_func.h"
7575
#include "parser/parse_type.h"
76+
#if PG_VERSION_NUM >= 190000
77+
#include "parser/parse_node.h"
78+
#endif
7679
#include "storage/fd.h"
7780
#include "tcop/tcopprot.h"
7881
#include "tcop/utility.h"
@@ -86,6 +89,7 @@
8689
#include "utils/snapmgr.h"
8790
#include "utils/syscache.h"
8891
#include "utils/varlena.h"
92+
#include "utils/tuplestore.h"
8993

9094
#include "constants.h"
9195
#include "tleextension.h"
@@ -1332,7 +1336,7 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
13321336
PGC_USERSET, PGC_S_SESSION,
13331337
GetUserId(),
13341338
GUC_ACTION_SAVE, true, 0, false);
1335-
if (log_min_messages < WARNING)
1339+
if (LOG_MIN_MESSAGES_VALUE < WARNING)
13361340
(void) set_config_option_ext("log_min_messages", "warning",
13371341
PGC_SUSET, PGC_S_SESSION,
13381342
BOOTSTRAP_SUPERUSERID,
@@ -2067,14 +2071,25 @@ CreateExtensionInternal(char *extensionName,
20672071

20682072
if (!OidIsValid(schemaOid))
20692073
{
2074+
#if PG_VERSION_NUM >= 190000
2075+
ParseState *pstate = make_parsestate(NULL);
2076+
#endif
20702077
CreateSchemaStmt *csstmt = makeNode(CreateSchemaStmt);
20712078

2079+
#if PG_VERSION_NUM >= 190000
2080+
pstate->p_sourcetext = "(generated CREATE SCHEMA command)";
2081+
#endif
2082+
20722083
csstmt->schemaname = schemaName;
20732084
csstmt->authrole = NULL; /* will be created by current user */
20742085
csstmt->schemaElts = NIL;
20752086
csstmt->if_not_exists = false;
2087+
#if PG_VERSION_NUM >= 190000
2088+
CreateSchemaCommand(pstate, csstmt, -1, -1);
2089+
#else
20762090
CreateSchemaCommand(csstmt, "(generated CREATE SCHEMA command)",
20772091
-1, -1);
2092+
#endif
20782093

20792094
/*
20802095
* CreateSchemaCommand includes CommandCounterIncrement, so new

test/expected/pg_tle_versions_1.out

Whitespace-only changes.

0 commit comments

Comments
 (0)