cockroachdb / cockroachdb/cockroach

sql: `::regtype` cast returns wrong name for arrays

Open
#97,456 0 comments 0 reactions 0 assignees View on GitHub
C-bug T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Using `::regtype` for arrays uses the `_arr` name instead of `arr[]`.

psql:

```
otan=# select 'int8[]'::regtype::oid;
oid
------
1016
(1 row)

otan=# select 1016::oid::regtype;
regtype
----------
bigint[]
(1 row)
```

cockroach:

```
root@127.0.0.1:26257/defaultdb> select 'int[]'::regtype::oid;
oid
--------
1016
(1 row)

Time: 1ms total (execution 1ms / network 0ms)

root@127.0.0.1:26257/defaultdb> select 1016::oid::regtype;
regtype
-----------
_int8
(1 row)

Time: 2ms total (execution 2ms / network 0ms)
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two `::regtype` queries in CockroachDB and then trace the regtype cast and type-name formatting paths in the Go codebase. Done means an array OID such as 1016 renders as `bigint[]` or `int8[]` rather than `_int8`, matching the PostgreSQL behavior shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.