cockroachdb / cockroachdb/cockroach
sql: limit max depth of routine execution
Open
A-sql-plpgsql
A-sql-routine
C-enhancement
E-quick-win
T-sql-queries
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
We use recursive calls to implement loops in PL/pgSQL, and may in the future allow users to create recursive UDFs. We recently [fixed](https://github.com/cockroachdb/cockroach/pull/155195) a test failure where an infinite loop with tail-call-optimization disabled caused a stack overflow, but that fix is only applied in test builds. While we expect TCO to apply to the recursive structure built for PL/pgSQL loops, it's possible that there are some cases we're missing. We should defensively limit the recursion depth for all routines even for production builds.
Jira issue: CRDB-55345
Contributor guide
Assessment
This issue has not been assessed yet.