Skip to content

Commit a9b5399

Browse files
committed
Merge branch 'master' into PG16_to_master
Resolved conflicts: src/backend/catalog/ag_catalog.c src/backend/catalog/ag_label.c src/backend/executor/cypher_utils.c src/backend/nodes/cypher_readfuncs.c src/backend/parser/cypher_expr.c src/backend/parser/cypher_item.c src/backend/parser/cypher_parse_agg.c src/backend/utils/adt/agtype.c Modified specifically for PG16 branch: .github/workflows/go-driver.yml .github/workflows/installcheck.yaml .github/workflows/jdbc-driver.yaml .github/workflows/nodejs-driver.yaml .github/workflows/python-driver.yaml README.md
2 parents 8e56db9 + 81ecd56 commit a9b5399

16 files changed

+197
-112
lines changed

.github/workflows/go-driver.yml

+3-15
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Go Driver Tests
22

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

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

1010
jobs:
1111
build:
@@ -23,19 +23,7 @@ jobs:
2323

2424
- name: Set tag based on branch
2525
run: |
26-
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
27-
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
28-
echo "TAG=latest" >> $GITHUB_ENV
29-
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
30-
echo "TAG=PG16_latest" >> $GITHUB_ENV
31-
fi
32-
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
33-
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
34-
echo "TAG=latest" >> $GITHUB_ENV
35-
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
36-
echo "TAG=PG16_latest" >> $GITHUB_ENV
37-
fi
38-
fi
26+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3927
4028
- name: Run apache/age docker image
4129
run: |

.github/workflows/installcheck.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build / Regression
22

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

99
jobs:
1010
build:

.github/workflows/jdbc-driver.yaml

+3-15
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: JDBC Driver Tests
22

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

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

1010
jobs:
1111
build:
@@ -25,19 +25,7 @@ jobs:
2525

2626
- name: Set tag based on branch
2727
run: |
28-
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
29-
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
30-
echo "TAG=latest" >> $GITHUB_ENV
31-
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
32-
echo "TAG=PG16_latest" >> $GITHUB_ENV
33-
fi
34-
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
35-
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
36-
echo "TAG=latest" >> $GITHUB_ENV
37-
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
38-
echo "TAG=PG16_latest" >> $GITHUB_ENV
39-
fi
40-
fi
28+
echo "TAG=PG16_latest" >> $GITHUB_ENV
4129
4230
- name: Build and Test
4331
run: |

.github/workflows/nodejs-driver.yaml

+3-15
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Nodejs Driver Tests
22

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

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

1010
jobs:
1111
build:
@@ -20,19 +20,7 @@ jobs:
2020

2121
- name: Set tag based on branch
2222
run: |
23-
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
24-
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
25-
echo "TAG=latest" >> $GITHUB_ENV
26-
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
27-
echo "TAG=PG16_latest" >> $GITHUB_ENV
28-
fi
29-
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
30-
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
31-
echo "TAG=latest" >> $GITHUB_ENV
32-
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
33-
echo "TAG=PG16_latest" >> $GITHUB_ENV
34-
fi
35-
fi
23+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3624
3725
- name: Run apache/age docker image
3826
run: |

.github/workflows/python-driver.yaml

+3-15
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Python Driver Tests
22

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

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

1010
jobs:
1111
build:
@@ -20,19 +20,7 @@ jobs:
2020

