Skip to content

sql: disallow set-returning functions in CASE expressions #97119

@mgartner

Description

@mgartner

CRDB allows set-returning functions in CASE expressions, while Postgres does not. For example, this succeeds in CRDB but fails in Postgres:

SELECT CASE WHEN true THEN generate_series(1, 3) ELSE 1 END;

The behavior of such an expression is not well-defined, and the results are unexpected, if not down right incorrect. For example:

defaultdb> SELECT CASE WHEN false THEN generate_series(1, 3) ELSE 1 END;
  case
--------
     1
     1
     1
(3 rows)

I'd expect this expression to return only a single row.

We should probably disallow set-returning functions within CASE expressions (and other conditional expressions).

Jira issue: CRDB-24525

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries Team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions