cockroachdb / cockroachdb/cockroach

sql: support tail-call optimization for recursive routines

Open
#119,956 0 comments 0 reactions 0 assignees View on GitHub
C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

We currently implement tail-call optimization to reduce overhead for the sub-routines of a PL/pgSQL routine (in particular, for loops). This issue tracks adding support for the same optimization for explicit tail-recursion in routines, both SQL and PL/pgSQL. The optimizer will have to determine whether a nested call is in tail-call position somehow, and keep track of this property in a way that forms execution. There will also have to be some work to make exception handlers work with more general TCO; specifically, `sql.routineGenerator` will have to track exception handlers on a stack, rather than only looking at the handler for the current routine.

Jira issue: CRDB-36412

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.