2121
- name: Set tag based on branch
2222
run: |
23-
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
24-
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
25-
echo "TAG=latest" >> $GITHUB_ENV
26-
elif [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
27-
echo "TAG=PG16_latest" >> $GITHUB_ENV
28-
fi
29-
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
30-
if [[ "$GITHUB_BASE_REF" == "master" ]]; then
31-
echo "TAG=latest" >> $GITHUB_ENV
32-
elif [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
33-
echo "TAG=PG16_latest" >> $GITHUB_ENV
34-
fi
35-
fi
23+
echo "TAG=PG16_latest" >> $GITHUB_ENV
3624
3725
- name: Run apache/age docker image
3826
run: |

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
<img src="https://img.shields.io/badge/Release-v1.4.0-FFA500?labelColor=gray&style=flat&link=https://github.com/apache/age/releases"/>
3434
</a>
3535
&nbsp;
36-
<a href="https://www.postgresql.org/docs/15/index.html">
37-
<img src="https://img.shields.io/badge/Version-Postgresql 15-00008B?labelColor=gray&style=flat&link=https://www.postgresql.org/docs/15/index.html"/>
36+
<a href="https://www.postgresql.org/docs/16/index.html">
37+
<img src="https://img.shields.io/badge/Version-Postgresql 16-00008B?labelColor=gray&style=flat&link=https://www.postgresql.org/docs/16/index.html"/>
3838
</a>
3939
&nbsp;
4040
<a href="https://github.com/apache/age/issues">
@@ -131,7 +131,7 @@ Apache AGE is intended to be simple to install and run. It can be installed with
131131
&nbsp;Install PostgreSQL
132132
</h4>
133133

134-
You will need to install an AGE compatible version of Postgres<a>, for now AGE supports Postgres 11, 12, 13, 14 & 15. Supporting the latest versions is on AGE roadmap.
134+
You will need to install an AGE compatible version of Postgres<a>, for now AGE supports Postgres 11, 12, 13, 14, 15 & 16. Supporting the latest versions is on AGE roadmap.
135135

136136
<h4>
137137
&nbsp;Installation via Package Manager
@@ -149,7 +149,7 @@ sudo apt install postgresql
149149
&nbsp;Installation From Source Code
150150
</h4>
151151

152-
You can <a href="https://www.postgresql.org/ftp/source/"> download the Postgres </a> source code and install your own instance of Postgres. You can read instructions on how to install from source code for different versions on the <a href="https://www.postgresql.org/docs/15/installation.html">official Postgres Website.</a>
152+
You can <a href="https://www.postgresql.org/ftp/source/"> download the Postgres </a> source code and install your own instance of Postgres. You can read instructions on how to install from source code for different versions on the <a href="https://www.postgresql.org/docs/16/installation.html">official Postgres Website.</a>
153153

154154

155155

@@ -158,7 +158,7 @@ You can <a href="https://www.postgresql.org/ftp/source/"> download the Postgres
158158

159159
Clone the <a href="https://github.com/apache/age">github repository</a> or download the <a href="https://github.com/apache/age/releases">download an official release.
160160
</a>
161-
Run the pg_config utility and check the version of PostgreSQL. Currently, only PostgreSQL versions 11, 12, 13, 14 & 15 are supported. If you have any other version of Postgres, you will need to install PostgreSQL version 11, 12, 13, 14, or 15.
161+
Run the pg_config utility and check the version of PostgreSQL. Currently, only PostgreSQL versions 11, 12, 13, 14, 15 & 16 are supported. If you have any other version of Postgres, you will need to install PostgreSQL version 11, 12, 13, 14, 15 or 16.
162162
<br>
163163

164164
```bash

src/backend/catalog/ag_catalog.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -86,26 +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
100104
{
101105
Assert(IsA(pstmt, PlannedStmt));
102106
Assert(pstmt->commandType == CMD_UTILITY);
103107
Assert(queryString != NULL); /* required as of 8.4 */
104108
Assert(qc == NULL || qc->commandTag == CMDTAG_UNKNOWN);
105-
standard_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, queryEnv,
106-
dest, qc);
109+
standard_ProcessUtility(pstmt, queryString, readOnlyTree, context,
110+
params, queryEnv, dest, qc);
107111
}
108-
109112
}
110113

111114
static void drop_age_extension(DropStmt *stmt)

src/backend/catalog/ag_label.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ Datum _label_name(PG_FUNCTION_ARGS)
188188
uint32 label_id;
189189

190190
if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
191-
PG_RETURN_NULL();
192-
//ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
193-
// errmsg("graph_oid and label_id must not be null")));
191+
{
192+
ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
193+
errmsg("graph_oid and label_id must not be null")));
194+
}
194195

195196
graph = PG_GETARG_OID(0);
196197

src/backend/executor/cypher_set.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ static void process_update_list(CustomScanState *node)
485485
}
486486

487487
// Alter the properties Agtype value.
488-
if (strcmp(update_item->prop_name, ""))
488+
if (update_item->prop_name != NULL &&
489+
strcmp(update_item->prop_name, "") != 0)
489490
{
490491
altered_properties = alter_property_value(original_properties,
491492
update_item->prop_name,

src/backend/executor/cypher_utils.c

+34-9
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@
5151

5252
/*
5353
* Given the graph name and the label name, create a ResultRelInfo for the table
54-
* those to variables represent. Open the Indices too.
54+
* those two variables represent. Open the Indices too.
5555
*/
5656
ResultRelInfo *create_entity_result_rel_info(EState *estate, char *graph_name,
5757
char *label_name)
5858
{
59-
RangeVar *rv;
60-
Relation label_relation;
61-
ResultRelInfo *resultRelInfo;
59+
RangeVar *rv = NULL;
60+
Relation label_relation = NULL;
61+
ResultRelInfo *resultRelInfo = NULL;
62+
ParseState *pstate = NULL;
63+
RangeTblEntry *rte = NULL;
64+
int pii = 0;
6265

63-
ParseState *pstate = make_parsestate(NULL);
66+
/* create a new parse state for this operation */
67+
pstate = make_parsestate(NULL);
6468

6569
resultRelInfo = palloc(sizeof(ResultRelInfo));
6670

@@ -75,12 +79,33 @@ ResultRelInfo *create_entity_result_rel_info(EState *estate, char *graph_name,
7579

7680
label_relation = parserOpenTable(pstate, rv, RowExclusiveLock);
7781

78-
// initialize the resultRelInfo
79-
InitResultRelInfo(resultRelInfo, label_relation,
80-
0, NULL,
82+
/*
83+
* Get the rte to determine the correct perminfoindex value. Some rtes
84+
* may have it set up, some created here (executor) may not.
85+
*
86+
* Note: The RTEPermissionInfo structure was added in PostgreSQL version 16.
87+
*
88+
* Note: We use the list_length because exec_rt_fetch starts at 1, not 0.
89+
* Doing this gives us the last rte in the es_range_table list, which
90+
* is the rte in question.
91+
*
92+
* If the rte is created here and doesn't have a perminfoindex, we
93+
* need to pass on a 0. Otherwise, later on GetResultRTEPermissionInfo
94+
* will attempt to get the rte's RTEPermissionInfo data, which doesn't
95+
* exist.
96+
*
97+
* TODO: Ideally, we should consider creating the RTEPermissionInfo data,
98+
* but as this is just a read of the label relation, it is likely
99+
* unnecessary.
100+
*/
101+
rte = exec_rt_fetch(list_length(estate->es_range_table), estate);
102+
pii = (rte->perminfoindex == 0) ? 0 : list_length(estate->es_range_table);
103+
104+
/* initialize the resultRelInfo */
105+
InitResultRelInfo(resultRelInfo, label_relation, pii, NULL,
81106
estate->es_instrument);
82107

83-
// open the parse state
108+
/* open the indices */
84109
ExecOpenIndices(resultRelInfo, false);
85110

86111
free_parsestate(pstate);

src/backend/nodes/cypher_readfuncs.c

+18-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "nodes/cypher_readfuncs.h"
2525
#include "nodes/cypher_nodes.h"
2626

27+
static char *nullable_string(const char *token, int length);
2728
/*
2829
* Copied From Postgres
2930
*
@@ -111,7 +112,7 @@
111112
#define READ_STRING_FIELD(fldname) \
112113
token = pg_strtok(&length); \
113114
token = pg_strtok(&length); \
114-
local_node->fldname = non_nullable_string(token, length)
115+
local_node->fldname = nullable_string(token, length)
115116

116117
// Read a parse location field (and throw away the value, per notes above)
117118
#define READ_LOCATION_FIELD(fldname) \
@@ -162,11 +163,22 @@
162163

163164
#define strtobool(x) ((*(x) == 't') ? true : false)
164165

165-
#define nullable_string(token,length) \
166-
((length) == 0 ? NULL : debackslash(token, length))
167-
168-
#define non_nullable_string(token,length) \
169-
((length == 2 && token[0] == '"' && token[1] == '"') ? "" : debackslash(token, length))
166+
/* copied from PG16 function of the same name for consistency */
167+
static char *nullable_string(const char *token, int length)
168+
{
169+
/* outToken emits <> for NULL, and pg_strtok makes that an empty string */
170+
if (length == 0)
171+
{
172+
return NULL;
173+
}
174+
/* outToken emits "" for empty string */
175+
if (length == 2 && token[0] == '"' && token[1] == '"')
176+
{
177+
return pstrdup("");
178+
}
179+
/* otherwise, we must remove protective backslashes added by outToken */
180+
return debackslash(token, length);
181+
}
170182

171183
/*
172184
* Default read function for cypher nodes. For most nodes, we don't expect

0 commit comments

Comments
 (0)