Skip to content

sql: INT4 column type not reported as INT4 when inspecting column types (SHOW CREATE, errors etc) #25098

@a-robinson

Description

@a-robinson

According to https://www.cockroachlabs.com/docs/stable/int.html#names-and-aliases, INT4 is treated as a 32-bit type that can't simply be aliased to a full 64-bit INTEGER. However, the actual code does convert INT4 columns to INTEGER on both v1.1.4 and v2.0.1:

root@:26257/> create database foo;                                                                                                                                                                          CREATE DATABASE

Time: 5.524673ms

root@:26257/> create table foo.bar (x INT4, y INT, z INT2);
CREATE TABLE

Time: 5.551593ms

root@:26257/> show create table foo.bar;
+---------+---------------------------------------+
|  Table  |              CreateTable              |
+---------+---------------------------------------+
| foo.bar | CREATE TABLE bar (                    |
|         |                                       |
|         |     x INTEGER NULL,                   |
|         |                                       |
|         |     y INT NULL,                       |
|         |                                       |
|         |     z SMALLINT NULL,                  |
|         |                                       |
|         |     FAMILY "primary" (x, y, z, rowid) |
|         |                                       |
|         | )                                     |
+---------+---------------------------------------+
(1 row)

Time: 7.215492ms

Which is wrong -- the code or the docs?

Metadata

Metadata

Assignees

Labels

A-sql-semanticsC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityS-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions