cockroachdb / cockroachdb/cockroach
Difference with PostgreSQL
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
[Please describe the issue you observed, and any steps we can take to reproduce it:
](q: unnest(): generator functions are not allowed in VALUES)
**To Reproduce**
I'd like to use CockroachDB with Listmonk which was designed for PostgreSQL 9.4+
I succeed to modify the schema for being working with CockroachDB 22.2.3 because the only problem I had was with DROP TYPE CASCADE…
But while preparing queries I get an error pq: unnest(): generator functions are not allowed in VALUES
the cause is in this query
```sql
WITH sub AS (
INSERT INTO subscribers (uuid, email, name, status, attribs)
VALUES($1, $2, $3, $4, $5)
RETURNING id, status
),
listIDs AS (
SELECT id as id FROM lists WHERE
(CASE WHEN CARDINALITY($6::INT[]) > 0 THEN id=ANY($6)
ELSE uuid=ANY($7::UUID[]) END)
),
subs AS (
INSERT INTO subscriber_lists (subscriber_id, list_id, status)
VALUES(
(SELECT id FROM sub),
UNNEST(ARRAY(SELECT id FROM listIDs)),
(CASE WHEN $4='blocklisted' THEN 'unsubscribed'::subscription_status ELSE $8::subscription_status END)
)
ON CONFLICT (subscriber_id, list_id) DO UPDATE
SET updated_at=NOW(),
status=(
CASE WHEN $4='blocklisted' OR (SELECT status FROM sub)='blocklisted'
THEN 'unsubscribed'::subscription_status
ELSE $8::subscription_status END
)
)
SELECT id from sub;
```
If possible, provide steps to reproduce the behavior:
1. Set up CockroachDB cluster ...
2. Send SQL ... / CLI command ...
3. Look at UI / log file / client app ...
4. See error
**Expected behavior**
This is working in PostgreSQL
**Environment:**
- CockroachDB version 22.2.3 hosted by cockroachlabs
Jira issue: CRDB-24339
Contributor guide
Assessment
This issue has not been assessed yet.