Skip to content

Commit 69d8494

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
2 parents 8e56db9 + 81ecd56 commit 69d8494

15 files changed

+196
-79
lines changed

.github/workflows/go-driver.yml

+4-8
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:
@@ -24,15 +24,11 @@ jobs:
2424
- name: Set tag based on branch
2525
run: |
2626
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
27+
if [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
3028
echo "TAG=PG16_latest" >> $GITHUB_ENV
3129
fi
3230
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
31+
if [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
3632
echo "TAG=PG16_latest" >> $GITHUB_ENV
3733
fi
3834
fi

.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

+4-8
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:
@@ -26,15 +26,11 @@ jobs:
2626
- name: Set tag based on branch
2727
run: |
2828
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
29+
if [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
3230
echo "TAG=PG16_latest" >> $GITHUB_ENV
3331
fi
3432
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
33+
if [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
3834
echo "TAG=PG16_latest" >> $GITHUB_ENV
3935
fi
4036
fi

.github/workflows/nodejs-driver.yaml

+4-8
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:
@@ -21,15 +21,11 @@ jobs:
2121
- name: Set tag based on branch
2222
run: |
2323
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
24+
if [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
2725
echo "TAG=PG16_latest" >> $GITHUB_ENV
2826
fi
2927
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
28+
if [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
3329
echo "TAG=PG16_latest" >> $GITHUB_ENV
3430
fi
3531
fi

.github/workflows/python-driver.yaml

+4-8
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:
@@ -21,15 +21,11 @@ jobs:
2121
- name: Set tag based on branch
2222
run: |
2323
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
24+
if [[ "$GITHUB_REF" == "refs/heads/PG16" ]]; then
2725
echo "TAG=PG16_latest" >> $GITHUB_ENV
2826
fi
2927
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
28+
if [[ "$GITHUB_BASE_REF" == "PG16" ]]; then
3329
echo "TAG=PG16_latest" >> $GITHUB_ENV
3430
fi
3531
fi

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)