Skip to content

Commit 81ecd56

Browse files
jrgemignanimuhammadshoaibrafsun42
authored
Master to PostgreSQL version 16 (#1451)
* Initial PG16 version (#1237) Fixed empty string handling. Previously, the PG 16 outToken emitted NULL for an empty string, but now it emits an empty string "". Consequently, our cypher read function required modification to properly decode the empty string as a plain token, thereby addressing the comparison issue. Compared the branches and added the necessary changes so that the query's rteperminfos variable doesn't stay NULL. Fix missing include varatt.h (causing undefined symbol VARDATA_ANY) & Fixing some test cases of the failings Added missing include varatt.h to fix the undefined symbol while loading age into postgresql because usage of VARDATA_ANY needs to import varatt.h in PG16 Modified initialisation of ResultRelInfo and removed unnecessary RTEs Compared the branches and added the necessary changes so that the query's rteperminfos variable doesn't stay NULL. Modified initialisation of ResultRelInfo and removed unnecessary RTEs One of the problems that we were facing was related to the ResultRelInfo pointing at the wrong RTE via its ri_RangeTableIndex. The create_entity_result_rel_info() function does not have the capability of setting the ri_RootResultRelInfo to the correct ResultRelInfo node because it does not have access to the ModifyTableState node. The solution for this was to set the third argument in InitResultRelInfo() to be zero instead of list_length(estate->es_range_table). In the update_entity_tuple() function, when we call table_tuple_update() and assign the returned value to the result variable, the buffer variable receives the value of 0. Made a workaround so that the original value isn't lost. This is a work in progress for the new field that was added to the struct Var called varnullingrels. According to the documentation, this field is responsible for marking the Vars as nullable, if they are coming from a JOIN, either LEFT JOIN, RIGHT JOIN, or FULL OUTER JOIN. The changes were made following an "optional match" clause which is being treated as a LEFT JOIN from our extension. A function markRelsAsNulledBy is added because its internal in Postgres and doesn't belong in a header file, therefore it can't be exported. This function is added before the creation of the Vars from the make_vertex_expr and make_edge_expr, to correctly mark the specific PNSI as nullable, so later in the planner stage, the Vars will be correctly nulled. Fix incorrect typecasting in agtype_to_graphid function. Fix incorrect returns to the fuction _label_name, _ag_build_vertex and _ag_build_edge. Contributors Panagiotis Foliadis <[email protected]> Matheus Farias <[email protected]> Mohamed Mokhtar <[email protected]> Hannan Aamir <[email protected]> John Gemignani <[email protected]> Muhammad Taha Naveed <[email protected]> Wendel de Lana <[email protected]> --------- * Fix Docker files to reflect PostgreSQL version 16 (#1448) Fixed the following Docker files to reflect running under PostgreSQL version 16. modified: docker/Dockerfile modified: docker/Dockerfile.dev This impacts the DockerHub builds. * Mark null-returning RTEs in outer joins as nullable RTEs that appear in the right side of a left join are marked as 'nullable'. The column references to a nullable RTE within the join's RTE are also marked as 'nullable'. This concept is introduced in Postgresql v16. The change in Postgresql v16's pullup_replace_vars_callback() function causes different plans to be generated depending on whether appropriate RTEs are marked nullable. Without marking nullable, in a left join, any function call expression containing right RTE's columns as arguments are not evaluated at the scan level, rather it is evaluated after the join is performed. At that point, the function call may receive null input, which was unexpected in previous Postgresql versions. See: ---- - Postgresql v16's commit: Make Vars be outer-join-aware https://www.postgresql.org/message-id/[email protected] - The 'Vars and PlaceHolderVars' section in the Postgresql v16's optimizer/README.md * Fix minor code formatting. --------- Co-authored-by: Shoaib <[email protected]> Co-authored-by: Rafsun Masud <[email protected]>
1 parent 0ea1186 commit 81ecd56

29 files changed

+334
-167
lines changed

.github/workflows/go-driver.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Go Driver Tests
22

33
on:
44
push:
5-
branches: [ "master", "PG15" ]
5+
branches: [ "master", "PG16" ]
66

77
pull_request:
8-
branches: [ "master", "PG15" ]
8+
branches: [ "master", "PG16" ]
99

1010
jobs:
1111
build:
@@ -26,14 +26,14 @@ jobs:
2626
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
2727
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
2828
echo "TAG=latest" >> $GITHUB_ENV
29-
elif [[ "$GITHUB_REF" == "refs/heads/PG15" ]]; then
30-
echo "TAG=PG15_latest" >> $GITHUB_ENV
29+
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
30+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3131
fi
3232
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
3333
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
3434
echo "TAG=latest" >> $GITHUB_ENV
35-
elif [[ "$GITHUB_BASE_REF" == "PG15" ]]; then
36-
echo "TAG=PG15_latest" >> $GITHUB_ENV
35+
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
36+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3737
fi
3838
fi
3939

.github/workflows/installcheck.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,45 @@ name: Build / Regression
22

33
on:
44
push:
5-
branches: [ 'master', 'PG15' ]
5+
branches: [ 'master', 'PG16' ]
66
pull_request:
7-
branches: [ 'master', 'PG15' ]
7+
branches: [ 'master', 'PG16' ]
88

99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: Get latest commit id of PostgreSQL 15
14+
- name: Get latest commit id of PostgreSQL 16
1515
run: |
16-
echo "PG_COMMIT_HASH=$(git ls-remote git://git.postgresql.org/git/postgresql.git refs/heads/REL_15_STABLE | awk '{print $1}')" >> $GITHUB_ENV
16+
echo "PG_COMMIT_HASH=$(git ls-remote git://git.postgresql.org/git/postgresql.git refs/heads/REL_16_STABLE | awk '{print $1}')" >> $GITHUB_ENV
1717
18-
- name: Cache PostgreSQL 15
18+
- name: Cache PostgreSQL 16
1919
uses: actions/cache@v3
20-
id: pg15cache
20+
id: pg16cache
2121
with:
22-
path: ~/pg15
23-
key: ${{ runner.os }}-v1-pg15-${{ env.PG_COMMIT_HASH }}
22+
path: ~/pg16
23+
key: ${{ runner.os }}-v1-pg16-${{ env.PG_COMMIT_HASH }}
2424

25-
- name: Install PostgreSQL 15
26-
if: steps.pg15cache.outputs.cache-hit != 'true'
25+
- name: Install PostgreSQL 16
26+
if: steps.pg16cache.outputs.cache-hit != 'true'
2727
run: |
28-
git clone --depth 1 --branch REL_15_STABLE git://git.postgresql.org/git/postgresql.git ~/pg15source
29-
cd ~/pg15source
30-
./configure --prefix=$HOME/pg15 CFLAGS="-std=gnu99 -ggdb -O0" --enable-cassert
28+
git clone --depth 1 --branch REL_16_STABLE git://git.postgresql.org/git/postgresql.git ~/pg16source
29+
cd ~/pg16source
30+
./configure --prefix=$HOME/pg16 CFLAGS="-std=gnu99 -ggdb -O0" --enable-cassert
3131
make install -j$(nproc) > /dev/null
3232
3333
- uses: actions/checkout@v3
3434

3535
- name: Build
3636
id: build
3737
run: |
38-
make PG_CONFIG=$HOME/pg15/bin/pg_config install -j$(nproc)
38+
make PG_CONFIG=$HOME/pg16/bin/pg_config install -j$(nproc)
3939
4040
- name: Regression tests
4141
id: regression_tests
4242
run: |
43-
make PG_CONFIG=$HOME/pg15/bin/pg_config installcheck
43+
make PG_CONFIG=$HOME/pg16/bin/pg_config installcheck
4444
continue-on-error: true
4545

4646
- name: Dump regression test errors

.github/workflows/jdbc-driver.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: JDBC Driver Tests
22

33
on:
44
push:
5-
branches: [ "master", "PG15" ]
5+
branches: [ "master", "PG16" ]
66

77
pull_request:
8-
branches: [ "master", "PG15" ]
8+
branches: [ "master", "PG16" ]
99

1010
jobs:
1111
build:
@@ -28,14 +28,14 @@ jobs:
2828
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
2929
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
3030
echo "TAG=latest" >> $GITHUB_ENV
31-
elif [[ "$GITHUB_REF" == "refs/heads/PG15" ]]; then
32-
echo "TAG=PG15_latest" >> $GITHUB_ENV
31+
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
32+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3333
fi
3434
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
3535
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
3636
echo "TAG=latest" >> $GITHUB_ENV
37-
elif [[ "$GITHUB_BASE_REF" == "PG15" ]]; then
38-
echo "TAG=PG15_latest" >> $GITHUB_ENV
37+
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
38+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3939
fi
4040
fi
4141

.github/workflows/nodejs-driver.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Nodejs Driver Tests
22

33
on:
44
push:
5-
branches: [ "master", "PG15" ]
5+
branches: [ "master", "PG16" ]
66

77
pull_request:
8-
branches: [ "master", "PG15" ]
8+
branches: [ "master", "PG16" ]
99

1010
jobs:
1111
build:
@@ -23,14 +23,14 @@ jobs:
2323
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
2424
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
2525
echo "TAG=latest" >> $GITHUB_ENV
26-
elif [[ "$GITHUB_REF" == "refs/heads/PG15" ]]; then
27-
echo "TAG=PG15_latest" >> $GITHUB_ENV
26+
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
27+
echo "TAG=PG16_latest" >> $GITHUB_ENV
2828
fi
2929
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
3030
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
3131
echo "TAG=latest" >> $GITHUB_ENV
32-
elif [[ "$GITHUB_BASE_REF" == "PG15" ]]; then
33-
echo "TAG=PG15_latest" >> $GITHUB_ENV
32+
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
33+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3434
fi
3535
fi
3636

.github/workflows/python-driver.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Python Driver Tests
22

33
on:
44
push:
5-
branches: [ "master", "PG15" ]
5+
branches: [ "master", "PG16" ]
66

77
pull_request:
8-
branches: [ "master", "PG15" ]
8+
branches: [ "master", "PG16" ]
99

1010
jobs:
1111
build:
@@ -23,14 +23,14 @@ jobs:
2323
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
2424
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
2525
echo "TAG=latest" >> $GITHUB_ENV
26-
elif [[ "$GITHUB_REF" == "refs/heads/PG15" ]]; then
27-
echo "TAG=PG15_latest" >> $GITHUB_ENV
26+
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
27+
echo "TAG=PG16_latest" >> $GITHUB_ENV
2828
fi
2929
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
3030
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
3131
echo "TAG=latest" >> $GITHUB_ENV
32-
elif [[ "$GITHUB_BASE_REF" == "PG15" ]]; then
33-
echo "TAG=PG15_latest" >> $GITHUB_ENV
32+
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
33+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3434
fi
3535
fi
3636

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ age--*.*.*.sql
77
.DS_Store
88
*.tokens
99
*.interp
10+
*.dylib

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
# limitations under the License.
1717
#
1818

19-
FROM postgres:15
19+
FROM postgres:16
2020

2121
RUN apt-get update \
2222
&& apt-get install -y --no-install-recommends --no-install-suggests \
2323
bison \
2424
build-essential \
2525
flex \
26-
postgresql-server-dev-15 \
26+
postgresql-server-dev-16 \
2727
locales
2828

2929
ENV LANG=en_US.UTF-8

docker/Dockerfile.dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
#
1818

1919

20-
FROM postgres:15
20+
FROM postgres:16
2121

2222
RUN apt-get update
2323
RUN apt-get install --assume-yes --no-install-recommends --no-install-suggests \
2424
bison \
2525
build-essential \
2626
flex \
27-
postgresql-server-dev-15 \
27+
postgresql-server-dev-16 \
2828
locales
2929

3030
ENV LANG=en_US.UTF-8

src/backend/catalog/ag_catalog.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,29 @@ void process_utility_hook_fini(void)
8686
* from being thrown, we need to disable the object_access_hook before dropping
8787
* the extension.
8888
*/
89-
void ag_ProcessUtility_hook(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree,
90-
ProcessUtilityContext context, ParamListInfo params,
91-
QueryEnvironment *queryEnv, DestReceiver *dest,
92-
QueryCompletion *qc)
89+
void ag_ProcessUtility_hook(PlannedStmt *pstmt, const char *queryString,
90+
bool readOnlyTree, ProcessUtilityContext context,
91+
ParamListInfo params, QueryEnvironment *queryEnv,
92+
DestReceiver *dest, QueryCompletion *qc)
9393
{
9494
if (is_age_drop(pstmt))
95+
{
9596
drop_age_extension((DropStmt *)pstmt->utilityStmt);
97+
}
9698
else if (prev_process_utility_hook)
97-
(*prev_process_utility_hook) (pstmt, queryString, readOnlyTree, context, params,
98-
queryEnv, dest, qc);
99+
{
100+
(*prev_process_utility_hook) (pstmt, queryString, readOnlyTree, context,
101+
params, queryEnv, dest, qc);
102+
}
99103
else
100-
standard_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, queryEnv,
101-
dest, qc);
104+
{
105+
Assert(IsA(pstmt, PlannedStmt));
106+
Assert(pstmt->commandType == CMD_UTILITY);
107+
Assert(queryString != NULL); /* required as of 8.4 */
108+
Assert(qc == NULL || qc->commandTag == CMDTAG_UNKNOWN);
109+
standard_ProcessUtility(pstmt, queryString, readOnlyTree, context,
110+
params, queryEnv, dest, qc);
111+
}
102112
}
103113

104114
static void drop_age_extension(DropStmt *stmt)

src/backend/catalog/ag_graph.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ void insert_graph(const Name graph_name, const Oid nsp_id)
4949
HeapTuple tuple;
5050

5151

52-
AssertArg(graph_name);
53-
AssertArg(OidIsValid(nsp_id));
52+
Assert(graph_name);
53+
Assert(OidIsValid(nsp_id));
5454

5555
ag_graph = table_open(ag_graph_relation_id(), RowExclusiveLock);
5656
values[Anum_ag_graph_oid - 1] = ObjectIdGetDatum(nsp_id);

0 commit comments

Comments
 (0)