Skip to content

Mark agtype_string_match_starts_with/_ends_with IMMUTABLE - #2579

Open
mmustafasenoglu wants to merge 1 commit into
apache:masterfrom
mmustafasenoglu:fix/string-match-immutable
Open

mmustafasenoglu wants to merge 1 commit into
apache:masterfrom
mmustafasenoglu:fix/string-match-immutable

Conversation

@mmustafasenoglu

Copy link
Copy Markdown
Contributor

Fixes #2576

starts_with and ends_with are pure string comparisons over their inputs, same as contains which is already IMMUTABLE, so there is no reason for them to stay STABLE. This unblocks user-built expression indexes on STARTS WITH / ENDS WITH predicates (Postgres rejects STABLE functions in index expressions).

Changes:

  • sql/agtype_string.sql: STABLE -> IMMUTABLE on the two functions

@MuhammadTahaNaveed

Copy link
Copy Markdown
Member

@mmustafasenoglu you need to update the upgrade script age--1.8.0--y.y.y.sql as well.

@mmustafasenoglu
mmustafasenoglu force-pushed the fix/string-match-immutable branch from 194bec0 to afc220b Compare October 11, 2026 13:50
Copilot AI balanced review requested due to automatic review settings October 11, 2026 13:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@mmustafasenoglu

Copy link
Copy Markdown
Contributor Author

Done - added ALTER FUNCTION entries for both functions to age--1.8.0--y.y.y.sql.

@MuhammadTahaNaveed

Copy link
Copy Markdown
Member

@mmustafasenoglu This branch has conflicts that must be resolved

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 apache#2576

Signed-off-by: Mustafa Senoglu <mmustafasenoglu0@gmail.com>
@mmustafasenoglu
mmustafasenoglu force-pushed the fix/string-match-immutable branch from afc220b to 5b18ec7 Compare October 12, 2026 12:14
@mmustafasenoglu

Copy link
Copy Markdown
Contributor Author

Rebased onto latest master and kept both the new btree upgrade block and the IMMUTABLE ALTER FUNCTION entries. Ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mark agtype_string_match_starts_with / _ends_with IMMUTABLE (contains already is)

3 participants