From 103f51d3ec8bc416309ab837a2abed5e5de781a4 Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Tue, 1 Oct 2019 13:29:35 +0200 Subject: [PATCH] Add C API for creating a procedure result Reviewers: mferencevic, ipaljak, dsantl Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2464 --- include/mg_procedure.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/mg_procedure.h b/include/mg_procedure.h index 529a363b9..65a68355b 100644 --- a/include/mg_procedure.h +++ b/include/mg_procedure.h @@ -366,6 +366,33 @@ const struct mgp_edge *mgp_path_edge_at(const struct mgp_path *path, size_t index); ///@} +/// @name Procedure Result +/// These functions and types are used to set the result of your custom +/// procedure. +///@{ + +/// Stores either an error result or a list of mgp_result_record instances. +struct mgp_result; +/// Represents a record of resulting field values. +struct mgp_result_record; + +/// Set the error as the result of the procedure. +/// If there's no memory for copying the error message, 0 is returned. +int mgp_result_set_error_msg(struct mgp_result *res, const char *error_msg); + +/// Create a new record for results. +/// Return NULL if unable to allocate a mgp_result_record. +struct mgp_result_record *mgp_result_new_record(struct mgp_result *res); + +/// Assign a value to a field in the given record. +/// Return 0 if there's no memory to copy the mgp_value to mgp_result_record or +/// if the combination of `field_name` and `val` does not satisfy the +/// procedure's result signature. +int mgp_result_record_insert(struct mgp_result_record *record, + const char *field_name, + const struct mgp_value *val); +///@} + #ifdef __cplusplus } // extern "C" #endif