cockroachdb / cockroachdb/cockroach
sql: null_ordered_last does not produce correct results with tuples
- 主要言語
- Go
- スター
- 32.5k
- フォーク
- 4.1k
- PR マージ指標
- PR 指標を取得中
説明
**Describe the problem**
By default, CockroachDB orders NULLs before all other values. For compatibility with Postgres, we added a session setting, `null_ordered_last`, which changes the default to order NULLs after all other values. This works in most cases, thanks to some transformations we make in the optimizer to add extra ordering columns. However, it is broken when the ordering column is a tuple.
**To Reproduce**
On `./cockroach demo`, on master (23.1 alpha), run the following:
```
SET null_ordered_last = true;
WITH t (x, y) AS (
VALUES
((1, 1), 1),
((NULL::RECORD), 2),
((1, NULL::INT), 3),
((NULL::INT, NULL::INT), 4)
)
SELECT *
FROM t
ORDER BY x;
```
The result on CockorachDB:
```
x | y
--------+----
(1,) | 3
(1,1) | 1
NULL | 2
(,) | 4
```
The result on Postgres:
```
x | y
-------+---
(1,1) | 1
(1,) | 3
(,) | 4
| 2
```
**Expected behavior**
The CockroachDB output should match Postgres when `null_ordered_last` is true.
**Environment:**
- CockroachDB version: v23.1.0-alpha....dirty
- Server OS: macOS Monterey
- Client app: cockroach demo
Jira issue: CRDB-22400
コントリビューションガイド
評価
この issue はまだ評価されていません。