Skip to content

Commit

Permalink
chore: compile on pg16
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Jan 31, 2024
1 parent 58f76aa commit 78f14ab
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let
postgresql_13
postgresql_14
postgresql_15
postgresql_16
];
pgWithExt = { postgresql }: postgresql.withPackages (p: [
(callPackage ./nix/supautils.nix { inherit postgresql; extraMakeFlags = "TEST=1"; })
Expand Down
16 changes: 11 additions & 5 deletions src/constrained_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
#include <errno.h>

#include "constrained_extensions.h"
#include "utils.h"

static void
static JSON_ACTION_RETURN_TYPE
json_array_start(void *state)
{
json_constrained_extension_parse_state *parse = state;

parse->state = JCE_UNEXPECTED_ARRAY;
parse->error_msg = "unexpected array";
JSON_ACTION_RETURN;
}

static void
static JSON_ACTION_RETURN_TYPE
json_object_start(void *state)
{
json_constrained_extension_parse_state *parse = state;
Expand All @@ -44,9 +46,10 @@ json_object_start(void *state)
default:
break;
}
JSON_ACTION_RETURN;
}

static void
static JSON_ACTION_RETURN_TYPE
json_object_end(void *state)
{
json_constrained_extension_parse_state *parse = state;
Expand All @@ -60,9 +63,10 @@ json_object_end(void *state)
default:
break;
}
JSON_ACTION_RETURN;
}

static void
static JSON_ACTION_RETURN_TYPE
json_object_field_start(void *state, char *fname, bool isnull)
{
json_constrained_extension_parse_state *parse = state;
Expand Down Expand Up @@ -91,9 +95,10 @@ json_object_field_start(void *state, char *fname, bool isnull)
default:
break;
}
JSON_ACTION_RETURN;
}

static void
static JSON_ACTION_RETURN_TYPE
json_scalar(void *state, char *token, JsonTokenType tokentype)
{
json_constrained_extension_parse_state *parse = state;
Expand Down Expand Up @@ -144,6 +149,7 @@ json_scalar(void *state, char *token, JsonTokenType tokentype)
default:
break;
}
JSON_ACTION_RETURN;
}

json_constrained_extension_parse_state
Expand Down
16 changes: 11 additions & 5 deletions src/extensions_parameter_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
#include <utils/memutils.h>

#include "extensions_parameter_overrides.h"
#include "utils.h"

static void json_array_start(void *state) {
static JSON_ACTION_RETURN_TYPE json_array_start(void *state) {
json_extension_parameter_overrides_parse_state *parse = state;

parse->state = JEPO_UNEXPECTED_ARRAY;
parse->error_msg = "unexpected array";
JSON_ACTION_RETURN;
}

static void json_object_start(void *state) {
static JSON_ACTION_RETURN_TYPE json_object_start(void *state) {
json_extension_parameter_overrides_parse_state *parse = state;

switch (parse->state) {
Expand All @@ -32,9 +34,10 @@ static void json_object_start(void *state) {
default:
break;
}
JSON_ACTION_RETURN;
}

static void json_object_end(void *state) {
static JSON_ACTION_RETURN_TYPE json_object_end(void *state) {
json_extension_parameter_overrides_parse_state *parse = state;

switch (parse->state) {
Expand All @@ -45,9 +48,10 @@ static void json_object_end(void *state) {
default:
break;
}
JSON_ACTION_RETURN;
}

static void json_object_field_start(void *state, char *fname, bool isnull) {
static JSON_ACTION_RETURN_TYPE json_object_field_start(void *state, char *fname, bool isnull) {
json_extension_parameter_overrides_parse_state *parse = state;
extension_parameter_overrides *x = &parse->epos[parse->total_epos];

Expand All @@ -69,9 +73,10 @@ static void json_object_field_start(void *state, char *fname, bool isnull) {
default:
break;
}
JSON_ACTION_RETURN;
}

static void json_scalar(void *state, char *token, JsonTokenType tokentype) {
static JSON_ACTION_RETURN_TYPE json_scalar(void *state, char *token, JsonTokenType tokentype) {
json_extension_parameter_overrides_parse_state *parse = state;
extension_parameter_overrides *x = &parse->epos[parse->total_epos];

Expand Down Expand Up @@ -99,6 +104,7 @@ static void json_scalar(void *state, char *token, JsonTokenType tokentype) {
default:
break;
}
JSON_ACTION_RETURN;
}

json_extension_parameter_overrides_parse_state
Expand Down
13 changes: 13 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@

#define PG14_GTE (PG_VERSION_NUM >= 140000)
#define PG15_GTE (PG_VERSION_NUM >= 150000)
#define PG16_GTE (PG_VERSION_NUM >= 160000)

#if PG16_GTE

#define JSON_ACTION_RETURN_TYPE JsonParseErrorType
#define JSON_ACTION_RETURN return JSON_SUCCESS

#else

#define JSON_ACTION_RETURN_TYPE void
#define JSON_ACTION_RETURN return

#endif

#if PG14_GTE

Expand Down

0 comments on commit 78f14ab

Please sign in to comment.