From afc220b6737773c15db7fe218653323a215a26f9 Mon Sep 17 00:00:00 2001 From: Mustafa Senoglu Date: Thu, 24 Sep 2026 13:34:39 +0300 Subject: [PATCH] Mark agtype_string_match_starts_with/_ends_with IMMUTABLE Same inputs always produce the same output with no catalog lookups or session state, matching agtype_string_match_contains which is already IMMUTABLE. Unblocks user-built expression indexes on STARTS WITH / ENDS WITH predicates. Also updates the 1.8.0 upgrade script with ALTER FUNCTION entries. Fixes #2576 Signed-off-by: Mustafa Senoglu --- age--1.8.0--y.y.y.sql | 19 +++++++++++++++---- sql/agtype_string.sql | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/age--1.8.0--y.y.y.sql b/age--1.8.0--y.y.y.sql index 097d066ee..796481bc6 100644 --- a/age--1.8.0--y.y.y.sql +++ b/age--1.8.0--y.y.y.sql @@ -58,10 +58,21 @@ CREATE FUNCTION ag_catalog.load_labels_from_file(graph_name name, DROP FUNCTION IF EXISTS ag_catalog.load_edges_from_file(name, name, text, bool); CREATE FUNCTION ag_catalog.load_edges_from_file(graph_name name, - label_name name, - file_path text, - load_as_agtype bool default false, - delimiter text default ',') + label_name name, + file_path text, + load_as_agtype bool default false, + delimiter text default ',') RETURNS void LANGUAGE c AS 'MODULE_PATHNAME'; + +-- +-- Mark agtype_string_match_starts_with/_ends_with IMMUTABLE +-- +-- Issue #2576: same inputs always produce the same output with no catalog +-- lookups or session state, matching agtype_string_match_contains which is +-- already IMMUTABLE. + +ALTER FUNCTION ag_catalog.agtype_string_match_starts_with(agtype, agtype) IMMUTABLE; + +ALTER FUNCTION ag_catalog.agtype_string_match_ends_with(agtype, agtype) IMMUTABLE; diff --git a/sql/agtype_string.sql b/sql/agtype_string.sql index 0d7b2013f..0be44eb1b 100644 --- a/sql/agtype_string.sql +++ b/sql/agtype_string.sql @@ -24,7 +24,7 @@ CREATE FUNCTION ag_catalog.agtype_string_match_starts_with(agtype, agtype) RETURNS agtype LANGUAGE c - STABLE + IMMUTABLE RETURNS NULL ON NULL INPUT PARALLEL SAFE AS 'MODULE_PATHNAME'; @@ -32,7 +32,7 @@ AS 'MODULE_PATHNAME'; CREATE FUNCTION ag_catalog.agtype_string_match_ends_with(agtype, agtype) RETURNS agtype LANGUAGE c - STABLE + IMMUTABLE RETURNS NULL ON NULL INPUT PARALLEL SAFE AS 'MODULE_PATHNAME';