|
25 | 25 | #include "catalog/ag_label.h" |
26 | 26 | #include "executor/cypher_executor.h" |
27 | 27 | #include "executor/cypher_utils.h" |
| 28 | +#include "executor/executor.h" |
| 29 | +#include "pg_config.h" |
28 | 30 |
|
29 | 31 | static void begin_cypher_delete(CustomScanState *node, EState *estate, |
30 | 32 | int eflags); |
@@ -55,6 +57,11 @@ const CustomExecMethods cypher_delete_exec_methods = {DELETE_SCAN_STATE_NAME, |
55 | 57 | NULL, |
56 | 58 | NULL}; |
57 | 59 |
|
| 60 | +#if PG_VERSION_NUM >= 18000 |
| 61 | +#define TUPLE_DESC_ATTR_TYPE_ID TupleDescAttr(tupleDescriptor, entity_position - 1)->atttypid |
| 62 | +#else |
| 63 | +#define TUPLE_DESC_ATTR_TYPE_ID tupleDescriptor->attrs[entity_position - 1]->atttypid |
| 64 | +#endif |
58 | 65 | /* |
59 | 66 | * Initialization at the beginning of execution. Setup the child node, |
60 | 67 | * setup its scan tuple slot and projection info, expression context, |
@@ -257,13 +264,15 @@ static agtype_value *extract_entity(CustomScanState *node, |
257 | 264 | tupleDescriptor = scanTupleSlot->tts_tupleDescriptor; |
258 | 265 |
|
259 | 266 | /* type checking, make sure the entity is an agtype vertex or edge */ |
260 | | - if (tupleDescriptor->attrs[entity_position -1].atttypid != AGTYPEOID) |
| 267 | + // First make sure the entity is an agtype. this is set per extension. Also, from postgresql 16 onwards use TupleDescAttr so that it works on both attrs and compact_attrs. |
| 268 | + if (TUPLE_DESC_ATTR_TYPE_ID != AGTYPEOID) |
261 | 269 | ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
262 | 270 | errmsg("DELETE clause can only delete agtype"))); |
263 | 271 |
|
264 | 272 | original_entity = DATUM_GET_AGTYPE_P(scanTupleSlot->tts_values[entity_position - 1]); |
265 | 273 | original_entity_value = get_ith_agtype_value_from_container(&original_entity->root, 0); |
266 | 274 |
|
| 275 | + // We are not deleting anything other than vertices and edges. |
267 | 276 | if (original_entity_value->type != AGTV_VERTEX && original_entity_value->type != AGTV_EDGE) |
268 | 277 | ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
269 | 278 | errmsg("DELETE clause can only delete vertices and edges"))); |
|
0 commit comments