Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
strategy:
matrix:
pg: [14, 13, 12, 11, 10, 9.6, 9.5, 9.4]
pg: [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4]
name: 🐘 PostgreSQL ${{ matrix.pg }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ To run the tests use:

All the tests are in the sql directory.

### Running tests interactively in docker

First terminal:

```
docker stop pgx-test-v1 && docker rm pgx-test-v1
docker run -it --name pgx-test-v1 --mount "type=bind,src=$(pwd),dst=/repo" pgxn/pgxn-tools bash
pg-start 12
tail -f /var/log/postgresql/postgresql-12-test.log
```

Second terminal:

```
docker exec -it pgx-test-v1 bash
cd repo/ && make clean && make all PROFILE="-Werror" && sudo make install
make installcheck PGUSER=postgres
```


## BENCHMARKING

The exact queries can be found in `./example`
Expand Down
23 changes: 20 additions & 3 deletions jsonb_deep_sum.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ jsonb_deep_add(PG_FUNCTION_ARGS)
v2;
JsonbIteratorToken r1,
r2;
JsonbValue *res;
JsonbParseState *state = NULL;

/* Here we create the new jsonb */
int nestedLevel = 0;

// JsonbInState added in Pg 19
// https://github.com/postgres/postgres/commit/0986e95161cec929d8f39c01e9848f34526be421#diff-e2cc4121fa71649fd07c5c71cb382075688efd1e6522e203f2889681532655a4
#if PG_VERSION_NUM >= 190000
JsonbInState state;
memset(&state, 0, sizeof(state));
#else
JsonbParseState *state = NULL;
JsonbValue *res;
#endif


if (jb1 == NULL)
#ifdef PG_RETURN_JSONB_P
PG_RETURN_JSONB_P(jb2);
Expand Down Expand Up @@ -149,12 +158,20 @@ jsonb_deep_add(PG_FUNCTION_ARGS)

}

#if PG_VERSION_NUM >= 190000
pushJsonbValue(&state, WJB_END_OBJECT, NULL);
#else
res = pushJsonbValue(&state, WJB_END_OBJECT, NULL);
#endif

Assert(res != NULL);

#ifdef PG_RETURN_JSONB_P
PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
#if PG_VERSION_NUM >= 190000
PG_RETURN_JSONB_P(JsonbValueToJsonb(state.result));
#else
PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
#endif
#else
PG_RETURN_JSONB(JsonbValueToJsonb(res));
#endif
Expand Down
Loading