Skip to content

Fix crash in age_to*list functions called with non-agtype argument - #2609

Open
ritojoao wants to merge 1 commit into
apache:masterfrom
ritojoao:fix/2563-tolist-argtype
Open

ritojoao wants to merge 1 commit into
apache:masterfrom
ritojoao:fix/2563-tolist-argtype

Conversation

@ritojoao

Copy link
Copy Markdown

Fixes #2563

What was wrong

age_tobooleanlist, age_tofloatlist, age_tointegerlist and age_tostringlist are declared with VARIADIC "any". When one of them is called from plain SQL with an untyped literal such as '[true]', the argument is not an agtype, but the C code read it as one. On a cassert build of PostgreSQL 18 this terminated the backend (server closed the connection unexpectedly). Passing '[true]'::agtype and calling through Cypher were not affected.

What changed

Each of the four functions now checks get_fn_expr_argtype(fcinfo->flinfo, 0) != AGTYPEOID and raises an ordinary error (for example toBooleanList() argument must be of type agtype). This is the same approach age_tail already uses. I added regression cases to regress/sql/expr.sql and regress/expected/expr.out: the four failing calls, plus two calls with ::agtype that still work.

How tested

Environment: Ubuntu 24.04 container (Bison 3.8.2), PostgreSQL REL_18_STABLE built with --enable-cassert -O0, AGE built with COPT=-Werror, then make installcheck EXTRA_TESTS="pgvector fuzzystrmatch pg_trgm", following installcheck.yaml.

  • master with the new test files, without the fix: the expr test fails because the server terminates abnormally at the first new call.
  • unmodified master: all 47 tests pass.
  • this branch: all 47 tests pass.

Not run: the other PostgreSQL versions, the driver workflows (go, jdbc, nodejs, python), and the upgrade-script checks beyond what make installcheck runs by itself.

Thank you for taking a look.

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.

age_to*list functions crash the server (SIGSEGV) on array-shaped SQL literals

1 participant