Skip to content

feat: add variadic function support to eval#4114

Open
icehaunter wants to merge 3 commits intomainfrom
ilia/variadic-functions
Open

feat: add variadic function support to eval#4114
icehaunter wants to merge 3 commits intomainfrom
ilia/variadic-functions

Conversation

@icehaunter
Copy link
Copy Markdown
Contributor

Summary

  • add variadic function support to the eval stack, including defpostgres definitions and overload lookup support
  • lower coalesce, greatest, and least through the shared function parsing and execution path
  • tighten variadic parsing behavior around explicit VARIADIC calls and precedence between exact and variadic overloads
  • implement true coalesce short-circuiting in parser reduction and runtime execution

Testing

  • mix test test/electric/replication/eval_test.exs test/electric/replication/eval/*.exs

Teach the eval stack to define, resolve, parse, and execute variadic postgres-style functions.

This adds VARIADIC support to defpostgres definitions, expands variadic overloads during function lookup, and preserves the existing packed variadic AST/runtime calling convention.

It also lowers PostgreSQL special-form AST nodes for coalesce, greatest, and least through the shared function path, and exposes those three functions in the known function registry.

Tests were added first in parser and runner coverage for overload resolution, packed variadic AST shape, and nil-handling semantics.
Clarify the Func field comments, reject explicit VARIADIC calls until they are fully supported, and harden variadic argument packing.

This also adds parser coverage for explicit VARIADIC rejection and for preferring exact non-variadic overloads over variadic expansions.
Evaluate coalesce arguments lazily in both parser reduction and runtime execution so unreachable branches are not forced eagerly.

This preserves constant-folding for leading NULL branches, avoids reducing later dead branches once coalesce has a decisive argument, and adds regression tests for parser and runner short-circuit behavior.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2667 1 2666 1
View the top 1 failed test(s) by shortest run time
Elixir.Electric.Replication.PublicationManagerTest::test component restarts handles relation tracker restart
Stack Traces | 0.16s run time
22) test component restarts handles relation tracker restart (Electric.Replication.PublicationManagerTest)
     .../electric/replication/publication_manager_test.exs:503
     ** (exit) exited in: GenServer.call({:via, Registry, {:"Electric.ProcessRegistry:Electric.Replication.PublicationManagerTest test component restarts handles relation tracker restart", {Electric.Replication.PublicationManager.RelationTracker, nil}}}, {:remove_shape, "45463459-1775846139201787"}, 5000)
         ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
     code: PublicationManager.remove_shape(ctx.stack_id, shape_handle)
     stacktrace:
       (elixir 1.19.5) lib/gen_server.ex:1135: GenServer.call/3
       (electric 1.5.1) .../replication/publication_manager/relation_tracker.ex:73: Electric.Replication.PublicationManager.RelationTracker.remove_shape/2
       .../electric/replication/publication_manager_test.exs:522: (test)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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.

1 participant