Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Mark agtype_string_match_starts_with / _ends_with IMMUTABLE (contains already is)

クローズ 初心者向け
#2,576 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@mmustafasenoglu がすでに取り組んでいます。

2026年9月24日 から。

  • #2579 @mmustafasenoglu による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, postgresql, sql
領域
databases

調査の方向性

sql/agtype_string.sql から始め、agtype_string_match_starts_with と agtype_string_match_ends_with の volatility 宣言を agtype_string_match_contains と比較します。2 つの関数を IMMUTABLE としてマークし、その後、PostgreSQL が式インデックスの定義内でそれらの呼び出しを受け付けることを確認します。src/backend/parser/cypher_expr.c:1604-1628 の parser コンテキストから、この変更によって自動的なインデックス pushdown が追加されない理由が分かります。

索引モデルが issue の本文から書いたものです。

説明

sql/agtype_string.sql declares three agtype string-matching functions:

  • agtype_string_match_starts_with — STABLE
  • agtype_string_match_ends_with — STABLE
  • agtype_string_match_contains — IMMUTABLE

All three are pure functions over agtype values — same inputs, same output, every time, no
catalog lookups, no session state. There's no functional reason for contains to be
IMMUTABLE while starts_with/ends_with are STABLE; this looks like an oversight rather
than a deliberate distinction.

Concrete cost of the current state: PostgreSQL requires a function to be IMMUTABLE to be
used as an expression-index key (STABLE/VOLATILE functions are rejected at CREATE INDEX
time with "functions in index expression must be marked IMMUTABLE"). So today there is no way
— not even by hand-building an index — to accelerate a STARTS WITH or ENDS WITH predicate
via an expression index. CONTAINS doesn't have this problem only because it happens to
already be marked correctly.

What this fix does and doesn't do, to be upfront about the limit of the ask: marking these
two functions IMMUTABLE does not, by itself, make WHERE n.prop STARTS WITH 'x' or
ENDS WITH start using an index automatically. Read in source
(src/backend/parser/cypher_expr.c:1604-1628, AGE 1.7.0), Cypher's STARTS WITH/ENDS WITH
compile to a FuncExpr call of these functions, not to an operator — and AGE's automatic
property-index pushdown (match_clause_to_indexcol() and friends) matches on operators via
opclass, not on arbitrary function calls. No operator, no automatic pushdown, regardless of
volatility.

What the IMMUTABLE marking does unlock: a user can build their own expression index
directly on the function call —
CREATE INDEX ON <graph>."<Label>" (agtype_string_match_starts_with(properties, ...))
— and use it via a manual rewrite of the predicate, or as groundwork for a future operator +
opclass that would let AGE's own pushdown logic reach it. Today that manual path is not just
unoptimized, it's flatly unavailable because Postgres refuses the CREATE INDEX outright on a
STABLE function.

So: two honest, separate claims — (1) this is a one-line correctness fix (volatility category
should match reality), and (2) it is a prerequisite for indexable prefix/suffix matching, not
a fix for it by itself. #2417 shows the maintainers have recently merged planner-metadata-only
changes to agtype operators for exactly this kind of correctness reason; happy to open this
as a PR if a maintainer confirms there isn't a reason these were left STABLE that we're
missing.

主要言語
C
スター
4.9k
フォーク
535
平均マージ
9日 18時間
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/age のほかの issue

apache/age の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。