Context-dependent RECORD comparisons
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 73
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 129
Description
https://www.postgresql.org/docs/15/functions-comparisons.html#COMPOSITE-TYPE-COMPARISON
These are the expected results from Postgres:
```sql
SELECT ROW(NULL::int4) = ROW(NULL::int4); -> null
```
```sql
SELECT ROW(NULL::int4) = ANY(ARRAY[ROW(NULL::int4)]); -> true
```
These are our current results in Doltgres:
```sql
SELECT ROW(NULL::int4) = ROW(NULL::int4); -> null
```
```sql
SELECT ROW(NULL::int4) = ANY(ARRAY[ROW(NULL::int4)]); -> null
```
Both of these are record comparisons, but the way that they are handled is context-dependent. We probably should special case the two scenarios in the documentation and change the default comparison logic for record types to properly handle nulls in all other contexts.
Relevant function:
https://github.com/dolthub/doltgresql/blob/7886f0f87010c73da7115fcf9dc275ca25ff1cf7/server/compare/utils.go#L27-L32
Contributor guide
Research direction
Start by reading server/compare/utils.go at the referenced comparison logic, then compare the two listed SQL expressions with PostgreSQL's composite-type comparison documentation. Reproduce both queries in Doltgres and verify that record comparisons involving NULL return PostgreSQL-compatible results in each context, while checking the surrounding comparison behavior for other record contexts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100