cockroachdb / cockroachdb/cockroach

sql: infinite loop with recursive common table expression

Open
#93,368 1 comment 0 reactions 0 assignees View on GitHub
C-bug O-pg-regress T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

The following query causes CockroachDB to loop forever delivering results to the client:

```
WITH RECURSIVE x (n) AS (SELECT 1 UNION ALL SELECT count(*) FROM x) SELECT * FROM x;
```

Postgres rejects this query outright:

```
jordan=# WITH RECURSIVE x (n) AS (SELECT 1 UNION ALL SELECT count(*) FROM x) SELECT * FROM x;
ERROR: aggregate functions are not allowed in a recursive query's recursive term
LINE 1: ...ITH RECURSIVE x (n) AS (SELECT 1 UNION ALL SELECT count(*) F...
```

Jira issue: CRDB-22287

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.