From 9f0e1c642680c69e10eb1760be07984f9ecc6d39 Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Mon, 22 Jun 2026 23:07:12 +0000 Subject: Fix joins, rename, union Co-authored-by: Marcos Magueta --- include/RNT_C_API.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'include/RNT_C_API.h') diff --git a/include/RNT_C_API.h b/include/RNT_C_API.h index 1a59785..19f6165 100644 --- a/include/RNT_C_API.h +++ b/include/RNT_C_API.h @@ -397,6 +397,7 @@ typedef struct { typedef struct { rnt_plan_t left; rnt_plan_t right; + const char** attrs; } PlanArgsJoin; /** @@ -421,6 +422,38 @@ typedef struct { const char** attrs; } PlanArgsProject; +/** + * MATERIALIZE context: caches @p source on its first scan, then replays the + * cache on later scans without touching @p source again. + * + * Put this on the inner side of a JOIN so the inner relation is read once + * instead of once per outer tuple. Only safe when @p source does not depend on + * the outer tuple (no Var SCAN leaves bound by the JOIN), since the cache is + * reused as-is for every outer tuple. Takes ownership of @p source; on failure + * @p source is freed. + */ +typedef struct { + rnt_plan_t source; +} PlanArgsMaterialize; + +/** + * RENAME context: returns @p source, with the keys of @p pairs the values of it. + * + * @p pairs is a NULL-terminated array of pairs containing the original attribute + * name together with it's new name. + */ + +typedef struct { + rnt_plan_t source; + const char** pairs; +} PlanArgsRename; + +/** UNION context. */ + +typedef struct { + rnt_plan_t *sources; +} PlanArgsUnion; + /** * A single plan-construction request. @p operation selects which context member * is read; the others are ignored. The members are laid out side by side rather @@ -433,6 +466,9 @@ typedef struct { PlanArgsJoin join; PlanArgsTake take; PlanArgsProject project; + PlanArgsMaterialize materialize; + PlanArgsRename rename; + PlanArgsUnion union_; } PlanAction; /** -- cgit v1.2.3